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" 61 } MMX3DNowLevel = NoMMX3DNow;
62 enum XOPEnum { NoXOP, SSE4A, FMA4, XOP } XOPLevel = NoXOP;
67 bool HasPCLMUL =
false;
68 bool HasVPCLMULQDQ =
false;
70 bool HasLZCNT =
false;
71 bool HasRDRND =
false;
72 bool HasFSGSBASE =
false;
75 bool HasPOPCNT =
false;
77 bool HasPRFCHW =
false;
78 bool HasRDSEED =
false;
84 bool HasAVX512CD =
false;
85 bool HasAVX512VPOPCNTDQ =
false;
86 bool HasAVX512VNNI =
false;
87 bool HasAVX512BF16 =
false;
88 bool HasAVX512ER =
false;
89 bool HasAVX512PF =
false;
90 bool HasAVX512DQ =
false;
91 bool HasAVX512BITALG =
false;
92 bool HasAVX512BW =
false;
93 bool HasAVX512VL =
false;
94 bool HasAVX512VBMI =
false;
95 bool HasAVX512VBMI2 =
false;
96 bool HasAVX512IFMA =
false;
97 bool HasAVX512VP2INTERSECT =
false;
99 bool HasSHSTK =
false;
102 bool HasCX16 =
false;
103 bool HasFXSR =
false;
104 bool HasXSAVE =
false;
105 bool HasXSAVEOPT =
false;
106 bool HasXSAVEC =
false;
107 bool HasXSAVES =
false;
108 bool HasMWAITX =
false;
109 bool HasCLZERO =
false;
110 bool HasCLDEMOTE =
false;
111 bool HasPCONFIG =
false;
113 bool HasCLFLUSHOPT =
false;
114 bool HasCLWB =
false;
115 bool HasMOVBE =
false;
116 bool HasPREFETCHWT1 =
false;
117 bool HasRDPID =
false;
118 bool HasRetpolineExternalThunk =
false;
119 bool HasLAHFSAHF =
false;
120 bool HasWBNOINVD =
false;
121 bool HasWAITPKG =
false;
122 bool HasMOVDIRI =
false;
123 bool HasMOVDIR64B =
false;
124 bool HasPTWRITE =
false;
125 bool HasINVPCID =
false;
126 bool HasENQCMD =
false;
135 #define PROC(ENUM, STRING, IS64BIT) CK_##ENUM, 136 #include "clang/Basic/X86Target.def" 139 bool checkCPUKind(CPUKind
Kind)
const;
141 CPUKind getCPUKind(StringRef CPU)
const;
143 enum FPMathKind { FP_Default, FP_SSE, FP_387 } FPMath = FP_Default;
148 LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
153 return LongDoubleFormat == &llvm::APFloat::IEEEquad() ?
"g" :
"e";
158 return SSELevel == NoSSE ? 2 : 0;
169 bool validateCpuSupports(StringRef Name)
const override;
171 bool validateCpuIs(StringRef Name)
const override;
173 bool validateCPUSpecificCPUDispatch(StringRef Name)
const override;
175 char CPUSpecificManglingCharacter(StringRef Name)
const override;
177 void getCPUSpecificCPUDispatchFeatures(
181 bool validateAsmConstraint(
const char *&Name,
185 bool &HasSizeMismatch)
const override {
188 if (RegName.equals(
"esp") || RegName.equals(
"ebp")) {
190 HasSizeMismatch = RegSize != 32;
197 bool validateOutputSize(
const llvm::StringMap<bool> &FeatureMap,
198 StringRef Constraint,
unsigned Size)
const override;
200 bool validateInputSize(
const llvm::StringMap<bool> &FeatureMap,
201 StringRef Constraint,
unsigned Size)
const override;
213 virtual bool validateOperandSize(
const llvm::StringMap<bool> &FeatureMap,
214 StringRef Constraint,
unsigned Size)
const;
216 std::string convertConstraint(
const char *&Constraint)
const override;
218 return "~{dirflag},~{fpsr},~{flags}";
222 StringRef Expression)
const override {
223 StringRef::iterator I, E;
224 for (I = Constraint.begin(), E = Constraint.end(); I != E; ++I) {
225 if (isalpha(*I) || *I ==
'@')
249 if ((++I != E) && ((*I ==
'0') || (*I ==
'z')))
265 static void setSSELevel(llvm::StringMap<bool> &Features, X86SSEEnum
Level,
268 static void setMMXLevel(llvm::StringMap<bool> &Features, MMX3DNowEnum Level,
271 static void setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level,
275 bool Enabled)
const override {
276 setFeatureEnabledImpl(Features, Name, Enabled);
281 static void setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
282 StringRef Name,
bool Enabled);
287 const std::vector<std::string> &FeaturesVec)
const override;
289 bool isValidFeatureName(StringRef Name)
const override;
291 bool hasFeature(StringRef Feature)
const override;
293 bool handleTargetFeatures(std::vector<std::string> &Features,
297 if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX512F)
299 if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX)
301 if (getTriple().getArch() == llvm::Triple::x86 &&
302 MMX3DNowLevel == NoMMX3DNow)
308 return checkCPUKind(getCPUKind(Name));
313 bool setCPU(
const std::string &Name)
override {
314 return checkCPUKind(CPU = getCPUKind(Name));
317 unsigned multiVersionSortPriority(StringRef Name)
const override;
319 bool setFPMath(StringRef Name)
override;
348 getSupportedOpenCLOpts().supportAll();
354 if (AddrSpace ==
ptr64)
360 return getPointerWidthV(AddrSpace);
369 DoubleAlign = LongLongAlign = 32;
370 LongDoubleWidth = 96;
371 LongDoubleAlign = 32;
373 resetDataLayout(
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-" 374 "f80:32-n8:16:32-S128");
375 SizeType = UnsignedInt;
376 PtrDiffType = SignedInt;
377 IntPtrType = SignedInt;
381 RealTypeUsesObjCFPRet =
386 MaxAtomicPromoteWidth = 64;
387 MaxAtomicInlineWidth = 32;
403 StringRef Constraint,
unsigned Size)
const override {
404 switch (Constraint[0]) {
426 MaxAtomicInlineWidth = 64;
439 unsigned Major, Minor, Micro;
440 getTriple().getOSVersion(Major, Minor, Micro);
442 if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 26) || Major == 0)
454 SizeType = UnsignedLong;
455 IntPtrType = SignedLong;
456 PtrDiffType = SignedLong;
465 LongDoubleWidth = 128;
466 LongDoubleAlign = 128;
468 MaxVectorAlign = 256;
470 llvm::Triple T = llvm::Triple(Triple);
472 UseSignedCharForObjCBool =
false;
473 SizeType = UnsignedLong;
474 IntPtrType = SignedLong;
475 resetDataLayout(
"e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-" 476 "f80:128-n8:16:32-S128");
477 HasAlignMac68kSupport =
true;
498 DoubleAlign = LongLongAlign = 64;
500 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
501 resetDataLayout(IsWinCOFF ?
"e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:" 502 "64-i64:64-f80:32-n8:16:32-a:0:32-S32" 503 :
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:" 504 "64-i64:64-f80:32-n8:16:32-a:0:32-S32");
515 LongDoubleWidth = LongDoubleAlign = 64;
516 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
551 DoubleAlign = LongLongAlign = 64;
552 resetDataLayout(
"e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:" 553 "32-n8:16:32-a:0:32-S32");
588 LongDoubleWidth = 64;
589 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
590 resetDataLayout(
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:32-f64:" 591 "32-f128:32-n8:16:32-a:0:32-S32");
592 WIntType = UnsignedInt;
597 return CC ==
CC_C ? CCCR_OK : CCCR_Warning;
615 SizeType = UnsignedLong;
616 IntPtrType = SignedLong;
617 PtrDiffType = SignedLong;
633 const bool IsX32 = getTriple().getEnvironment() == llvm::Triple::GNUX32;
635 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
636 LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 32 : 64;
637 LongDoubleWidth = 128;
638 LongDoubleAlign = 128;
639 LargeArrayMinWidth = 128;
640 LargeArrayAlign = 128;
642 SizeType = IsX32 ? UnsignedInt : UnsignedLong;
643 PtrDiffType = IsX32 ? SignedInt : SignedLong;
644 IntPtrType = IsX32 ? SignedInt : SignedLong;
645 IntMaxType = IsX32 ? SignedLongLong : SignedLong;
646 Int64Type = IsX32 ? SignedLongLong : SignedLong;
650 resetDataLayout(IsX32 ?
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-" 651 "i64:64-f80:128-n8:16:32:64-S128" 652 : IsWinCOFF ?
"e-m:w-p270:32:32-p271:32:32-p272:64:" 653 "64-i64:64-f80:128-n8:16:32:64-S128" 654 :
"e-m:e-p270:32:32-p271:32:32-p272:64:" 655 "64-i64:64-f80:128-n8:16:32:64-S128");
661 ComplexLongDoubleUsesFP2Ret =
true;
664 HasBuiltinMSVaList =
true;
667 MaxAtomicPromoteWidth = 128;
668 MaxAtomicInlineWidth = 64;
712 bool &HasSizeMismatch)
const override {
715 if (RegName.equals(
"rsp") || RegName.equals(
"rbp")) {
717 HasSizeMismatch = RegSize != 64;
728 MaxAtomicInlineWidth = 128;
740 LongWidth = LongAlign = 32;
741 DoubleAlign = LongLongAlign = 64;
742 IntMaxType = SignedLongLong;
743 Int64Type = SignedLongLong;
744 SizeType = UnsignedLongLong;
745 PtrDiffType = SignedLongLong;
746 IntPtrType = SignedLongLong;
782 LongDoubleWidth = LongDoubleAlign = 64;
783 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
795 return CCK_MicrosoftWin64;
807 LongDoubleWidth = LongDoubleAlign = 128;
808 LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
819 TLSSupported =
false;
840 Int64Type = SignedLongLong;
842 llvm::Triple T = llvm::Triple(Triple);
844 UseSignedCharForObjCBool =
false;
845 resetDataLayout(
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:" 866 IntMaxType = SignedLongLong;
867 Int64Type = SignedLongLong;
878 LongDoubleWidth = 64;
879 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
889 LongDoubleFormat = &llvm::APFloat::IEEEquad();
894 #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.
uint64_t getPointerWidthV(unsigned AddrSpace) const override
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.
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
virtual bool validateOperandSize(const llvm::StringMap< bool > &FeatureMap, StringRef Constraint, unsigned Size) const
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...
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
static const unsigned X86AddrSpaceMap[]
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)
bool validateOperandSize(const llvm::StringMap< bool > &FeatureMap, StringRef Constraint, unsigned Size) const override
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.
uint64_t getPointerAlignV(unsigned AddrSpace) 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)
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 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.