LLVM 23.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"
15
16// Some system headers or GCC predefined macros conflict with identifiers in
17// this file. Undefine them here.
18#undef NetBSD
19#undef mips
20#undef sparc
21
22namespace llvm {
23enum class ExceptionHandling;
24class Twine;
25
26/// Triple - Helper class for working with autoconf configuration names. For
27/// historical reasons, we also call these 'triples' (they used to contain
28/// exactly three fields).
29///
30/// Configuration names are strings in the canonical form:
31/// ARCHITECTURE-VENDOR-OPERATING_SYSTEM
32/// or
33/// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
34///
35/// This class is used for clients which want to support arbitrary
36/// configuration names, but also want to implement certain special
37/// behavior for particular configurations. This class isolates the mapping
38/// from the components of the configuration name to well known IDs.
39///
40/// At its core the Triple class is designed to be a wrapper for a triple
41/// string; the constructor does not change or normalize the triple string.
42/// Clients that need to handle the non-canonical triples that users often
43/// specify should use the normalize method.
44///
45/// See autoconf/config.guess for a glimpse into what configuration names
46/// look like in practice.
47class Triple {
48public:
49 enum ArchType {
51
52 arm, // ARM (little endian): arm, armv.*, xscale
53 armeb, // ARM (big endian): armeb
54 aarch64, // AArch64 (little endian): aarch64
55 aarch64_be, // AArch64 (big endian): aarch64_be
56 aarch64_32, // AArch64 (little endian) ILP32: aarch64_32
57 arc, // ARC: Synopsys ARC
58 avr, // AVR: Atmel AVR microcontroller
59 bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
60 bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
61 csky, // CSKY: csky
62 dxil, // DXIL 32-bit DirectX bytecode
63 hexagon, // Hexagon: hexagon
64 loongarch32, // LoongArch (32-bit): loongarch32
65 loongarch64, // LoongArch (64-bit): loongarch64
66 m68k, // M68k: Motorola 680x0 family
67 mips, // MIPS: mips, mipsallegrex, mipsr6
68 mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
69 mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
70 mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
71 msp430, // MSP430: msp430
72 ppc, // PPC: powerpc
73 ppcle, // PPCLE: powerpc (little endian)
74 ppc64, // PPC64: powerpc64, ppu
75 ppc64le, // PPC64LE: powerpc64le
76 r600, // R600: AMD GPUs HD2XXX - HD6XXX
77 amdgpu, // AMDGPU: AMD GCN+ GPUs
78 riscv32, // RISC-V (32-bit, little endian): riscv32
79 riscv64, // RISC-V (64-bit, little endian): riscv64
80 riscv32be, // RISC-V (32-bit, big endian): riscv32be
81 riscv64be, // RISC-V (64-bit, big endian): riscv64be
82 sparc, // Sparc: sparc
83 sparcv9, // Sparcv9: Sparcv9
84 sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
85 systemz, // SystemZ: s390x
86 // OpenASIP (http://openasip.org) / big endian 32b targets: tce
88 // OpenASIP (http://openasip.org) / little endian 32b targets: tcele
90 // OpenASIP (http://openasip.org) / little endian 64b targets: tcele
92 thumb, // Thumb (little endian): thumb, thumbv.*
93 thumbeb, // Thumb (big endian): thumbeb
94 x86, // X86: i[3-9]86
95 x86_64, // X86-64: amd64, x86_64
96 xcore, // XCore: xcore
97 xtensa, // Tensilica: Xtensa
98 nvptx, // NVPTX: 32-bit
99 nvptx64, // NVPTX: 64-bit
100 amdil, // AMDIL
101 amdil64, // AMDIL with 64-bit pointers
102 hsail, // AMD HSAIL
103 hsail64, // AMD HSAIL with 64-bit pointers
104 spir, // SPIR: standard portable IR for OpenCL 32-bit version
105 spir64, // SPIR: standard portable IR for OpenCL 64-bit version
106 spirv, // SPIR-V with logical memory layout.
107 spirv32, // SPIR-V with 32-bit pointers
108 spirv64, // SPIR-V with 64-bit pointers
109 kalimba, // Kalimba: generic kalimba
110 shave, // SHAVE: Movidius vector VLIW processors
111 lanai, // Lanai: Lanai 32-bit
112 wasm32, // WebAssembly with 32-bit pointers
113 wasm64, // WebAssembly with 64-bit pointers
114 renderscript32, // 32-bit RenderScript
115 renderscript64, // 64-bit RenderScript
116 ve, // NEC SX-Aurora Vector Engine
118 };
121
157
161
163
167
169
171
172 // SPIR-V sub-arch corresponds to its version.
180
181 // DXIL sub-arch corresponds to its version.
193
194 // AMDGPU sub-arch
199
207
213
214 // 810 is its own major arch.
216
224
225 // 908 and 90a are not covered by a generic target, and are their own major
226 // subarches.
229
233
239
248
259
264
268
272
277 };
298 enum OSType {
300
308 Lv2, // PS3
320 CUDA, // NVIDIA CUDA
321 NVCL, // NVIDIA OpenCL
322 AMDHSA, // AMD HSA Runtime
326 TvOS, // Apple tvOS
327 WatchOS, // Apple watchOS
328 BridgeOS, // Apple bridgeOS
329 DriverKit, // Apple DriverKit
330 XROS, // Apple XROS
332 AMDPAL, // AMD PAL Runtime
333 HermitCore, // HermitCore Unikernel/Multikernel
334 Hurd, // GNU/Hurd
335 WASI, // Deprecated alias of WASI 0.1; in the future will be WASI 1.0.
336 WASIp1, // WASI 0.1
337 WASIp2, // WASI 0.2
338 WASIp3, // WASI 0.3
340 ShaderModel, // DirectX ShaderModel
343 Vulkan, // Vulkan SPIR-V
351 };
354
382
387 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
388 MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
389
390 // Shader Stages
391 // The order of these values matters, and must be kept in sync with the
392 // language options enum in Clang. The ordering is enforced in
393 // static_asserts in Triple.cpp and in Clang.
412
416 };
429
430private:
431 std::string Data;
432
433 /// The parsed arch type.
434 ArchType Arch{};
435
436 /// The parsed subarchitecture type.
437 SubArchType SubArch{};
438
439 /// The parsed vendor type.
440 VendorType Vendor{};
441
442 /// The parsed OS type.
443 OSType OS{};
444
445 /// The parsed Environment type.
446 EnvironmentType Environment{};
447
448 /// The object format type.
449 ObjectFormatType ObjectFormat{};
450
451public:
452 /// @name Constructors
453 /// @{
454
455 /// Default constructor is the same as an empty string and leaves all
456 /// triple fields unknown.
457 Triple() = default;
458
459 LLVM_ABI explicit Triple(std::string &&Str);
460 explicit Triple(StringRef Str) : Triple(Str.str()) {}
461 explicit Triple(const char *Str) : Triple(std::string(Str)) {}
462 explicit Triple(const std::string &Str) : Triple(std::string(Str)) {}
463 LLVM_ABI explicit Triple(const Twine &Str);
464
465 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
466 const Twine &OSStr);
467 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
468 const Twine &OSStr, const Twine &EnvironmentStr);
469 LLVM_ABI Triple(ArchType A, SubArchType SA = NoSubArch,
470 VendorType V = UnknownVendor, OSType OS = UnknownOS);
471 LLVM_ABI Triple(ArchType A, SubArchType SA, VendorType V, OSType OS,
472 EnvironmentType E);
473 LLVM_ABI Triple(ArchType A, SubArchType SA, VendorType V, OSType OS,
474 EnvironmentType E, ObjectFormatType OF);
475
476 LLVM_ABI bool operator==(const Triple &Other) const;
477 bool operator!=(const Triple &Other) const { return !(*this == Other); }
478
479 LLVM_ABI bool operator<(const Triple &Other) const;
480
481 /// @}
482 /// @name Normalization
483 /// @{
484
485 /// Canonical form
486 enum class CanonicalForm {
487 ANY = 0,
488 THREE_IDENT = 3, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM
489 FOUR_IDENT = 4, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
490 FIVE_IDENT = 5, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT-FORMAT
491 };
492
493 /// Turn an arbitrary machine specification into the canonical triple form (or
494 /// something sensible that the Triple class understands if nothing better can
495 /// reasonably be done). In particular, it handles the common case in which
496 /// otherwise valid components are in the wrong order. \p Form is used to
497 /// specify the output canonical form.
498 LLVM_ABI static std::string
500
501 /// Return the normalized form of this triple's string.
502 std::string normalize(CanonicalForm Form = CanonicalForm::ANY) const {
503 return normalize(Data, Form);
504 }
505
506 /// @}
507 /// @name Typed Component Access
508 /// @{
509
510 /// Get the parsed architecture type of this triple.
511 ArchType getArch() const { return Arch; }
512
513 /// get the parsed subarchitecture type for this triple.
514 SubArchType getSubArch() const { return SubArch; }
515
516 /// Get the parsed vendor type of this triple.
517 VendorType getVendor() const { return Vendor; }
518
519 /// Get the parsed operating system type of this triple.
520 OSType getOS() const { return OS; }
521
522 /// Does this triple have the optional environment (fourth) component?
523 bool hasEnvironment() const { return getEnvironmentName() != ""; }
524
525 /// Get the parsed environment type of this triple.
526 EnvironmentType getEnvironment() const { return Environment; }
527
528 /// Parse the version number from the OS name component of the
529 /// triple, if present.
530 ///
531 /// For example, "fooos1.2.3" would return (1, 2, 3).
533
534 /// Get the object format for this triple.
535 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
536
537 /// Parse the version number from the OS name component of the triple, if
538 /// present.
539 ///
540 /// For example, "fooos1.2.3" would return (1, 2, 3).
542
543 /// Return just the major version number, this is specialized because it is a
544 /// common query.
545 unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
546
547 /// Parse the version number as with getOSVersion and then translate generic
548 /// "darwin" versions to the corresponding OS X versions. This may also be
549 /// called with IOS triples but the OS X version number is just set to a
550 /// constant 10.4.0 in that case. Returns true if successful.
552
553 /// Parse the version number as with getOSVersion. This should only be called
554 /// with IOS or generic triples.
556
557 /// Parse the version number as with getOSVersion. This should only be called
558 /// with WatchOS or generic triples.
560
561 /// Parse the version number as with getOSVersion.
563
564 /// Parse the Vulkan version number from the OSVersion and SPIR-V version
565 /// (SubArch). This should only be called with Vulkan SPIR-V triples.
567
568 /// Parse the DXIL version number from the OSVersion and DXIL version
569 /// (SubArch). This should only be called with DXIL triples.
571
572 /// @}
573 /// @name Direct Component Access
574 /// @{
575
576 const std::string &str() const { return Data; }
577
578 const std::string &getTriple() const { return Data; }
579
580 /// Whether the triple is empty / default constructed.
581 bool empty() const { return Data.empty(); }
582
583 /// Get the architecture (first) component of the triple.
585
586 /// Get the vendor (second) component of the triple.
588
589 /// Get the operating system (third) component of the triple.
591
592 /// Get the optional environment (fourth) component of the triple, or "" if
593 /// empty.
595
596 /// Get the operating system and optional environment components as a single
597 /// string (separated by a '-' if the environment component is present).
599
600 /// Get the version component of the environment component as a single
601 /// string (the version after the environment).
602 ///
603 /// For example, "fooos1.2.3" would return "1.2.3".
605
606 /// @}
607 /// @name Convenience Predicates
608 /// @{
609
610 /// Returns the pointer width of this architecture.
612
613 /// Returns the pointer width of this architecture.
614 unsigned getArchPointerBitWidth() const {
616 }
617
618 /// Returns the trampoline size in bytes for this configuration.
619 LLVM_ABI unsigned getTrampolineSize() const;
620
621 /// Test whether the architecture is 64-bit
622 ///
623 /// Note that this tests for 64-bit pointer width, and nothing else. Note
624 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
625 /// 16-bit. The inner details of pointer width for particular architectures
626 /// is not summed up in the triple, and so only a coarse grained predicate
627 /// system is provided.
628 LLVM_ABI bool isArch64Bit() const;
629
630 /// Test whether the architecture is 32-bit
631 ///
632 /// Note that this tests for 32-bit pointer width, and nothing else.
633 LLVM_ABI bool isArch32Bit() const;
634
635 /// Test whether the architecture is 16-bit
636 ///
637 /// Note that this tests for 16-bit pointer width, and nothing else.
638 LLVM_ABI bool isArch16Bit() const;
639
640 /// Helper function for doing comparisons against version numbers included in
641 /// the target triple.
642 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
643 unsigned Micro = 0) const {
644 if (Minor == 0) {
645 return getOSVersion() < VersionTuple(Major);
646 }
647 if (Micro == 0) {
648 return getOSVersion() < VersionTuple(Major, Minor);
649 }
650 return getOSVersion() < VersionTuple(Major, Minor, Micro);
651 }
652
653 bool isOSVersionGE(unsigned Major, unsigned Minor = 0,
654 unsigned Micro = 0) const {
655 return !isOSVersionLT(Major, Minor, Micro);
656 }
657
658 bool isOSVersionLT(const Triple &Other) const {
659 return getOSVersion() < Other.getOSVersion();
660 }
661
662 bool isOSVersionGE(const Triple &Other) const {
663 return getOSVersion() >= Other.getOSVersion();
664 }
665
666 /// Comparison function for checking OS X version compatibility, which handles
667 /// supporting skewed version numbering schemes used by the "darwin" triples.
668 LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
669 unsigned Micro = 0) const;
670
671 bool isMacOSXVersionGE(unsigned Major, unsigned Minor = 0,
672 unsigned Micro = 0) const {
673 return !isMacOSXVersionLT(Major, Minor, Micro);
674 }
675
676 /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
677 /// and "osx" as OS X triples.
678 bool isMacOSX() const {
679 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
680 }
681
682 /// Is this an iOS triple.
683 /// Note: This identifies tvOS as a variant of iOS. If that ever
684 /// changes, i.e., if the two operating systems diverge or their version
685 /// numbers get out of sync, that will need to be changed.
686 /// watchOS has completely different version numbers so it is not included.
687 bool isiOS() const { return getOS() == Triple::IOS || isTvOS(); }
688
689 /// Is this an Apple tvOS triple.
690 bool isTvOS() const { return getOS() == Triple::TvOS; }
691
692 /// Is this an Apple watchOS triple.
693 bool isWatchOS() const { return getOS() == Triple::WatchOS; }
694
695 bool isWatchABI() const { return getSubArch() == Triple::ARMSubArch_v7k; }
696
697 /// Is this an Apple XROS triple.
698 bool isXROS() const { return getOS() == Triple::XROS; }
699
700 /// Is this an Apple BridgeOS triple.
701 bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }
702
703 /// Is this an Apple DriverKit triple.
704 bool isDriverKit() const { return getOS() == Triple::DriverKit; }
705
706 bool isOSzOS() const { return getOS() == Triple::ZOS; }
707
708 /// Is this an Apple MachO triple.
709 bool isAppleMachO() const {
710 return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
711 }
712
713 /// Is this an Apple firmware triple.
714 bool isAppleFirmware() const {
715 return (getVendor() == Triple::Apple) && isOSFirmware();
716 }
717
718 /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
719 /// bridgeOS).
720 bool isOSDarwin() const {
721 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
723 // Apple firmware isn't necessarily a Darwin based OS, but for most intents
724 // and purposes it can be treated like a Darwin OS in the compiler.
725 }
726
729 }
730
732 return getEnvironment() == Triple::MacABI;
733 }
734
735 /// Returns true for targets that run on a macOS machine.
736 bool isTargetMachineMac() const {
737 return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
739 }
740
741 bool isOSNetBSD() const { return getOS() == Triple::NetBSD; }
742
743 bool isOSOpenBSD() const { return getOS() == Triple::OpenBSD; }
744
745 bool isOSFreeBSD() const { return getOS() == Triple::FreeBSD; }
746
747 bool isOSFuchsia() const { return getOS() == Triple::Fuchsia; }
748
749 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
750
751 bool isOSSolaris() const { return getOS() == Triple::Solaris; }
752
753 bool isOSIAMCU() const { return getOS() == Triple::ELFIAMCU; }
754
755 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
756
757 bool isGNUEnvironment() const {
759 return Env == Triple::GNU || Env == Triple::GNUT64 ||
760 Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
761 Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
762 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
763 Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
764 Env == Triple::GNUSF || Env == Triple::GNUX32;
765 }
766
767 /// Tests whether the OS is Haiku.
768 bool isOSHaiku() const { return getOS() == Triple::Haiku; }
769
770 /// Tests whether the OS is UEFI.
771 bool isUEFI() const { return getOS() == Triple::UEFI; }
772
773 /// Tests whether the OS is Windows.
774 bool isOSWindows() const { return getOS() == Triple::Win32; }
775
776 /// Tests whether the OS is Windows or UEFI. These targets generally share
777 /// Windows low-level platform ABI conventions, but this does not imply
778 /// support for a hosted Windows environment or its runtime libraries. Use
779 /// object format or environment predicates when those properties matter.
780 bool isOSWindowsOrUEFI() const { return isOSWindows() || isUEFI(); }
781
782 /// Checks if the environment is MSVC.
784 return isOSWindows() && getEnvironment() == Triple::MSVC;
785 }
786
787 /// Checks if the environment could be MSVC.
792
793 // Checks if we're using the Windows Arm64EC ABI.
794 bool isWindowsArm64EC() const {
795 return getArch() == Triple::aarch64 &&
797 }
798
801 }
802
805 }
806
809 }
810
812 return isOSWindows() && getEnvironment() == Triple::GNU;
813 }
814
815 /// Tests for either Cygwin or MinGW OS
816 bool isOSCygMing() const {
818 }
819
820 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
825
826 /// Tests whether the OS is Linux.
827 bool isOSLinux() const { return getOS() == Triple::Linux; }
828
829 /// Tests whether the OS is kFreeBSD.
830 bool isOSKFreeBSD() const { return getOS() == Triple::KFreeBSD; }
831
832 /// Tests whether the OS is Hurd.
833 bool isOSHurd() const { return getOS() == Triple::Hurd; }
834
835 /// Tests whether the OS is WASI.
836 bool isOSWASI() const {
837 return getOS() == Triple::WASI || getOS() == Triple::WASIp1 ||
839 }
840
841 /// Tests whether the OS is Emscripten.
842 bool isOSEmscripten() const { return getOS() == Triple::Emscripten; }
843
844 /// Tests whether the OS uses glibc.
845 bool isOSGlibc() const {
846 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
847 getOS() == Triple::Hurd) &&
849 }
850
851 /// Tests whether the OS is AIX.
852 bool isOSAIX() const { return getOS() == Triple::AIX; }
853
854 bool isOSSerenity() const { return getOS() == Triple::Serenity; }
855
856 /// Tests whether the OS is QURT.
857 bool isOSQurt() const { return getOS() == Triple::QURT; }
858
859 /// Tests whether the OS is H2.
860 bool isOSH2() const { return getOS() == Triple::H2; }
861
862 /// Tests whether the OS uses the ELF binary format.
863 bool isOSBinFormatELF() const { return getObjectFormat() == Triple::ELF; }
864
865 /// Tests whether the OS uses the COFF binary format.
866 bool isOSBinFormatCOFF() const { return getObjectFormat() == Triple::COFF; }
867
868 /// Tests whether the OS uses the GOFF binary format.
869 bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
870
871 /// Tests whether the environment is MachO.
873
874 /// Tests whether the OS uses the Wasm binary format.
875 bool isOSBinFormatWasm() const { return getObjectFormat() == Triple::Wasm; }
876
877 /// Tests whether the OS uses the XCOFF binary format.
879
880 /// Tests whether the OS uses the DXContainer binary format.
883 }
884
885 /// Tests whether the target uses WALI Wasm
886 bool isWALI() const {
887 return getArch() == Triple::wasm32 && isOSLinux() &&
889 }
890
891 /// Tests whether the target is the PS4 platform.
892 bool isPS4() const {
893 return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
894 getOS() == Triple::PS4;
895 }
896
897 /// Tests whether the target is the PS5 platform.
898 bool isPS5() const {
899 return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
900 getOS() == Triple::PS5;
901 }
902
903 /// Tests whether the target is the PS4 or PS5 platform.
904 bool isPS() const { return isPS4() || isPS5(); }
905
906 /// Tests whether the target is Android
907 bool isAndroid() const { return getEnvironment() == Triple::Android; }
908
909 bool isAndroidVersionLT(unsigned Major) const {
910 assert(isAndroid() && "Not an Android triple!");
911
913
914 // 64-bit targets did not exist before API level 21 (Lollipop).
915 if (isArch64Bit() && Version.getMajor() < 21)
916 return VersionTuple(21) < VersionTuple(Major);
917
918 return Version < VersionTuple(Major);
919 }
920
921 /// Tests whether the environment is musl-libc
934
935 /// Tests whether the target is OHOS
936 /// LiteOS default enviroment is also OHOS, but omited on triple.
937 bool isOHOSFamily() const { return isOpenHOS() || isOSLiteOS(); }
938
939 bool isOpenHOS() const { return getEnvironment() == Triple::OpenHOS; }
940
941 bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
942
943 /// Tests whether the target is DXIL.
944 bool isDXIL() const { return getArch() == Triple::dxil; }
945
946 bool isShaderModelOS() const { return getOS() == Triple::ShaderModel; }
947
948 bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
949
950 bool isOSManagarm() const { return getOS() == Triple::Managarm; }
951
952 bool isOSFirmware() const { return getOS() == Triple::Firmware; }
953
956 return Env == Triple::Pixel || Env == Triple::Vertex ||
957 Env == Triple::Geometry || Env == Triple::Hull ||
958 Env == Triple::Domain || Env == Triple::Compute ||
959 Env == Triple::Library || Env == Triple::RayGeneration ||
960 Env == Triple::Intersection || Env == Triple::AnyHit ||
961 Env == Triple::ClosestHit || Env == Triple::Miss ||
962 Env == Triple::Callable || Env == Triple::Mesh ||
964 }
965
966 /// Tests whether the target is SPIR (32- or 64-bit).
967 bool isSPIR() const {
968 return getArch() == Triple::spir || getArch() == Triple::spir64;
969 }
970
971 /// Tests whether the target is SPIR-V (32/64-bit/Logical).
972 bool isSPIRV() const {
973 return getArch() == Triple::spirv32 || getArch() == Triple::spirv64 ||
975 }
976
977 // Tests whether the target is SPIR-V or SPIR.
978 bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
979
980 /// Tests whether the target is SPIR-V Logical
981 bool isSPIRVLogical() const { return getArch() == Triple::spirv; }
982
983 /// Tests whether the target is NVPTX (32- or 64-bit).
984 bool isNVPTX() const {
985 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
986 }
987
988 /// Tests whether the target is AMDGCN
989 bool isAMDGCN() const { return getArch() == Triple::amdgpu; }
990
991 bool isAMDGPU() const { return isAMDGCN() || getArch() == Triple::r600; }
992
993 /// Tests whether the target is Thumb (little and big endian).
994 bool isThumb() const {
995 return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
996 }
997
998 /// Tests whether the target is ARM (little and big endian).
999 bool isARM() const {
1000 return getArch() == Triple::arm || getArch() == Triple::armeb;
1001 }
1002
1003 /// Tests whether the target is LFI.
1004 bool isLFI() const {
1005 return (getArch() == Triple::aarch64 &&
1007 (getArch() == Triple::x86_64 &&
1009 }
1010
1011 /// Tests whether the target supports the EHABI exception
1012 /// handling standard.
1027
1028 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
1029 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
1030 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
1031 // even for GNUEABI, so we can make a distinction here and still conform to
1032 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
1033 // FIXME: The Darwin exception is temporary, while we move users to
1034 // "*-*-*-macho" triples as quickly as possible.
1035 bool isTargetAEABI() const {
1036 return (getEnvironment() == Triple::EABI ||
1038 !isOSDarwin() && !isOSWindows();
1039 }
1040
1048
1049 bool isTargetMuslAEABI() const {
1050 return (getEnvironment() == Triple::MuslEABI ||
1053 !isOSDarwin() && !isOSWindows();
1054 }
1055
1056 /// Tests whether the target is T32.
1057 bool isArmT32() const {
1058 switch (getSubArch()) {
1070 return false;
1071 default:
1072 return true;
1073 }
1074 }
1075
1076 /// Tests whether the target is an M-class.
1077 bool isArmMClass() const {
1078 switch (getSubArch()) {
1085 return true;
1086 default:
1087 return false;
1088 }
1089 }
1090
1091 /// Tests whether the target is AArch64 (little and big endian).
1092 bool isAArch64() const {
1093 return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
1095 }
1096
1097 /// Tests whether the target is AArch64 and pointers are the size specified by
1098 /// \p PointerWidth.
1099 bool isAArch64(int PointerWidth) const {
1100 assert(PointerWidth == 64 || PointerWidth == 32);
1101 if (!isAArch64())
1102 return false;
1103 return getArch() == Triple::aarch64_32 ||
1105 ? PointerWidth == 32
1106 : PointerWidth == 64;
1107 }
1108
1109 bool isAVR() const { return getArch() == Triple::avr; }
1110
1111 /// Tests whether the target is 32-bit LoongArch.
1112 bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
1113
1114 /// Tests whether the target is 64-bit LoongArch.
1115 bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
1116
1117 /// Tests whether the target is LoongArch (32- and 64-bit).
1118 bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
1119
1120 /// Tests whether the target is MIPS 32-bit (little and big endian).
1121 bool isMIPS32() const {
1122 return getArch() == Triple::mips || getArch() == Triple::mipsel;
1123 }
1124
1125 /// Tests whether the target is MIPS 64-bit (little and big endian).
1126 bool isMIPS64() const {
1127 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
1128 }
1129
1130 /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
1131 bool isMIPS() const { return isMIPS32() || isMIPS64(); }
1132
1133 /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
1134 bool isPPC() const {
1135 return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
1137 }
1138
1139 /// Tests whether the target is 32-bit PowerPC (little and big endian).
1140 bool isPPC32() const {
1141 return getArch() == Triple::ppc || getArch() == Triple::ppcle;
1142 }
1143
1144 /// Tests whether the target is 64-bit PowerPC (little and big endian).
1145 bool isPPC64() const {
1146 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
1147 }
1148
1149 /// Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
1150 bool isPPC64ELFv2ABI() const {
1151 return (getArch() == Triple::ppc64 &&
1152 ((getOS() == Triple::FreeBSD &&
1153 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1154 getOS() == Triple::OpenBSD || isMusl()));
1155 }
1156
1157 /// Tests whether the target 32-bit PowerPC uses Secure PLT.
1158 bool isPPC32SecurePlt() const {
1159 return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
1160 ((getOS() == Triple::FreeBSD &&
1161 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1163 isMusl()));
1164 }
1165
1166 /// Tests whether the target is 32-bit RISC-V.
1167 bool isRISCV32() const {
1169 }
1170
1171 /// Tests whether the target is 64-bit RISC-V.
1172 bool isRISCV64() const {
1174 }
1175
1176 /// Tests whether the target is RISC-V (32- and 64-bit).
1177 bool isRISCV() const { return isRISCV32() || isRISCV64(); }
1178
1179 /// Tests whether the target is 32-bit SPARC (little and big endian).
1180 bool isSPARC32() const {
1181 return getArch() == Triple::sparc || getArch() == Triple::sparcel;
1182 }
1183
1184 /// Tests whether the target is 64-bit SPARC (big endian).
1185 bool isSPARC64() const { return getArch() == Triple::sparcv9; }
1186
1187 /// Tests whether the target is SPARC.
1188 bool isSPARC() const { return isSPARC32() || isSPARC64(); }
1189
1190 /// Tests whether the target is SystemZ.
1191 bool isSystemZ() const { return getArch() == Triple::systemz; }
1192
1193 /// Tests whether the target is x86 (32- or 64-bit).
1194 bool isX86() const {
1195 return getArch() == Triple::x86 || getArch() == Triple::x86_64;
1196 }
1197
1198 /// Tests whether the target is x86 (32-bit).
1199 bool isX86_32() const { return getArch() == Triple::x86; }
1200
1201 /// Tests whether the target is x86 (64-bit).
1202 bool isX86_64() const { return getArch() == Triple::x86_64; }
1203
1204 /// Tests whether the target is VE
1205 bool isVE() const { return getArch() == Triple::ve; }
1206
1207 /// Tests whether the target is wasm (32- and 64-bit).
1208 bool isWasm() const {
1209 return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
1210 }
1211
1212 // Tests whether the target is CSKY
1213 bool isCSKY() const { return getArch() == Triple::csky; }
1214
1215 /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
1216 bool isArm64e() const {
1217 return getArch() == Triple::aarch64 &&
1219 }
1220
1221 // Tests whether the target is N32.
1222 bool isABIN32() const {
1224 return Env == Triple::GNUABIN32 || Env == Triple::MuslABIN32;
1225 }
1226
1227 /// Tests whether the target is X32.
1228 bool isX32() const {
1230 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
1231 }
1232
1233 /// Tests whether the target is eBPF.
1234 bool isBPF() const {
1235 return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
1236 }
1237
1238 /// Tests whether MSVC linker or UEFI targets.
1239 /// Used to default to -mincremental-linker-compatible if we are
1240 /// targeting the MSVC linker or *-uefi triples.
1244
1245 /// Tests if the target forces 64-bit time_t on a 32-bit architecture.
1246 bool isTime64ABI() const {
1248 return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1249 Env == Triple::GNUEABIHFT64;
1250 }
1251
1252 /// Tests if the target forces hardfloat.
1253 bool isHardFloatABI() const {
1255 return Env == llvm::Triple::GNUEABIHF ||
1258 }
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:47
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:1134
bool isOSDragonFly() const
Definition Triple.h:749
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:736
bool isArmT32() const
Tests whether the target is T32.
Definition Triple.h:1057
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1737
bool isAndroidVersionLT(unsigned Major) const
Definition Triple.h:909
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:816
bool isWatchABI() const
Definition Triple.h:695
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:401
@ LastEnvironmentType
Definition Triple.h:415
@ UnknownEnvironment
Definition Triple.h:353
@ RootSignature
Definition Triple.h:409
@ Amplification
Definition Triple.h:408
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:994
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition Triple.h:892
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1202
bool isPPC64ELFv2ABI() const
Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
Definition Triple.h:1150
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:836
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition Triple.h:967
CanonicalForm
Canonical form.
Definition Triple.h:486
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition Triple.h:875
bool isOSQurt() const
Tests whether the OS is QURT.
Definition Triple.h:857
LLVM_ABI bool operator<(const Triple &Other) const
Definition Triple.cpp:32
bool isDriverKit() const
Is this an Apple DriverKit triple.
Definition Triple.h:704
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:614
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:833
bool isHardFloatABI() const
Tests if the target forces hardfloat.
Definition Triple.h:1253
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1234
bool isX32() const
Tests whether the target is X32.
Definition Triple.h:1228
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:461
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:535
bool isAArch64(int PointerWidth) const
Tests whether the target is AArch64 and pointers are the size specified by PointerWidth.
Definition Triple.h:1099
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:514
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1194
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1216
std::string normalize(CanonicalForm Form=CanonicalForm::ANY) const
Return the normalized form of this triple's string.
Definition Triple.h:502
bool isTargetEHABICompatible() const
Tests whether the target supports the EHABI exception handling standard.
Definition Triple.h:1013
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:869
bool isWindowsGNUEnvironment() const
Definition Triple.h:811
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:741
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:907
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:1004
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:821
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition Triple.h:872
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:1222
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1468
bool isAVR() const
Definition Triple.h:1109
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition Triple.h:1261
bool isWindowsCoreCLREnvironment() const
Definition Triple.h:799
bool isSPIROrSPIRV() const
Definition Triple.h:978
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:1126
@ loongarch32
Definition Triple.h:64
@ renderscript64
Definition Triple.h:115
@ UnknownArch
Definition Triple.h:50
@ loongarch64
Definition Triple.h:65
@ renderscript32
Definition Triple.h:114
bool hasDefaultDataSections() const
Tests whether the target uses -data-sections as default.
Definition Triple.h:1280
bool isTargetGNUAEABI() const
Definition Triple.h:1041
bool isOSSolaris() const
Definition Triple.h:751
bool isOSH2() const
Tests whether the OS is H2.
Definition Triple.h:860
bool isRISCV32() const
Tests whether the target is 32-bit RISC-V.
Definition Triple.h:1167
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition Triple.h:830
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:520
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:658
bool isPPC32() const
Tests whether the target is 32-bit PowerPC (little and big endian).
Definition Triple.h:1140
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:511
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:866
bool isRISCV64() const
Tests whether the target is 64-bit RISC-V.
Definition Triple.h:1172
bool isCSKY() const
Definition Triple.h:1213
bool isLoongArch64() const
Tests whether the target is 64-bit LoongArch.
Definition Triple.h:1115
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:1180
bool isSimulatorEnvironment() const
Definition Triple.h:727
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:576
bool isOSzOS() const
Definition Triple.h:706
bool isOSSerenity() const
Definition Triple.h:854
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:937
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:526
bool isOSOpenBSD() const
Definition Triple.h:743
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:755
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:1121
bool isShaderModelOS() const
Definition Triple.h:946
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:771
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:774
bool isOSFirmware() const
Definition Triple.h:952
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:922
const std::string & getTriple() const
Definition Triple.h:578
bool isOSWindowsOrUEFI() const
Tests whether the OS is Windows or UEFI.
Definition Triple.h:780
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:662
bool isOSBinFormatDXContainer() const
Tests whether the OS uses the DXContainer binary format.
Definition Triple.h:881
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:878
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:1049
@ UnknownObjectFormat
Definition Triple.h:418
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:999
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:1077
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:827
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:701
bool isOSManagarm() const
Definition Triple.h:950
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1177
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition Triple.h:989
bool isAMDGPU() const
Definition Triple.h:991
bool isLoongArch32() const
Tests whether the target is 32-bit LoongArch.
Definition Triple.h:1112
bool isOSLiteOS() const
Definition Triple.h:941
@ UnknownVendor
Definition Triple.h:279
@ ImaginationTechnologies
Definition Triple.h:286
@ LastVendorType
Definition Triple.h:296
@ MipsTechnologies
Definition Triple.h:287
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:984
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:852
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:153
@ AMDGPUSubArch600
Definition Triple.h:196
@ MipsSubArch_r6
Definition Triple.h:168
@ X86_64SubArch_lfi
Definition Triple.h:162
@ DXILSubArch_v1_2
Definition Triple.h:184
@ ARMSubArch_v7
Definition Triple.h:144
@ ARMSubArch_v8m_mainline
Definition Triple.h:142
@ AMDGPUSubArch1153
Definition Triple.h:257
@ ARMSubArch_v9_6a
Definition Triple.h:123
@ AMDGPUSubArch1012
Definition Triple.h:237
@ ARMSubArch_v8r
Definition Triple.h:140
@ AMDGPUSubArch1150
Definition Triple.h:254
@ ARMSubArch_v9_1a
Definition Triple.h:128
@ DXILSubArch_v1_1
Definition Triple.h:183
@ AMDGPUSubArch703
Definition Triple.h:204
@ AMDGPUSubArch1201
Definition Triple.h:267
@ LatestDXILSubArch
Definition Triple.h:192
@ FirstAMDGPUSubArch
Definition Triple.h:275
@ SPIRVSubArch_v10
Definition Triple.h:173
@ AMDGPUSubArch9
Definition Triple.h:217
@ SPIRVSubArch_v13
Definition Triple.h:176
@ AMDGPUSubArch1172
Definition Triple.h:263
@ AMDGPUSubArch1035
Definition Triple.h:246
@ ARMSubArch_v7k
Definition Triple.h:148
@ AMDGPUSubArch9_4
Definition Triple.h:230
@ AMDGPUSubArch6
Definition Triple.h:195
@ AMDGPUSubArch1033
Definition Triple.h:244
@ AMDGPUSubArch1103
Definition Triple.h:253
@ ARMSubArch_v8_7a
Definition Triple.h:132
@ AMDGPUSubArch1034
Definition Triple.h:245
@ AMDGPUSubArch1154
Definition Triple.h:258
@ ARMSubArch_v8
Definition Triple.h:139
@ SPIRVSubArch_v16
Definition Triple.h:179
@ ARMSubArch_v8_1a
Definition Triple.h:138
@ ARMSubArch_v9_2a
Definition Triple.h:127
@ AMDGPUSubArch1200
Definition Triple.h:266
@ AMDGPUSubArch10_3
Definition Triple.h:240
@ DXILSubArch_v1_3
Definition Triple.h:185
@ SPIRVSubArch_v15
Definition Triple.h:178
@ ARMSubArch_v7m
Definition Triple.h:146
@ AMDGPUSubArch1102
Definition Triple.h:252
@ ARMSubArch_v9_7a
Definition Triple.h:122
@ AMDGPUSubArch1013
Definition Triple.h:238
@ AMDGPUSubArch902
Definition Triple.h:219
@ ARMSubArch_v6k
Definition Triple.h:152
@ AMDGPUSubArch1010
Definition Triple.h:235
@ AMDGPUSubArch90A
Definition Triple.h:228
@ ARMSubArch_v5
Definition Triple.h:154
@ AMDGPUSubArch1170
Definition Triple.h:261
@ AArch64SubArch_arm64e
Definition Triple.h:158
@ AMDGPUSubArch810
Definition Triple.h:215
@ ARMSubArch_v6
Definition Triple.h:150
@ AMDGPUSubArch11
Definition Triple.h:249
@ AMDGPUSubArch1151
Definition Triple.h:255
@ ARMSubArch_v9_5a
Definition Triple.h:124
@ AMDGPUSubArch602
Definition Triple.h:198
@ ARMSubArch_v7ve
Definition Triple.h:149
@ ARMSubArch_v8m_baseline
Definition Triple.h:141
@ ARMSubArch_v8_8a
Definition Triple.h:131
@ AMDGPUSubArch942
Definition Triple.h:231
@ AMDGPUSubArch7
Definition Triple.h:200
@ AMDGPUSubArch702
Definition Triple.h:203
@ AMDGPUSubArch950
Definition Triple.h:232
@ ARMSubArch_v8_2a
Definition Triple.h:137
@ LastAMDGPUSubArch
Definition Triple.h:276
@ ARMSubArch_v7s
Definition Triple.h:147
@ AMDGPUSubArch1251
Definition Triple.h:271
@ AMDGPUSubArch805
Definition Triple.h:212
@ DXILSubArch_v1_0
Definition Triple.h:182
@ DXILSubArch_v1_7
Definition Triple.h:189
@ AMDGPUSubArch12_5
Definition Triple.h:269
@ KalimbaSubArch_v3
Definition Triple.h:164
@ DXILSubArch_v1_5
Definition Triple.h:187
@ AMDGPUSubArch1250
Definition Triple.h:270
@ AMDGPUSubArch1030
Definition Triple.h:241
@ ARMSubArch_v8_4a
Definition Triple.h:135
@ AMDGPUSubArch803
Definition Triple.h:211
@ AMDGPUSubArch601
Definition Triple.h:197
@ ARMSubArch_v8_9a
Definition Triple.h:130
@ AMDGPUSubArch10_1
Definition Triple.h:234
@ AMDGPUSubArch904
Definition Triple.h:220
@ AMDGPUSubArch11_7
Definition Triple.h:260
@ AMDGPUSubArch705
Definition Triple.h:206
@ AMDGPUSubArch802
Definition Triple.h:210
@ AMDGPUSubArch8
Definition Triple.h:208
@ ARMSubArch_v7em
Definition Triple.h:145
@ SPIRVSubArch_v12
Definition Triple.h:175
@ AMDGPUSubArch90C
Definition Triple.h:223
@ SPIRVSubArch_v14
Definition Triple.h:177
@ AMDGPUSubArch1100
Definition Triple.h:250
@ KalimbaSubArch_v4
Definition Triple.h:165
@ AMDGPUSubArch909
Definition Triple.h:222
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:143
@ AMDGPUSubArch1036
Definition Triple.h:247
@ ARMSubArch_v8_3a
Definition Triple.h:136
@ AArch64SubArch_arm64ec
Definition Triple.h:159
@ ARMSubArch_v8_6a
Definition Triple.h:133
@ ARMSubArch_v5te
Definition Triple.h:155
@ KalimbaSubArch_v5
Definition Triple.h:166
@ AMDGPUSubArch701
Definition Triple.h:202
@ ARMSubArch_v4t
Definition Triple.h:156
@ AMDGPUSubArch1171
Definition Triple.h:262
@ DXILSubArch_v1_6
Definition Triple.h:188
@ AMDGPUSubArch1011
Definition Triple.h:236
@ AMDGPUSubArch906
Definition Triple.h:221
@ AMDGPUSubArch900
Definition Triple.h:218
@ AMDGPUSubArch1152
Definition Triple.h:256
@ DXILSubArch_v1_8
Definition Triple.h:190
@ AMDGPUSubArch801
Definition Triple.h:209
@ ARMSubArch_v9_4a
Definition Triple.h:125
@ ARMSubArch_v8_5a
Definition Triple.h:134
@ AArch64SubArch_lfi
Definition Triple.h:160
@ ARMSubArch_v6m
Definition Triple.h:151
@ ARMSubArch_v9_3a
Definition Triple.h:126
@ DXILSubArch_v1_9
Definition Triple.h:191
@ AMDGPUSubArch704
Definition Triple.h:205
@ AMDGPUSubArch1031
Definition Triple.h:242
@ AMDGPUSubArch1101
Definition Triple.h:251
@ ARMSubArch_v9
Definition Triple.h:129
@ AMDGPUSubArch13
Definition Triple.h:273
@ AMDGPUSubArch12
Definition Triple.h:265
@ DXILSubArch_v1_4
Definition Triple.h:186
@ AMDGPUSubArch700
Definition Triple.h:201
@ SPIRVSubArch_v11
Definition Triple.h:174
@ PPCSubArch_spe
Definition Triple.h:170
@ AMDGPUSubArch1032
Definition Triple.h:243
@ AMDGPUSubArch1310
Definition Triple.h:274
@ AMDGPUSubArch908
Definition Triple.h:227
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:1185
bool isWindowsCygwinEnvironment() const
Definition Triple.h:807
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:460
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:678
Triple(const std::string &Str)
Definition Triple.h:462
bool isOSFreeBSD() const
Definition Triple.h:745
bool isXROS() const
Is this an Apple XROS triple.
Definition Triple.h:698
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:1199
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:714
bool isDefaultIncrementalLinkerCompatibleByDefault() const
Tests whether MSVC linker or UEFI targets.
Definition Triple.h:1241
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:517
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1188
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition Triple.h:1145
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:720
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:981
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:642
bool isTvOS() const
Is this an Apple tvOS triple.
Definition Triple.h:690
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition Triple.h:842
bool isWindowsArm64EC() const
Definition Triple.h:794
bool isOSVersionGE(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Definition Triple.h:653
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition Triple.h:693
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:581
bool isiOS() const
Is this an iOS triple.
Definition Triple.h:687
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1131
bool isMacOSXVersionGE(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Definition Triple.h:671
bool isWALI() const
Tests whether the target uses WALI Wasm.
Definition Triple.h:886
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition Triple.h:845
bool isTargetAEABI() const
Definition Triple.h:1035
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:904
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1208
bool isVulkanOS() const
Definition Triple.h:948
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1459
bool isOSIAMCU() const
Definition Triple.h:753
bool isOpenHOS() const
Definition Triple.h:939
bool isMacCatalystEnvironment() const
Definition Triple.h:731
bool isPS5() const
Tests whether the target is the PS5 platform.
Definition Triple.h:898
bool isSPIRV() const
Tests whether the target is SPIR-V (32/64-bit/Logical).
Definition Triple.h:972
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1092
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:709
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:1191
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:1158
bool isTime64ABI() const
Tests if the target forces 64-bit time_t on a 32-bit architecture.
Definition Triple.h:1246
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:477
unsigned getOSMajorVersion() const
Return just the major version number, this is specialized because it is a common query.
Definition Triple.h:545
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2312
bool isOSFuchsia() const
Definition Triple.h:747
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:863
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:788
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:523
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:783
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:768
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:944
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:757
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1118
bool isShaderStageEnvironment() const
Definition Triple.h:954
bool isWindowsItaniumEnvironment() const
Definition Triple.h:803
bool isVE() const
Tests whether the target is VE.
Definition Triple.h:1205
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:860