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 HasRetpoline =
false;
102 bool HasRetpolineExternalThunk =
false;
103 bool HasLAHFSAHF =
false;
104 bool HasWBNOINVD =
false;
105 bool HasWAITPKG =
false;
106 bool HasMOVDIRI =
false;
107 bool HasMOVDIR64B =
false;
108 bool HasPTWRITE =
false;
109 bool HasINVPCID =
false;
118 #define PROC(ENUM, STRING, IS64BIT) CK_##ENUM, 119 #include "clang/Basic/X86Target.def" 122 bool checkCPUKind(CPUKind
Kind)
const;
124 CPUKind getCPUKind(StringRef CPU)
const;
126 std::string getCPUKindCanonicalName(CPUKind
Kind)
const;
128 enum FPMathKind { FP_Default, FP_SSE, FP_387 } FPMath = FP_Default;
133 LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
138 return SSELevel == NoSSE ? 2 : 0;
149 bool validateCpuSupports(StringRef Name)
const override;
151 bool validateCpuIs(StringRef Name)
const override;
153 bool validateCPUSpecificCPUDispatch(StringRef Name)
const override;
155 char CPUSpecificManglingCharacter(StringRef Name)
const override;
157 void getCPUSpecificCPUDispatchFeatures(
161 bool validateAsmConstraint(
const char *&Name,
165 bool &HasSizeMismatch)
const override {
168 if (RegName.equals(
"esp") || RegName.equals(
"ebp")) {
170 HasSizeMismatch = RegSize != 32;
177 bool validateOutputSize(StringRef Constraint,
unsigned Size)
const override;
179 bool validateInputSize(StringRef Constraint,
unsigned Size)
const override;
192 virtual bool validateOperandSize(StringRef Constraint,
unsigned Size)
const;
194 std::string convertConstraint(
const char *&Constraint)
const override;
196 return "~{dirflag},~{fpsr},~{flags}";
200 StringRef Expression)
const override {
201 StringRef::iterator I, E;
202 for (I = Constraint.begin(), E = Constraint.end(); I != E; ++I) {
227 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));
295 return getTriple().isOSBinFormatELF();
297 unsigned multiVersionSortPriority(StringRef Name)
const override;
299 bool setFPMath(StringRef Name)
override;
328 getSupportedOpenCLOpts().supportAll();
337 DoubleAlign = LongLongAlign = 32;
338 LongDoubleWidth = 96;
339 LongDoubleAlign = 32;
341 resetDataLayout(
"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
342 SizeType = UnsignedInt;
343 PtrDiffType = SignedInt;
344 IntPtrType = SignedInt;
348 RealTypeUsesObjCFPRet =
355 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
371 switch (Constraint[0]) {
401 unsigned Major, Minor, Micro;
402 getTriple().getOSVersion(Major, Minor, Micro);
404 if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 26) || Major == 0)
416 SizeType = UnsignedLong;
417 IntPtrType = SignedLong;
418 PtrDiffType = SignedLong;
427 LongDoubleWidth = 128;
428 LongDoubleAlign = 128;
430 MaxVectorAlign = 256;
432 llvm::Triple T = llvm::Triple(Triple);
434 UseSignedCharForObjCBool =
false;
435 SizeType = UnsignedLong;
436 IntPtrType = SignedLong;
437 resetDataLayout(
"e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128");
438 HasAlignMac68kSupport =
true;
459 DoubleAlign = LongLongAlign = 64;
461 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
462 resetDataLayout(IsWinCOFF
463 ?
"e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 464 :
"e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
475 LongDoubleWidth = LongDoubleAlign = 64;
476 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
512 DoubleAlign = LongLongAlign = 64;
513 resetDataLayout(
"e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
548 LongDoubleWidth = 64;
549 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
550 resetDataLayout(
"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32");
551 WIntType = UnsignedInt;
556 return CC ==
CC_C ? CCCR_OK : CCCR_Warning;
574 SizeType = UnsignedLong;
575 IntPtrType = SignedLong;
576 PtrDiffType = SignedLong;
592 const bool IsX32 = getTriple().getEnvironment() == llvm::Triple::GNUX32;
594 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
595 LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 32 : 64;
596 LongDoubleWidth = 128;
597 LongDoubleAlign = 128;
598 LargeArrayMinWidth = 128;
599 LargeArrayAlign = 128;
601 SizeType = IsX32 ? UnsignedInt : UnsignedLong;
602 PtrDiffType = IsX32 ? SignedInt : SignedLong;
603 IntPtrType = IsX32 ? SignedInt : SignedLong;
604 IntMaxType = IsX32 ? SignedLongLong : SignedLong;
605 Int64Type = IsX32 ? SignedLongLong : SignedLong;
609 resetDataLayout(IsX32
610 ?
"e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128" 611 : IsWinCOFF ?
"e-m:w-i64:64-f80:128-n8:16:32:64-S128" 612 :
"e-m:e-i64:64-f80:128-n8:16:32:64-S128");
618 ComplexLongDoubleUsesFP2Ret =
true;
621 HasBuiltinMSVaList =
true;
624 MaxAtomicPromoteWidth = 128;
625 MaxAtomicInlineWidth = 64;
669 bool &HasSizeMismatch)
const override {
672 if (RegName.equals(
"rsp") || RegName.equals(
"rbp")) {
674 HasSizeMismatch = RegSize != 64;
685 MaxAtomicInlineWidth = 128;
697 LongWidth = LongAlign = 32;
698 DoubleAlign = LongLongAlign = 64;
699 IntMaxType = SignedLongLong;
700 Int64Type = SignedLongLong;
701 SizeType = UnsignedLongLong;
702 PtrDiffType = SignedLongLong;
703 IntPtrType = SignedLongLong;
739 LongDoubleWidth = LongDoubleAlign = 64;
740 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
753 return CCK_MicrosoftWin64;
765 LongDoubleWidth = LongDoubleAlign = 128;
766 LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
777 TLSSupported =
false;
798 Int64Type = SignedLongLong;
800 llvm::Triple T = llvm::Triple(Triple);
802 UseSignedCharForObjCBool =
false;
803 resetDataLayout(
"e-m:o-i64:64-f80:128-n8:16:32:64-S128");
823 IntMaxType = SignedLongLong;
824 Int64Type = SignedLongLong;
835 LongDoubleWidth = 64;
836 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
846 LongDoubleFormat = &llvm::APFloat::IEEEquad();
853 #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.
bool supportsMultiVersioning() const override
Identify whether this taret supports multiversioning of functions, which requires support for cpu_sup...
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)