14 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_X86_H 15 #define LLVM_CLANG_LIB_BASIC_TARGETS_X86_H 20 #include "llvm/ADT/Triple.h" 21 #include "llvm/Support/Compiler.h" 47 } MMX3DNowLevel = NoMMX3DNow;
48 enum XOPEnum { NoXOP, SSE4A, FMA4, XOP } XOPLevel = NoXOP;
52 bool HasPCLMUL =
false;
53 bool HasVPCLMULQDQ =
false;
55 bool HasLZCNT =
false;
56 bool HasRDRND =
false;
57 bool HasFSGSBASE =
false;
60 bool HasPOPCNT =
false;
62 bool HasPRFCHW =
false;
63 bool HasRDSEED =
false;
69 bool HasAVX512CD =
false;
70 bool HasAVX512VPOPCNTDQ =
false;
71 bool HasAVX512VNNI =
false;
72 bool HasAVX512ER =
false;
73 bool HasAVX512PF =
false;
74 bool HasAVX512DQ =
false;
75 bool HasAVX512BITALG =
false;
76 bool HasAVX512BW =
false;
77 bool HasAVX512VL =
false;
78 bool HasAVX512VBMI =
false;
79 bool HasAVX512VBMI2 =
false;
80 bool HasAVX512IFMA =
false;
83 bool HasSHSTK =
false;
87 bool HasXSAVE =
false;
88 bool HasXSAVEOPT =
false;
89 bool HasXSAVEC =
false;
90 bool HasXSAVES =
false;
91 bool HasMWAITX =
false;
92 bool HasCLZERO =
false;
93 bool HasCLDEMOTE =
false;
94 bool HasPCONFIG =
false;
96 bool HasCLFLUSHOPT =
false;
98 bool HasMOVBE =
false;
99 bool HasPREFETCHWT1 =
false;
100 bool HasRDPID =
false;
101 bool HasRetpolineExternalThunk =
false;
102 bool HasLAHFSAHF =
false;
103 bool HasWBNOINVD =
false;
104 bool HasWAITPKG =
false;
105 bool HasMOVDIRI =
false;
106 bool HasMOVDIR64B =
false;
107 bool HasPTWRITE =
false;
108 bool HasINVPCID =
false;
117 #define PROC(ENUM, STRING, IS64BIT) CK_##ENUM, 118 #include "clang/Basic/X86Target.def" 121 bool checkCPUKind(CPUKind
Kind)
const;
123 CPUKind getCPUKind(StringRef CPU)
const;
125 std::string getCPUKindCanonicalName(CPUKind
Kind)
const;
127 enum FPMathKind { FP_Default, FP_SSE, FP_387 } FPMath = FP_Default;
132 LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
137 return SSELevel == NoSSE ? 2 : 0;
148 bool validateCpuSupports(StringRef Name)
const override;
150 bool validateCpuIs(StringRef Name)
const override;
152 bool validateCPUSpecificCPUDispatch(StringRef Name)
const override;
154 char CPUSpecificManglingCharacter(StringRef Name)
const override;
156 void getCPUSpecificCPUDispatchFeatures(
160 bool validateAsmConstraint(
const char *&Name,
164 bool &HasSizeMismatch)
const override {
167 if (RegName.equals(
"esp") || RegName.equals(
"ebp")) {
169 HasSizeMismatch = RegSize != 32;
176 bool validateOutputSize(StringRef Constraint,
unsigned Size)
const override;
178 bool validateInputSize(StringRef Constraint,
unsigned Size)
const override;
191 virtual bool validateOperandSize(StringRef Constraint,
unsigned Size)
const;
193 std::string convertConstraint(
const char *&Constraint)
const override;
195 return "~{dirflag},~{fpsr},~{flags}";
199 StringRef Expression)
const override {
200 StringRef::iterator I, E;
201 for (I = Constraint.begin(), E = Constraint.end(); I != E; ++I) {
226 if ((++I != E) && ((*I ==
'0') || (*I ==
'z')))
242 static void setSSELevel(llvm::StringMap<bool> &Features, X86SSEEnum
Level,
245 static void setMMXLevel(llvm::StringMap<bool> &Features, MMX3DNowEnum Level,
248 static void setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level,
252 bool Enabled)
const override {
253 setFeatureEnabledImpl(Features, Name, Enabled);
258 static void setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
259 StringRef Name,
bool Enabled);
264 const std::vector<std::string> &FeaturesVec)
const override;
266 bool isValidFeatureName(StringRef Name)
const override;
268 bool hasFeature(StringRef Feature)
const override;
270 bool handleTargetFeatures(std::vector<std::string> &Features,
274 if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX512F)
276 if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX)
278 if (getTriple().getArch() == llvm::Triple::x86 &&
279 MMX3DNowLevel == NoMMX3DNow)
285 return checkCPUKind(getCPUKind(Name));
290 bool setCPU(
const std::string &Name)
override {
291 return checkCPUKind(CPU = getCPUKind(Name));
294 unsigned multiVersionSortPriority(StringRef Name)
const override;
296 bool setFPMath(StringRef Name)
override;
325 getSupportedOpenCLOpts().supportAll();
334 DoubleAlign = LongLongAlign = 32;
335 LongDoubleWidth = 96;
336 LongDoubleAlign = 32;
338 resetDataLayout(
"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
339 SizeType = UnsignedInt;
340 PtrDiffType = SignedInt;
341 IntPtrType = SignedInt;
345 RealTypeUsesObjCFPRet =
352 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
368 switch (Constraint[0]) {
398 unsigned Major, Minor, Micro;
399 getTriple().getOSVersion(Major, Minor, Micro);
401 if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 26) || Major == 0)
413 SizeType = UnsignedLong;
414 IntPtrType = SignedLong;
415 PtrDiffType = SignedLong;
424 LongDoubleWidth = 128;
425 LongDoubleAlign = 128;
427 MaxVectorAlign = 256;
429 llvm::Triple T = llvm::Triple(Triple);
431 UseSignedCharForObjCBool =
false;
432 SizeType = UnsignedLong;
433 IntPtrType = SignedLong;
434 resetDataLayout(
"e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128");
435 HasAlignMac68kSupport =
true;
456 DoubleAlign = LongLongAlign = 64;
458 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
459 resetDataLayout(IsWinCOFF
460 ?
"e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 461 :
"e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
472 LongDoubleWidth = LongDoubleAlign = 64;
473 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
509 DoubleAlign = LongLongAlign = 64;
510 resetDataLayout(
"e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
545 LongDoubleWidth = 64;
546 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
547 resetDataLayout(
"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32");
548 WIntType = UnsignedInt;
553 return CC ==
CC_C ? CCCR_OK : CCCR_Warning;
571 SizeType = UnsignedLong;
572 IntPtrType = SignedLong;
573 PtrDiffType = SignedLong;
589 const bool IsX32 = getTriple().getEnvironment() == llvm::Triple::GNUX32;
591 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
592 LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 32 : 64;
593 LongDoubleWidth = 128;
594 LongDoubleAlign = 128;
595 LargeArrayMinWidth = 128;
596 LargeArrayAlign = 128;
598 SizeType = IsX32 ? UnsignedInt : UnsignedLong;
599 PtrDiffType = IsX32 ? SignedInt : SignedLong;
600 IntPtrType = IsX32 ? SignedInt : SignedLong;
601 IntMaxType = IsX32 ? SignedLongLong : SignedLong;
602 Int64Type = IsX32 ? SignedLongLong : SignedLong;
606 resetDataLayout(IsX32
607 ?
"e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128" 608 : IsWinCOFF ?
"e-m:w-i64:64-f80:128-n8:16:32:64-S128" 609 :
"e-m:e-i64:64-f80:128-n8:16:32:64-S128");
615 ComplexLongDoubleUsesFP2Ret =
true;
618 HasBuiltinMSVaList =
true;
621 MaxAtomicPromoteWidth = 128;
622 MaxAtomicInlineWidth = 64;
666 bool &HasSizeMismatch)
const override {
669 if (RegName.equals(
"rsp") || RegName.equals(
"rbp")) {
671 HasSizeMismatch = RegSize != 64;
682 MaxAtomicInlineWidth = 128;
694 LongWidth = LongAlign = 32;
695 DoubleAlign = LongLongAlign = 64;
696 IntMaxType = SignedLongLong;
697 Int64Type = SignedLongLong;
698 SizeType = UnsignedLongLong;
699 PtrDiffType = SignedLongLong;
700 IntPtrType = SignedLongLong;
736 LongDoubleWidth = LongDoubleAlign = 64;
737 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
750 return CCK_MicrosoftWin64;
762 LongDoubleWidth = LongDoubleAlign = 128;
763 LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
774 TLSSupported =
false;
795 Int64Type = SignedLongLong;
797 llvm::Triple T = llvm::Triple(Triple);
799 UseSignedCharForObjCBool =
false;
800 resetDataLayout(
"e-m:o-i64:64-f80:128-n8:16:32:64-S128");
820 IntMaxType = SignedLongLong;
821 Int64Type = SignedLongLong;
832 LongDoubleWidth = 64;
833 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
843 LongDoubleFormat = &llvm::APFloat::IEEEquad();
850 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
virtual bool checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override
Check if the target supports CFProtection branch.
StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const override
Extracts a register from the passed constraint (if it is a single-register constraint) and the asm la...
void setMaxAtomicWidth() override
Set the maximum inline or promote width lock-free atomic operation for the given target.
void DefineStd(MacroBuilder &Builder, StringRef MacroName, const LangOptions &Opts)
DefineStd - Define a macro name and standard variants.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature...
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
unsigned getUnwindWordWidth() const override
__builtin_va_list as defined by the x86-64 ABI: http://refspecs.linuxbase.org/elf/x86_64-abi-0.21.pdf
X86TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Options for controlling the target.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
virtual bool validateOperandSize(StringRef Constraint, unsigned Size) const
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const override
Validate register name used for global register variables.
WindowsX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
AndroidX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument...
bool useFloat128ManglingForLongDouble() const override
Return true if the 'long double' type should be mangled like __float128.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
unsigned getFloatEvalMethod() const override
Return the value for the C99 FLT_EVAL_METHOD macro.
MicrosoftX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
X86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
DarwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override
Gets the default calling convention for the given target and declaration context. ...
MicrosoftX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Concrete class used by the front-end to report problems and issues.
unsigned getRegisterWidth() const override
Return the "preferred" register width on this target.
bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const override
Validate register name used for global register variables.
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
bool allowsLargerPreferedTypeAlignment() const override
Whether target allows to overalign ABI-specified preferred alignment.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
Exposes information about the current target.
AndroidX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getVisualStudioDefines(const LangOptions &Opts, MacroBuilder &Builder) const
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
HaikuX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
bool setCPU(const std::string &Name) override
Target the specified CPU.
CPUKind
Enumeration of all of the X86 CPUs supported by Clang.
StringRef getABI() const override
Get the ABI currently in use.
virtual bool checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override
Check if the target supports CFProtection branch.
void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
NetBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Defines the clang::TargetOptions class.
TargetInfo::CallingConvKind getCallingConvKind(bool ClangABICompat4) const override
CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override
Gets the default calling convention for the given target and declaration context. ...
RTEMSX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
bool useFP16ConversionIntrinsics() const override
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
OpenBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Dataflow Directional Tag Classes.
typedef char* __builtin_va_list;
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
bool validateOperandSize(StringRef Constraint, unsigned Size) const override
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument...
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
handleTargetFeatures - Perform initialization based on the user configured set of features...
bool hasSjLjLowering() const override
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm...
unsigned getFloatEvalMethod() const override
Return the value for the C99 FLT_EVAL_METHOD macro.
MCUX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
WindowsX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
void setSupportedOpenCLOpts() override
Set supported OpenCL extensions and optional core features.
MinGWX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
Defines the clang::TargetInfo interface.
void setFeatureEnabled(llvm::StringMap< bool > &Features, StringRef Name, bool Enabled) const override
Enable or disable a specific target feature; the feature name must be valid.
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
handleTargetFeatures - Perform initialization based on the user configured set of features...
CygwinX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
OpenBSDX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
MinGWX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
X86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
DarwinI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)