1 //=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Nate Begeman and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the X86 specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef X86SUBTARGET_H
15 #define X86SUBTARGET_H
17 #include "llvm/Target/TargetSubtarget.h"
24 class X86Subtarget : public TargetSubtarget {
27 NoMMXSSE, MMX, SSE1, SSE2, SSE3
31 NoThreeDNow, ThreeDNow, ThreeDNowA
34 /// X86SSELevel - MMX, SSE1, SSE2, SSE3, or none supported.
35 X86SSEEnum X86SSELevel;
37 /// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
38 X863DNowEnum X863DNowLevel;
40 /// Is64Bit - True if the processor supports Em64T.
43 /// stackAlignment - The minimum alignment known to hold of the stack frame on
44 /// entry to the function and which must be maintained by every function.
45 unsigned stackAlignment;
47 /// Min. memset / memcpy size that is turned into rep/movs, rep/stos ops.
48 unsigned MinRepStrSizeThreshold;
50 /// Used by instruction selector
51 bool indirectExternAndWeakGlobals;
55 isELF, isCygwin, isDarwin, isWindows
58 /// This constructor initializes the data members to match that
59 /// of the specified module.
61 X86Subtarget(const Module &M, const std::string &FS);
63 /// getStackAlignment - Returns the minimum alignment known to hold of the
64 /// stack frame on entry to the function and which must be maintained by every
65 /// function for this subtarget.
66 unsigned getStackAlignment() const { return stackAlignment; }
68 /// getMinRepStrSizeThreshold - Returns the minimum memset / memcpy size
69 /// required to turn the operation into a X86 rep/movs or rep/stos
70 /// instruction. This is only used if the src / dst alignment is not DWORD
72 unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; }
74 /// Returns true if the instruction selector should treat global values
75 /// referencing external or weak symbols as indirect rather than direct
77 bool getIndirectExternAndWeakGlobals() const {
78 return indirectExternAndWeakGlobals;
81 /// ParseSubtargetFeatures - Parses features string setting specified
82 /// subtarget options. Definition of function is auto generated by tblgen.
83 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
85 bool is64Bit() const { return Is64Bit; }
87 bool hasMMX() const { return X86SSELevel >= MMX; }
88 bool hasSSE1() const { return X86SSELevel >= SSE1; }
89 bool hasSSE2() const { return X86SSELevel >= SSE2; }
90 bool hasSSE3() const { return X86SSELevel >= SSE3; }
91 bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
92 bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
94 } // End llvm namespace