10b57cec5SDimitry Andric //===--- X86.h - Declare X86 target feature support -------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file declares X86 TargetInfo objects. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_X86_H 140b57cec5SDimitry Andric #define LLVM_CLANG_LIB_BASIC_TARGETS_X86_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "OSTargets.h" 1781ad6265SDimitry Andric #include "clang/Basic/BitmaskEnum.h" 180b57cec5SDimitry Andric #include "clang/Basic/TargetInfo.h" 190b57cec5SDimitry Andric #include "clang/Basic/TargetOptions.h" 200b57cec5SDimitry Andric #include "llvm/Support/Compiler.h" 2106c3fb27SDimitry Andric #include "llvm/TargetParser/Triple.h" 2206c3fb27SDimitry Andric #include "llvm/TargetParser/X86TargetParser.h" 23bdd1243dSDimitry Andric #include <optional> 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric namespace clang { 260b57cec5SDimitry Andric namespace targets { 270b57cec5SDimitry Andric 28480093f4SDimitry Andric static const unsigned X86AddrSpaceMap[] = { 29480093f4SDimitry Andric 0, // Default 30480093f4SDimitry Andric 0, // opencl_global 31480093f4SDimitry Andric 0, // opencl_local 32480093f4SDimitry Andric 0, // opencl_constant 33480093f4SDimitry Andric 0, // opencl_private 34480093f4SDimitry Andric 0, // opencl_generic 35e8d8bef9SDimitry Andric 0, // opencl_global_device 36e8d8bef9SDimitry Andric 0, // opencl_global_host 37480093f4SDimitry Andric 0, // cuda_device 38480093f4SDimitry Andric 0, // cuda_constant 39480093f4SDimitry Andric 0, // cuda_shared 40fe6060f1SDimitry Andric 0, // sycl_global 41fe6060f1SDimitry Andric 0, // sycl_global_device 42fe6060f1SDimitry Andric 0, // sycl_global_host 43fe6060f1SDimitry Andric 0, // sycl_local 44fe6060f1SDimitry Andric 0, // sycl_private 45480093f4SDimitry Andric 270, // ptr32_sptr 46480093f4SDimitry Andric 271, // ptr32_uptr 47bdd1243dSDimitry Andric 272, // ptr64 48bdd1243dSDimitry Andric 0, // hlsl_groupshared 4906c3fb27SDimitry Andric // Wasm address space values for this target are dummy values, 5006c3fb27SDimitry Andric // as it is only enabled for Wasm targets. 5106c3fb27SDimitry Andric 20, // wasm_funcref 52480093f4SDimitry Andric }; 53480093f4SDimitry Andric 540b57cec5SDimitry Andric // X86 target abstract base class; x86-32 and x86-64 are very close, so 550b57cec5SDimitry Andric // most of the implementation can be shared. 560b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric enum X86SSEEnum { 590b57cec5SDimitry Andric NoSSE, 600b57cec5SDimitry Andric SSE1, 610b57cec5SDimitry Andric SSE2, 620b57cec5SDimitry Andric SSE3, 630b57cec5SDimitry Andric SSSE3, 640b57cec5SDimitry Andric SSE41, 650b57cec5SDimitry Andric SSE42, 660b57cec5SDimitry Andric AVX, 670b57cec5SDimitry Andric AVX2, 680b57cec5SDimitry Andric AVX512F 690b57cec5SDimitry Andric } SSELevel = NoSSE; 70*0fca6ea1SDimitry Andric bool HasMMX = false; 710b57cec5SDimitry Andric enum XOPEnum { NoXOP, SSE4A, FMA4, XOP } XOPLevel = NoXOP; 72480093f4SDimitry Andric enum AddrSpace { ptr32_sptr = 270, ptr32_uptr = 271, ptr64 = 272 }; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric bool HasAES = false; 750b57cec5SDimitry Andric bool HasVAES = false; 760b57cec5SDimitry Andric bool HasPCLMUL = false; 770b57cec5SDimitry Andric bool HasVPCLMULQDQ = false; 780b57cec5SDimitry Andric bool HasGFNI = false; 790b57cec5SDimitry Andric bool HasLZCNT = false; 800b57cec5SDimitry Andric bool HasRDRND = false; 810b57cec5SDimitry Andric bool HasFSGSBASE = false; 820b57cec5SDimitry Andric bool HasBMI = false; 830b57cec5SDimitry Andric bool HasBMI2 = false; 840b57cec5SDimitry Andric bool HasPOPCNT = false; 850b57cec5SDimitry Andric bool HasRTM = false; 860b57cec5SDimitry Andric bool HasPRFCHW = false; 870b57cec5SDimitry Andric bool HasRDSEED = false; 880b57cec5SDimitry Andric bool HasADX = false; 890b57cec5SDimitry Andric bool HasTBM = false; 900b57cec5SDimitry Andric bool HasLWP = false; 910b57cec5SDimitry Andric bool HasFMA = false; 920b57cec5SDimitry Andric bool HasF16C = false; 935f757f3fSDimitry Andric bool HasAVX10_1 = false; 945f757f3fSDimitry Andric bool HasAVX10_1_512 = false; 955f757f3fSDimitry Andric bool HasEVEX512 = false; 960b57cec5SDimitry Andric bool HasAVX512CD = false; 970b57cec5SDimitry Andric bool HasAVX512VPOPCNTDQ = false; 980b57cec5SDimitry Andric bool HasAVX512VNNI = false; 99349cc55cSDimitry Andric bool HasAVX512FP16 = false; 1000b57cec5SDimitry Andric bool HasAVX512BF16 = false; 1010b57cec5SDimitry Andric bool HasAVX512DQ = false; 1020b57cec5SDimitry Andric bool HasAVX512BITALG = false; 1030b57cec5SDimitry Andric bool HasAVX512BW = false; 1040b57cec5SDimitry Andric bool HasAVX512VL = false; 1050b57cec5SDimitry Andric bool HasAVX512VBMI = false; 1060b57cec5SDimitry Andric bool HasAVX512VBMI2 = false; 107bdd1243dSDimitry Andric bool HasAVXIFMA = false; 1080b57cec5SDimitry Andric bool HasAVX512IFMA = false; 1090b57cec5SDimitry Andric bool HasAVX512VP2INTERSECT = false; 1100b57cec5SDimitry Andric bool HasSHA = false; 11106c3fb27SDimitry Andric bool HasSHA512 = false; 1120b57cec5SDimitry Andric bool HasSHSTK = false; 11306c3fb27SDimitry Andric bool HasSM3 = false; 1140b57cec5SDimitry Andric bool HasSGX = false; 11506c3fb27SDimitry Andric bool HasSM4 = false; 1160b57cec5SDimitry Andric bool HasCX8 = false; 1170b57cec5SDimitry Andric bool HasCX16 = false; 1180b57cec5SDimitry Andric bool HasFXSR = false; 1190b57cec5SDimitry Andric bool HasXSAVE = false; 1200b57cec5SDimitry Andric bool HasXSAVEOPT = false; 1210b57cec5SDimitry Andric bool HasXSAVEC = false; 1220b57cec5SDimitry Andric bool HasXSAVES = false; 1230b57cec5SDimitry Andric bool HasMWAITX = false; 1240b57cec5SDimitry Andric bool HasCLZERO = false; 1250b57cec5SDimitry Andric bool HasCLDEMOTE = false; 1260b57cec5SDimitry Andric bool HasPCONFIG = false; 1270b57cec5SDimitry Andric bool HasPKU = false; 1280b57cec5SDimitry Andric bool HasCLFLUSHOPT = false; 1290b57cec5SDimitry Andric bool HasCLWB = false; 1300b57cec5SDimitry Andric bool HasMOVBE = false; 131bdd1243dSDimitry Andric bool HasPREFETCHI = false; 1320b57cec5SDimitry Andric bool HasRDPID = false; 133753f127fSDimitry Andric bool HasRDPRU = false; 1340b57cec5SDimitry Andric bool HasRetpolineExternalThunk = false; 1350b57cec5SDimitry Andric bool HasLAHFSAHF = false; 1360b57cec5SDimitry Andric bool HasWBNOINVD = false; 1370b57cec5SDimitry Andric bool HasWAITPKG = false; 1380b57cec5SDimitry Andric bool HasMOVDIRI = false; 1390b57cec5SDimitry Andric bool HasMOVDIR64B = false; 1400b57cec5SDimitry Andric bool HasPTWRITE = false; 1410b57cec5SDimitry Andric bool HasINVPCID = false; 1420b57cec5SDimitry Andric bool HasENQCMD = false; 14306c3fb27SDimitry Andric bool HasAVXVNNIINT16 = false; 144bdd1243dSDimitry Andric bool HasAMXFP16 = false; 145bdd1243dSDimitry Andric bool HasCMPCCXADD = false; 146bdd1243dSDimitry Andric bool HasRAOINT = false; 147bdd1243dSDimitry Andric bool HasAVXVNNIINT8 = false; 148bdd1243dSDimitry Andric bool HasAVXNECONVERT = false; 149e8d8bef9SDimitry Andric bool HasKL = false; // For key locker 150e8d8bef9SDimitry Andric bool HasWIDEKL = false; // For wide key locker 151e8d8bef9SDimitry Andric bool HasHRESET = false; 152e8d8bef9SDimitry Andric bool HasAVXVNNI = false; 1535ffd83dbSDimitry Andric bool HasAMXTILE = false; 1545ffd83dbSDimitry Andric bool HasAMXINT8 = false; 1555ffd83dbSDimitry Andric bool HasAMXBF16 = false; 15606c3fb27SDimitry Andric bool HasAMXCOMPLEX = false; 1575ffd83dbSDimitry Andric bool HasSERIALIZE = false; 1585ffd83dbSDimitry Andric bool HasTSXLDTRK = false; 1595f757f3fSDimitry Andric bool HasUSERMSR = false; 160e8d8bef9SDimitry Andric bool HasUINTR = false; 161349cc55cSDimitry Andric bool HasCRC32 = false; 162349cc55cSDimitry Andric bool HasX87 = false; 1635f757f3fSDimitry Andric bool HasEGPR = false; 1645f757f3fSDimitry Andric bool HasPush2Pop2 = false; 1655f757f3fSDimitry Andric bool HasPPX = false; 1665f757f3fSDimitry Andric bool HasNDD = false; 1675f757f3fSDimitry Andric bool HasCCMP = false; 168*0fca6ea1SDimitry Andric bool HasNF = false; 1695f757f3fSDimitry Andric bool HasCF = false; 170*0fca6ea1SDimitry Andric bool HasZU = false; 171*0fca6ea1SDimitry Andric bool HasInlineAsmUseGPR32 = false; 172*0fca6ea1SDimitry Andric bool HasBranchHint = false; 1730b57cec5SDimitry Andric 1740b57cec5SDimitry Andric protected: 1755ffd83dbSDimitry Andric llvm::X86::CPUKind CPU = llvm::X86::CK_None; 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andric enum FPMathKind { FP_Default, FP_SSE, FP_387 } FPMath = FP_Default; 1780b57cec5SDimitry Andric 1790b57cec5SDimitry Andric public: X86TargetInfo(const llvm::Triple & Triple,const TargetOptions &)1800b57cec5SDimitry Andric X86TargetInfo(const llvm::Triple &Triple, const TargetOptions &) 1810b57cec5SDimitry Andric : TargetInfo(Triple) { 18261cfbce3SDimitry Andric BFloat16Width = BFloat16Align = 16; 18361cfbce3SDimitry Andric BFloat16Format = &llvm::APFloat::BFloat(); 1840b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::x87DoubleExtended(); 185480093f4SDimitry Andric AddrSpaceMap = &X86AddrSpaceMap; 1865ffd83dbSDimitry Andric HasStrictFP = true; 187*0fca6ea1SDimitry Andric HasUnalignedAccess = true; 188e8d8bef9SDimitry Andric 189e8d8bef9SDimitry Andric bool IsWinCOFF = 190e8d8bef9SDimitry Andric getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); 191e8d8bef9SDimitry Andric if (IsWinCOFF) 192e8d8bef9SDimitry Andric MaxVectorAlign = MaxTLSAlign = 8192u * getCharWidth(); 1930b57cec5SDimitry Andric } 1940b57cec5SDimitry Andric getLongDoubleMangling()1950b57cec5SDimitry Andric const char *getLongDoubleMangling() const override { 1960b57cec5SDimitry Andric return LongDoubleFormat == &llvm::APFloat::IEEEquad() ? "g" : "e"; 1970b57cec5SDimitry Andric } 1980b57cec5SDimitry Andric getFPEvalMethod()19981ad6265SDimitry Andric LangOptions::FPEvalMethodKind getFPEvalMethod() const override { 2000b57cec5SDimitry Andric // X87 evaluates with 80 bits "long double" precision. 20181ad6265SDimitry Andric return SSELevel == NoSSE ? LangOptions::FPEvalMethodKind::FEM_Extended 20281ad6265SDimitry Andric : LangOptions::FPEvalMethodKind::FEM_Source; 2030b57cec5SDimitry Andric } 2040b57cec5SDimitry Andric 20581ad6265SDimitry Andric // EvalMethod `source` is not supported for targets with `NoSSE` feature. supportSourceEvalMethod()20681ad6265SDimitry Andric bool supportSourceEvalMethod() const override { return SSELevel > NoSSE; } 20781ad6265SDimitry Andric 2080b57cec5SDimitry Andric ArrayRef<const char *> getGCCRegNames() const override; 2090b57cec5SDimitry Andric getGCCRegAliases()2100b57cec5SDimitry Andric ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 211bdd1243dSDimitry Andric return std::nullopt; 2120b57cec5SDimitry Andric } 2130b57cec5SDimitry Andric 2140b57cec5SDimitry Andric ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override; 2150b57cec5SDimitry Andric isSPRegName(StringRef RegName)2165ffd83dbSDimitry Andric bool isSPRegName(StringRef RegName) const override { 217*0fca6ea1SDimitry Andric return RegName == "esp" || RegName == "rsp"; 2185ffd83dbSDimitry Andric } 2195ffd83dbSDimitry Andric supportsCpuSupports()220*0fca6ea1SDimitry Andric bool supportsCpuSupports() const override { return true; } supportsCpuIs()221*0fca6ea1SDimitry Andric bool supportsCpuIs() const override { return true; } supportsCpuInit()222*0fca6ea1SDimitry Andric bool supportsCpuInit() const override { return true; } 223*0fca6ea1SDimitry Andric 22406c3fb27SDimitry Andric bool validateCpuSupports(StringRef FeatureStr) const override; 2250b57cec5SDimitry Andric 22606c3fb27SDimitry Andric bool validateCpuIs(StringRef FeatureStr) const override; 2270b57cec5SDimitry Andric 2280b57cec5SDimitry Andric bool validateCPUSpecificCPUDispatch(StringRef Name) const override; 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andric char CPUSpecificManglingCharacter(StringRef Name) const override; 2310b57cec5SDimitry Andric 2320b57cec5SDimitry Andric void getCPUSpecificCPUDispatchFeatures( 2330b57cec5SDimitry Andric StringRef Name, 2340b57cec5SDimitry Andric llvm::SmallVectorImpl<StringRef> &Features) const override; 2350b57cec5SDimitry Andric 236bdd1243dSDimitry Andric std::optional<unsigned> getCPUCacheLineSize() const override; 2375ffd83dbSDimitry Andric 2380b57cec5SDimitry Andric bool validateAsmConstraint(const char *&Name, 2390b57cec5SDimitry Andric TargetInfo::ConstraintInfo &info) const override; 2400b57cec5SDimitry Andric validateGlobalRegisterVariable(StringRef RegName,unsigned RegSize,bool & HasSizeMismatch)2410b57cec5SDimitry Andric bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, 2420b57cec5SDimitry Andric bool &HasSizeMismatch) const override { 2430b57cec5SDimitry Andric // esp and ebp are the only 32-bit registers the x86 backend can currently 2440b57cec5SDimitry Andric // handle. 245*0fca6ea1SDimitry Andric if (RegName == "esp" || RegName == "ebp") { 2460b57cec5SDimitry Andric // Check that the register size is 32-bit. 2470b57cec5SDimitry Andric HasSizeMismatch = RegSize != 32; 2480b57cec5SDimitry Andric return true; 2490b57cec5SDimitry Andric } 2500b57cec5SDimitry Andric 2510b57cec5SDimitry Andric return false; 2520b57cec5SDimitry Andric } 2530b57cec5SDimitry Andric 254480093f4SDimitry Andric bool validateOutputSize(const llvm::StringMap<bool> &FeatureMap, 255480093f4SDimitry Andric StringRef Constraint, unsigned Size) const override; 2560b57cec5SDimitry Andric 257480093f4SDimitry Andric bool validateInputSize(const llvm::StringMap<bool> &FeatureMap, 258480093f4SDimitry Andric StringRef Constraint, unsigned Size) const override; 2590b57cec5SDimitry Andric 260972a253aSDimitry Andric bool checkCFProtectionReturnSupported(DiagnosticsEngine & Diags)2610b57cec5SDimitry Andric checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override { 2629c231325SEd Maste if (CPU == llvm::X86::CK_None || CPU >= llvm::X86::CK_PentiumPro) 2630b57cec5SDimitry Andric return true; 2649c231325SEd Maste return TargetInfo::checkCFProtectionReturnSupported(Diags); 2650b57cec5SDimitry Andric }; 2660b57cec5SDimitry Andric 267972a253aSDimitry Andric bool checkCFProtectionBranchSupported(DiagnosticsEngine & Diags)2680b57cec5SDimitry Andric checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override { 2699c231325SEd Maste if (CPU == llvm::X86::CK_None || CPU >= llvm::X86::CK_PentiumPro) 2700b57cec5SDimitry Andric return true; 2719c231325SEd Maste return TargetInfo::checkCFProtectionBranchSupported(Diags); 2720b57cec5SDimitry Andric }; 2730b57cec5SDimitry Andric 274480093f4SDimitry Andric virtual bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap, 275480093f4SDimitry Andric StringRef Constraint, unsigned Size) const; 2760b57cec5SDimitry Andric 2770b57cec5SDimitry Andric std::string convertConstraint(const char *&Constraint) const override; getClobbers()27806c3fb27SDimitry Andric std::string_view getClobbers() const override { 2790b57cec5SDimitry Andric return "~{dirflag},~{fpsr},~{flags}"; 2800b57cec5SDimitry Andric } 2810b57cec5SDimitry Andric getConstraintRegister(StringRef Constraint,StringRef Expression)2820b57cec5SDimitry Andric StringRef getConstraintRegister(StringRef Constraint, 2830b57cec5SDimitry Andric StringRef Expression) const override { 2840b57cec5SDimitry Andric StringRef::iterator I, E; 2850b57cec5SDimitry Andric for (I = Constraint.begin(), E = Constraint.end(); I != E; ++I) { 2860b57cec5SDimitry Andric if (isalpha(*I) || *I == '@') 2870b57cec5SDimitry Andric break; 2880b57cec5SDimitry Andric } 2890b57cec5SDimitry Andric if (I == E) 2900b57cec5SDimitry Andric return ""; 2910b57cec5SDimitry Andric switch (*I) { 2920b57cec5SDimitry Andric // For the register constraints, return the matching register name 2930b57cec5SDimitry Andric case 'a': 2940b57cec5SDimitry Andric return "ax"; 2950b57cec5SDimitry Andric case 'b': 2960b57cec5SDimitry Andric return "bx"; 2970b57cec5SDimitry Andric case 'c': 2980b57cec5SDimitry Andric return "cx"; 2990b57cec5SDimitry Andric case 'd': 3000b57cec5SDimitry Andric return "dx"; 3010b57cec5SDimitry Andric case 'S': 3020b57cec5SDimitry Andric return "si"; 3030b57cec5SDimitry Andric case 'D': 3040b57cec5SDimitry Andric return "di"; 3050b57cec5SDimitry Andric // In case the constraint is 'r' we need to return Expression 3060b57cec5SDimitry Andric case 'r': 3070b57cec5SDimitry Andric return Expression; 3080b57cec5SDimitry Andric // Double letters Y<x> constraints 3090b57cec5SDimitry Andric case 'Y': 3100b57cec5SDimitry Andric if ((++I != E) && ((*I == '0') || (*I == 'z'))) 3110b57cec5SDimitry Andric return "xmm0"; 3120b57cec5SDimitry Andric break; 3130b57cec5SDimitry Andric default: 3140b57cec5SDimitry Andric break; 3150b57cec5SDimitry Andric } 3160b57cec5SDimitry Andric return ""; 3170b57cec5SDimitry Andric } 3180b57cec5SDimitry Andric useFP16ConversionIntrinsics()3190b57cec5SDimitry Andric bool useFP16ConversionIntrinsics() const override { 3200b57cec5SDimitry Andric return false; 3210b57cec5SDimitry Andric } 3220b57cec5SDimitry Andric 3230b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 3240b57cec5SDimitry Andric MacroBuilder &Builder) const override; 3250b57cec5SDimitry Andric 3260b57cec5SDimitry Andric void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name, 3275ffd83dbSDimitry Andric bool Enabled) const final; 3280b57cec5SDimitry Andric 3290b57cec5SDimitry Andric bool 3300b57cec5SDimitry Andric initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, 3310b57cec5SDimitry Andric StringRef CPU, 3320b57cec5SDimitry Andric const std::vector<std::string> &FeaturesVec) const override; 3330b57cec5SDimitry Andric 3340b57cec5SDimitry Andric bool isValidFeatureName(StringRef Name) const override; 3350b57cec5SDimitry Andric 3365ffd83dbSDimitry Andric bool hasFeature(StringRef Feature) const final; 3370b57cec5SDimitry Andric 3380b57cec5SDimitry Andric bool handleTargetFeatures(std::vector<std::string> &Features, 3390b57cec5SDimitry Andric DiagnosticsEngine &Diags) override; 3400b57cec5SDimitry Andric getABI()3410b57cec5SDimitry Andric StringRef getABI() const override { 3420b57cec5SDimitry Andric if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX512F) 3430b57cec5SDimitry Andric return "avx512"; 3440b57cec5SDimitry Andric if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX) 3450b57cec5SDimitry Andric return "avx"; 346*0fca6ea1SDimitry Andric if (getTriple().getArch() == llvm::Triple::x86 && !HasMMX) 3470b57cec5SDimitry Andric return "no-mmx"; 3480b57cec5SDimitry Andric return ""; 3490b57cec5SDimitry Andric } 3500b57cec5SDimitry Andric supportsTargetAttributeTune()351e8d8bef9SDimitry Andric bool supportsTargetAttributeTune() const override { 352e8d8bef9SDimitry Andric return true; 353e8d8bef9SDimitry Andric } 354e8d8bef9SDimitry Andric isValidCPUName(StringRef Name)3550b57cec5SDimitry Andric bool isValidCPUName(StringRef Name) const override { 3565ffd83dbSDimitry Andric bool Only64Bit = getTriple().getArch() != llvm::Triple::x86; 3575ffd83dbSDimitry Andric return llvm::X86::parseArchX86(Name, Only64Bit) != llvm::X86::CK_None; 3580b57cec5SDimitry Andric } 3590b57cec5SDimitry Andric isValidTuneCPUName(StringRef Name)360e8d8bef9SDimitry Andric bool isValidTuneCPUName(StringRef Name) const override { 361e8d8bef9SDimitry Andric if (Name == "generic") 362e8d8bef9SDimitry Andric return true; 363e8d8bef9SDimitry Andric 364e8d8bef9SDimitry Andric // Allow 32-bit only CPUs regardless of 64-bit mode unlike isValidCPUName. 365e8d8bef9SDimitry Andric // NOTE: gcc rejects 32-bit mtune CPUs in 64-bit mode. But being lenient 366e8d8bef9SDimitry Andric // since mtune was ignored by clang for so long. 367e8d8bef9SDimitry Andric return llvm::X86::parseTuneCPU(Name) != llvm::X86::CK_None; 368e8d8bef9SDimitry Andric } 369e8d8bef9SDimitry Andric 3700b57cec5SDimitry Andric void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override; 371e8d8bef9SDimitry Andric void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const override; 3720b57cec5SDimitry Andric setCPU(const std::string & Name)3730b57cec5SDimitry Andric bool setCPU(const std::string &Name) override { 3745ffd83dbSDimitry Andric bool Only64Bit = getTriple().getArch() != llvm::Triple::x86; 3755ffd83dbSDimitry Andric CPU = llvm::X86::parseArchX86(Name, Only64Bit); 3765ffd83dbSDimitry Andric return CPU != llvm::X86::CK_None; 3770b57cec5SDimitry Andric } 3780b57cec5SDimitry Andric 3790b57cec5SDimitry Andric unsigned multiVersionSortPriority(StringRef Name) const override; 3800b57cec5SDimitry Andric 3810b57cec5SDimitry Andric bool setFPMath(StringRef Name) override; 3820b57cec5SDimitry Andric supportsExtendIntArgs()383fe6060f1SDimitry Andric bool supportsExtendIntArgs() const override { 384fe6060f1SDimitry Andric return getTriple().getArch() != llvm::Triple::x86; 385fe6060f1SDimitry Andric } 386fe6060f1SDimitry Andric checkCallingConvention(CallingConv CC)3870b57cec5SDimitry Andric CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { 3880b57cec5SDimitry Andric // Most of the non-ARM calling conventions are i386 conventions. 3890b57cec5SDimitry Andric switch (CC) { 3900b57cec5SDimitry Andric case CC_X86ThisCall: 3910b57cec5SDimitry Andric case CC_X86FastCall: 3920b57cec5SDimitry Andric case CC_X86StdCall: 3930b57cec5SDimitry Andric case CC_X86VectorCall: 3940b57cec5SDimitry Andric case CC_X86RegCall: 3950b57cec5SDimitry Andric case CC_C: 3960b57cec5SDimitry Andric case CC_PreserveMost: 3970b57cec5SDimitry Andric case CC_Swift: 3980b57cec5SDimitry Andric case CC_X86Pascal: 3990b57cec5SDimitry Andric case CC_IntelOclBicc: 4000b57cec5SDimitry Andric case CC_OpenCLKernel: 4010b57cec5SDimitry Andric return CCCR_OK; 402fe6060f1SDimitry Andric case CC_SwiftAsync: 403fe6060f1SDimitry Andric return CCCR_Error; 4040b57cec5SDimitry Andric default: 4050b57cec5SDimitry Andric return CCCR_Warning; 4060b57cec5SDimitry Andric } 4070b57cec5SDimitry Andric } 4080b57cec5SDimitry Andric checkArithmeticFenceSupported()409fe6060f1SDimitry Andric bool checkArithmeticFenceSupported() const override { return true; } 410fe6060f1SDimitry Andric getDefaultCallingConv()4110b57cec5SDimitry Andric CallingConv getDefaultCallingConv() const override { 4120b57cec5SDimitry Andric return CC_C; 4130b57cec5SDimitry Andric } 4140b57cec5SDimitry Andric hasSjLjLowering()4150b57cec5SDimitry Andric bool hasSjLjLowering() const override { return true; } 4160b57cec5SDimitry Andric setSupportedOpenCLOpts()417e8d8bef9SDimitry Andric void setSupportedOpenCLOpts() override { supportAllOpenCLOpts(); } 418480093f4SDimitry Andric getPointerWidthV(LangAS AS)419bdd1243dSDimitry Andric uint64_t getPointerWidthV(LangAS AS) const override { 420bdd1243dSDimitry Andric unsigned TargetAddrSpace = getTargetAddressSpace(AS); 421bdd1243dSDimitry Andric if (TargetAddrSpace == ptr32_sptr || TargetAddrSpace == ptr32_uptr) 422480093f4SDimitry Andric return 32; 423bdd1243dSDimitry Andric if (TargetAddrSpace == ptr64) 424480093f4SDimitry Andric return 64; 425480093f4SDimitry Andric return PointerWidth; 426480093f4SDimitry Andric } 427480093f4SDimitry Andric getPointerAlignV(LangAS AddrSpace)428bdd1243dSDimitry Andric uint64_t getPointerAlignV(LangAS AddrSpace) const override { 429480093f4SDimitry Andric return getPointerWidthV(AddrSpace); 430480093f4SDimitry Andric } 43161cfbce3SDimitry Andric 4320b57cec5SDimitry Andric }; 4330b57cec5SDimitry Andric 4340b57cec5SDimitry Andric // X86-32 generic target 4350b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY X86_32TargetInfo : public X86TargetInfo { 4360b57cec5SDimitry Andric public: X86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)4370b57cec5SDimitry Andric X86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 4380b57cec5SDimitry Andric : X86TargetInfo(Triple, Opts) { 4390b57cec5SDimitry Andric DoubleAlign = LongLongAlign = 32; 4400b57cec5SDimitry Andric LongDoubleWidth = 96; 4410b57cec5SDimitry Andric LongDoubleAlign = 32; 4420b57cec5SDimitry Andric SuitableAlign = 128; 4435f757f3fSDimitry Andric resetDataLayout(Triple.isOSBinFormatMachO() 4445f757f3fSDimitry Andric ? "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:" 4455f757f3fSDimitry Andric "128-f64:32:64-f80:32-n8:16:32-S128" 4465f757f3fSDimitry Andric : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:" 4475f757f3fSDimitry Andric "128-f64:32:64-f80:32-n8:16:32-S128", 448fe6060f1SDimitry Andric Triple.isOSBinFormatMachO() ? "_" : ""); 4490b57cec5SDimitry Andric SizeType = UnsignedInt; 4500b57cec5SDimitry Andric PtrDiffType = SignedInt; 4510b57cec5SDimitry Andric IntPtrType = SignedInt; 4520b57cec5SDimitry Andric RegParmMax = 3; 4530b57cec5SDimitry Andric 4540b57cec5SDimitry Andric // Use fpret for all types. 45581ad6265SDimitry Andric RealTypeUsesObjCFPRetMask = 456753f127fSDimitry Andric (unsigned)(FloatModeKind::Float | FloatModeKind::Double | 45781ad6265SDimitry Andric FloatModeKind::LongDouble); 4580b57cec5SDimitry Andric 4590b57cec5SDimitry Andric // x86-32 has atomics up to 8 bytes 4600b57cec5SDimitry Andric MaxAtomicPromoteWidth = 64; 4610b57cec5SDimitry Andric MaxAtomicInlineWidth = 32; 4620b57cec5SDimitry Andric } 4630b57cec5SDimitry Andric getBuiltinVaListKind()4640b57cec5SDimitry Andric BuiltinVaListKind getBuiltinVaListKind() const override { 4650b57cec5SDimitry Andric return TargetInfo::CharPtrBuiltinVaList; 4660b57cec5SDimitry Andric } 4670b57cec5SDimitry Andric getEHDataRegisterNumber(unsigned RegNo)4680b57cec5SDimitry Andric int getEHDataRegisterNumber(unsigned RegNo) const override { 4690b57cec5SDimitry Andric if (RegNo == 0) 4700b57cec5SDimitry Andric return 0; 4710b57cec5SDimitry Andric if (RegNo == 1) 4720b57cec5SDimitry Andric return 2; 4730b57cec5SDimitry Andric return -1; 4740b57cec5SDimitry Andric } 4750b57cec5SDimitry Andric validateOperandSize(const llvm::StringMap<bool> & FeatureMap,StringRef Constraint,unsigned Size)476480093f4SDimitry Andric bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap, 477480093f4SDimitry Andric StringRef Constraint, unsigned Size) const override { 4780b57cec5SDimitry Andric switch (Constraint[0]) { 4790b57cec5SDimitry Andric default: 4800b57cec5SDimitry Andric break; 4810b57cec5SDimitry Andric case 'R': 4820b57cec5SDimitry Andric case 'q': 4830b57cec5SDimitry Andric case 'Q': 4840b57cec5SDimitry Andric case 'a': 4850b57cec5SDimitry Andric case 'b': 4860b57cec5SDimitry Andric case 'c': 4870b57cec5SDimitry Andric case 'd': 4880b57cec5SDimitry Andric case 'S': 4890b57cec5SDimitry Andric case 'D': 4900b57cec5SDimitry Andric return Size <= 32; 4910b57cec5SDimitry Andric case 'A': 4920b57cec5SDimitry Andric return Size <= 64; 4930b57cec5SDimitry Andric } 4940b57cec5SDimitry Andric 495480093f4SDimitry Andric return X86TargetInfo::validateOperandSize(FeatureMap, Constraint, Size); 4960b57cec5SDimitry Andric } 4970b57cec5SDimitry Andric setMaxAtomicWidth()4980b57cec5SDimitry Andric void setMaxAtomicWidth() override { 4990b57cec5SDimitry Andric if (hasFeature("cx8")) 5000b57cec5SDimitry Andric MaxAtomicInlineWidth = 64; 5010b57cec5SDimitry Andric } 5020b57cec5SDimitry Andric 5030b57cec5SDimitry Andric ArrayRef<Builtin::Info> getTargetBuiltins() const override; 5045ffd83dbSDimitry Andric hasBitIntType()5050eae32dcSDimitry Andric bool hasBitIntType() const override { return true; } getMaxBitIntWidth()506bdd1243dSDimitry Andric size_t getMaxBitIntWidth() const override { 507bdd1243dSDimitry Andric return llvm::IntegerType::MAX_INT_BITS; 508bdd1243dSDimitry Andric } 5090b57cec5SDimitry Andric }; 5100b57cec5SDimitry Andric 5110b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo 5120b57cec5SDimitry Andric : public NetBSDTargetInfo<X86_32TargetInfo> { 5130b57cec5SDimitry Andric public: NetBSDI386TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)5140b57cec5SDimitry Andric NetBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 5150b57cec5SDimitry Andric : NetBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {} 5160b57cec5SDimitry Andric }; 5170b57cec5SDimitry Andric 5180b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY OpenBSDI386TargetInfo 5190b57cec5SDimitry Andric : public OpenBSDTargetInfo<X86_32TargetInfo> { 5200b57cec5SDimitry Andric public: OpenBSDI386TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)5210b57cec5SDimitry Andric OpenBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 5220b57cec5SDimitry Andric : OpenBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) { 5230b57cec5SDimitry Andric SizeType = UnsignedLong; 5240b57cec5SDimitry Andric IntPtrType = SignedLong; 5250b57cec5SDimitry Andric PtrDiffType = SignedLong; 5260b57cec5SDimitry Andric } 5270b57cec5SDimitry Andric }; 5280b57cec5SDimitry Andric 5290b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY DarwinI386TargetInfo 5300b57cec5SDimitry Andric : public DarwinTargetInfo<X86_32TargetInfo> { 5310b57cec5SDimitry Andric public: DarwinI386TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)5320b57cec5SDimitry Andric DarwinI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 5330b57cec5SDimitry Andric : DarwinTargetInfo<X86_32TargetInfo>(Triple, Opts) { 5340b57cec5SDimitry Andric LongDoubleWidth = 128; 5350b57cec5SDimitry Andric LongDoubleAlign = 128; 5360b57cec5SDimitry Andric SuitableAlign = 128; 5370b57cec5SDimitry Andric MaxVectorAlign = 256; 5380b57cec5SDimitry Andric // The watchOS simulator uses the builtin bool type for Objective-C. 5390b57cec5SDimitry Andric llvm::Triple T = llvm::Triple(Triple); 5400b57cec5SDimitry Andric if (T.isWatchOS()) 5410b57cec5SDimitry Andric UseSignedCharForObjCBool = false; 5420b57cec5SDimitry Andric SizeType = UnsignedLong; 5430b57cec5SDimitry Andric IntPtrType = SignedLong; 5445f757f3fSDimitry Andric resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-" 5455f757f3fSDimitry Andric "f64:32:64-f80:128-n8:16:32-S128", 5465f757f3fSDimitry Andric "_"); 5470b57cec5SDimitry Andric HasAlignMac68kSupport = true; 5480b57cec5SDimitry Andric } 5490b57cec5SDimitry Andric handleTargetFeatures(std::vector<std::string> & Features,DiagnosticsEngine & Diags)5500b57cec5SDimitry Andric bool handleTargetFeatures(std::vector<std::string> &Features, 5510b57cec5SDimitry Andric DiagnosticsEngine &Diags) override { 5520b57cec5SDimitry Andric if (!DarwinTargetInfo<X86_32TargetInfo>::handleTargetFeatures(Features, 5530b57cec5SDimitry Andric Diags)) 5540b57cec5SDimitry Andric return false; 5550b57cec5SDimitry Andric // We now know the features we have: we can decide how to align vectors. 5560b57cec5SDimitry Andric MaxVectorAlign = 5570b57cec5SDimitry Andric hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128; 5580b57cec5SDimitry Andric return true; 5590b57cec5SDimitry Andric } 5600b57cec5SDimitry Andric }; 5610b57cec5SDimitry Andric 5620b57cec5SDimitry Andric // x86-32 Windows target 5630b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY WindowsX86_32TargetInfo 5640b57cec5SDimitry Andric : public WindowsTargetInfo<X86_32TargetInfo> { 5650b57cec5SDimitry Andric public: WindowsX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)5660b57cec5SDimitry Andric WindowsX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 5670b57cec5SDimitry Andric : WindowsTargetInfo<X86_32TargetInfo>(Triple, Opts) { 5680b57cec5SDimitry Andric DoubleAlign = LongLongAlign = 64; 5690b57cec5SDimitry Andric bool IsWinCOFF = 5700b57cec5SDimitry Andric getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); 57104eeddc0SDimitry Andric bool IsMSVC = getTriple().isWindowsMSVCEnvironment(); 57204eeddc0SDimitry Andric std::string Layout = IsWinCOFF ? "e-m:x" : "e-m:e"; 5735f757f3fSDimitry Andric Layout += "-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-"; 57404eeddc0SDimitry Andric Layout += IsMSVC ? "f80:128" : "f80:32"; 57504eeddc0SDimitry Andric Layout += "-n8:16:32-a:0:32-S32"; 57604eeddc0SDimitry Andric resetDataLayout(Layout, IsWinCOFF ? "_" : ""); 5770b57cec5SDimitry Andric } 5780b57cec5SDimitry Andric }; 5790b57cec5SDimitry Andric 5800b57cec5SDimitry Andric // x86-32 Windows Visual Studio target 5810b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32TargetInfo 5820b57cec5SDimitry Andric : public WindowsX86_32TargetInfo { 5830b57cec5SDimitry Andric public: MicrosoftX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)5840b57cec5SDimitry Andric MicrosoftX86_32TargetInfo(const llvm::Triple &Triple, 5850b57cec5SDimitry Andric const TargetOptions &Opts) 5860b57cec5SDimitry Andric : WindowsX86_32TargetInfo(Triple, Opts) { 5870b57cec5SDimitry Andric LongDoubleWidth = LongDoubleAlign = 64; 5880b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEdouble(); 5890b57cec5SDimitry Andric } 5900b57cec5SDimitry Andric getTargetDefines(const LangOptions & Opts,MacroBuilder & Builder)5910b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 5920b57cec5SDimitry Andric MacroBuilder &Builder) const override { 5930b57cec5SDimitry Andric WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); 5940b57cec5SDimitry Andric // The value of the following reflects processor type. 5950b57cec5SDimitry Andric // 300=386, 400=486, 500=Pentium, 600=Blend (default) 5960b57cec5SDimitry Andric // We lost the original triple, so we use the default. 5970b57cec5SDimitry Andric Builder.defineMacro("_M_IX86", "600"); 5980b57cec5SDimitry Andric } 5990b57cec5SDimitry Andric }; 6000b57cec5SDimitry Andric 6010b57cec5SDimitry Andric // x86-32 MinGW target 6020b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY MinGWX86_32TargetInfo 6030b57cec5SDimitry Andric : public WindowsX86_32TargetInfo { 6040b57cec5SDimitry Andric public: MinGWX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)6050b57cec5SDimitry Andric MinGWX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 6060b57cec5SDimitry Andric : WindowsX86_32TargetInfo(Triple, Opts) { 6070b57cec5SDimitry Andric HasFloat128 = true; 6080b57cec5SDimitry Andric } 6090b57cec5SDimitry Andric getTargetDefines(const LangOptions & Opts,MacroBuilder & Builder)6100b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 6110b57cec5SDimitry Andric MacroBuilder &Builder) const override { 6120b57cec5SDimitry Andric WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); 6130b57cec5SDimitry Andric Builder.defineMacro("_X86_"); 6140b57cec5SDimitry Andric } 6150b57cec5SDimitry Andric }; 6160b57cec5SDimitry Andric 6170b57cec5SDimitry Andric // x86-32 Cygwin target 6180b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY CygwinX86_32TargetInfo : public X86_32TargetInfo { 6190b57cec5SDimitry Andric public: CygwinX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)6200b57cec5SDimitry Andric CygwinX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 6210b57cec5SDimitry Andric : X86_32TargetInfo(Triple, Opts) { 6220b57cec5SDimitry Andric this->WCharType = TargetInfo::UnsignedShort; 6230b57cec5SDimitry Andric DoubleAlign = LongLongAlign = 64; 6245f757f3fSDimitry Andric resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-" 6255f757f3fSDimitry Andric "i128:128-f80:32-n8:16:32-a:0:32-S32", 626fe6060f1SDimitry Andric "_"); 6270b57cec5SDimitry Andric } 6280b57cec5SDimitry Andric getTargetDefines(const LangOptions & Opts,MacroBuilder & Builder)6290b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 6300b57cec5SDimitry Andric MacroBuilder &Builder) const override { 6310b57cec5SDimitry Andric X86_32TargetInfo::getTargetDefines(Opts, Builder); 6320b57cec5SDimitry Andric Builder.defineMacro("_X86_"); 6330b57cec5SDimitry Andric Builder.defineMacro("__CYGWIN__"); 6340b57cec5SDimitry Andric Builder.defineMacro("__CYGWIN32__"); 6350b57cec5SDimitry Andric addCygMingDefines(Opts, Builder); 6360b57cec5SDimitry Andric DefineStd(Builder, "unix", Opts); 6370b57cec5SDimitry Andric if (Opts.CPlusPlus) 6380b57cec5SDimitry Andric Builder.defineMacro("_GNU_SOURCE"); 6390b57cec5SDimitry Andric } 6400b57cec5SDimitry Andric }; 6410b57cec5SDimitry Andric 6420b57cec5SDimitry Andric // x86-32 Haiku target 6430b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY HaikuX86_32TargetInfo 6440b57cec5SDimitry Andric : public HaikuTargetInfo<X86_32TargetInfo> { 6450b57cec5SDimitry Andric public: HaikuX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)6460b57cec5SDimitry Andric HaikuX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 6470b57cec5SDimitry Andric : HaikuTargetInfo<X86_32TargetInfo>(Triple, Opts) {} 6480b57cec5SDimitry Andric getTargetDefines(const LangOptions & Opts,MacroBuilder & Builder)6490b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 6500b57cec5SDimitry Andric MacroBuilder &Builder) const override { 6510b57cec5SDimitry Andric HaikuTargetInfo<X86_32TargetInfo>::getTargetDefines(Opts, Builder); 6520b57cec5SDimitry Andric Builder.defineMacro("__INTEL__"); 6530b57cec5SDimitry Andric } 6540b57cec5SDimitry Andric }; 6550b57cec5SDimitry Andric 6560b57cec5SDimitry Andric // X86-32 MCU target 6570b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY MCUX86_32TargetInfo : public X86_32TargetInfo { 6580b57cec5SDimitry Andric public: MCUX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)6590b57cec5SDimitry Andric MCUX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 6600b57cec5SDimitry Andric : X86_32TargetInfo(Triple, Opts) { 6610b57cec5SDimitry Andric LongDoubleWidth = 64; 662*0fca6ea1SDimitry Andric DefaultAlignForAttributeAligned = 32; 6630b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEdouble(); 6645f757f3fSDimitry Andric resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:32-" 6655f757f3fSDimitry Andric "f64:32-f128:32-n8:16:32-a:0:32-S32"); 6660b57cec5SDimitry Andric WIntType = UnsignedInt; 6670b57cec5SDimitry Andric } 6680b57cec5SDimitry Andric checkCallingConvention(CallingConv CC)6690b57cec5SDimitry Andric CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { 6700b57cec5SDimitry Andric // On MCU we support only C calling convention. 6710b57cec5SDimitry Andric return CC == CC_C ? CCCR_OK : CCCR_Warning; 6720b57cec5SDimitry Andric } 6730b57cec5SDimitry Andric getTargetDefines(const LangOptions & Opts,MacroBuilder & Builder)6740b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 6750b57cec5SDimitry Andric MacroBuilder &Builder) const override { 6760b57cec5SDimitry Andric X86_32TargetInfo::getTargetDefines(Opts, Builder); 6770b57cec5SDimitry Andric Builder.defineMacro("__iamcu"); 6780b57cec5SDimitry Andric Builder.defineMacro("__iamcu__"); 6790b57cec5SDimitry Andric } 6800b57cec5SDimitry Andric allowsLargerPreferedTypeAlignment()6810b57cec5SDimitry Andric bool allowsLargerPreferedTypeAlignment() const override { return false; } 6820b57cec5SDimitry Andric }; 6830b57cec5SDimitry Andric 6840b57cec5SDimitry Andric // x86-32 RTEMS target 6850b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY RTEMSX86_32TargetInfo : public X86_32TargetInfo { 6860b57cec5SDimitry Andric public: RTEMSX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)6870b57cec5SDimitry Andric RTEMSX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 6880b57cec5SDimitry Andric : X86_32TargetInfo(Triple, Opts) { 6890b57cec5SDimitry Andric SizeType = UnsignedLong; 6900b57cec5SDimitry Andric IntPtrType = SignedLong; 6910b57cec5SDimitry Andric PtrDiffType = SignedLong; 6920b57cec5SDimitry Andric } 6930b57cec5SDimitry Andric getTargetDefines(const LangOptions & Opts,MacroBuilder & Builder)6940b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 6950b57cec5SDimitry Andric MacroBuilder &Builder) const override { 6960b57cec5SDimitry Andric X86_32TargetInfo::getTargetDefines(Opts, Builder); 6970b57cec5SDimitry Andric Builder.defineMacro("__INTEL__"); 6980b57cec5SDimitry Andric Builder.defineMacro("__rtems__"); 6990b57cec5SDimitry Andric } 7000b57cec5SDimitry Andric }; 7010b57cec5SDimitry Andric 7020b57cec5SDimitry Andric // x86-64 generic target 7030b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY X86_64TargetInfo : public X86TargetInfo { 7040b57cec5SDimitry Andric public: X86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)7050b57cec5SDimitry Andric X86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 7060b57cec5SDimitry Andric : X86TargetInfo(Triple, Opts) { 707fe6060f1SDimitry Andric const bool IsX32 = getTriple().isX32(); 7080b57cec5SDimitry Andric bool IsWinCOFF = 7090b57cec5SDimitry Andric getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); 7100b57cec5SDimitry Andric LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 32 : 64; 7110b57cec5SDimitry Andric LongDoubleWidth = 128; 7120b57cec5SDimitry Andric LongDoubleAlign = 128; 7130b57cec5SDimitry Andric LargeArrayMinWidth = 128; 7140b57cec5SDimitry Andric LargeArrayAlign = 128; 7150b57cec5SDimitry Andric SuitableAlign = 128; 7160b57cec5SDimitry Andric SizeType = IsX32 ? UnsignedInt : UnsignedLong; 7170b57cec5SDimitry Andric PtrDiffType = IsX32 ? SignedInt : SignedLong; 7180b57cec5SDimitry Andric IntPtrType = IsX32 ? SignedInt : SignedLong; 7190b57cec5SDimitry Andric IntMaxType = IsX32 ? SignedLongLong : SignedLong; 7200b57cec5SDimitry Andric Int64Type = IsX32 ? SignedLongLong : SignedLong; 7210b57cec5SDimitry Andric RegParmMax = 6; 7220b57cec5SDimitry Andric 7230b57cec5SDimitry Andric // Pointers are 32-bit in x32. 724a7dea167SDimitry Andric resetDataLayout(IsX32 ? "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-" 7255f757f3fSDimitry Andric "i64:64-i128:128-f80:128-n8:16:32:64-S128" 7265f757f3fSDimitry Andric : IsWinCOFF ? "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:" 7275f757f3fSDimitry Andric "64-i128:128-f80:128-n8:16:32:64-S128" 7285f757f3fSDimitry Andric : "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:" 7295f757f3fSDimitry Andric "64-i128:128-f80:128-n8:16:32:64-S128"); 7300b57cec5SDimitry Andric 7310b57cec5SDimitry Andric // Use fpret only for long double. 732753f127fSDimitry Andric RealTypeUsesObjCFPRetMask = (unsigned)FloatModeKind::LongDouble; 7330b57cec5SDimitry Andric 7340b57cec5SDimitry Andric // Use fp2ret for _Complex long double. 7350b57cec5SDimitry Andric ComplexLongDoubleUsesFP2Ret = true; 7360b57cec5SDimitry Andric 7370b57cec5SDimitry Andric // Make __builtin_ms_va_list available. 7380b57cec5SDimitry Andric HasBuiltinMSVaList = true; 7390b57cec5SDimitry Andric 7400b57cec5SDimitry Andric // x86-64 has atomics up to 16 bytes. 7410b57cec5SDimitry Andric MaxAtomicPromoteWidth = 128; 7420b57cec5SDimitry Andric MaxAtomicInlineWidth = 64; 7430b57cec5SDimitry Andric } 7440b57cec5SDimitry Andric getBuiltinVaListKind()7450b57cec5SDimitry Andric BuiltinVaListKind getBuiltinVaListKind() const override { 7460b57cec5SDimitry Andric return TargetInfo::X86_64ABIBuiltinVaList; 7470b57cec5SDimitry Andric } 7480b57cec5SDimitry Andric getEHDataRegisterNumber(unsigned RegNo)7490b57cec5SDimitry Andric int getEHDataRegisterNumber(unsigned RegNo) const override { 7500b57cec5SDimitry Andric if (RegNo == 0) 7510b57cec5SDimitry Andric return 0; 7520b57cec5SDimitry Andric if (RegNo == 1) 7530b57cec5SDimitry Andric return 1; 7540b57cec5SDimitry Andric return -1; 7550b57cec5SDimitry Andric } 7560b57cec5SDimitry Andric checkCallingConvention(CallingConv CC)7570b57cec5SDimitry Andric CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { 7580b57cec5SDimitry Andric switch (CC) { 7590b57cec5SDimitry Andric case CC_C: 7600b57cec5SDimitry Andric case CC_Swift: 761fe6060f1SDimitry Andric case CC_SwiftAsync: 7620b57cec5SDimitry Andric case CC_X86VectorCall: 7630b57cec5SDimitry Andric case CC_IntelOclBicc: 7640b57cec5SDimitry Andric case CC_Win64: 7650b57cec5SDimitry Andric case CC_PreserveMost: 7660b57cec5SDimitry Andric case CC_PreserveAll: 767*0fca6ea1SDimitry Andric case CC_PreserveNone: 7680b57cec5SDimitry Andric case CC_X86RegCall: 7690b57cec5SDimitry Andric case CC_OpenCLKernel: 7700b57cec5SDimitry Andric return CCCR_OK; 7710b57cec5SDimitry Andric default: 7720b57cec5SDimitry Andric return CCCR_Warning; 7730b57cec5SDimitry Andric } 7740b57cec5SDimitry Andric } 7750b57cec5SDimitry Andric getDefaultCallingConv()7760b57cec5SDimitry Andric CallingConv getDefaultCallingConv() const override { 7770b57cec5SDimitry Andric return CC_C; 7780b57cec5SDimitry Andric } 7790b57cec5SDimitry Andric 7800b57cec5SDimitry Andric // for x32 we need it here explicitly hasInt128Type()7810b57cec5SDimitry Andric bool hasInt128Type() const override { return true; } 7820b57cec5SDimitry Andric getUnwindWordWidth()7830b57cec5SDimitry Andric unsigned getUnwindWordWidth() const override { return 64; } 7840b57cec5SDimitry Andric getRegisterWidth()7850b57cec5SDimitry Andric unsigned getRegisterWidth() const override { return 64; } 7860b57cec5SDimitry Andric validateGlobalRegisterVariable(StringRef RegName,unsigned RegSize,bool & HasSizeMismatch)7870b57cec5SDimitry Andric bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, 7880b57cec5SDimitry Andric bool &HasSizeMismatch) const override { 7890b57cec5SDimitry Andric // rsp and rbp are the only 64-bit registers the x86 backend can currently 7900b57cec5SDimitry Andric // handle. 791*0fca6ea1SDimitry Andric if (RegName == "rsp" || RegName == "rbp") { 7920b57cec5SDimitry Andric // Check that the register size is 64-bit. 7930b57cec5SDimitry Andric HasSizeMismatch = RegSize != 64; 7940b57cec5SDimitry Andric return true; 7950b57cec5SDimitry Andric } 7960b57cec5SDimitry Andric 7970b57cec5SDimitry Andric // Check if the register is a 32-bit register the backend can handle. 7980b57cec5SDimitry Andric return X86TargetInfo::validateGlobalRegisterVariable(RegName, RegSize, 7990b57cec5SDimitry Andric HasSizeMismatch); 8000b57cec5SDimitry Andric } 8010b57cec5SDimitry Andric setMaxAtomicWidth()8020b57cec5SDimitry Andric void setMaxAtomicWidth() override { 8030b57cec5SDimitry Andric if (hasFeature("cx16")) 8040b57cec5SDimitry Andric MaxAtomicInlineWidth = 128; 8050b57cec5SDimitry Andric } 8060b57cec5SDimitry Andric 8070b57cec5SDimitry Andric ArrayRef<Builtin::Info> getTargetBuiltins() const override; 8085ffd83dbSDimitry Andric hasBitIntType()8090eae32dcSDimitry Andric bool hasBitIntType() const override { return true; } getMaxBitIntWidth()810bdd1243dSDimitry Andric size_t getMaxBitIntWidth() const override { 811bdd1243dSDimitry Andric return llvm::IntegerType::MAX_INT_BITS; 812bdd1243dSDimitry Andric } 8130b57cec5SDimitry Andric }; 8140b57cec5SDimitry Andric 8150b57cec5SDimitry Andric // x86-64 Windows target 8160b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY WindowsX86_64TargetInfo 8170b57cec5SDimitry Andric : public WindowsTargetInfo<X86_64TargetInfo> { 8180b57cec5SDimitry Andric public: WindowsX86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)8190b57cec5SDimitry Andric WindowsX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 8200b57cec5SDimitry Andric : WindowsTargetInfo<X86_64TargetInfo>(Triple, Opts) { 8210b57cec5SDimitry Andric LongWidth = LongAlign = 32; 8220b57cec5SDimitry Andric DoubleAlign = LongLongAlign = 64; 8230b57cec5SDimitry Andric IntMaxType = SignedLongLong; 8240b57cec5SDimitry Andric Int64Type = SignedLongLong; 8250b57cec5SDimitry Andric SizeType = UnsignedLongLong; 8260b57cec5SDimitry Andric PtrDiffType = SignedLongLong; 8270b57cec5SDimitry Andric IntPtrType = SignedLongLong; 8280b57cec5SDimitry Andric } 8290b57cec5SDimitry Andric getBuiltinVaListKind()8300b57cec5SDimitry Andric BuiltinVaListKind getBuiltinVaListKind() const override { 8310b57cec5SDimitry Andric return TargetInfo::CharPtrBuiltinVaList; 8320b57cec5SDimitry Andric } 8330b57cec5SDimitry Andric checkCallingConvention(CallingConv CC)8340b57cec5SDimitry Andric CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { 8350b57cec5SDimitry Andric switch (CC) { 8360b57cec5SDimitry Andric case CC_X86StdCall: 8370b57cec5SDimitry Andric case CC_X86ThisCall: 8380b57cec5SDimitry Andric case CC_X86FastCall: 8390b57cec5SDimitry Andric return CCCR_Ignore; 8400b57cec5SDimitry Andric case CC_C: 8410b57cec5SDimitry Andric case CC_X86VectorCall: 8420b57cec5SDimitry Andric case CC_IntelOclBicc: 8430b57cec5SDimitry Andric case CC_PreserveMost: 8440b57cec5SDimitry Andric case CC_PreserveAll: 845*0fca6ea1SDimitry Andric case CC_PreserveNone: 8460b57cec5SDimitry Andric case CC_X86_64SysV: 8470b57cec5SDimitry Andric case CC_Swift: 848fe6060f1SDimitry Andric case CC_SwiftAsync: 8490b57cec5SDimitry Andric case CC_X86RegCall: 8500b57cec5SDimitry Andric case CC_OpenCLKernel: 8510b57cec5SDimitry Andric return CCCR_OK; 8520b57cec5SDimitry Andric default: 8530b57cec5SDimitry Andric return CCCR_Warning; 8540b57cec5SDimitry Andric } 8550b57cec5SDimitry Andric } 8560b57cec5SDimitry Andric }; 8570b57cec5SDimitry Andric 8580b57cec5SDimitry Andric // x86-64 Windows Visual Studio target 8590b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64TargetInfo 8600b57cec5SDimitry Andric : public WindowsX86_64TargetInfo { 8610b57cec5SDimitry Andric public: MicrosoftX86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)8620b57cec5SDimitry Andric MicrosoftX86_64TargetInfo(const llvm::Triple &Triple, 8630b57cec5SDimitry Andric const TargetOptions &Opts) 8640b57cec5SDimitry Andric : WindowsX86_64TargetInfo(Triple, Opts) { 8650b57cec5SDimitry Andric LongDoubleWidth = LongDoubleAlign = 64; 8660b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEdouble(); 8670b57cec5SDimitry Andric } 8680b57cec5SDimitry Andric getTargetDefines(const LangOptions & Opts,MacroBuilder & Builder)8690b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 8700b57cec5SDimitry Andric MacroBuilder &Builder) const override { 8710b57cec5SDimitry Andric WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder); 8720b57cec5SDimitry Andric Builder.defineMacro("_M_X64", "100"); 8730b57cec5SDimitry Andric Builder.defineMacro("_M_AMD64", "100"); 8740b57cec5SDimitry Andric } 8750b57cec5SDimitry Andric 8760b57cec5SDimitry Andric TargetInfo::CallingConvKind getCallingConvKind(bool ClangABICompat4)8770b57cec5SDimitry Andric getCallingConvKind(bool ClangABICompat4) const override { 8780b57cec5SDimitry Andric return CCK_MicrosoftWin64; 8790b57cec5SDimitry Andric } 8800b57cec5SDimitry Andric }; 8810b57cec5SDimitry Andric 8820b57cec5SDimitry Andric // x86-64 MinGW target 8830b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY MinGWX86_64TargetInfo 8840b57cec5SDimitry Andric : public WindowsX86_64TargetInfo { 8850b57cec5SDimitry Andric public: MinGWX86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)8860b57cec5SDimitry Andric MinGWX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 8870b57cec5SDimitry Andric : WindowsX86_64TargetInfo(Triple, Opts) { 8880b57cec5SDimitry Andric // Mingw64 rounds long double size and alignment up to 16 bytes, but sticks 8890b57cec5SDimitry Andric // with x86 FP ops. Weird. 8900b57cec5SDimitry Andric LongDoubleWidth = LongDoubleAlign = 128; 8910b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::x87DoubleExtended(); 8920b57cec5SDimitry Andric HasFloat128 = true; 8930b57cec5SDimitry Andric } 8940b57cec5SDimitry Andric }; 8950b57cec5SDimitry Andric 8960b57cec5SDimitry Andric // x86-64 Cygwin target 8970b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo { 8980b57cec5SDimitry Andric public: CygwinX86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)8990b57cec5SDimitry Andric CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 9000b57cec5SDimitry Andric : X86_64TargetInfo(Triple, Opts) { 9010b57cec5SDimitry Andric this->WCharType = TargetInfo::UnsignedShort; 9020b57cec5SDimitry Andric TLSSupported = false; 9030b57cec5SDimitry Andric } 9040b57cec5SDimitry Andric getTargetDefines(const LangOptions & Opts,MacroBuilder & Builder)9050b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 9060b57cec5SDimitry Andric MacroBuilder &Builder) const override { 9070b57cec5SDimitry Andric X86_64TargetInfo::getTargetDefines(Opts, Builder); 9080b57cec5SDimitry Andric Builder.defineMacro("__x86_64__"); 9090b57cec5SDimitry Andric Builder.defineMacro("__CYGWIN__"); 9100b57cec5SDimitry Andric Builder.defineMacro("__CYGWIN64__"); 9110b57cec5SDimitry Andric addCygMingDefines(Opts, Builder); 9120b57cec5SDimitry Andric DefineStd(Builder, "unix", Opts); 9130b57cec5SDimitry Andric if (Opts.CPlusPlus) 9140b57cec5SDimitry Andric Builder.defineMacro("_GNU_SOURCE"); 9150b57cec5SDimitry Andric } 9160b57cec5SDimitry Andric }; 9170b57cec5SDimitry Andric 9180b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY DarwinX86_64TargetInfo 9190b57cec5SDimitry Andric : public DarwinTargetInfo<X86_64TargetInfo> { 9200b57cec5SDimitry Andric public: DarwinX86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)9210b57cec5SDimitry Andric DarwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 9220b57cec5SDimitry Andric : DarwinTargetInfo<X86_64TargetInfo>(Triple, Opts) { 9230b57cec5SDimitry Andric Int64Type = SignedLongLong; 9240b57cec5SDimitry Andric // The 64-bit iOS simulator uses the builtin bool type for Objective-C. 9250b57cec5SDimitry Andric llvm::Triple T = llvm::Triple(Triple); 9260b57cec5SDimitry Andric if (T.isiOS()) 9270b57cec5SDimitry Andric UseSignedCharForObjCBool = false; 9285f757f3fSDimitry Andric resetDataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-" 9295f757f3fSDimitry Andric "f80:128-n8:16:32:64-S128", 9305f757f3fSDimitry Andric "_"); 9310b57cec5SDimitry Andric } 9320b57cec5SDimitry Andric handleTargetFeatures(std::vector<std::string> & Features,DiagnosticsEngine & Diags)9330b57cec5SDimitry Andric bool handleTargetFeatures(std::vector<std::string> &Features, 9340b57cec5SDimitry Andric DiagnosticsEngine &Diags) override { 9350b57cec5SDimitry Andric if (!DarwinTargetInfo<X86_64TargetInfo>::handleTargetFeatures(Features, 9360b57cec5SDimitry Andric Diags)) 9370b57cec5SDimitry Andric return false; 9380b57cec5SDimitry Andric // We now know the features we have: we can decide how to align vectors. 9390b57cec5SDimitry Andric MaxVectorAlign = 9400b57cec5SDimitry Andric hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128; 9410b57cec5SDimitry Andric return true; 9420b57cec5SDimitry Andric } 9430b57cec5SDimitry Andric }; 9440b57cec5SDimitry Andric 9450b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY OpenBSDX86_64TargetInfo 9460b57cec5SDimitry Andric : public OpenBSDTargetInfo<X86_64TargetInfo> { 9470b57cec5SDimitry Andric public: OpenBSDX86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)9480b57cec5SDimitry Andric OpenBSDX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 9490b57cec5SDimitry Andric : OpenBSDTargetInfo<X86_64TargetInfo>(Triple, Opts) { 9500b57cec5SDimitry Andric IntMaxType = SignedLongLong; 9510b57cec5SDimitry Andric Int64Type = SignedLongLong; 9520b57cec5SDimitry Andric } 9530b57cec5SDimitry Andric }; 9540b57cec5SDimitry Andric 9550b57cec5SDimitry Andric // x86_32 Android target 9560b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY AndroidX86_32TargetInfo 9570b57cec5SDimitry Andric : public LinuxTargetInfo<X86_32TargetInfo> { 9580b57cec5SDimitry Andric public: AndroidX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)9590b57cec5SDimitry Andric AndroidX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 9600b57cec5SDimitry Andric : LinuxTargetInfo<X86_32TargetInfo>(Triple, Opts) { 9610b57cec5SDimitry Andric SuitableAlign = 32; 9620b57cec5SDimitry Andric LongDoubleWidth = 64; 9630b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEdouble(); 9640b57cec5SDimitry Andric } 9650b57cec5SDimitry Andric }; 9660b57cec5SDimitry Andric 9670b57cec5SDimitry Andric // x86_64 Android target 9680b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY AndroidX86_64TargetInfo 9690b57cec5SDimitry Andric : public LinuxTargetInfo<X86_64TargetInfo> { 9700b57cec5SDimitry Andric public: AndroidX86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)9710b57cec5SDimitry Andric AndroidX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 9720b57cec5SDimitry Andric : LinuxTargetInfo<X86_64TargetInfo>(Triple, Opts) { 9730b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEquad(); 9740b57cec5SDimitry Andric } 9750b57cec5SDimitry Andric }; 97606c3fb27SDimitry Andric 97706c3fb27SDimitry Andric // x86_32 OHOS target 97806c3fb27SDimitry Andric class LLVM_LIBRARY_VISIBILITY OHOSX86_32TargetInfo 97906c3fb27SDimitry Andric : public OHOSTargetInfo<X86_32TargetInfo> { 98006c3fb27SDimitry Andric public: OHOSX86_32TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)98106c3fb27SDimitry Andric OHOSX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 98206c3fb27SDimitry Andric : OHOSTargetInfo<X86_32TargetInfo>(Triple, Opts) { 98306c3fb27SDimitry Andric SuitableAlign = 32; 98406c3fb27SDimitry Andric LongDoubleWidth = 64; 98506c3fb27SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEdouble(); 98606c3fb27SDimitry Andric } 98706c3fb27SDimitry Andric }; 98806c3fb27SDimitry Andric 98906c3fb27SDimitry Andric // x86_64 OHOS target 99006c3fb27SDimitry Andric class LLVM_LIBRARY_VISIBILITY OHOSX86_64TargetInfo 99106c3fb27SDimitry Andric : public OHOSTargetInfo<X86_64TargetInfo> { 99206c3fb27SDimitry Andric public: OHOSX86_64TargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)99306c3fb27SDimitry Andric OHOSX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 99406c3fb27SDimitry Andric : OHOSTargetInfo<X86_64TargetInfo>(Triple, Opts) { 99506c3fb27SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEquad(); 99606c3fb27SDimitry Andric } 99706c3fb27SDimitry Andric }; 9980b57cec5SDimitry Andric } // namespace targets 9990b57cec5SDimitry Andric } // namespace clang 10000b57cec5SDimitry Andric #endif // LLVM_CLANG_LIB_BASIC_TARGETS_X86_H 1001