13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_X86_H 14 #define LLVM_CLANG_LIB_BASIC_TARGETS_X86_H 19 #include "llvm/ADT/Triple.h" 20 #include "llvm/Support/Compiler.h" 46 } MMX3DNowLevel = NoMMX3DNow;
47 enum XOPEnum { NoXOP, SSE4A, FMA4, XOP } XOPLevel = NoXOP;
51 bool HasPCLMUL =
false;
52 bool HasVPCLMULQDQ =
false;
54 bool HasLZCNT =
false;
55 bool HasRDRND =
false;
56 bool HasFSGSBASE =
false;
59 bool HasPOPCNT =
false;
61 bool HasPRFCHW =
false;
62 bool HasRDSEED =
false;
68 bool HasAVX512CD =
false;
69 bool HasAVX512VPOPCNTDQ =
false;
70 bool HasAVX512VNNI =
false;
71 bool HasAVX512BF16 =
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;
81 bool HasAVX512VP2INTERSECT =
false;
84 bool HasSHSTK =
false;
89 bool HasXSAVE =
false;
90 bool HasXSAVEOPT =
false;
91 bool HasXSAVEC =
false;
92 bool HasXSAVES =
false;
93 bool HasMWAITX =
false;
94 bool HasCLZERO =
false;
95 bool HasCLDEMOTE =
false;
96 bool HasPCONFIG =
false;
98 bool HasCLFLUSHOPT =
false;
100 bool HasMOVBE =
false;
101 bool HasPREFETCHWT1 =
false;
102 bool HasRDPID =
false;
103 bool HasRetpolineExternalThunk =
false;
104 bool HasLAHFSAHF =
false;
105 bool HasWBNOINVD =
false;
106 bool HasWAITPKG =
false;
107 bool HasMOVDIRI =
false;
108 bool HasMOVDIR64B =
false;
109 bool HasPTWRITE =
false;
110 bool HasINVPCID =
false;
111 bool HasENQCMD =
false;
120 #define PROC(ENUM, STRING, IS64BIT) CK_##ENUM, 121 #include "clang/Basic/X86Target.def" 124 bool checkCPUKind(CPUKind
Kind)
const;
126 CPUKind getCPUKind(StringRef CPU)
const;
128 enum FPMathKind { FP_Default, FP_SSE, FP_387 } FPMath = FP_Default;
133 LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
137 return LongDoubleFormat == &llvm::APFloat::IEEEquad() ?
"g" :
"e";
142 return SSELevel == NoSSE ? 2 : 0;
153 bool validateCpuSupports(StringRef Name)
const override;
155 bool validateCpuIs(StringRef Name)
const override;
157 bool validateCPUSpecificCPUDispatch(StringRef Name)
const override;
159 char CPUSpecificManglingCharacter(StringRef Name)
const override;
161 void getCPUSpecificCPUDispatchFeatures(
165 bool validateAsmConstraint(
const char *&Name,
169 bool &HasSizeMismatch)
const override {
172 if (RegName.equals(
"esp") || RegName.equals(
"ebp")) {
174 HasSizeMismatch = RegSize != 32;
181 bool validateOutputSize(StringRef Constraint,
unsigned Size)
const override;
183 bool validateInputSize(StringRef Constraint,
unsigned Size)
const override;
196 virtual bool validateOperandSize(StringRef Constraint,
unsigned Size)
const;
198 std::string convertConstraint(
const char *&Constraint)
const override;
200 return "~{dirflag},~{fpsr},~{flags}";
204 StringRef Expression)
const override {
205 StringRef::iterator I, E;
206 for (I = Constraint.begin(), E = Constraint.end(); I != E; ++I) {
207 if (isalpha(*I) || *I ==
'@')
231 if ((++I != E) && ((*I ==
'0') || (*I ==
'z')))
247 static void setSSELevel(llvm::StringMap<bool> &Features, X86SSEEnum
Level,
250 static void setMMXLevel(llvm::StringMap<bool> &Features, MMX3DNowEnum Level,
253 static void setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level,
257 bool Enabled)
const override {
258 setFeatureEnabledImpl(Features, Name, Enabled);
263 static void setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
264 StringRef Name,
bool Enabled);
269 const std::vector<std::string> &FeaturesVec)
const override;
271 bool isValidFeatureName(StringRef Name)
const override;
273 bool hasFeature(StringRef Feature)
const override;
275 bool handleTargetFeatures(std::vector<std::string> &Features,
279 if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX512F)
281 if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX)
283 if (getTriple().getArch() == llvm::Triple::x86 &&
284 MMX3DNowLevel == NoMMX3DNow)
290 return checkCPUKind(getCPUKind(Name));
295 bool setCPU(
const std::string &Name)
override {
296 return checkCPUKind(CPU = getCPUKind(Name));
299 unsigned multiVersionSortPriority(StringRef Name)
const override;
301 bool setFPMath(StringRef Name)
override;
330 getSupportedOpenCLOpts().supportAll();
339 DoubleAlign = LongLongAlign = 32;
340 LongDoubleWidth = 96;
341 LongDoubleAlign = 32;
343 resetDataLayout(
"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
344 SizeType = UnsignedInt;
345 PtrDiffType = SignedInt;
346 IntPtrType = SignedInt;
350 RealTypeUsesObjCFPRet =
355 MaxAtomicPromoteWidth = 64;
356 MaxAtomicInlineWidth = 32;
372 switch (Constraint[0]) {
394 MaxAtomicInlineWidth = 64;
407 unsigned Major, Minor, Micro;
408 getTriple().getOSVersion(Major, Minor, Micro);
410 if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 26) || Major == 0)
422 SizeType = UnsignedLong;
423 IntPtrType = SignedLong;
424 PtrDiffType = SignedLong;
433 LongDoubleWidth = 128;
434 LongDoubleAlign = 128;
436 MaxVectorAlign = 256;
438 llvm::Triple T = llvm::Triple(Triple);
440 UseSignedCharForObjCBool =
false;
441 SizeType = UnsignedLong;
442 IntPtrType = SignedLong;
443 resetDataLayout(
"e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128");
444 HasAlignMac68kSupport =
true;
465 DoubleAlign = LongLongAlign = 64;
467 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
468 resetDataLayout(IsWinCOFF
469 ?
"e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 470 :
"e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
481 LongDoubleWidth = LongDoubleAlign = 64;
482 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
517 DoubleAlign = LongLongAlign = 64;
518 resetDataLayout(
"e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
553 LongDoubleWidth = 64;
554 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
555 resetDataLayout(
"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32");
556 WIntType = UnsignedInt;
561 return CC ==
CC_C ? CCCR_OK : CCCR_Warning;
579 SizeType = UnsignedLong;
580 IntPtrType = SignedLong;
581 PtrDiffType = SignedLong;
597 const bool IsX32 = getTriple().getEnvironment() == llvm::Triple::GNUX32;
599 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
600 LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 32 : 64;
601 LongDoubleWidth = 128;
602 LongDoubleAlign = 128;
603 LargeArrayMinWidth = 128;
604 LargeArrayAlign = 128;
606 SizeType = IsX32 ? UnsignedInt : UnsignedLong;
607 PtrDiffType = IsX32 ? SignedInt : SignedLong;
608 IntPtrType = IsX32 ? SignedInt : SignedLong;
609 IntMaxType = IsX32 ? SignedLongLong : SignedLong;
610 Int64Type = IsX32 ? SignedLongLong : SignedLong;
614 resetDataLayout(IsX32
615 ?
"e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128" 616 : IsWinCOFF ?
"e-m:w-i64:64-f80:128-n8:16:32:64-S128" 617 :
"e-m:e-i64:64-f80:128-n8:16:32:64-S128");
623 ComplexLongDoubleUsesFP2Ret =
true;
626 HasBuiltinMSVaList =
true;
629 MaxAtomicPromoteWidth = 128;
630 MaxAtomicInlineWidth = 64;
674 bool &HasSizeMismatch)
const override {
677 if (RegName.equals(
"rsp") || RegName.equals(
"rbp")) {
679 HasSizeMismatch = RegSize != 64;
690 MaxAtomicInlineWidth = 128;
702 LongWidth = LongAlign = 32;
703 DoubleAlign = LongLongAlign = 64;
704 IntMaxType = SignedLongLong;
705 Int64Type = SignedLongLong;
706 SizeType = UnsignedLongLong;
707 PtrDiffType = SignedLongLong;
708 IntPtrType = SignedLongLong;
744 LongDoubleWidth = LongDoubleAlign = 64;
745 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
757 return CCK_MicrosoftWin64;
769 LongDoubleWidth = LongDoubleAlign = 128;
770 LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
781 TLSSupported =
false;
802 Int64Type = SignedLongLong;
804 llvm::Triple T = llvm::Triple(Triple);
806 UseSignedCharForObjCBool =
false;
807 resetDataLayout(
"e-m:o-i64:64-f80:128-n8:16:32:64-S128");
827 IntMaxType = SignedLongLong;
828 Int64Type = SignedLongLong;
839 LongDoubleWidth = 64;
840 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
850 LongDoubleFormat = &llvm::APFloat::IEEEquad();
855 #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...
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)
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)
CallingConv getDefaultCallingConv() const override
Gets the default calling convention for the given target and declaration context. ...
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 getDefaultCallingConv() const override
Gets the default calling convention for the given target and declaration context. ...
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
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)
const char * getLongDoubleMangling() const override
Return the mangled code of long double.
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)
void setMaxAtomicWidth() override
Set the maximum inline or promote width lock-free atomic operation for the given target.