LLVM 24.0.0git
Triple.h
Go to the documentation of this file.
1//===-- llvm/TargetParser/Triple.h - Target triple helper class--*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TARGETPARSER_TRIPLE_H
10#define LLVM_TARGETPARSER_TRIPLE_H
11
12#include "llvm/ADT/StringRef.h"
16
17// Some system headers or GCC predefined macros conflict with identifiers in
18// this file. Undefine them here.
19#undef NetBSD
20#undef mips
21#undef sparc
22
23namespace llvm {
24enum class ExceptionHandling;
25class Twine;
26
27/// Triple - Helper class for working with autoconf configuration names. For
28/// historical reasons, we also call these 'triples' (they used to contain
29/// exactly three fields).
30///
31/// Configuration names are strings in the canonical form:
32/// ARCHITECTURE-VENDOR-OPERATING_SYSTEM
33/// or
34/// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
35///
36/// This class is used for clients which want to support arbitrary
37/// configuration names, but also want to implement certain special
38/// behavior for particular configurations. This class isolates the mapping
39/// from the components of the configuration name to well known IDs.
40///
41/// At its core the Triple class is designed to be a wrapper for a triple
42/// string; the constructor does not change or normalize the triple string.
43/// Clients that need to handle the non-canonical triples that users often
44/// specify should use the normalize method.
45///
46/// See autoconf/config.guess for a glimpse into what configuration names
47/// look like in practice.
48class Triple {
49public:
50 enum ArchType {
52
53 arm, // ARM (little endian): arm, armv.*, xscale
54 armeb, // ARM (big endian): armeb
55 aarch64, // AArch64 (little endian): aarch64
56 aarch64_be, // AArch64 (big endian): aarch64_be
57 aarch64_32, // AArch64 (little endian) ILP32: aarch64_32
58 arc, // ARC: Synopsys ARC
59 avr, // AVR: Atmel AVR microcontroller
60 bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
61 bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
62 csky, // CSKY: csky
63 dxil, // DXIL 32-bit DirectX bytecode
64 hexagon, // Hexagon: hexagon
65 loongarch32, // LoongArch (32-bit): loongarch32
66 loongarch64, // LoongArch (64-bit): loongarch64
67 m68k, // M68k: Motorola 680x0 family
68 mips, // MIPS: mips, mipsallegrex, mipsr6
69 mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
70 mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
71 mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
72 msp430, // MSP430: msp430
73 ppc, // PPC: powerpc
74 ppcle, // PPCLE: powerpc (little endian)
75 ppc64, // PPC64: powerpc64, ppu
76 ppc64le, // PPC64LE: powerpc64le
77 r600, // R600: AMD GPUs HD2XXX - HD6XXX
78 amdgpu, // AMDGPU: AMD GCN+ GPUs
79 riscv32, // RISC-V (32-bit, little endian): riscv32
80 riscv64, // RISC-V (64-bit, little endian): riscv64
81 riscv32be, // RISC-V (32-bit, big endian): riscv32be
82 riscv64be, // RISC-V (64-bit, big endian): riscv64be
83 sparc, // Sparc: sparc
84 sparcv9, // Sparcv9: Sparcv9
85 sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
86 systemz, // SystemZ: s390x
87 // OpenASIP (http://openasip.org) / big endian 32b targets: tce
89 // OpenASIP (http://openasip.org) / little endian 32b targets: tcele
91 // OpenASIP (http://openasip.org) / little endian 64b targets: tcele
93 thumb, // Thumb (little endian): thumb, thumbv.*
94 thumbeb, // Thumb (big endian): thumbeb
95 x86, // X86: i[3-9]86
96 x86_64, // X86-64: amd64, x86_64
97 xcore, // XCore: xcore
98 xtensa, // Tensilica: Xtensa
99 nvptx, // NVPTX: 32-bit
100 nvptx64, // NVPTX: 64-bit
101 amdil, // AMDIL
102 amdil64, // AMDIL with 64-bit pointers
103 hsail, // AMD HSAIL
104 hsail64, // AMD HSAIL with 64-bit pointers
105 spir, // SPIR: standard portable IR for OpenCL 32-bit version
106 spir64, // SPIR: standard portable IR for OpenCL 64-bit version
107 spirv, // SPIR-V with logical memory layout.
108 spirv32, // SPIR-V with 32-bit pointers
109 spirv64, // SPIR-V with 64-bit pointers
110 kalimba, // Kalimba: generic kalimba
111 shave, // SHAVE: Movidius vector VLIW processors
112 lanai, // Lanai: Lanai 32-bit
113 wasm32, // WebAssembly with 32-bit pointers
114 wasm64, // WebAssembly with 64-bit pointers
115 renderscript32, // 32-bit RenderScript
116 renderscript64, // 64-bit RenderScript
117 ve, // NEC SX-Aurora Vector Engine
119 };
122
158
162
164
168
170
172
173 // SPIR-V sub-arch corresponds to its version.
181
182 // DXIL sub-arch corresponds to its version.
194
195 // AMDGPU sub-arch
200
208
214
215 // 810 is its own major arch.
217
225
226 // 908 and 90a are not covered by a generic target, and are their own major
227 // subarches.
230
234
240
249
260
265
269
273
278 };
299 enum OSType {
301
309 Lv2, // PS3
321 CUDA, // NVIDIA CUDA
322 NVCL, // NVIDIA OpenCL
323 AMDHSA, // AMD HSA Runtime
327 TvOS, // Apple tvOS
328 WatchOS, // Apple watchOS
329 BridgeOS, // Apple bridgeOS
330 DriverKit, // Apple DriverKit
331 XROS, // Apple XROS
333 AMDPAL, // AMD PAL Runtime
334 HermitCore, // HermitCore Unikernel/Multikernel
335 Hurd, // GNU/Hurd
336 WASI, // Deprecated alias of WASI 0.1; in the future will be WASI 1.0.
337 WASIp1, // WASI 0.1
338 WASIp2, // WASI 0.2
339 WASIp3, // WASI 0.3
341 ShaderModel, // DirectX ShaderModel
344 Vulkan, // Vulkan SPIR-V
352 };
355
383
388 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
389 MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
390
391 // Shader Stages
392 // The order of these values matters, and must be kept in sync with the
393 // language options enum in Clang. The ordering is enforced in
394 // static_asserts in Triple.cpp and in Clang.
413
417 };
430
431private:
432 std::string Data;
433
434 /// The parsed arch type.
435 ArchType Arch{};
436
437 /// The parsed subarchitecture type.
438 SubArchType SubArch{};
439
440 /// The parsed vendor type.
441 VendorType Vendor{};
442
443 /// The parsed OS type.
444 OSType OS{};
445
446 /// The parsed Environment type.
447 EnvironmentType Environment{};
448
449 /// The object format type.
450 ObjectFormatType ObjectFormat{};
451
452public:
453 /// @name Constructors
454 /// @{
455
456 /// Default constructor is the same as an empty string and leaves all
457 /// triple fields unknown.
458 Triple() = default;
459
460 LLVM_ABI explicit Triple(std::string &&Str);
461 explicit Triple(StringRef Str) : Triple(Str.str()) {}
462 explicit Triple(const char *Str) : Triple(std::string(Str)) {}
463 explicit Triple(const std::string &Str) : Triple(std::string(Str)) {}
464 LLVM_ABI explicit Triple(const Twine &Str);
465
466 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
467 const Twine &OSStr);
468 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
469 const Twine &OSStr, const Twine &EnvironmentStr);
470 LLVM_ABI Triple(ArchType A, SubArchType SA = NoSubArch,
471 VendorType V = UnknownVendor, OSType OS = UnknownOS);
472 LLVM_ABI Triple(ArchType A, SubArchType SA, VendorType V, OSType OS,
473 EnvironmentType E);
474 LLVM_ABI Triple(ArchType A, SubArchType SA, VendorType V, OSType OS,
475 EnvironmentType E, ObjectFormatType OF);
476
477 LLVM_ABI bool operator==(const Triple &Other) const;
478 bool operator!=(const Triple &Other) const { return !(*this == Other); }
479
480 LLVM_ABI bool operator<(const Triple &Other) const;
481
482 /// @}
483 /// @name Normalization
484 /// @{
485
486 /// Canonical form
487 enum class CanonicalForm {
488 ANY = 0,
489 THREE_IDENT = 3, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM
490 FOUR_IDENT = 4, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
491 FIVE_IDENT = 5, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT-FORMAT
492 };
493
494 /// Turn an arbitrary machine specification into the canonical triple form (or
495 /// something sensible that the Triple class understands if nothing better can
496 /// reasonably be done). In particular, it handles the common case in which
497 /// otherwise valid components are in the wrong order. \p Form is used to
498 /// specify the output canonical form.
499 LLVM_ABI static std::string
501
502 /// Return the normalized form of this triple's string.
503 std::string normalize(CanonicalForm Form = CanonicalForm::ANY) const {
504 return normalize(Data, Form);
505 }
506
507 /// @}
508 /// @name Typed Component Access
509 /// @{
510
511 /// Get the parsed architecture type of this triple.
512 ArchType getArch() const { return Arch; }
513
514 /// get the parsed subarchitecture type for this triple.
515 SubArchType getSubArch() const { return SubArch; }
516
517 /// Get the parsed vendor type of this triple.
518 VendorType getVendor() const { return Vendor; }
519
520 /// Get the parsed operating system type of this triple.
521 OSType getOS() const { return OS; }
522
523 /// Does this triple have the optional environment (fourth) component?
524 bool hasEnvironment() const { return getEnvironmentName() != ""; }
525
526 /// Get the parsed environment type of this triple.
527 EnvironmentType getEnvironment() const { return Environment; }
528
529 /// Parse the version number from the OS name component of the
530 /// triple, if present.
531 ///
532 /// For example, "fooos1.2.3" would return (1, 2, 3).
534
535 /// Get the object format for this triple.
536 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
537
538 /// Parse the version number from the OS name component of the triple, if
539 /// present.
540 ///
541 /// For example, "fooos1.2.3" would return (1, 2, 3).
543
544 /// Return just the major version number, this is specialized because it is a
545 /// common query.
546 unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
547
548 /// Parse the version number as with getOSVersion and then translate generic
549 /// "darwin" versions to the corresponding OS X versions. This may also be
550 /// called with IOS triples but the OS X version number is just set to a
551 /// constant 10.4.0 in that case. Returns true if successful.
553
554 /// Parse the version number as with getOSVersion. This should only be called
555 /// with IOS or generic triples.
557
558 /// Parse the version number as with getOSVersion. This should only be called
559 /// with WatchOS or generic triples.
561
562 /// Parse the version number as with getOSVersion.
564
565 /// Parse the Vulkan version number from the OSVersion and SPIR-V version
566 /// (SubArch). This should only be called with Vulkan SPIR-V triples.
568
569 /// Parse the DXIL version number from the OSVersion and DXIL version
570 /// (SubArch). This should only be called with DXIL triples.
572
573 /// @}
574 /// @name Direct Component Access
575 /// @{
576
577 const std::string &str() const { return Data; }
578
579 const std::string &getTriple() const { return Data; }
580
581 /// Whether the triple is empty / default constructed.
582 bool empty() const { return Data.empty(); }
583
584 /// Get the architecture (first) component of the triple.
586
587 /// Get the vendor (second) component of the triple.
589
590 /// Get the operating system (third) component of the triple.
592
593 /// Get the optional environment (fourth) component of the triple, or "" if
594 /// empty.
596
597 /// Get the operating system and optional environment components as a single
598 /// string (separated by a '-' if the environment component is present).
600
601 /// Get the version component of the environment component as a single
602 /// string (the version after the environment).
603 ///
604 /// For example, "fooos1.2.3" would return "1.2.3".
606
607 /// @}
608 /// @name Convenience Predicates
609 /// @{
610
611 /// Returns the pointer width of this architecture.
613
614 /// Returns the pointer width of this architecture.
615 unsigned getArchPointerBitWidth() const {
617 }
618
619 /// Returns the trampoline size in bytes for this configuration.
620 LLVM_ABI unsigned getTrampolineSize() const;
621
622 /// Test whether the architecture is 64-bit
623 ///
624 /// Note that this tests for 64-bit pointer width, and nothing else. Note
625 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
626 /// 16-bit. The inner details of pointer width for particular architectures
627 /// is not summed up in the triple, and so only a coarse grained predicate
628 /// system is provided.
629 LLVM_ABI bool isArch64Bit() const;
630
631 /// Test whether the architecture is 32-bit
632 ///
633 /// Note that this tests for 32-bit pointer width, and nothing else.
634 LLVM_ABI bool isArch32Bit() const;
635
636 /// Test whether the architecture is 16-bit
637 ///
638 /// Note that this tests for 16-bit pointer width, and nothing else.
639 LLVM_ABI bool isArch16Bit() const;
640
641 /// Helper function for doing comparisons against version numbers included in
642 /// the target triple.
643 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
644 unsigned Micro = 0) const {
645 if (Minor == 0) {
646 return getOSVersion() < VersionTuple(Major);
647 }
648 if (Micro == 0) {
649 return getOSVersion() < VersionTuple(Major, Minor);
650 }
651 return getOSVersion() < VersionTuple(Major, Minor, Micro);
652 }
653
654 bool isOSVersionGE(unsigned Major, unsigned Minor = 0,
655 unsigned Micro = 0) const {
656 return !isOSVersionLT(Major, Minor, Micro);
657 }
658
659 bool isOSVersionLT(const Triple &Other) const {
660 return getOSVersion() < Other.getOSVersion();
661 }
662
663 bool isOSVersionGE(const Triple &Other) const {
664 return getOSVersion() >= Other.getOSVersion();
665 }
666
667 /// Comparison function for checking OS X version compatibility, which handles
668 /// supporting skewed version numbering schemes used by the "darwin" triples.
669 LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
670 unsigned Micro = 0) const;
671
672 bool isMacOSXVersionGE(unsigned Major, unsigned Minor = 0,
673 unsigned Micro = 0) const {
674 return !isMacOSXVersionLT(Major, Minor, Micro);
675 }
676
677 /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
678 /// and "osx" as OS X triples.
679 bool isMacOSX() const {
680 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
681 }
682
683 /// Is this an iOS triple.
684 /// Note: This identifies tvOS as a variant of iOS. If that ever
685 /// changes, i.e., if the two operating systems diverge or their version
686 /// numbers get out of sync, that will need to be changed.
687 /// watchOS has completely different version numbers so it is not included.
688 bool isiOS() const { return getOS() == Triple::IOS || isTvOS(); }
689
690 /// Is this an Apple tvOS triple.
691 bool isTvOS() const { return getOS() == Triple::TvOS; }
692
693 /// Is this an Apple watchOS triple.
694 bool isWatchOS() const { return getOS() == Triple::WatchOS; }
695
696 bool isWatchABI() const { return getSubArch() == Triple::ARMSubArch_v7k; }
697
698 /// Is this an Apple XROS triple.
699 bool isXROS() const { return getOS() == Triple::XROS; }
700
701 /// Is this an Apple BridgeOS triple.
702 bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }
703
704 /// Is this an Apple DriverKit triple.
705 bool isDriverKit() const { return getOS() == Triple::DriverKit; }
706
707 bool isOSzOS() const { return getOS() == Triple::ZOS; }
708
709 /// Is this an Apple MachO triple.
710 bool isAppleMachO() const {
711 return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
712 }
713
714 /// Is this an Apple firmware triple.
715 bool isAppleFirmware() const {
716 return (getVendor() == Triple::Apple) && isOSFirmware();
717 }
718
719 /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
720 /// bridgeOS).
721 bool isOSDarwin() const {
722 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
724 // Apple firmware isn't necessarily a Darwin based OS, but for most intents
725 // and purposes it can be treated like a Darwin OS in the compiler.
726 }
727
730 }
731
733 return getEnvironment() == Triple::MacABI;
734 }
735
736 /// Returns true for targets that run on a macOS machine.
737 bool isTargetMachineMac() const {
738 return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
740 }
741
742 bool isOSNetBSD() const { return getOS() == Triple::NetBSD; }
743
744 bool isOSOpenBSD() const { return getOS() == Triple::OpenBSD; }
745
746 bool isOSFreeBSD() const { return getOS() == Triple::FreeBSD; }
747
748 bool isOSFuchsia() const { return getOS() == Triple::Fuchsia; }
749
750 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
751
752 bool isOSSolaris() const { return getOS() == Triple::Solaris; }
753
754 bool isOSIAMCU() const { return getOS() == Triple::ELFIAMCU; }
755
756 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
757
758 bool isGNUEnvironment() const {
760 return Env == Triple::GNU || Env == Triple::GNUT64 ||
761 Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
762 Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
763 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
764 Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
765 Env == Triple::GNUSF || Env == Triple::GNUX32;
766 }
767
768 /// Tests whether the OS is Haiku.
769 bool isOSHaiku() const { return getOS() == Triple::Haiku; }
770
771 /// Tests whether the OS is UEFI.
772 bool isUEFI() const { return getOS() == Triple::UEFI; }
773
774 /// Tests whether the OS is Windows.
775 bool isOSWindows() const { return getOS() == Triple::Win32; }
776
777 /// Tests whether the OS is Windows or UEFI. These targets generally share
778 /// Windows low-level platform ABI conventions, but this does not imply
779 /// support for a hosted Windows environment or its runtime libraries. Use
780 /// object format or environment predicates when those properties matter.
781 bool isOSWindowsOrUEFI() const { return isOSWindows() || isUEFI(); }
782
783 /// Checks if the environment is MSVC.
785 return isOSWindows() && getEnvironment() == Triple::MSVC;
786 }
787
788 /// Checks if the environment could be MSVC.
793
794 // Checks if we're using the Windows Arm64EC ABI.
795 bool isWindowsArm64EC() const {
796 return getArch() == Triple::aarch64 &&
798 }
799
802 }
803
806 }
807
810 }
811
813 return isOSWindows() && getEnvironment() == Triple::GNU;
814 }
815
816 /// Tests for either Cygwin or MinGW OS
817 bool isOSCygMing() const {
819 }
820
821 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
826
827 /// Tests whether the OS is Linux.
828 bool isOSLinux() const { return getOS() == Triple::Linux; }
829
830 /// Tests whether the OS is kFreeBSD.
831 bool isOSKFreeBSD() const { return getOS() == Triple::KFreeBSD; }
832
833 /// Tests whether the OS is Hurd.
834 bool isOSHurd() const { return getOS() == Triple::Hurd; }
835
836 /// Tests whether the OS is WASI.
837 bool isOSWASI() const {
838 return getOS() == Triple::WASI || getOS() == Triple::WASIp1 ||
840 }
841
842 /// Tests whether the OS is Emscripten.
843 bool isOSEmscripten() const { return getOS() == Triple::Emscripten; }
844
845 /// Tests whether the OS uses glibc.
846 bool isOSGlibc() const {
847 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
848 getOS() == Triple::Hurd) &&
850 }
851
852 /// Tests whether the OS is AIX.
853 bool isOSAIX() const { return getOS() == Triple::AIX; }
854
855 bool isOSSerenity() const { return getOS() == Triple::Serenity; }
856
857 /// Tests whether the OS is QURT.
858 bool isOSQurt() const { return getOS() == Triple::QURT; }
859
860 /// Tests whether the OS is H2.
861 bool isOSH2() const { return getOS() == Triple::H2; }
862
863 /// Tests whether the OS uses the ELF binary format.
864 bool isOSBinFormatELF() const { return getObjectFormat() == Triple::ELF; }
865
866 /// Tests whether the OS uses the COFF binary format.
867 bool isOSBinFormatCOFF() const { return getObjectFormat() == Triple::COFF; }
868
869 /// Tests whether the OS uses the GOFF binary format.
870 bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
871
872 /// Tests whether the environment is MachO.
874
875 /// Tests whether the OS uses the Wasm binary format.
876 bool isOSBinFormatWasm() const { return getObjectFormat() == Triple::Wasm; }
877
878 /// Tests whether the OS uses the XCOFF binary format.
880
881 /// Tests whether the OS uses the DXContainer binary format.
884 }
885
886 /// Tests whether the target uses WALI Wasm
887 bool isWALI() const {
888 return getArch() == Triple::wasm32 && isOSLinux() &&
890 }
891
892 /// Tests whether the target is the PS4 platform.
893 bool isPS4() const {
894 return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
895 getOS() == Triple::PS4;
896 }
897
898 /// Tests whether the target is the PS5 platform.
899 bool isPS5() const {
900 return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
901 getOS() == Triple::PS5;
902 }
903
904 /// Tests whether the target is the PS4 or PS5 platform.
905 bool isPS() const { return isPS4() || isPS5(); }
906
907 /// Tests whether the target is Android
908 bool isAndroid() const { return getEnvironment() == Triple::Android; }
909
910 bool isAndroidVersionLT(unsigned Major) const {
911 assert(isAndroid() && "Not an Android triple!");
912
914
915 // 64-bit targets did not exist before API level 21 (Lollipop).
916 if (isArch64Bit() && Version.getMajor() < 21)
917 return VersionTuple(21) < VersionTuple(Major);
918
919 return Version < VersionTuple(Major);
920 }
921
922 /// Tests whether the environment is musl-libc
935
936 /// Tests whether the target is OHOS
937 /// LiteOS default enviroment is also OHOS, but omited on triple.
938 bool isOHOSFamily() const { return isOpenHOS() || isOSLiteOS(); }
939
940 bool isOpenHOS() const { return getEnvironment() == Triple::OpenHOS; }
941
942 bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
943
944 /// Tests whether the target is DXIL.
945 bool isDXIL() const { return getArch() == Triple::dxil; }
946
947 bool isShaderModelOS() const { return getOS() == Triple::ShaderModel; }
948
949 bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
950
951 bool isOSManagarm() const { return getOS() == Triple::Managarm; }
952
953 bool isOSFirmware() const { return getOS() == Triple::Firmware; }
954
957 return Env == Triple::Pixel || Env == Triple::Vertex ||
958 Env == Triple::Geometry || Env == Triple::Hull ||
959 Env == Triple::Domain || Env == Triple::Compute ||
960 Env == Triple::Library || Env == Triple::RayGeneration ||
961 Env == Triple::Intersection || Env == Triple::AnyHit ||
962 Env == Triple::ClosestHit || Env == Triple::Miss ||
963 Env == Triple::Callable || Env == Triple::Mesh ||
965 }
966
967 /// Tests whether the target is SPIR (32- or 64-bit).
968 bool isSPIR() const {
969 return getArch() == Triple::spir || getArch() == Triple::spir64;
970 }
971
972 /// Tests whether the target is SPIR-V (32/64-bit/Logical).
973 bool isSPIRV() const {
974 return getArch() == Triple::spirv32 || getArch() == Triple::spirv64 ||
976 }
977
978 // Tests whether the target is SPIR-V or SPIR.
979 bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
980
981 /// Tests whether the target is SPIR-V Logical
982 bool isSPIRVLogical() const { return getArch() == Triple::spirv; }
983
984 /// Tests whether the target is NVPTX (32- or 64-bit).
985 bool isNVPTX() const {
986 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
987 }
988
989 /// Tests whether the target is AMDGCN
990 bool isAMDGCN() const { return getArch() == Triple::amdgpu; }
991
992 bool isAMDGPU() const { return isAMDGCN() || getArch() == Triple::r600; }
993
994 /// Tests whether the target is Thumb (little and big endian).
995 bool isThumb() const {
996 return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
997 }
998
999 /// Tests whether the target is ARM (little and big endian).
1000 bool isARM() const {
1001 return getArch() == Triple::arm || getArch() == Triple::armeb;
1002 }
1003
1004 /// Tests whether the target is LFI.
1005 bool isLFI() const {
1006 return (getArch() == Triple::aarch64 &&
1008 (getArch() == Triple::x86_64 &&
1010 }
1011
1012 /// Tests whether the target supports the EHABI exception
1013 /// handling standard.
1028
1029 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
1030 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
1031 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
1032 // even for GNUEABI, so we can make a distinction here and still conform to
1033 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
1034 // FIXME: The Darwin exception is temporary, while we move users to
1035 // "*-*-*-macho" triples as quickly as possible.
1036 bool isTargetAEABI() const {
1037 return (getEnvironment() == Triple::EABI ||
1039 !isOSDarwin() && !isOSWindows();
1040 }
1041
1049
1050 bool isTargetMuslAEABI() const {
1051 return (getEnvironment() == Triple::MuslEABI ||
1054 !isOSDarwin() && !isOSWindows();
1055 }
1056
1057 /// Tests whether the target is T32.
1058 bool isArmT32() const {
1059 switch (getSubArch()) {
1071 return false;
1072 default:
1073 return true;
1074 }
1075 }
1076
1077 /// Tests whether the target is an M-class.
1078 bool isArmMClass() const {
1079 switch (getSubArch()) {
1086 return true;
1087 default:
1088 return false;
1089 }
1090 }
1091
1092 /// Tests whether the target is AArch64 (little and big endian).
1093 bool isAArch64() const {
1094 return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
1096 }
1097
1098 /// Tests whether the target is AArch64 and pointers are the size specified by
1099 /// \p PointerWidth.
1100 bool isAArch64(int PointerWidth) const {
1101 assert(PointerWidth == 64 || PointerWidth == 32);
1102 if (!isAArch64())
1103 return false;
1104 return getArch() == Triple::aarch64_32 ||
1106 ? PointerWidth == 32
1107 : PointerWidth == 64;
1108 }
1109
1110 bool isAVR() const { return getArch() == Triple::avr; }
1111
1112 /// Tests whether the target is 32-bit LoongArch.
1113 bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
1114
1115 /// Tests whether the target is 64-bit LoongArch.
1116 bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
1117
1118 /// Tests whether the target is LoongArch (32- and 64-bit).
1119 bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
1120
1121 /// Tests whether the target is MIPS 32-bit (little and big endian).
1122 bool isMIPS32() const {
1123 return getArch() == Triple::mips || getArch() == Triple::mipsel;
1124 }
1125
1126 /// Tests whether the target is MIPS 64-bit (little and big endian).
1127 bool isMIPS64() const {
1128 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
1129 }
1130
1131 /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
1132 bool isMIPS() const { return isMIPS32() || isMIPS64(); }
1133
1134 /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
1135 bool isPPC() const {
1136 return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
1138 }
1139
1140 /// Tests whether the target is 32-bit PowerPC (little and big endian).
1141 bool isPPC32() const {
1142 return getArch() == Triple::ppc || getArch() == Triple::ppcle;
1143 }
1144
1145 /// Tests whether the target is 64-bit PowerPC (little and big endian).
1146 bool isPPC64() const {
1147 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
1148 }
1149
1150 /// Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
1151 bool isPPC64ELFv2ABI() const {
1152 return (getArch() == Triple::ppc64 &&
1153 ((getOS() == Triple::FreeBSD &&
1154 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1155 getOS() == Triple::OpenBSD || isMusl()));
1156 }
1157
1158 /// Tests whether the target 32-bit PowerPC uses Secure PLT.
1159 bool isPPC32SecurePlt() const {
1160 return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
1161 ((getOS() == Triple::FreeBSD &&
1162 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1164 isMusl()));
1165 }
1166
1167 /// Tests whether the target is 32-bit RISC-V.
1168 bool isRISCV32() const {
1170 }
1171
1172 /// Tests whether the target is 64-bit RISC-V.
1173 bool isRISCV64() const {
1175 }
1176
1177 /// Tests whether the target is RISC-V (32- and 64-bit).
1178 bool isRISCV() const { return isRISCV32() || isRISCV64(); }
1179
1180 /// Tests whether the target is 32-bit SPARC (little and big endian).
1181 bool isSPARC32() const {
1182 return getArch() == Triple::sparc || getArch() == Triple::sparcel;
1183 }
1184
1185 /// Tests whether the target is 64-bit SPARC (big endian).
1186 bool isSPARC64() const { return getArch() == Triple::sparcv9; }
1187
1188 /// Tests whether the target is SPARC.
1189 bool isSPARC() const { return isSPARC32() || isSPARC64(); }
1190
1191 /// Tests whether the target is SystemZ.
1192 bool isSystemZ() const { return getArch() == Triple::systemz; }
1193
1194 /// Tests whether the target is x86 (32- or 64-bit).
1195 bool isX86() const {
1196 return getArch() == Triple::x86 || getArch() == Triple::x86_64;
1197 }
1198
1199 /// Tests whether the target is x86 (32-bit).
1200 bool isX86_32() const { return getArch() == Triple::x86; }
1201
1202 /// Tests whether the target is x86 (64-bit).
1203 bool isX86_64() const { return getArch() == Triple::x86_64; }
1204
1205 /// Tests whether the target is VE
1206 bool isVE() const { return getArch() == Triple::ve; }
1207
1208 /// Tests whether the target is wasm (32- and 64-bit).
1209 bool isWasm() const {
1210 return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
1211 }
1212
1213 // Tests whether the target is CSKY
1214 bool isCSKY() const { return getArch() == Triple::csky; }
1215
1216 /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
1217 bool isArm64e() const {
1218 return getArch() == Triple::aarch64 &&
1220 }
1221
1222 // Tests whether the target is N32.
1223 bool isABIN32() const {
1225 return Env == Triple::GNUABIN32 || Env == Triple::MuslABIN32;
1226 }
1227
1228 /// Tests whether the target is X32.
1229 bool isX32() const {
1231 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
1232 }
1233
1234 /// Tests whether the target is eBPF.
1235 bool isBPF() const {
1236 return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
1237 }
1238
1239 /// Tests whether MSVC linker or UEFI targets.
1240 /// Used to default to -mincremental-linker-compatible if we are
1241 /// targeting the MSVC linker or *-uefi triples.
1245
1246 /// Tests if the target forces 64-bit time_t on a 32-bit architecture.
1247 bool isTime64ABI() const {
1249 return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1250 Env == Triple::GNUEABIHFT64;
1251 }
1252
1253 /// Returns the default floating-point ABI for this target triple, i.e. the
1254 /// ABI the code generator will resolve FloatABI::Default to
1256
1257 /// Tests if the target's default floating-point ABI is hard float.
1259
1260 /// Tests whether the target supports comdat
1261 bool supportsCOMDAT() const {
1262 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
1264 }
1265
1266 /// Tests whether the target uses emulated TLS as default.
1267 ///
1268 /// Note: Android API level 29 (10) introduced ELF TLS.
1270 return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
1272 }
1273
1274 /// True if the target uses TLSDESC by default.
1275 bool hasDefaultTLSDESC() const {
1276 return isAArch64() || (isAndroid() && isRISCV64()) || isOSFuchsia();
1277 }
1278
1279 /// Tests whether the target uses -data-sections as default.
1281 return isOSBinFormatXCOFF() || isWasm();
1282 }
1283
1284 /// Returns the default wchar_t size (in bytes) for this target triple.
1285 LLVM_ABI unsigned getDefaultWCharSize() const;
1286
1287 /// Tests if the environment supports dllimport/export annotations.
1288 bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
1289
1290 /// @}
1291 /// @name Mutators
1292 /// @{
1293
1294 /// Set the architecture (first) component of the triple to a known type.
1295 LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch = NoSubArch);
1296
1297 /// Set the vendor (second) component of the triple to a known type.
1298 LLVM_ABI void setVendor(VendorType Kind);
1299
1300 /// Set the operating system (third) component of the triple to a known type.
1301 LLVM_ABI void setOS(OSType Kind);
1302
1303 /// Set the environment (fourth) component of the triple to a known type.
1304 LLVM_ABI void setEnvironment(EnvironmentType Kind);
1305
1306 /// Set the object file format.
1307 LLVM_ABI void setObjectFormat(ObjectFormatType Kind);
1308
1309 /// Set all components to the new triple \p Str.
1310 LLVM_ABI void setTriple(const Twine &Str);
1311
1312 /// Set the architecture (first) component of the triple by name.
1313 LLVM_ABI void setArchName(StringRef Str);
1314
1315 /// Set the vendor (second) component of the triple by name.
1317
1318 /// Set the operating system (third) component of the triple by name.
1319 LLVM_ABI void setOSName(StringRef Str);
1320
1321 /// Set the optional environment (fourth) component of the triple by name.
1323
1324 /// Set the operating system and optional environment components with a single
1325 /// string.
1327
1328 /// @}
1329 /// @name Helpers to build variants of a particular triple.
1330 /// @{
1331
1332 /// Form a triple with a 32-bit variant of the current architecture.
1333 ///
1334 /// This can be used to move across "families" of architectures where useful.
1335 ///
1336 /// \returns A new triple with a 32-bit architecture or an unknown
1337 /// architecture if no such variant can be found.
1339
1340 /// Form a triple with a 64-bit variant of the current architecture.
1341 ///
1342 /// This can be used to move across "families" of architectures where useful.
1343 ///
1344 /// \returns A new triple with a 64-bit architecture or an unknown
1345 /// architecture if no such variant can be found.
1347
1348 /// Form a triple with a big endian variant of the current architecture.
1349 ///
1350 /// This can be used to move across "families" of architectures where useful.
1351 ///
1352 /// \returns A new triple with a big endian architecture or an unknown
1353 /// architecture if no such variant can be found.
1355
1356 /// Form a triple with a little endian variant of the current architecture.
1357 ///
1358 /// This can be used to move across "families" of architectures where useful.
1359 ///
1360 /// \returns A new triple with a little endian architecture or an unknown
1361 /// architecture if no such variant can be found.
1363
1364 /// Tests whether the target triple is little endian.
1365 ///
1366 /// \returns true if the triple is little endian, false otherwise.
1367 LLVM_ABI bool isLittleEndian() const;
1368
1369 /// Test whether target triples are compatible.
1370 LLVM_ABI bool isCompatibleWith(const Triple &Other) const;
1371
1372 /// Test whether the target triple is for a GPU.
1373 bool isGPU() const { return isSPIROrSPIRV() || isNVPTX() || isAMDGPU(); }
1374
1375 /// Merge target triples.
1376 LLVM_ABI std::string merge(const Triple &Other) const;
1377
1378 /// Some platforms have different minimum supported OS versions that
1379 /// varies by the architecture specified in the triple. This function
1380 /// returns the minimum supported OS version for this triple if one an exists,
1381 /// or an invalid version tuple if this triple doesn't have one.
1383
1384 /// @}
1385 /// @name Static helpers for IDs.
1386 /// @{
1387
1388 /// Get the canonical name for the \p Kind architecture.
1389 LLVM_ABI static StringRef getArchTypeName(ArchType Kind);
1390
1391 /// Get the architecture name based on \p Kind and \p SubArch.
1392 LLVM_ABI static StringRef getArchName(ArchType Kind,
1393 SubArchType SubArch = NoSubArch);
1394
1395 /// Get the "prefix" canonical name for the \p Kind architecture. This is the
1396 /// prefix used by the architecture specific builtins, and is suitable for
1397 /// passing to \see Intrinsic::getIntrinsicForClangBuiltin().
1398 ///
1399 /// \return - The architecture prefix, or 0 if none is defined.
1400 LLVM_ABI static StringRef getArchTypePrefix(ArchType Kind);
1401
1402 /// Get the canonical name for the \p Kind vendor.
1403 LLVM_ABI static StringRef getVendorTypeName(VendorType Kind);
1404
1405 /// Get the canonical name for the \p Kind operating system.
1406 LLVM_ABI static StringRef getOSTypeName(OSType Kind);
1407
1408 /// Get the canonical name for the \p Kind environment.
1409 LLVM_ABI static StringRef getEnvironmentTypeName(EnvironmentType Kind);
1410
1411 /// Get the name for the \p Object format.
1412 LLVM_ABI static StringRef
1413 getObjectFormatTypeName(ObjectFormatType ObjectFormat);
1414
1415 /// @}
1416 /// @name Static helpers for converting alternate architecture names.
1417 /// @{
1418
1419 /// The canonical type for the given LLVM architecture name (e.g., "x86").
1420 LLVM_ABI static ArchType getArchTypeForLLVMName(StringRef Str);
1421
1422 /// Parse anything recognized as an architecture for the first field of the
1423 /// triple.
1424 LLVM_ABI static ArchType parseArch(StringRef Str);
1425
1426 /// Parse the subarchitecture encoded in the first (architecture) field of the
1427 /// triple (e.g. "amdgpu9.00" -> AMDGPUSubArch900). Returns NoSubArch if the
1428 /// string does not encode a recognized subarchitecture.
1429 LLVM_ABI static SubArchType parseSubArch(StringRef Str);
1430
1431 /// @}
1432
1433 /// Returns a canonicalized OS version number for the specified OS.
1434 LLVM_ABI static VersionTuple
1435 getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version,
1436 bool IsInValidRange);
1437
1438 /// Returns whether an OS version is invalid and would not map to an Apple OS.
1439 LLVM_ABI static bool isValidVersionForOS(OSType OSKind,
1440 const VersionTuple &Version);
1441
1443
1444 /// Compute the LLVM IR data layout string based on the triple. Some targets
1445 /// customize the layout based on the ABIName string.
1446 LLVM_ABI std::string computeDataLayout(StringRef ABIName = "") const;
1447};
1448
1449} // namespace llvm
1450
1451#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
Defines the llvm::VersionTuple class, which represents a version in the form major[....
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Comparison function for checking OS X version compatibility, which handles supporting skewed version ...
Definition Triple.cpp:2367
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1518
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1135
bool isOSDragonFly() const
Definition Triple.h:750
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1463
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1638
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1746
bool isTargetMachineMac() const
Returns true for targets that run on a macOS machine.
Definition Triple.h:737
bool isArmT32() const
Tests whether the target is T32.
Definition Triple.h:1058
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1737
bool isAndroidVersionLT(unsigned Major) const
Definition Triple.h:910
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:1877
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:817
bool isWatchABI() const
Definition Triple.h:696
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:402
@ LastEnvironmentType
Definition Triple.h:416
@ UnknownEnvironment
Definition Triple.h:354
@ RootSignature
Definition Triple.h:410
@ Amplification
Definition Triple.h:409
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:995
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition Triple.h:893
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1203
bool isPPC64ELFv2ABI() const
Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
Definition Triple.h:1151
static LLVM_ABI VersionTuple getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version, bool IsInValidRange)
Returns a canonicalized OS version number for the specified OS.
Definition Triple.cpp:2421
bool isOSWASI() const
Tests whether the OS is WASI.
Definition Triple.h:837
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition Triple.h:968
CanonicalForm
Canonical form.
Definition Triple.h:487
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition Triple.h:876
bool isOSQurt() const
Tests whether the OS is QURT.
Definition Triple.h:858
LLVM_ABI bool operator<(const Triple &Other) const
Definition Triple.cpp:32
bool isDriverKit() const
Is this an Apple DriverKit triple.
Definition Triple.h:705
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:615
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2194
bool isOSHurd() const
Tests whether the OS is Hurd.
Definition Triple.h:834
bool isHardFloatABI() const
Tests if the target's default floating-point ABI is hard float.
Definition Triple.h:1258
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1235
bool isX32() const
Tests whether the target is X32.
Definition Triple.h:1229
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition Triple.cpp:421
Triple(const char *Str)
Definition Triple.h:462
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:536
bool isAArch64(int PointerWidth) const
Tests whether the target is AArch64 and pointers are the size specified by PointerWidth.
Definition Triple.h:1100
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:515
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1195
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1217
std::string normalize(CanonicalForm Form=CanonicalForm::ANY) const
Return the normalized form of this triple's string.
Definition Triple.h:503
bool isTargetEHABICompatible() const
Tests whether the target supports the EHABI exception handling standard.
Definition Triple.h:1014
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:870
bool isWindowsGNUEnvironment() const
Definition Triple.h:812
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1750
bool isOSNetBSD() const
Definition Triple.h:742
LLVM_ABI std::string computeDataLayout(StringRef ABIName="") const
Compute the LLVM IR data layout string based on the triple.
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1767
bool isAndroid() const
Tests whether the target is Android.
Definition Triple.h:908
bool hasDefaultTLSDESC() const
True if the target uses TLSDESC by default.
Definition Triple.h:1275
bool isLFI() const
Tests whether the target is LFI.
Definition Triple.h:1005
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:1991
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition Triple.h:822
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition Triple.h:873
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2249
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1728
bool isABIN32() const
Definition Triple.h:1223
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1468
bool isAVR() const
Definition Triple.h:1110
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition Triple.h:1261
bool isWindowsCoreCLREnvironment() const
Definition Triple.h:800
bool isSPIROrSPIRV() const
Definition Triple.h:979
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2509
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition Triple.h:1127
@ loongarch32
Definition Triple.h:65
@ renderscript64
Definition Triple.h:116
@ UnknownArch
Definition Triple.h:51
@ loongarch64
Definition Triple.h:66
@ renderscript32
Definition Triple.h:115
bool hasDefaultDataSections() const
Tests whether the target uses -data-sections as default.
Definition Triple.h:1280
bool isTargetGNUAEABI() const
Definition Triple.h:1042
bool isOSSolaris() const
Definition Triple.h:752
bool isOSH2() const
Tests whether the OS is H2.
Definition Triple.h:861
bool isRISCV32() const
Tests whether the target is 32-bit RISC-V.
Definition Triple.h:1168
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition Triple.h:831
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1716
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:521
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1491
static LLVM_ABI std::string normalize(StringRef Str, CanonicalForm Form=CanonicalForm::ANY)
Turn an arbitrary machine specification into the canonical triple form (or something sensible that th...
Definition Triple.cpp:1228
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:499
bool isOSVersionLT(const Triple &Other) const
Definition Triple.h:659
bool isPPC32() const
Tests whether the target is 32-bit PowerPC (little and big endian).
Definition Triple.h:1141
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:512
LLVM_ABI bool operator==(const Triple &Other) const
Definition Triple.cpp:26
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:1847
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:867
bool isRISCV64() const
Tests whether the target is 64-bit RISC-V.
Definition Triple.h:1173
bool isCSKY() const
Definition Triple.h:1214
bool isLoongArch64() const
Tests whether the target is 64-bit LoongArch.
Definition Triple.h:1116
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1474
bool isSPARC32() const
Tests whether the target is 32-bit SPARC (little and big endian).
Definition Triple.h:1181
bool isSimulatorEnvironment() const
Definition Triple.h:728
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1703
const std::string & str() const
Definition Triple.h:577
bool isOSzOS() const
Definition Triple.h:707
bool isOSSerenity() const
Definition Triple.h:855
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:938
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:527
bool isOSOpenBSD() const
Definition Triple.h:744
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1678
bool isOSUnknown() const
Definition Triple.h:756
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1666
static LLVM_ABI ArchType parseArch(StringRef Str)
Parse anything recognized as an architecture for the first field of the triple.
Definition Triple.cpp:638
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition Triple.h:1122
bool isShaderModelOS() const
Definition Triple.h:947
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:772
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:775
bool isOSFirmware() const
Definition Triple.h:953
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:923
const std::string & getTriple() const
Definition Triple.h:579
bool isOSWindowsOrUEFI() const
Tests whether the OS is Windows or UEFI.
Definition Triple.h:781
static LLVM_ABI StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition Triple.cpp:38
bool isOSVersionGE(const Triple &Other) const
Definition Triple.h:663
bool isOSBinFormatDXContainer() const
Tests whether the OS uses the DXContainer binary format.
Definition Triple.h:882
bool isGPU() const
Test whether the target triple is for a GPU.
Definition Triple.h:1373
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition Triple.h:879
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:434
bool isTargetMuslAEABI() const
Definition Triple.h:1050
@ UnknownObjectFormat
Definition Triple.h:419
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:1000
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2355
bool isArmMClass() const
Tests whether the target is an M-class.
Definition Triple.h:1078
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:828
static LLVM_ABI SubArchType parseSubArch(StringRef Str)
Parse the subarchitecture encoded in the first (architecture) field of the triple (e....
Definition Triple.cpp:776
bool isBridgeOS() const
Is this an Apple BridgeOS triple.
Definition Triple.h:702
bool isOSManagarm() const
Definition Triple.h:951
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1178
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition Triple.h:990
bool isAMDGPU() const
Definition Triple.h:992
bool isLoongArch32() const
Tests whether the target is 32-bit LoongArch.
Definition Triple.h:1113
bool isOSLiteOS() const
Definition Triple.h:942
@ UnknownVendor
Definition Triple.h:280
@ ImaginationTechnologies
Definition Triple.h:287
@ LastVendorType
Definition Triple.h:297
@ MipsTechnologies
Definition Triple.h:288
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:985
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:853
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2384
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1865
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1480
@ ARMSubArch_v6t2
Definition Triple.h:154
@ AMDGPUSubArch600
Definition Triple.h:197
@ MipsSubArch_r6
Definition Triple.h:169
@ X86_64SubArch_lfi
Definition Triple.h:163
@ DXILSubArch_v1_2
Definition Triple.h:185
@ ARMSubArch_v7
Definition Triple.h:145
@ ARMSubArch_v8m_mainline
Definition Triple.h:143
@ AMDGPUSubArch1153
Definition Triple.h:258
@ ARMSubArch_v9_6a
Definition Triple.h:124
@ AMDGPUSubArch1012
Definition Triple.h:238
@ ARMSubArch_v8r
Definition Triple.h:141
@ AMDGPUSubArch1150
Definition Triple.h:255
@ ARMSubArch_v9_1a
Definition Triple.h:129
@ DXILSubArch_v1_1
Definition Triple.h:184
@ AMDGPUSubArch703
Definition Triple.h:205
@ AMDGPUSubArch1201
Definition Triple.h:268
@ LatestDXILSubArch
Definition Triple.h:193
@ FirstAMDGPUSubArch
Definition Triple.h:276
@ SPIRVSubArch_v10
Definition Triple.h:174
@ AMDGPUSubArch9
Definition Triple.h:218
@ SPIRVSubArch_v13
Definition Triple.h:177
@ AMDGPUSubArch1172
Definition Triple.h:264
@ AMDGPUSubArch1035
Definition Triple.h:247
@ ARMSubArch_v7k
Definition Triple.h:149
@ AMDGPUSubArch9_4
Definition Triple.h:231
@ AMDGPUSubArch6
Definition Triple.h:196
@ AMDGPUSubArch1033
Definition Triple.h:245
@ AMDGPUSubArch1103
Definition Triple.h:254
@ ARMSubArch_v8_7a
Definition Triple.h:133
@ AMDGPUSubArch1034
Definition Triple.h:246
@ AMDGPUSubArch1154
Definition Triple.h:259
@ ARMSubArch_v8
Definition Triple.h:140
@ SPIRVSubArch_v16
Definition Triple.h:180
@ ARMSubArch_v8_1a
Definition Triple.h:139
@ ARMSubArch_v9_2a
Definition Triple.h:128
@ AMDGPUSubArch1200
Definition Triple.h:267
@ AMDGPUSubArch10_3
Definition Triple.h:241
@ DXILSubArch_v1_3
Definition Triple.h:186
@ SPIRVSubArch_v15
Definition Triple.h:179
@ ARMSubArch_v7m
Definition Triple.h:147
@ AMDGPUSubArch1102
Definition Triple.h:253
@ ARMSubArch_v9_7a
Definition Triple.h:123
@ AMDGPUSubArch1013
Definition Triple.h:239
@ AMDGPUSubArch902
Definition Triple.h:220
@ ARMSubArch_v6k
Definition Triple.h:153
@ AMDGPUSubArch1010
Definition Triple.h:236
@ AMDGPUSubArch90A
Definition Triple.h:229
@ ARMSubArch_v5
Definition Triple.h:155
@ AMDGPUSubArch1170
Definition Triple.h:262
@ AArch64SubArch_arm64e
Definition Triple.h:159
@ AMDGPUSubArch810
Definition Triple.h:216
@ ARMSubArch_v6
Definition Triple.h:151
@ AMDGPUSubArch11
Definition Triple.h:250
@ AMDGPUSubArch1151
Definition Triple.h:256
@ ARMSubArch_v9_5a
Definition Triple.h:125
@ AMDGPUSubArch602
Definition Triple.h:199
@ ARMSubArch_v7ve
Definition Triple.h:150
@ ARMSubArch_v8m_baseline
Definition Triple.h:142
@ ARMSubArch_v8_8a
Definition Triple.h:132
@ AMDGPUSubArch942
Definition Triple.h:232
@ AMDGPUSubArch7
Definition Triple.h:201
@ AMDGPUSubArch702
Definition Triple.h:204
@ AMDGPUSubArch950
Definition Triple.h:233
@ ARMSubArch_v8_2a
Definition Triple.h:138
@ LastAMDGPUSubArch
Definition Triple.h:277
@ ARMSubArch_v7s
Definition Triple.h:148
@ AMDGPUSubArch1251
Definition Triple.h:272
@ AMDGPUSubArch805
Definition Triple.h:213
@ DXILSubArch_v1_0
Definition Triple.h:183
@ DXILSubArch_v1_7
Definition Triple.h:190
@ AMDGPUSubArch12_5
Definition Triple.h:270
@ KalimbaSubArch_v3
Definition Triple.h:165
@ DXILSubArch_v1_5
Definition Triple.h:188
@ AMDGPUSubArch1250
Definition Triple.h:271
@ AMDGPUSubArch1030
Definition Triple.h:242
@ ARMSubArch_v8_4a
Definition Triple.h:136
@ AMDGPUSubArch803
Definition Triple.h:212
@ AMDGPUSubArch601
Definition Triple.h:198
@ ARMSubArch_v8_9a
Definition Triple.h:131
@ AMDGPUSubArch10_1
Definition Triple.h:235
@ AMDGPUSubArch904
Definition Triple.h:221
@ AMDGPUSubArch11_7
Definition Triple.h:261
@ AMDGPUSubArch705
Definition Triple.h:207
@ AMDGPUSubArch802
Definition Triple.h:211
@ AMDGPUSubArch8
Definition Triple.h:209
@ ARMSubArch_v7em
Definition Triple.h:146
@ SPIRVSubArch_v12
Definition Triple.h:176
@ AMDGPUSubArch90C
Definition Triple.h:224
@ SPIRVSubArch_v14
Definition Triple.h:178
@ AMDGPUSubArch1100
Definition Triple.h:251
@ KalimbaSubArch_v4
Definition Triple.h:166
@ AMDGPUSubArch909
Definition Triple.h:223
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:144
@ AMDGPUSubArch1036
Definition Triple.h:248
@ ARMSubArch_v8_3a
Definition Triple.h:137
@ AArch64SubArch_arm64ec
Definition Triple.h:160
@ ARMSubArch_v8_6a
Definition Triple.h:134
@ ARMSubArch_v5te
Definition Triple.h:156
@ KalimbaSubArch_v5
Definition Triple.h:167
@ AMDGPUSubArch701
Definition Triple.h:203
@ ARMSubArch_v4t
Definition Triple.h:157
@ AMDGPUSubArch1171
Definition Triple.h:263
@ DXILSubArch_v1_6
Definition Triple.h:189
@ AMDGPUSubArch1011
Definition Triple.h:237
@ AMDGPUSubArch906
Definition Triple.h:222
@ AMDGPUSubArch900
Definition Triple.h:219
@ AMDGPUSubArch1152
Definition Triple.h:257
@ DXILSubArch_v1_8
Definition Triple.h:191
@ AMDGPUSubArch801
Definition Triple.h:210
@ ARMSubArch_v9_4a
Definition Triple.h:126
@ ARMSubArch_v8_5a
Definition Triple.h:135
@ AArch64SubArch_lfi
Definition Triple.h:161
@ ARMSubArch_v6m
Definition Triple.h:152
@ ARMSubArch_v9_3a
Definition Triple.h:127
@ DXILSubArch_v1_9
Definition Triple.h:192
@ AMDGPUSubArch704
Definition Triple.h:206
@ AMDGPUSubArch1031
Definition Triple.h:243
@ AMDGPUSubArch1101
Definition Triple.h:252
@ ARMSubArch_v9
Definition Triple.h:130
@ AMDGPUSubArch13
Definition Triple.h:274
@ AMDGPUSubArch12
Definition Triple.h:266
@ DXILSubArch_v1_4
Definition Triple.h:187
@ AMDGPUSubArch700
Definition Triple.h:202
@ SPIRVSubArch_v11
Definition Triple.h:175
@ PPCSubArch_spe
Definition Triple.h:171
@ AMDGPUSubArch1032
Definition Triple.h:244
@ AMDGPUSubArch1310
Definition Triple.h:275
@ AMDGPUSubArch908
Definition Triple.h:228
LLVM_ABI bool getMacOSXVersion(VersionTuple &Version) const
Parse the version number as with getOSVersion and then translate generic "darwin" versions to the cor...
Definition Triple.cpp:1532
bool isSPARC64() const
Tests whether the target is 64-bit SPARC (big endian).
Definition Triple.h:1186
bool isWindowsCygwinEnvironment() const
Definition Triple.h:808
static LLVM_ABI bool isValidVersionForOS(OSType OSKind, const VersionTuple &Version)
Returns whether an OS version is invalid and would not map to an Apple OS.
Definition Triple.cpp:2478
Triple(StringRef Str)
Definition Triple.h:461
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:679
Triple(const std::string &Str)
Definition Triple.h:463
bool isOSFreeBSD() const
Definition Triple.h:746
bool isXROS() const
Is this an Apple XROS triple.
Definition Triple.h:699
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1762
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1726
bool isX86_32() const
Tests whether the target is x86 (32-bit).
Definition Triple.h:1200
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1754
bool isAppleFirmware() const
Is this an Apple firmware triple.
Definition Triple.h:715
bool isDefaultIncrementalLinkerCompatibleByDefault() const
Tests whether MSVC linker or UEFI targets.
Definition Triple.h:1242
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:518
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1189
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition Triple.h:1146
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:721
bool hasDLLImportExport() const
Tests if the environment supports dllimport/export annotations.
Definition Triple.h:1288
bool isSPIRVLogical() const
Tests whether the target is SPIR-V Logical.
Definition Triple.h:982
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:447
bool isOSVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Helper function for doing comparisons against version numbers included in the target triple.
Definition Triple.h:643
bool isTvOS() const
Is this an Apple tvOS triple.
Definition Triple.h:691
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition Triple.h:843
bool isWindowsArm64EC() const
Definition Triple.h:795
bool isOSVersionGE(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Definition Triple.h:654
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition Triple.h:694
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:582
bool isiOS() const
Is this an iOS triple.
Definition Triple.h:688
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1132
bool isMacOSXVersionGE(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Definition Triple.h:672
bool isWALI() const
Tests whether the target uses WALI Wasm.
Definition Triple.h:887
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition Triple.h:846
LLVM_ABI FloatABI::ABIType getDefaultFloatABI() const
Returns the default floating-point ABI for this target triple, i.e.
Definition Triple.cpp:2569
bool isTargetAEABI() const
Definition Triple.h:1036
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:905
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1209
bool isVulkanOS() const
Definition Triple.h:949
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1459
bool isOSIAMCU() const
Definition Triple.h:754
bool isOpenHOS() const
Definition Triple.h:940
bool isMacCatalystEnvironment() const
Definition Triple.h:732
bool isPS5() const
Tests whether the target is the PS5 platform.
Definition Triple.h:899
bool isSPIRV() const
Tests whether the target is SPIR-V (32/64-bit/Logical).
Definition Triple.h:973
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1093
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:460
bool isAppleMachO() const
Is this an Apple MachO triple.
Definition Triple.h:710
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:1873
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2111
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1586
bool hasDefaultEmulatedTLS() const
Tests whether the target uses emulated TLS as default.
Definition Triple.h:1269
bool isSystemZ() const
Tests whether the target is SystemZ.
Definition Triple.h:1192
LLVM_ABI StringRef getEnvironmentVersionString() const
Get the version component of the environment component as a single string (the version after the envi...
Definition Triple.cpp:1495
bool isPPC32SecurePlt() const
Tests whether the target 32-bit PowerPC uses Secure PLT.
Definition Triple.h:1159
bool isTime64ABI() const
Tests if the target forces 64-bit time_t on a 32-bit architecture.
Definition Triple.h:1247
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:1869
bool operator!=(const Triple &Other) const
Definition Triple.h:478
unsigned getOSMajorVersion() const
Return just the major version number, this is specialized because it is a common query.
Definition Triple.h:546
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2312
bool isOSFuchsia() const
Definition Triple.h:748
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:864
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:789
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:524
LLVM_ABI unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2302
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition Triple.h:784
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition Triple.cpp:300
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition Triple.h:769
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition Triple.cpp:1718
bool isDXIL() const
Tests whether the target is DXIL.
Definition Triple.h:945
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1722
bool isGNUEnvironment() const
Definition Triple.h:758
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1119
bool isShaderStageEnvironment() const
Definition Triple.h:955
bool isWindowsItaniumEnvironment() const
Definition Triple.h:804
bool isVE() const
Tests whether the target is VE.
Definition Triple.h:1206
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getMajor() const
Retrieve the major version number.
This is an optimization pass for GlobalISel generic memory operations.
ExceptionHandling
Definition CodeGen.h:53
@ Other
Any other memory.
Definition ModRef.h:68
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878