LLVM 22.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 amdgcn, // AMDGCN: 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 tce, // TCE (http://tce.cs.tut.fi/): tce
87 tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
88 thumb, // Thumb (little endian): thumb, thumbv.*
89 thumbeb, // Thumb (big endian): thumbeb
90 x86, // X86: i[3-9]86
91 x86_64, // X86-64: amd64, x86_64
92 xcore, // XCore: xcore
93 xtensa, // Tensilica: Xtensa
94 nvptx, // NVPTX: 32-bit
95 nvptx64, // NVPTX: 64-bit
96 amdil, // AMDIL
97 amdil64, // AMDIL with 64-bit pointers
98 hsail, // AMD HSAIL
99 hsail64, // AMD HSAIL with 64-bit pointers
100 spir, // SPIR: standard portable IR for OpenCL 32-bit version
101 spir64, // SPIR: standard portable IR for OpenCL 64-bit version
102 spirv, // SPIR-V with logical memory layout.
103 spirv32, // SPIR-V with 32-bit pointers
104 spirv64, // SPIR-V with 64-bit pointers
105 kalimba, // Kalimba: generic kalimba
106 shave, // SHAVE: Movidius vector VLIW processors
107 lanai, // Lanai: Lanai 32-bit
108 wasm32, // WebAssembly with 32-bit pointers
109 wasm64, // WebAssembly with 64-bit pointers
110 renderscript32, // 32-bit RenderScript
111 renderscript64, // 64-bit RenderScript
112 ve, // NEC SX-Aurora Vector Engine
114 };
117
152
155
159
161
163
164 // SPIR-V sub-arch corresponds to its version.
172
173 // DXIL sub-arch corresponds to its version.
184 };
187
204 };
205 enum OSType {
207
215 Lv2, // PS3
227 CUDA, // NVIDIA CUDA
228 NVCL, // NVIDIA OpenCL
229 AMDHSA, // AMD HSA Runtime
233 TvOS, // Apple tvOS
234 WatchOS, // Apple watchOS
235 BridgeOS, // Apple bridgeOS
236 DriverKit, // Apple DriverKit
237 XROS, // Apple XROS
239 AMDPAL, // AMD PAL Runtime
240 HermitCore, // HermitCore Unikernel/Multikernel
241 Hurd, // GNU/Hurd
242 WASI, // Experimental WebAssembly OS
244 ShaderModel, // DirectX ShaderModel
247 Vulkan, // Vulkan SPIR-V
250 };
253
280
285 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
286 MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
287
288 // Shader Stages
289 // The order of these values matters, and must be kept in sync with the
290 // language options enum in Clang. The ordering is enforced in
291 // static_asserts in Triple.cpp and in Clang.
310
314 };
317
326 };
327
328private:
329 std::string Data;
330
331 /// The parsed arch type.
332 ArchType Arch{};
333
334 /// The parsed subarchitecture type.
335 SubArchType SubArch{};
336
337 /// The parsed vendor type.
338 VendorType Vendor{};
339
340 /// The parsed OS type.
341 OSType OS{};
342
343 /// The parsed Environment type.
344 EnvironmentType Environment{};
345
346 /// The object format type.
347 ObjectFormatType ObjectFormat{};
348
349public:
350 /// @name Constructors
351 /// @{
352
353 /// Default constructor is the same as an empty string and leaves all
354 /// triple fields unknown.
355 Triple() = default;
356
357 LLVM_ABI explicit Triple(std::string &&Str);
358 explicit Triple(StringRef Str) : Triple(Str.str()) {}
359 explicit Triple(const char *Str) : Triple(std::string(Str)) {}
360 explicit Triple(const std::string &Str) : Triple(std::string(Str)) {}
361 LLVM_ABI explicit Triple(const Twine &Str);
362
363 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
364 const Twine &OSStr);
365 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
366 const Twine &OSStr, const Twine &EnvironmentStr);
367
368 bool operator==(const Triple &Other) const {
369 return Arch == Other.Arch && SubArch == Other.SubArch &&
370 Vendor == Other.Vendor && OS == Other.OS &&
371 Environment == Other.Environment &&
372 ObjectFormat == Other.ObjectFormat;
373 }
374
375 bool operator!=(const Triple &Other) const {
376 return !(*this == Other);
377 }
378
379 /// @}
380 /// @name Normalization
381 /// @{
382
383 /// Canonical form
384 enum class CanonicalForm {
385 ANY = 0,
386 THREE_IDENT = 3, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM
387 FOUR_IDENT = 4, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
388 FIVE_IDENT = 5, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT-FORMAT
389 };
390
391 /// Turn an arbitrary machine specification into the canonical triple form (or
392 /// something sensible that the Triple class understands if nothing better can
393 /// reasonably be done). In particular, it handles the common case in which
394 /// otherwise valid components are in the wrong order. \p Form is used to
395 /// specify the output canonical form.
396 LLVM_ABI static std::string
398
399 /// Return the normalized form of this triple's string.
400 std::string normalize(CanonicalForm Form = CanonicalForm::ANY) const {
401 return normalize(Data, Form);
402 }
403
404 /// @}
405 /// @name Typed Component Access
406 /// @{
407
408 /// Get the parsed architecture type of this triple.
409 ArchType getArch() const { return Arch; }
410
411 /// get the parsed subarchitecture type for this triple.
412 SubArchType getSubArch() const { return SubArch; }
413
414 /// Get the parsed vendor type of this triple.
415 VendorType getVendor() const { return Vendor; }
416
417 /// Get the parsed operating system type of this triple.
418 OSType getOS() const { return OS; }
419
420 /// Does this triple have the optional environment (fourth) component?
421 bool hasEnvironment() const {
422 return getEnvironmentName() != "";
423 }
424
425 /// Get the parsed environment type of this triple.
426 EnvironmentType getEnvironment() const { return Environment; }
427
428 /// Parse the version number from the OS name component of the
429 /// triple, if present.
430 ///
431 /// For example, "fooos1.2.3" would return (1, 2, 3).
433
434 /// Get the object format for this triple.
435 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
436
437 /// Parse the version number from the OS name component of the triple, if
438 /// present.
439 ///
440 /// For example, "fooos1.2.3" would return (1, 2, 3).
442
443 /// Return just the major version number, this is specialized because it is a
444 /// common query.
445 unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
446
447 /// Parse the version number as with getOSVersion and then translate generic
448 /// "darwin" versions to the corresponding OS X versions. This may also be
449 /// called with IOS triples but the OS X version number is just set to a
450 /// constant 10.4.0 in that case. Returns true if successful.
452
453 /// Parse the version number as with getOSVersion. This should only be called
454 /// with IOS or generic triples.
456
457 /// Parse the version number as with getOSVersion. This should only be called
458 /// with WatchOS or generic triples.
460
461 /// Parse the version number as with getOSVersion.
463
464 /// Parse the Vulkan version number from the OSVersion and SPIR-V version
465 /// (SubArch). This should only be called with Vulkan SPIR-V triples.
467
468 /// Parse the DXIL version number from the OSVersion and DXIL version
469 /// (SubArch). This should only be called with DXIL triples.
471
472 /// @}
473 /// @name Direct Component Access
474 /// @{
475
476 const std::string &str() const { return Data; }
477
478 const std::string &getTriple() const { return Data; }
479
480 /// Whether the triple is empty / default constructed.
481 bool empty() const { return Data.empty(); }
482
483 /// Get the architecture (first) component of the triple.
485
486 /// Get the vendor (second) component of the triple.
488
489 /// Get the operating system (third) component of the triple.
491
492 /// Get the optional environment (fourth) component of the triple, or "" if
493 /// empty.
495
496 /// Get the operating system and optional environment components as a single
497 /// string (separated by a '-' if the environment component is present).
499
500 /// Get the version component of the environment component as a single
501 /// string (the version after the environment).
502 ///
503 /// For example, "fooos1.2.3" would return "1.2.3".
505
506 /// @}
507 /// @name Convenience Predicates
508 /// @{
509
510 /// Returns the pointer width of this architecture.
512
513 /// Returns the pointer width of this architecture.
514 unsigned getArchPointerBitWidth() const {
516 }
517
518 /// Returns the trampoline size in bytes for this configuration.
519 LLVM_ABI unsigned getTrampolineSize() const;
520
521 /// Test whether the architecture is 64-bit
522 ///
523 /// Note that this tests for 64-bit pointer width, and nothing else. Note
524 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
525 /// 16-bit. The inner details of pointer width for particular architectures
526 /// is not summed up in the triple, and so only a coarse grained predicate
527 /// system is provided.
528 LLVM_ABI bool isArch64Bit() const;
529
530 /// Test whether the architecture is 32-bit
531 ///
532 /// Note that this tests for 32-bit pointer width, and nothing else.
533 LLVM_ABI bool isArch32Bit() const;
534
535 /// Test whether the architecture is 16-bit
536 ///
537 /// Note that this tests for 16-bit pointer width, and nothing else.
538 LLVM_ABI bool isArch16Bit() const;
539
540 /// Helper function for doing comparisons against version numbers included in
541 /// the target triple.
542 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
543 unsigned Micro = 0) const {
544 if (Minor == 0) {
545 return getOSVersion() < VersionTuple(Major);
546 }
547 if (Micro == 0) {
548 return getOSVersion() < VersionTuple(Major, Minor);
549 }
550 return getOSVersion() < VersionTuple(Major, Minor, Micro);
551 }
552
553 bool isOSVersionLT(const Triple &Other) const {
554 return getOSVersion() < Other.getOSVersion();
555 }
556
557 /// Comparison function for checking OS X version compatibility, which handles
558 /// supporting skewed version numbering schemes used by the "darwin" triples.
559 LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
560 unsigned Micro = 0) const;
561
562 /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
563 /// and "osx" as OS X triples.
564 bool isMacOSX() const {
565 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
566 }
567
568 /// Is this an iOS triple.
569 /// Note: This identifies tvOS as a variant of iOS. If that ever
570 /// changes, i.e., if the two operating systems diverge or their version
571 /// numbers get out of sync, that will need to be changed.
572 /// watchOS has completely different version numbers so it is not included.
573 bool isiOS() const {
574 return getOS() == Triple::IOS || isTvOS();
575 }
576
577 /// Is this an Apple tvOS triple.
578 bool isTvOS() const {
579 return getOS() == Triple::TvOS;
580 }
581
582 /// Is this an Apple watchOS triple.
583 bool isWatchOS() const {
584 return getOS() == Triple::WatchOS;
585 }
586
587 bool isWatchABI() const {
589 }
590
591 /// Is this an Apple XROS triple.
592 bool isXROS() const { return getOS() == Triple::XROS; }
593
594 /// Is this an Apple BridgeOS triple.
595 bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }
596
597 /// Is this an Apple DriverKit triple.
598 bool isDriverKit() const { return getOS() == Triple::DriverKit; }
599
600 bool isOSzOS() const { return getOS() == Triple::ZOS; }
601
602 /// Is this an Apple MachO triple.
603 bool isAppleMachO() const {
604 return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
605 }
606
607 /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
608 /// bridgeOS).
609 bool isOSDarwin() const {
610 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
611 isBridgeOS();
612 }
613
616 }
617
619 return getEnvironment() == Triple::MacABI;
620 }
621
622 /// Returns true for targets that run on a macOS machine.
623 bool isTargetMachineMac() const {
624 return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
626 }
627
628 bool isOSNetBSD() const {
629 return getOS() == Triple::NetBSD;
630 }
631
632 bool isOSOpenBSD() const {
633 return getOS() == Triple::OpenBSD;
634 }
635
636 bool isOSFreeBSD() const {
637 return getOS() == Triple::FreeBSD;
638 }
639
640 bool isOSFuchsia() const {
641 return getOS() == Triple::Fuchsia;
642 }
643
644 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
645
646 bool isOSSolaris() const {
647 return getOS() == Triple::Solaris;
648 }
649
650 bool isOSIAMCU() const {
651 return getOS() == Triple::ELFIAMCU;
652 }
653
654 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
655
656 bool isGNUEnvironment() const {
658 return Env == Triple::GNU || Env == Triple::GNUT64 ||
659 Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
660 Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
661 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
662 Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
663 Env == Triple::GNUSF || Env == Triple::GNUX32;
664 }
665
666 /// Tests whether the OS is Haiku.
667 bool isOSHaiku() const {
668 return getOS() == Triple::Haiku;
669 }
670
671 /// Tests whether the OS is UEFI.
672 bool isUEFI() const {
673 return getOS() == Triple::UEFI;
674 }
675
676 /// Tests whether the OS is Windows.
677 bool isOSWindows() const {
678 return getOS() == Triple::Win32;
679 }
680
681 /// Checks if the environment is MSVC.
683 return isOSWindows() && getEnvironment() == Triple::MSVC;
684 }
685
686 /// Checks if the environment could be MSVC.
690 }
691
692 // Checks if we're using the Windows Arm64EC ABI.
693 bool isWindowsArm64EC() const {
694 return getArch() == Triple::aarch64 &&
696 }
697
700 }
701
704 }
705
708 }
709
711 return isOSWindows() && getEnvironment() == Triple::GNU;
712 }
713
714 /// Tests for either Cygwin or MinGW OS
715 bool isOSCygMing() const {
717 }
718
719 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
720 bool isOSMSVCRT() const {
723 }
724
725 /// Tests whether the OS is Linux.
726 bool isOSLinux() const {
727 return getOS() == Triple::Linux;
728 }
729
730 /// Tests whether the OS is kFreeBSD.
731 bool isOSKFreeBSD() const {
732 return getOS() == Triple::KFreeBSD;
733 }
734
735 /// Tests whether the OS is Hurd.
736 bool isOSHurd() const {
737 return getOS() == Triple::Hurd;
738 }
739
740 /// Tests whether the OS is WASI.
741 bool isOSWASI() const {
742 return getOS() == Triple::WASI;
743 }
744
745 /// Tests whether the OS is Emscripten.
746 bool isOSEmscripten() const {
747 return getOS() == Triple::Emscripten;
748 }
749
750 /// Tests whether the OS uses glibc.
751 bool isOSGlibc() const {
752 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
753 getOS() == Triple::Hurd) &&
754 !isAndroid();
755 }
756
757 /// Tests whether the OS is AIX.
758 bool isOSAIX() const {
759 return getOS() == Triple::AIX;
760 }
761
762 bool isOSSerenity() const {
763 return getOS() == Triple::Serenity;
764 }
765
766 /// Tests whether the OS uses the ELF binary format.
767 bool isOSBinFormatELF() const {
768 return getObjectFormat() == Triple::ELF;
769 }
770
771 /// Tests whether the OS uses the COFF binary format.
772 bool isOSBinFormatCOFF() const {
773 return getObjectFormat() == Triple::COFF;
774 }
775
776 /// Tests whether the OS uses the GOFF binary format.
777 bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
778
779 /// Tests whether the environment is MachO.
780 bool isOSBinFormatMachO() const {
781 return getObjectFormat() == Triple::MachO;
782 }
783
784 /// Tests whether the OS uses the Wasm binary format.
785 bool isOSBinFormatWasm() const {
786 return getObjectFormat() == Triple::Wasm;
787 }
788
789 /// Tests whether the OS uses the XCOFF binary format.
790 bool isOSBinFormatXCOFF() const {
791 return getObjectFormat() == Triple::XCOFF;
792 }
793
794 /// Tests whether the OS uses the DXContainer binary format.
797 }
798
799 /// Tests whether the target is the PS4 platform.
800 bool isPS4() const {
801 return getArch() == Triple::x86_64 &&
802 getVendor() == Triple::SCEI &&
803 getOS() == Triple::PS4;
804 }
805
806 /// Tests whether the target is the PS5 platform.
807 bool isPS5() const {
808 return getArch() == Triple::x86_64 &&
809 getVendor() == Triple::SCEI &&
810 getOS() == Triple::PS5;
811 }
812
813 /// Tests whether the target is the PS4 or PS5 platform.
814 bool isPS() const { return isPS4() || isPS5(); }
815
816 /// Tests whether the target is Android
817 bool isAndroid() const { return getEnvironment() == Triple::Android; }
818
819 bool isAndroidVersionLT(unsigned Major) const {
820 assert(isAndroid() && "Not an Android triple!");
821
823
824 // 64-bit targets did not exist before API level 21 (Lollipop).
825 if (isArch64Bit() && Version.getMajor() < 21)
826 return VersionTuple(21) < VersionTuple(Major);
827
828 return Version < VersionTuple(Major);
829 }
830
831 /// Tests whether the environment is musl-libc
832 bool isMusl() const {
833 return getEnvironment() == Triple::Musl ||
842 }
843
844 /// Tests whether the target is OHOS
845 /// LiteOS default enviroment is also OHOS, but omited on triple.
846 bool isOHOSFamily() const { return isOpenHOS() || isOSLiteOS(); }
847
848 bool isOpenHOS() const { return getEnvironment() == Triple::OpenHOS; }
849
850 bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
851
852 /// Tests whether the target is DXIL.
853 bool isDXIL() const {
854 return getArch() == Triple::dxil;
855 }
856
857 bool isShaderModelOS() const {
858 return getOS() == Triple::ShaderModel;
859 }
860
861 bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
862
863 bool isOSManagarm() const { return getOS() == Triple::Managarm; }
864
867 return Env == Triple::Pixel || Env == Triple::Vertex ||
868 Env == Triple::Geometry || Env == Triple::Hull ||
869 Env == Triple::Domain || Env == Triple::Compute ||
870 Env == Triple::Library || Env == Triple::RayGeneration ||
871 Env == Triple::Intersection || Env == Triple::AnyHit ||
872 Env == Triple::ClosestHit || Env == Triple::Miss ||
873 Env == Triple::Callable || Env == Triple::Mesh ||
875 }
876
877 /// Tests whether the target is SPIR (32- or 64-bit).
878 bool isSPIR() const {
879 return getArch() == Triple::spir || getArch() == Triple::spir64;
880 }
881
882 /// Tests whether the target is SPIR-V (32/64-bit/Logical).
883 bool isSPIRV() const {
884 return getArch() == Triple::spirv32 || getArch() == Triple::spirv64 ||
886 }
887
888 // Tests whether the target is SPIR-V or SPIR.
889 bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
890
891 /// Tests whether the target is SPIR-V Logical
892 bool isSPIRVLogical() const {
893 return getArch() == Triple::spirv;
894 }
895
896 /// Tests whether the target is NVPTX (32- or 64-bit).
897 bool isNVPTX() const {
898 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
899 }
900
901 /// Tests whether the target is AMDGCN
902 bool isAMDGCN() const { return getArch() == Triple::amdgcn; }
903
904 bool isAMDGPU() const { return getArch() == Triple::r600 || isAMDGCN(); }
905
906 /// Tests whether the target is Thumb (little and big endian).
907 bool isThumb() const {
908 return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
909 }
910
911 /// Tests whether the target is ARM (little and big endian).
912 bool isARM() const {
913 return getArch() == Triple::arm || getArch() == Triple::armeb;
914 }
915
916 /// Tests whether the target supports the EHABI exception
917 /// handling standard.
919 return (isARM() || isThumb()) &&
930 }
931
932 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
933 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
934 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
935 // even for GNUEABI, so we can make a distinction here and still conform to
936 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
937 // FIXME: The Darwin exception is temporary, while we move users to
938 // "*-*-*-macho" triples as quickly as possible.
939 bool isTargetAEABI() const {
940 return (getEnvironment() == Triple::EABI ||
942 !isOSDarwin() && !isOSWindows();
943 }
944
945 bool isTargetGNUAEABI() const {
946 return (getEnvironment() == Triple::GNUEABI ||
950 !isOSDarwin() && !isOSWindows();
951 }
952
953 bool isTargetMuslAEABI() const {
954 return (getEnvironment() == Triple::MuslEABI ||
957 !isOSDarwin() && !isOSWindows();
958 }
959
960 /// Tests whether the target is T32.
961 bool isArmT32() const {
962 switch (getSubArch()) {
974 return false;
975 default:
976 return true;
977 }
978 }
979
980 /// Tests whether the target is an M-class.
981 bool isArmMClass() const {
982 switch (getSubArch()) {
989 return true;
990 default:
991 return false;
992 }
993 }
994
995 /// Tests whether the target is AArch64 (little and big endian).
996 bool isAArch64() const {
999 }
1000
1001 /// Tests whether the target is AArch64 and pointers are the size specified by
1002 /// \p PointerWidth.
1003 bool isAArch64(int PointerWidth) const {
1004 assert(PointerWidth == 64 || PointerWidth == 32);
1005 if (!isAArch64())
1006 return false;
1007 return getArch() == Triple::aarch64_32 ||
1009 ? PointerWidth == 32
1010 : PointerWidth == 64;
1011 }
1012
1013 /// Tests whether the target is 32-bit LoongArch.
1014 bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
1015
1016 /// Tests whether the target is 64-bit LoongArch.
1017 bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
1018
1019 /// Tests whether the target is LoongArch (32- and 64-bit).
1020 bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
1021
1022 /// Tests whether the target is MIPS 32-bit (little and big endian).
1023 bool isMIPS32() const {
1024 return getArch() == Triple::mips || getArch() == Triple::mipsel;
1025 }
1026
1027 /// Tests whether the target is MIPS 64-bit (little and big endian).
1028 bool isMIPS64() const {
1029 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
1030 }
1031
1032 /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
1033 bool isMIPS() const {
1034 return isMIPS32() || isMIPS64();
1035 }
1036
1037 /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
1038 bool isPPC() const {
1039 return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
1041 }
1042
1043 /// Tests whether the target is 32-bit PowerPC (little and big endian).
1044 bool isPPC32() const {
1045 return getArch() == Triple::ppc || getArch() == Triple::ppcle;
1046 }
1047
1048 /// Tests whether the target is 64-bit PowerPC (little and big endian).
1049 bool isPPC64() const {
1050 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
1051 }
1052
1053 /// Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
1054 bool isPPC64ELFv2ABI() const {
1055 return (getArch() == Triple::ppc64 &&
1056 ((getOS() == Triple::FreeBSD &&
1057 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1058 getOS() == Triple::OpenBSD || isMusl()));
1059 }
1060
1061 /// Tests whether the target 32-bit PowerPC uses Secure PLT.
1062 bool isPPC32SecurePlt() const {
1063 return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
1064 ((getOS() == Triple::FreeBSD &&
1065 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1067 isMusl()));
1068 }
1069
1070 /// Tests whether the target is 32-bit RISC-V.
1071 bool isRISCV32() const {
1073 }
1074
1075 /// Tests whether the target is 64-bit RISC-V.
1076 bool isRISCV64() const {
1078 }
1079
1080 /// Tests whether the target is RISC-V (32- and 64-bit).
1081 bool isRISCV() const { return isRISCV32() || isRISCV64(); }
1082
1083 /// Tests whether the target is 32-bit SPARC (little and big endian).
1084 bool isSPARC32() const {
1085 return getArch() == Triple::sparc || getArch() == Triple::sparcel;
1086 }
1087
1088 /// Tests whether the target is 64-bit SPARC (big endian).
1089 bool isSPARC64() const { return getArch() == Triple::sparcv9; }
1090
1091 /// Tests whether the target is SPARC.
1092 bool isSPARC() const { return isSPARC32() || isSPARC64(); }
1093
1094 /// Tests whether the target is SystemZ.
1095 bool isSystemZ() const {
1096 return getArch() == Triple::systemz;
1097 }
1098
1099 /// Tests whether the target is x86 (32- or 64-bit).
1100 bool isX86() const {
1101 return getArch() == Triple::x86 || getArch() == Triple::x86_64;
1102 }
1103
1104 /// Tests whether the target is VE
1105 bool isVE() const {
1106 return getArch() == Triple::ve;
1107 }
1108
1109 /// Tests whether the target is wasm (32- and 64-bit).
1110 bool isWasm() const {
1111 return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
1112 }
1113
1114 // Tests whether the target is CSKY
1115 bool isCSKY() const {
1116 return getArch() == Triple::csky;
1117 }
1118
1119 /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
1120 bool isArm64e() const {
1121 return getArch() == Triple::aarch64 &&
1123 }
1124
1125 // Tests whether the target is N32.
1126 bool isABIN32() const {
1128 return Env == Triple::GNUABIN32 || Env == Triple::MuslABIN32;
1129 }
1130
1131 /// Tests whether the target is X32.
1132 bool isX32() const {
1134 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
1135 }
1136
1137 /// Tests whether the target is eBPF.
1138 bool isBPF() const {
1139 return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
1140 }
1141
1142 /// Tests if the target forces 64-bit time_t on a 32-bit architecture.
1143 bool isTime64ABI() const {
1145 return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1146 Env == Triple::GNUEABIHFT64;
1147 }
1148
1149 /// Tests if the target forces hardfloat.
1150 bool isHardFloatABI() const {
1152 return Env == llvm::Triple::GNUEABIHF ||
1154 Env == llvm::Triple::MuslEABIHF ||
1155 Env == llvm::Triple::EABIHF;
1156 }
1157
1158 /// Tests whether the target supports comdat
1159 bool supportsCOMDAT() const {
1160 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
1162 }
1163
1164 /// Tests whether the target uses emulated TLS as default.
1165 ///
1166 /// Note: Android API level 29 (10) introduced ELF TLS.
1168 return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
1170 }
1171
1172 /// True if the target uses TLSDESC by default.
1173 bool hasDefaultTLSDESC() const {
1174 return isAArch64() || (isAndroid() && isRISCV64()) || isOSFuchsia();
1175 }
1176
1177 /// Tests whether the target uses -data-sections as default.
1179 return isOSBinFormatXCOFF() || isWasm();
1180 }
1181
1182 /// Tests if the environment supports dllimport/export annotations.
1183 bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
1184
1185 /// @}
1186 /// @name Mutators
1187 /// @{
1188
1189 /// Set the architecture (first) component of the triple to a known type.
1190 LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch = NoSubArch);
1191
1192 /// Set the vendor (second) component of the triple to a known type.
1193 LLVM_ABI void setVendor(VendorType Kind);
1194
1195 /// Set the operating system (third) component of the triple to a known type.
1196 LLVM_ABI void setOS(OSType Kind);
1197
1198 /// Set the environment (fourth) component of the triple to a known type.
1200
1201 /// Set the object file format.
1203
1204 /// Set all components to the new triple \p Str.
1205 LLVM_ABI void setTriple(const Twine &Str);
1206
1207 /// Set the architecture (first) component of the triple by name.
1208 LLVM_ABI void setArchName(StringRef Str);
1209
1210 /// Set the vendor (second) component of the triple by name.
1212
1213 /// Set the operating system (third) component of the triple by name.
1214 LLVM_ABI void setOSName(StringRef Str);
1215
1216 /// Set the optional environment (fourth) component of the triple by name.
1218
1219 /// Set the operating system and optional environment components with a single
1220 /// string.
1222
1223 /// @}
1224 /// @name Helpers to build variants of a particular triple.
1225 /// @{
1226
1227 /// Form a triple with a 32-bit variant of the current architecture.
1228 ///
1229 /// This can be used to move across "families" of architectures where useful.
1230 ///
1231 /// \returns A new triple with a 32-bit architecture or an unknown
1232 /// architecture if no such variant can be found.
1234
1235 /// Form a triple with a 64-bit variant of the current architecture.
1236 ///
1237 /// This can be used to move across "families" of architectures where useful.
1238 ///
1239 /// \returns A new triple with a 64-bit architecture or an unknown
1240 /// architecture if no such variant can be found.
1242
1243 /// Form a triple with a big endian variant of the current architecture.
1244 ///
1245 /// This can be used to move across "families" of architectures where useful.
1246 ///
1247 /// \returns A new triple with a big endian architecture or an unknown
1248 /// architecture if no such variant can be found.
1250
1251 /// Form a triple with a little endian variant of the current architecture.
1252 ///
1253 /// This can be used to move across "families" of architectures where useful.
1254 ///
1255 /// \returns A new triple with a little endian architecture or an unknown
1256 /// architecture if no such variant can be found.
1258
1259 /// Tests whether the target triple is little endian.
1260 ///
1261 /// \returns true if the triple is little endian, false otherwise.
1262 LLVM_ABI bool isLittleEndian() const;
1263
1264 /// Test whether target triples are compatible.
1265 LLVM_ABI bool isCompatibleWith(const Triple &Other) const;
1266
1267 /// Test whether the target triple is for a GPU.
1268 bool isGPU() const { return isSPIRV() || isNVPTX() || isAMDGPU(); }
1269
1270 /// Merge target triples.
1271 LLVM_ABI std::string merge(const Triple &Other) const;
1272
1273 /// Some platforms have different minimum supported OS versions that
1274 /// varies by the architecture specified in the triple. This function
1275 /// returns the minimum supported OS version for this triple if one an exists,
1276 /// or an invalid version tuple if this triple doesn't have one.
1278
1279 /// @}
1280 /// @name Static helpers for IDs.
1281 /// @{
1282
1283 /// Get the canonical name for the \p Kind architecture.
1285
1286 /// Get the architecture name based on \p Kind and \p SubArch.
1288 SubArchType SubArch = NoSubArch);
1289
1290 /// Get the "prefix" canonical name for the \p Kind architecture. This is the
1291 /// prefix used by the architecture specific builtins, and is suitable for
1292 /// passing to \see Intrinsic::getIntrinsicForClangBuiltin().
1293 ///
1294 /// \return - The architecture prefix, or 0 if none is defined.
1296
1297 /// Get the canonical name for the \p Kind vendor.
1299
1300 /// Get the canonical name for the \p Kind operating system.
1302
1303 /// Get the canonical name for the \p Kind environment.
1305
1306 /// Get the name for the \p Object format.
1307 LLVM_ABI static StringRef
1309
1310 /// @}
1311 /// @name Static helpers for converting alternate architecture names.
1312 /// @{
1313
1314 /// The canonical type for the given LLVM architecture name (e.g., "x86").
1316
1317 /// @}
1318
1319 /// Returns a canonicalized OS version number for the specified OS.
1320 LLVM_ABI static VersionTuple
1322 bool IsInValidRange);
1323
1324 /// Returns whether an OS version is invalid and would not map to an Apple OS.
1325 LLVM_ABI static bool isValidVersionForOS(OSType OSKind,
1326 const VersionTuple &Version);
1327
1329};
1330
1331} // End llvm namespace
1332
1333
1334#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition: Compiler.h:213
Defines the llvm::VersionTuple class, which represents a version in the form major[....
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
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:2161
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1438
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition: Triple.h:1038
bool isOSDragonFly() const
Definition: Triple.h:644
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition: Triple.cpp:1383
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1549
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1656
bool isTargetMachineMac() const
Returns true for targets that run on a macOS machine.
Definition: Triple.h:623
bool isArmT32() const
Tests whether the target is T32.
Definition: Triple.h:961
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition: Triple.cpp:1648
bool isAndroidVersionLT(unsigned Major) const
Definition: Triple.h:819
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1786
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition: Triple.h:715
bool isWatchABI() const
Definition: Triple.h:587
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ MuslABIN32
Definition: Triple.h:272
@ RayGeneration
Definition: Triple.h:299
@ GNUEABIT64
Definition: Triple.h:259
@ LastEnvironmentType
Definition: Triple.h:313
@ UnknownEnvironment
Definition: Triple.h:252
@ ClosestHit
Definition: Triple.h:302
@ MuslEABIHF
Definition: Triple.h:275
@ Amplification
Definition: Triple.h:306
@ Intersection
Definition: Triple.h:300
@ GNUEABIHFT64
Definition: Triple.h:261
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition: Triple.h:907
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition: Triple.h:800
bool isPPC64ELFv2ABI() const
Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
Definition: Triple.h:1054
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:2215
bool isOSWASI() const
Tests whether the OS is WASI.
Definition: Triple.h:741
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition: Triple.h:878
CanonicalForm
Canonical form.
Definition: Triple.h:384
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition: Triple.h:785
bool isDriverKit() const
Is this an Apple DriverKit triple.
Definition: Triple.h:598
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition: Triple.h:514
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:2022
bool isOSHurd() const
Tests whether the OS is Hurd.
Definition: Triple.h:736
bool isHardFloatABI() const
Tests if the target forces hardfloat.
Definition: Triple.h:1150
bool isBPF() const
Tests whether the target is eBPF.
Definition: Triple.h:1138
bool isX32() const
Tests whether the target is X32.
Definition: Triple.h:1132
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition: Triple.cpp:261
Triple(const char *Str)
Definition: Triple.h:359
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition: Triple.h:435
bool isAArch64(int PointerWidth) const
Tests whether the target is AArch64 and pointers are the size specified by PointerWidth.
Definition: Triple.h:1003
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition: Triple.h:412
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition: Triple.h:1100
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition: Triple.h:1120
std::string normalize(CanonicalForm Form=CanonicalForm::ANY) const
Return the normalized form of this triple's string.
Definition: Triple.h:400
bool isTargetEHABICompatible() const
Tests whether the target supports the EHABI exception handling standard.
Definition: Triple.h:918
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition: Triple.h:777
bool isWindowsGNUEnvironment() const
Definition: Triple.h:710
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1660
@ CheriotRTOS
Definition: Triple.h:248
@ LastOSType
Definition: Triple.h:249
@ HermitCore
Definition: Triple.h:240
@ ShaderModel
Definition: Triple.h:244
@ Emscripten
Definition: Triple.h:243
bool isOSNetBSD() const
Definition: Triple.h:628
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition: Triple.cpp:1677
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:817
bool hasDefaultTLSDESC() const
True if the target uses TLSDESC by default.
Definition: Triple.h:1173
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1869
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition: Triple.h:720
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:780
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:2065
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1640
bool isABIN32() const
Definition: Triple.h:1126
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition: Triple.cpp:1388
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition: Triple.h:1159
bool isWindowsCoreCLREnvironment() const
Definition: Triple.h:698
bool isSPIROrSPIRV() const
Definition: Triple.h:889
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition: Triple.cpp:2297
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition: Triple.h:1028
@ loongarch32
Definition: Triple.h:64
@ LastArchType
Definition: Triple.h:113
@ renderscript64
Definition: Triple.h:111
@ UnknownArch
Definition: Triple.h:50
@ aarch64_be
Definition: Triple.h:55
@ loongarch64
Definition: Triple.h:65
@ renderscript32
Definition: Triple.h:110
@ riscv32be
Definition: Triple.h:80
@ riscv64be
Definition: Triple.h:81
@ mips64el
Definition: Triple.h:70
@ aarch64_32
Definition: Triple.h:56
bool hasDefaultDataSections() const
Tests whether the target uses -data-sections as default.
Definition: Triple.h:1178
bool isTargetGNUAEABI() const
Definition: Triple.h:945
bool isOSSolaris() const
Definition: Triple.h:646
bool isRISCV32() const
Tests whether the target is 32-bit RISC-V.
Definition: Triple.h:1071
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition: Triple.h:731
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition: Triple.cpp:1624
OSType getOS() const
Get the parsed operating system type of this triple.
Definition: Triple.h:418
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1411
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:1155
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:438
bool isOSVersionLT(const Triple &Other) const
Definition: Triple.h:553
bool isPPC32() const
Tests whether the target is 32-bit PowerPC (little and big endian).
Definition: Triple.h:1044
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition: Triple.h:409
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition: Triple.cpp:1756
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:772
bool isRISCV64() const
Tests whether the target is 64-bit RISC-V.
Definition: Triple.h:1076
bool isCSKY() const
Definition: Triple.h:1115
bool isLoongArch64() const
Tests whether the target is 64-bit LoongArch.
Definition: Triple.h:1017
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:1394
bool isSPARC32() const
Tests whether the target is 32-bit SPARC (little and big endian).
Definition: Triple.h:1084
bool isSimulatorEnvironment() const
Definition: Triple.h:614
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition: Triple.cpp:1611
const std::string & str() const
Definition: Triple.h:476
bool isOSzOS() const
Definition: Triple.h:600
bool isOSSerenity() const
Definition: Triple.h:762
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition: Triple.h:846
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition: Triple.h:426
bool isOSOpenBSD() const
Definition: Triple.h:632
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition: Triple.cpp:1586
bool isOSUnknown() const
Definition: Triple.h:654
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1574
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition: Triple.h:1023
bool isShaderModelOS() const
Definition: Triple.h:857
bool isUEFI() const
Tests whether the OS is UEFI.
Definition: Triple.h:672
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:677
bool isMusl() const
Tests whether the environment is musl-libc.
Definition: Triple.h:832
const std::string & getTriple() const
Definition: Triple.h:478
static LLVM_ABI StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition: Triple.cpp:24
bool isOSBinFormatDXContainer() const
Tests whether the OS uses the DXContainer binary format.
Definition: Triple.h:795
bool isGPU() const
Test whether the target triple is for a GPU.
Definition: Triple.h:1268
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition: Triple.h:790
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition: Triple.cpp:287
bool isTargetMuslAEABI() const
Definition: Triple.h:953
ObjectFormatType
Definition: Triple.h:315
@ DXContainer
Definition: Triple.h:319
@ UnknownObjectFormat
Definition: Triple.h:316
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition: Triple.h:912
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:2152
bool isArmMClass() const
Tests whether the target is an M-class.
Definition: Triple.h:981
bool isOSLinux() const
Tests whether the OS is Linux.
Definition: Triple.h:726
bool isBridgeOS() const
Is this an Apple BridgeOS triple.
Definition: Triple.h:595
bool isOSManagarm() const
Definition: Triple.h:863
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition: Triple.h:1081
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition: Triple.h:902
bool isAMDGPU() const
Definition: Triple.h:904
bool isLoongArch32() const
Tests whether the target is 32-bit LoongArch.
Definition: Triple.h:1014
bool isOSLiteOS() const
Definition: Triple.h:850
@ UnknownVendor
Definition: Triple.h:186
@ OpenEmbedded
Definition: Triple.h:200
@ ImaginationTechnologies
Definition: Triple.h:193
@ LastVendorType
Definition: Triple.h:203
@ MipsTechnologies
Definition: Triple.h:194
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition: Triple.h:897
bool isOSAIX() const
Tests whether the OS is AIX.
Definition: Triple.h:758
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition: Triple.cpp:2178
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1774
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition: Triple.cpp:1400
@ ARMSubArch_v6t2
Definition: Triple.h:148
@ MipsSubArch_r6
Definition: Triple.h:160
@ DXILSubArch_v1_2
Definition: Triple.h:176
@ ARMSubArch_v7
Definition: Triple.h:139
@ ARMSubArch_v8m_mainline
Definition: Triple.h:137
@ ARMSubArch_v9_6a
Definition: Triple.h:118
@ ARMSubArch_v8r
Definition: Triple.h:135
@ ARMSubArch_v9_1a
Definition: Triple.h:123
@ DXILSubArch_v1_1
Definition: Triple.h:175
@ LatestDXILSubArch
Definition: Triple.h:183
@ SPIRVSubArch_v10
Definition: Triple.h:165
@ SPIRVSubArch_v13
Definition: Triple.h:168
@ ARMSubArch_v7k
Definition: Triple.h:143
@ ARMSubArch_v8_7a
Definition: Triple.h:127
@ ARMSubArch_v8
Definition: Triple.h:134
@ SPIRVSubArch_v16
Definition: Triple.h:171
@ ARMSubArch_v8_1a
Definition: Triple.h:133
@ ARMSubArch_v9_2a
Definition: Triple.h:122
@ DXILSubArch_v1_3
Definition: Triple.h:177
@ SPIRVSubArch_v15
Definition: Triple.h:170
@ ARMSubArch_v7m
Definition: Triple.h:141
@ ARMSubArch_v6k
Definition: Triple.h:147
@ ARMSubArch_v5
Definition: Triple.h:149
@ AArch64SubArch_arm64e
Definition: Triple.h:153
@ ARMSubArch_v6
Definition: Triple.h:145
@ ARMSubArch_v9_5a
Definition: Triple.h:119
@ ARMSubArch_v7ve
Definition: Triple.h:144
@ ARMSubArch_v8m_baseline
Definition: Triple.h:136
@ ARMSubArch_v8_8a
Definition: Triple.h:126
@ ARMSubArch_v8_2a
Definition: Triple.h:132
@ ARMSubArch_v7s
Definition: Triple.h:142
@ DXILSubArch_v1_0
Definition: Triple.h:174
@ DXILSubArch_v1_7
Definition: Triple.h:181
@ KalimbaSubArch_v3
Definition: Triple.h:156
@ DXILSubArch_v1_5
Definition: Triple.h:179
@ ARMSubArch_v8_4a
Definition: Triple.h:130
@ ARMSubArch_v8_9a
Definition: Triple.h:125
@ ARMSubArch_v7em
Definition: Triple.h:140
@ SPIRVSubArch_v12
Definition: Triple.h:167
@ SPIRVSubArch_v14
Definition: Triple.h:169
@ KalimbaSubArch_v4
Definition: Triple.h:157
@ ARMSubArch_v8_1m_mainline
Definition: Triple.h:138
@ ARMSubArch_v8_3a
Definition: Triple.h:131
@ AArch64SubArch_arm64ec
Definition: Triple.h:154
@ ARMSubArch_v8_6a
Definition: Triple.h:128
@ ARMSubArch_v5te
Definition: Triple.h:150
@ KalimbaSubArch_v5
Definition: Triple.h:158
@ ARMSubArch_v4t
Definition: Triple.h:151
@ DXILSubArch_v1_6
Definition: Triple.h:180
@ DXILSubArch_v1_8
Definition: Triple.h:182
@ ARMSubArch_v9_4a
Definition: Triple.h:120
@ ARMSubArch_v8_5a
Definition: Triple.h:129
@ ARMSubArch_v6m
Definition: Triple.h:146
@ ARMSubArch_v9_3a
Definition: Triple.h:121
@ ARMSubArch_v9
Definition: Triple.h:124
@ DXILSubArch_v1_4
Definition: Triple.h:178
@ SPIRVSubArch_v11
Definition: Triple.h:166
@ PPCSubArch_spe
Definition: Triple.h:162
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:1452
bool isSPARC64() const
Tests whether the target is 64-bit SPARC (big endian).
Definition: Triple.h:1089
bool isWindowsCygwinEnvironment() const
Definition: Triple.h:706
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:2266
Triple(StringRef Str)
Definition: Triple.h:358
bool isMacOSX() const
Is this a Mac OS X triple.
Definition: Triple.h:564
Triple(const std::string &Str)
Definition: Triple.h:360
bool isOSFreeBSD() const
Definition: Triple.h:636
bool isXROS() const
Is this an Apple XROS triple.
Definition: Triple.h:592
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition: Triple.cpp:1672
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1636
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1664
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition: Triple.h:415
bool isSPARC() const
Tests whether the target is SPARC.
Definition: Triple.h:1092
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition: Triple.h:1049
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition: Triple.h:609
bool hasDLLImportExport() const
Tests if the environment supports dllimport/export annotations.
Definition: Triple.h:1183
bool isSPIRVLogical() const
Tests whether the target is SPIR-V Logical.
Definition: Triple.h:892
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition: Triple.cpp:339
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:542
bool isTvOS() const
Is this an Apple tvOS triple.
Definition: Triple.h:578
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition: Triple.h:746
bool isWindowsArm64EC() const
Definition: Triple.h:693
bool operator==(const Triple &Other) const
Definition: Triple.h:368
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition: Triple.h:583
bool empty() const
Whether the triple is empty / default constructed.
Definition: Triple.h:481
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:573
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition: Triple.h:1033
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition: Triple.h:751
bool isTargetAEABI() const
Definition: Triple.h:939
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition: Triple.h:814
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition: Triple.h:1110
bool isVulkanOS() const
Definition: Triple.h:861
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1379
bool isOSIAMCU() const
Definition: Triple.h:650
bool isOpenHOS() const
Definition: Triple.h:848
bool isMacCatalystEnvironment() const
Definition: Triple.h:618
bool isPS5() const
Tests whether the target is the PS5 platform.
Definition: Triple.h:807
bool isSPIRV() const
Tests whether the target is SPIR-V (32/64-bit/Logical).
Definition: Triple.h:883
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition: Triple.h:996
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition: Triple.cpp:408
bool isAppleMachO() const
Is this an Apple MachO triple.
Definition: Triple.h:603
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1782
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1952
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1500
bool hasDefaultEmulatedTLS() const
Tests whether the target uses emulated TLS as default.
Definition: Triple.h:1167
bool isSystemZ() const
Tests whether the target is SystemZ.
Definition: Triple.h:1095
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:1415
bool isPPC32SecurePlt() const
Tests whether the target 32-bit PowerPC uses Secure PLT.
Definition: Triple.h:1062
bool isTime64ABI() const
Tests if the target forces 64-bit time_t on a 32-bit architecture.
Definition: Triple.h:1143
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1778
bool operator!=(const Triple &Other) const
Definition: Triple.h:375
unsigned getOSMajorVersion() const
Return just the major version number, this is specialized because it is a common query.
Definition: Triple.h:445
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:2117
bool isOSFuchsia() const
Definition: Triple.h:640
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:767
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition: Triple.h:687
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition: Triple.h:421
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition: Triple.h:682
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:171
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition: Triple.h:667
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1628
bool isDXIL() const
Tests whether the target is DXIL.
Definition: Triple.h:853
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1632
bool isGNUEnvironment() const
Definition: Triple.h:656
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition: Triple.h:1020
bool isShaderStageEnvironment() const
Definition: Triple.h:865
bool isWindowsItaniumEnvironment() const
Definition: Triple.h:702
bool isVE() const
Tests whether the target is VE.
Definition: Triple.h:1105
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]]].
Definition: VersionTuple.h:30
unsigned getMajor() const
Retrieve the major version number.
Definition: VersionTuple.h:72
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ExceptionHandling
Definition: CodeGen.h:53
@ Other
Any other memory.
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:851