File indexing completed on 2026-05-10 08:44:37
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_TARGETPARSER_TRIPLE_H
0010 #define LLVM_TARGETPARSER_TRIPLE_H
0011
0012 #include "llvm/ADT/Twine.h"
0013 #include "llvm/Support/VersionTuple.h"
0014
0015
0016
0017 #undef NetBSD
0018 #undef mips
0019 #undef sparc
0020
0021 namespace llvm {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 class Triple {
0045 public:
0046 enum ArchType {
0047 UnknownArch,
0048
0049 arm,
0050 armeb,
0051 aarch64,
0052 aarch64_be,
0053 aarch64_32,
0054 arc,
0055 avr,
0056 bpfel,
0057 bpfeb,
0058 csky,
0059 dxil,
0060 hexagon,
0061 loongarch32,
0062 loongarch64,
0063 m68k,
0064 mips,
0065 mipsel,
0066 mips64,
0067 mips64el,
0068 msp430,
0069 ppc,
0070 ppcle,
0071 ppc64,
0072 ppc64le,
0073 r600,
0074 amdgcn,
0075 riscv32,
0076 riscv64,
0077 sparc,
0078 sparcv9,
0079 sparcel,
0080 systemz,
0081 tce,
0082 tcele,
0083 thumb,
0084 thumbeb,
0085 x86,
0086 x86_64,
0087 xcore,
0088 xtensa,
0089 nvptx,
0090 nvptx64,
0091 amdil,
0092 amdil64,
0093 hsail,
0094 hsail64,
0095 spir,
0096 spir64,
0097 spirv,
0098 spirv32,
0099 spirv64,
0100 kalimba,
0101 shave,
0102 lanai,
0103 wasm32,
0104 wasm64,
0105 renderscript32,
0106 renderscript64,
0107 ve,
0108 LastArchType = ve
0109 };
0110 enum SubArchType {
0111 NoSubArch,
0112
0113 ARMSubArch_v9_6a,
0114 ARMSubArch_v9_5a,
0115 ARMSubArch_v9_4a,
0116 ARMSubArch_v9_3a,
0117 ARMSubArch_v9_2a,
0118 ARMSubArch_v9_1a,
0119 ARMSubArch_v9,
0120 ARMSubArch_v8_9a,
0121 ARMSubArch_v8_8a,
0122 ARMSubArch_v8_7a,
0123 ARMSubArch_v8_6a,
0124 ARMSubArch_v8_5a,
0125 ARMSubArch_v8_4a,
0126 ARMSubArch_v8_3a,
0127 ARMSubArch_v8_2a,
0128 ARMSubArch_v8_1a,
0129 ARMSubArch_v8,
0130 ARMSubArch_v8r,
0131 ARMSubArch_v8m_baseline,
0132 ARMSubArch_v8m_mainline,
0133 ARMSubArch_v8_1m_mainline,
0134 ARMSubArch_v7,
0135 ARMSubArch_v7em,
0136 ARMSubArch_v7m,
0137 ARMSubArch_v7s,
0138 ARMSubArch_v7k,
0139 ARMSubArch_v7ve,
0140 ARMSubArch_v6,
0141 ARMSubArch_v6m,
0142 ARMSubArch_v6k,
0143 ARMSubArch_v6t2,
0144 ARMSubArch_v5,
0145 ARMSubArch_v5te,
0146 ARMSubArch_v4t,
0147
0148 AArch64SubArch_arm64e,
0149 AArch64SubArch_arm64ec,
0150
0151 KalimbaSubArch_v3,
0152 KalimbaSubArch_v4,
0153 KalimbaSubArch_v5,
0154
0155 MipsSubArch_r6,
0156
0157 PPCSubArch_spe,
0158
0159
0160 SPIRVSubArch_v10,
0161 SPIRVSubArch_v11,
0162 SPIRVSubArch_v12,
0163 SPIRVSubArch_v13,
0164 SPIRVSubArch_v14,
0165 SPIRVSubArch_v15,
0166 SPIRVSubArch_v16,
0167
0168
0169 DXILSubArch_v1_0,
0170 DXILSubArch_v1_1,
0171 DXILSubArch_v1_2,
0172 DXILSubArch_v1_3,
0173 DXILSubArch_v1_4,
0174 DXILSubArch_v1_5,
0175 DXILSubArch_v1_6,
0176 DXILSubArch_v1_7,
0177 DXILSubArch_v1_8,
0178 LatestDXILSubArch = DXILSubArch_v1_8,
0179 };
0180 enum VendorType {
0181 UnknownVendor,
0182
0183 Apple,
0184 PC,
0185 SCEI,
0186 Freescale,
0187 IBM,
0188 ImaginationTechnologies,
0189 MipsTechnologies,
0190 NVIDIA,
0191 CSR,
0192 AMD,
0193 Mesa,
0194 SUSE,
0195 OpenEmbedded,
0196 Intel,
0197 LastVendorType = Intel
0198 };
0199 enum OSType {
0200 UnknownOS,
0201
0202 Darwin,
0203 DragonFly,
0204 FreeBSD,
0205 Fuchsia,
0206 IOS,
0207 KFreeBSD,
0208 Linux,
0209 Lv2,
0210 MacOSX,
0211 NetBSD,
0212 OpenBSD,
0213 Solaris,
0214 UEFI,
0215 Win32,
0216 ZOS,
0217 Haiku,
0218 RTEMS,
0219 NaCl,
0220 AIX,
0221 CUDA,
0222 NVCL,
0223 AMDHSA,
0224 PS4,
0225 PS5,
0226 ELFIAMCU,
0227 TvOS,
0228 WatchOS,
0229 BridgeOS,
0230 DriverKit,
0231 XROS,
0232 Mesa3D,
0233 AMDPAL,
0234 HermitCore,
0235 Hurd,
0236 WASI,
0237 Emscripten,
0238 ShaderModel,
0239 LiteOS,
0240 Serenity,
0241 Vulkan,
0242 LastOSType = Vulkan
0243 };
0244 enum EnvironmentType {
0245 UnknownEnvironment,
0246
0247 GNU,
0248 GNUT64,
0249 GNUABIN32,
0250 GNUABI64,
0251 GNUEABI,
0252 GNUEABIT64,
0253 GNUEABIHF,
0254 GNUEABIHFT64,
0255 GNUF32,
0256 GNUF64,
0257 GNUSF,
0258 GNUX32,
0259 GNUILP32,
0260 CODE16,
0261 EABI,
0262 EABIHF,
0263 Android,
0264 Musl,
0265 MuslABIN32,
0266 MuslABI64,
0267 MuslEABI,
0268 MuslEABIHF,
0269 MuslF32,
0270 MuslSF,
0271 MuslX32,
0272 LLVM,
0273
0274 MSVC,
0275 Itanium,
0276 Cygnus,
0277 CoreCLR,
0278 Simulator,
0279 MacABI,
0280
0281
0282
0283
0284
0285 Pixel,
0286 Vertex,
0287 Geometry,
0288 Hull,
0289 Domain,
0290 Compute,
0291 Library,
0292 RayGeneration,
0293 Intersection,
0294 AnyHit,
0295 ClosestHit,
0296 Miss,
0297 Callable,
0298 Mesh,
0299 Amplification,
0300 OpenCL,
0301 OpenHOS,
0302
0303 PAuthTest,
0304
0305 LastEnvironmentType = PAuthTest
0306 };
0307 enum ObjectFormatType {
0308 UnknownObjectFormat,
0309
0310 COFF,
0311 DXContainer,
0312 ELF,
0313 GOFF,
0314 MachO,
0315 SPIRV,
0316 Wasm,
0317 XCOFF,
0318 };
0319
0320 private:
0321 std::string Data;
0322
0323
0324 ArchType Arch{};
0325
0326
0327 SubArchType SubArch{};
0328
0329
0330 VendorType Vendor{};
0331
0332
0333 OSType OS{};
0334
0335
0336 EnvironmentType Environment{};
0337
0338
0339 ObjectFormatType ObjectFormat{};
0340
0341 public:
0342
0343
0344
0345
0346
0347 Triple() = default;
0348
0349 explicit Triple(const Twine &Str);
0350 Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
0351 Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
0352 const Twine &EnvironmentStr);
0353
0354 bool operator==(const Triple &Other) const {
0355 return Arch == Other.Arch && SubArch == Other.SubArch &&
0356 Vendor == Other.Vendor && OS == Other.OS &&
0357 Environment == Other.Environment &&
0358 ObjectFormat == Other.ObjectFormat;
0359 }
0360
0361 bool operator!=(const Triple &Other) const {
0362 return !(*this == Other);
0363 }
0364
0365
0366
0367
0368
0369
0370 enum class CanonicalForm {
0371 ANY = 0,
0372 THREE_IDENT = 3,
0373 FOUR_IDENT = 4,
0374 FIVE_IDENT = 5,
0375 };
0376
0377
0378
0379
0380
0381
0382 static std::string normalize(StringRef Str,
0383 CanonicalForm Form = CanonicalForm::ANY);
0384
0385
0386 std::string normalize(CanonicalForm Form = CanonicalForm::ANY) const {
0387 return normalize(Data, Form);
0388 }
0389
0390
0391
0392
0393
0394
0395 ArchType getArch() const { return Arch; }
0396
0397
0398 SubArchType getSubArch() const { return SubArch; }
0399
0400
0401 VendorType getVendor() const { return Vendor; }
0402
0403
0404 OSType getOS() const { return OS; }
0405
0406
0407 bool hasEnvironment() const {
0408 return getEnvironmentName() != "";
0409 }
0410
0411
0412 EnvironmentType getEnvironment() const { return Environment; }
0413
0414
0415
0416
0417
0418 VersionTuple getEnvironmentVersion() const;
0419
0420
0421 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
0422
0423
0424
0425
0426
0427 VersionTuple getOSVersion() const;
0428
0429
0430
0431 unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
0432
0433
0434
0435
0436
0437 bool getMacOSXVersion(VersionTuple &Version) const;
0438
0439
0440
0441 VersionTuple getiOSVersion() const;
0442
0443
0444
0445 VersionTuple getWatchOSVersion() const;
0446
0447
0448 VersionTuple getDriverKitVersion() const;
0449
0450
0451
0452 VersionTuple getVulkanVersion() const;
0453
0454
0455
0456 VersionTuple getDXILVersion() const;
0457
0458
0459
0460
0461
0462 const std::string &str() const { return Data; }
0463
0464 const std::string &getTriple() const { return Data; }
0465
0466
0467 StringRef getArchName() const;
0468
0469
0470 StringRef getVendorName() const;
0471
0472
0473 StringRef getOSName() const;
0474
0475
0476
0477 StringRef getEnvironmentName() const;
0478
0479
0480
0481 StringRef getOSAndEnvironmentName() const;
0482
0483
0484
0485
0486
0487 StringRef getEnvironmentVersionString() const;
0488
0489
0490
0491
0492
0493
0494 static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch);
0495
0496
0497 unsigned getArchPointerBitWidth() const {
0498 return getArchPointerBitWidth(getArch());
0499 }
0500
0501
0502 unsigned getTrampolineSize() const;
0503
0504
0505
0506
0507
0508
0509
0510
0511 bool isArch64Bit() const;
0512
0513
0514
0515
0516 bool isArch32Bit() const;
0517
0518
0519
0520
0521 bool isArch16Bit() const;
0522
0523
0524
0525 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
0526 unsigned Micro = 0) const {
0527 if (Minor == 0) {
0528 return getOSVersion() < VersionTuple(Major);
0529 }
0530 if (Micro == 0) {
0531 return getOSVersion() < VersionTuple(Major, Minor);
0532 }
0533 return getOSVersion() < VersionTuple(Major, Minor, Micro);
0534 }
0535
0536 bool isOSVersionLT(const Triple &Other) const {
0537 return getOSVersion() < Other.getOSVersion();
0538 }
0539
0540
0541
0542 bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
0543 unsigned Micro = 0) const;
0544
0545
0546
0547 bool isMacOSX() const {
0548 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
0549 }
0550
0551
0552
0553
0554
0555
0556 bool isiOS() const {
0557 return getOS() == Triple::IOS || isTvOS();
0558 }
0559
0560
0561 bool isTvOS() const {
0562 return getOS() == Triple::TvOS;
0563 }
0564
0565
0566 bool isWatchOS() const {
0567 return getOS() == Triple::WatchOS;
0568 }
0569
0570 bool isWatchABI() const {
0571 return getSubArch() == Triple::ARMSubArch_v7k;
0572 }
0573
0574
0575 bool isXROS() const { return getOS() == Triple::XROS; }
0576
0577
0578 bool isDriverKit() const { return getOS() == Triple::DriverKit; }
0579
0580 bool isOSzOS() const { return getOS() == Triple::ZOS; }
0581
0582
0583 bool isAppleMachO() const {
0584 return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
0585 }
0586
0587
0588 bool isOSDarwin() const {
0589 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS();
0590 }
0591
0592 bool isSimulatorEnvironment() const {
0593 return getEnvironment() == Triple::Simulator;
0594 }
0595
0596 bool isMacCatalystEnvironment() const {
0597 return getEnvironment() == Triple::MacABI;
0598 }
0599
0600
0601 bool isTargetMachineMac() const {
0602 return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
0603 isMacCatalystEnvironment()));
0604 }
0605
0606 bool isOSNetBSD() const {
0607 return getOS() == Triple::NetBSD;
0608 }
0609
0610 bool isOSOpenBSD() const {
0611 return getOS() == Triple::OpenBSD;
0612 }
0613
0614 bool isOSFreeBSD() const {
0615 return getOS() == Triple::FreeBSD;
0616 }
0617
0618 bool isOSFuchsia() const {
0619 return getOS() == Triple::Fuchsia;
0620 }
0621
0622 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
0623
0624 bool isOSSolaris() const {
0625 return getOS() == Triple::Solaris;
0626 }
0627
0628 bool isOSIAMCU() const {
0629 return getOS() == Triple::ELFIAMCU;
0630 }
0631
0632 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
0633
0634 bool isGNUEnvironment() const {
0635 EnvironmentType Env = getEnvironment();
0636 return Env == Triple::GNU || Env == Triple::GNUT64 ||
0637 Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
0638 Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
0639 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
0640 Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
0641 Env == Triple::GNUSF || Env == Triple::GNUX32;
0642 }
0643
0644
0645 bool isOSHaiku() const {
0646 return getOS() == Triple::Haiku;
0647 }
0648
0649
0650 bool isUEFI() const {
0651 return getOS() == Triple::UEFI;
0652 }
0653
0654
0655 bool isOSWindows() const {
0656 return getOS() == Triple::Win32;
0657 }
0658
0659
0660 bool isOSWindowsOrUEFI() const { return isOSWindows() || isUEFI(); }
0661
0662
0663 bool isKnownWindowsMSVCEnvironment() const {
0664 return isOSWindows() && getEnvironment() == Triple::MSVC;
0665 }
0666
0667
0668 bool isWindowsMSVCEnvironment() const {
0669 return isKnownWindowsMSVCEnvironment() ||
0670 (isOSWindows() && getEnvironment() == Triple::UnknownEnvironment);
0671 }
0672
0673
0674 bool isWindowsArm64EC() const {
0675 return getArch() == Triple::aarch64 &&
0676 getSubArch() == Triple::AArch64SubArch_arm64ec;
0677 }
0678
0679 bool isWindowsCoreCLREnvironment() const {
0680 return isOSWindows() && getEnvironment() == Triple::CoreCLR;
0681 }
0682
0683 bool isWindowsItaniumEnvironment() const {
0684 return isOSWindows() && getEnvironment() == Triple::Itanium;
0685 }
0686
0687 bool isWindowsCygwinEnvironment() const {
0688 return isOSWindows() && getEnvironment() == Triple::Cygnus;
0689 }
0690
0691 bool isWindowsGNUEnvironment() const {
0692 return isOSWindows() && getEnvironment() == Triple::GNU;
0693 }
0694
0695
0696 bool isOSCygMing() const {
0697 return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment();
0698 }
0699
0700
0701 bool isOSMSVCRT() const {
0702 return isWindowsMSVCEnvironment() || isWindowsGNUEnvironment() ||
0703 isWindowsItaniumEnvironment();
0704 }
0705
0706
0707 bool isOSNaCl() const {
0708 return getOS() == Triple::NaCl;
0709 }
0710
0711
0712 bool isOSLinux() const {
0713 return getOS() == Triple::Linux;
0714 }
0715
0716
0717 bool isOSKFreeBSD() const {
0718 return getOS() == Triple::KFreeBSD;
0719 }
0720
0721
0722 bool isOSHurd() const {
0723 return getOS() == Triple::Hurd;
0724 }
0725
0726
0727 bool isOSWASI() const {
0728 return getOS() == Triple::WASI;
0729 }
0730
0731
0732 bool isOSEmscripten() const {
0733 return getOS() == Triple::Emscripten;
0734 }
0735
0736
0737 bool isOSGlibc() const {
0738 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
0739 getOS() == Triple::Hurd) &&
0740 !isAndroid();
0741 }
0742
0743
0744 bool isOSAIX() const {
0745 return getOS() == Triple::AIX;
0746 }
0747
0748 bool isOSSerenity() const {
0749 return getOS() == Triple::Serenity;
0750 }
0751
0752
0753 bool isOSBinFormatELF() const {
0754 return getObjectFormat() == Triple::ELF;
0755 }
0756
0757
0758 bool isOSBinFormatCOFF() const {
0759 return getObjectFormat() == Triple::COFF;
0760 }
0761
0762
0763 bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
0764
0765
0766 bool isOSBinFormatMachO() const {
0767 return getObjectFormat() == Triple::MachO;
0768 }
0769
0770
0771 bool isOSBinFormatWasm() const {
0772 return getObjectFormat() == Triple::Wasm;
0773 }
0774
0775
0776 bool isOSBinFormatXCOFF() const {
0777 return getObjectFormat() == Triple::XCOFF;
0778 }
0779
0780
0781 bool isOSBinFormatDXContainer() const {
0782 return getObjectFormat() == Triple::DXContainer;
0783 }
0784
0785
0786 bool isPS4() const {
0787 return getArch() == Triple::x86_64 &&
0788 getVendor() == Triple::SCEI &&
0789 getOS() == Triple::PS4;
0790 }
0791
0792
0793 bool isPS5() const {
0794 return getArch() == Triple::x86_64 &&
0795 getVendor() == Triple::SCEI &&
0796 getOS() == Triple::PS5;
0797 }
0798
0799
0800 bool isPS() const { return isPS4() || isPS5(); }
0801
0802
0803 bool isAndroid() const { return getEnvironment() == Triple::Android; }
0804
0805 bool isAndroidVersionLT(unsigned Major) const {
0806 assert(isAndroid() && "Not an Android triple!");
0807
0808 VersionTuple Version = getEnvironmentVersion();
0809
0810
0811 if (isArch64Bit() && Version.getMajor() < 21)
0812 return VersionTuple(21) < VersionTuple(Major);
0813
0814 return Version < VersionTuple(Major);
0815 }
0816
0817
0818 bool isMusl() const {
0819 return getEnvironment() == Triple::Musl ||
0820 getEnvironment() == Triple::MuslABIN32 ||
0821 getEnvironment() == Triple::MuslABI64 ||
0822 getEnvironment() == Triple::MuslEABI ||
0823 getEnvironment() == Triple::MuslEABIHF ||
0824 getEnvironment() == Triple::MuslF32 ||
0825 getEnvironment() == Triple::MuslSF ||
0826 getEnvironment() == Triple::MuslX32 ||
0827 getEnvironment() == Triple::OpenHOS || isOSLiteOS();
0828 }
0829
0830
0831
0832 bool isOHOSFamily() const { return isOpenHOS() || isOSLiteOS(); }
0833
0834 bool isOpenHOS() const { return getEnvironment() == Triple::OpenHOS; }
0835
0836 bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
0837
0838
0839 bool isDXIL() const {
0840 return getArch() == Triple::dxil;
0841 }
0842
0843 bool isShaderModelOS() const {
0844 return getOS() == Triple::ShaderModel;
0845 }
0846
0847 bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
0848
0849 bool isShaderStageEnvironment() const {
0850 EnvironmentType Env = getEnvironment();
0851 return Env == Triple::Pixel || Env == Triple::Vertex ||
0852 Env == Triple::Geometry || Env == Triple::Hull ||
0853 Env == Triple::Domain || Env == Triple::Compute ||
0854 Env == Triple::Library || Env == Triple::RayGeneration ||
0855 Env == Triple::Intersection || Env == Triple::AnyHit ||
0856 Env == Triple::ClosestHit || Env == Triple::Miss ||
0857 Env == Triple::Callable || Env == Triple::Mesh ||
0858 Env == Triple::Amplification;
0859 }
0860
0861
0862 bool isSPIR() const {
0863 return getArch() == Triple::spir || getArch() == Triple::spir64;
0864 }
0865
0866
0867 bool isSPIRV() const {
0868 return getArch() == Triple::spirv32 || getArch() == Triple::spirv64 ||
0869 getArch() == Triple::spirv;
0870 }
0871
0872
0873 bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
0874
0875
0876 bool isSPIRVLogical() const {
0877 return getArch() == Triple::spirv;
0878 }
0879
0880
0881 bool isNVPTX() const {
0882 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
0883 }
0884
0885
0886 bool isAMDGCN() const { return getArch() == Triple::amdgcn; }
0887
0888 bool isAMDGPU() const {
0889 return getArch() == Triple::r600 || getArch() == Triple::amdgcn;
0890 }
0891
0892
0893 bool isThumb() const {
0894 return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
0895 }
0896
0897
0898 bool isARM() const {
0899 return getArch() == Triple::arm || getArch() == Triple::armeb;
0900 }
0901
0902
0903
0904 bool isTargetEHABICompatible() const {
0905 return (isARM() || isThumb()) &&
0906 (getEnvironment() == Triple::EABI ||
0907 getEnvironment() == Triple::GNUEABI ||
0908 getEnvironment() == Triple::GNUEABIT64 ||
0909 getEnvironment() == Triple::MuslEABI ||
0910 getEnvironment() == Triple::EABIHF ||
0911 getEnvironment() == Triple::GNUEABIHF ||
0912 getEnvironment() == Triple::GNUEABIHFT64 ||
0913 getEnvironment() == Triple::OpenHOS ||
0914 getEnvironment() == Triple::MuslEABIHF || isAndroid()) &&
0915 isOSBinFormatELF();
0916 }
0917
0918
0919 bool isArmT32() const {
0920 switch (getSubArch()) {
0921 case Triple::ARMSubArch_v8m_baseline:
0922 case Triple::ARMSubArch_v7s:
0923 case Triple::ARMSubArch_v7k:
0924 case Triple::ARMSubArch_v7ve:
0925 case Triple::ARMSubArch_v6:
0926 case Triple::ARMSubArch_v6m:
0927 case Triple::ARMSubArch_v6k:
0928 case Triple::ARMSubArch_v6t2:
0929 case Triple::ARMSubArch_v5:
0930 case Triple::ARMSubArch_v5te:
0931 case Triple::ARMSubArch_v4t:
0932 return false;
0933 default:
0934 return true;
0935 }
0936 }
0937
0938
0939 bool isArmMClass() const {
0940 switch (getSubArch()) {
0941 case Triple::ARMSubArch_v6m:
0942 case Triple::ARMSubArch_v7m:
0943 case Triple::ARMSubArch_v7em:
0944 case Triple::ARMSubArch_v8m_mainline:
0945 case Triple::ARMSubArch_v8m_baseline:
0946 case Triple::ARMSubArch_v8_1m_mainline:
0947 return true;
0948 default:
0949 return false;
0950 }
0951 }
0952
0953
0954 bool isAArch64() const {
0955 return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
0956 getArch() == Triple::aarch64_32;
0957 }
0958
0959
0960
0961 bool isAArch64(int PointerWidth) const {
0962 assert(PointerWidth == 64 || PointerWidth == 32);
0963 if (!isAArch64())
0964 return false;
0965 return getArch() == Triple::aarch64_32 ||
0966 getEnvironment() == Triple::GNUILP32
0967 ? PointerWidth == 32
0968 : PointerWidth == 64;
0969 }
0970
0971
0972 bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
0973
0974
0975 bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
0976
0977
0978 bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
0979
0980
0981 bool isMIPS32() const {
0982 return getArch() == Triple::mips || getArch() == Triple::mipsel;
0983 }
0984
0985
0986 bool isMIPS64() const {
0987 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
0988 }
0989
0990
0991 bool isMIPS() const {
0992 return isMIPS32() || isMIPS64();
0993 }
0994
0995
0996 bool isPPC() const {
0997 return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
0998 getArch() == Triple::ppcle || getArch() == Triple::ppc64le;
0999 }
1000
1001
1002 bool isPPC32() const {
1003 return getArch() == Triple::ppc || getArch() == Triple::ppcle;
1004 }
1005
1006
1007 bool isPPC64() const {
1008 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
1009 }
1010
1011
1012 bool isPPC64ELFv2ABI() const {
1013 return (getArch() == Triple::ppc64 &&
1014 ((getOS() == Triple::FreeBSD &&
1015 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1016 getOS() == Triple::OpenBSD || isMusl()));
1017 }
1018
1019
1020 bool isPPC32SecurePlt() const {
1021 return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
1022 ((getOS() == Triple::FreeBSD &&
1023 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1024 getOS() == Triple::NetBSD || getOS() == Triple::OpenBSD ||
1025 isMusl()));
1026 }
1027
1028
1029 bool isRISCV32() const { return getArch() == Triple::riscv32; }
1030
1031
1032 bool isRISCV64() const { return getArch() == Triple::riscv64; }
1033
1034
1035 bool isRISCV() const { return isRISCV32() || isRISCV64(); }
1036
1037
1038 bool isSPARC32() const {
1039 return getArch() == Triple::sparc || getArch() == Triple::sparcel;
1040 }
1041
1042
1043 bool isSPARC64() const { return getArch() == Triple::sparcv9; }
1044
1045
1046 bool isSPARC() const { return isSPARC32() || isSPARC64(); }
1047
1048
1049 bool isSystemZ() const {
1050 return getArch() == Triple::systemz;
1051 }
1052
1053
1054 bool isX86() const {
1055 return getArch() == Triple::x86 || getArch() == Triple::x86_64;
1056 }
1057
1058
1059 bool isVE() const {
1060 return getArch() == Triple::ve;
1061 }
1062
1063
1064 bool isWasm() const {
1065 return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
1066 }
1067
1068
1069 bool isCSKY() const {
1070 return getArch() == Triple::csky;
1071 }
1072
1073
1074 bool isArm64e() const {
1075 return getArch() == Triple::aarch64 &&
1076 getSubArch() == Triple::AArch64SubArch_arm64e;
1077 }
1078
1079
1080 bool isABIN32() const {
1081 EnvironmentType Env = getEnvironment();
1082 return Env == Triple::GNUABIN32 || Env == Triple::MuslABIN32;
1083 }
1084
1085
1086 bool isX32() const {
1087 EnvironmentType Env = getEnvironment();
1088 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
1089 }
1090
1091
1092 bool isBPF() const {
1093 return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
1094 }
1095
1096
1097 bool isTime64ABI() const {
1098 EnvironmentType Env = getEnvironment();
1099 return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1100 Env == Triple::GNUEABIHFT64;
1101 }
1102
1103
1104 bool isHardFloatABI() const {
1105 EnvironmentType Env = getEnvironment();
1106 return Env == llvm::Triple::GNUEABIHF ||
1107 Env == llvm::Triple::GNUEABIHFT64 ||
1108 Env == llvm::Triple::MuslEABIHF ||
1109 Env == llvm::Triple::EABIHF;
1110 }
1111
1112
1113 bool supportsCOMDAT() const {
1114 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
1115 isOSBinFormatDXContainer());
1116 }
1117
1118
1119
1120
1121 bool hasDefaultEmulatedTLS() const {
1122 return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
1123 isWindowsCygwinEnvironment() || isOHOSFamily();
1124 }
1125
1126
1127
1128 bool hasDefaultTLSDESC() const { return isAndroid() && isRISCV64(); }
1129
1130
1131 bool hasDefaultDataSections() const {
1132 return isOSBinFormatXCOFF() || isWasm();
1133 }
1134
1135
1136 bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
1137
1138
1139
1140
1141
1142
1143 void setArch(ArchType Kind, SubArchType SubArch = NoSubArch);
1144
1145
1146 void setVendor(VendorType Kind);
1147
1148
1149 void setOS(OSType Kind);
1150
1151
1152 void setEnvironment(EnvironmentType Kind);
1153
1154
1155 void setObjectFormat(ObjectFormatType Kind);
1156
1157
1158 void setTriple(const Twine &Str);
1159
1160
1161 void setArchName(StringRef Str);
1162
1163
1164 void setVendorName(StringRef Str);
1165
1166
1167 void setOSName(StringRef Str);
1168
1169
1170 void setEnvironmentName(StringRef Str);
1171
1172
1173
1174 void setOSAndEnvironmentName(StringRef Str);
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186 llvm::Triple get32BitArchVariant() const;
1187
1188
1189
1190
1191
1192
1193
1194 llvm::Triple get64BitArchVariant() const;
1195
1196
1197
1198
1199
1200
1201
1202 llvm::Triple getBigEndianArchVariant() const;
1203
1204
1205
1206
1207
1208
1209
1210 llvm::Triple getLittleEndianArchVariant() const;
1211
1212
1213
1214
1215 bool isLittleEndian() const;
1216
1217
1218 bool isCompatibleWith(const Triple &Other) const;
1219
1220
1221 std::string merge(const Triple &Other) const;
1222
1223
1224
1225
1226
1227 VersionTuple getMinimumSupportedOSVersion() const;
1228
1229
1230
1231
1232
1233
1234 static StringRef getArchTypeName(ArchType Kind);
1235
1236
1237 static StringRef getArchName(ArchType Kind, SubArchType SubArch = NoSubArch);
1238
1239
1240
1241
1242
1243
1244 static StringRef getArchTypePrefix(ArchType Kind);
1245
1246
1247 static StringRef getVendorTypeName(VendorType Kind);
1248
1249
1250 static StringRef getOSTypeName(OSType Kind);
1251
1252
1253 static StringRef getEnvironmentTypeName(EnvironmentType Kind);
1254
1255
1256 static StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat);
1257
1258
1259
1260
1261
1262
1263 static ArchType getArchTypeForLLVMName(StringRef Str);
1264
1265
1266
1267
1268 static VersionTuple getCanonicalVersionForOS(OSType OSKind,
1269 const VersionTuple &Version);
1270 };
1271
1272 }
1273
1274
1275 #endif