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
153
156
160
162
164
165 // SPIR-V sub-arch corresponds to its version.
173
174 // DXIL sub-arch corresponds to its version.
186 };
207 enum OSType {
209
217 Lv2, // PS3
229 CUDA, // NVIDIA CUDA
230 NVCL, // NVIDIA OpenCL
231 AMDHSA, // AMD HSA Runtime
235 TvOS, // Apple tvOS
236 WatchOS, // Apple watchOS
237 BridgeOS, // Apple bridgeOS
238 DriverKit, // Apple DriverKit
239 XROS, // Apple XROS
241 AMDPAL, // AMD PAL Runtime
242 HermitCore, // HermitCore Unikernel/Multikernel
243 Hurd, // GNU/Hurd
244 WASI, // Experimental WebAssembly OS
246 ShaderModel, // DirectX ShaderModel
249 Vulkan, // Vulkan SPIR-V
252 };
255
283
288 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
289 MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
290
291 // Shader Stages
292 // The order of these values matters, and must be kept in sync with the
293 // language options enum in Clang. The ordering is enforced in
294 // static_asserts in Triple.cpp and in Clang.
314
318 };
331
332private:
333 std::string Data;
334
335 /// The parsed arch type.
336 ArchType Arch{};
337
338 /// The parsed subarchitecture type.
339 SubArchType SubArch{};
340
341 /// The parsed vendor type.
342 VendorType Vendor{};
343
344 /// The parsed OS type.
345 OSType OS{};
346
347 /// The parsed Environment type.
348 EnvironmentType Environment{};
349
350 /// The object format type.
351 ObjectFormatType ObjectFormat{};
352
353public:
354 /// @name Constructors
355 /// @{
356
357 /// Default constructor is the same as an empty string and leaves all
358 /// triple fields unknown.
359 Triple() = default;
360
361 LLVM_ABI explicit Triple(std::string &&Str);
362 explicit Triple(StringRef Str) : Triple(Str.str()) {}
363 explicit Triple(const char *Str) : Triple(std::string(Str)) {}
364 explicit Triple(const std::string &Str) : Triple(std::string(Str)) {}
365 LLVM_ABI explicit Triple(const Twine &Str);
366
367 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
368 const Twine &OSStr);
369 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
370 const Twine &OSStr, const Twine &EnvironmentStr);
371
372 bool operator==(const Triple &Other) const {
373 return Arch == Other.Arch && SubArch == Other.SubArch &&
374 Vendor == Other.Vendor && OS == Other.OS &&
375 Environment == Other.Environment &&
376 ObjectFormat == Other.ObjectFormat;
377 }
378
379 bool operator!=(const Triple &Other) const {
380 return !(*this == Other);
381 }
382
383 /// @}
384 /// @name Normalization
385 /// @{
386
387 /// Canonical form
388 enum class CanonicalForm {
389 ANY = 0,
390 THREE_IDENT = 3, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM
391 FOUR_IDENT = 4, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
392 FIVE_IDENT = 5, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT-FORMAT
393 };
394
395 /// Turn an arbitrary machine specification into the canonical triple form (or
396 /// something sensible that the Triple class understands if nothing better can
397 /// reasonably be done). In particular, it handles the common case in which
398 /// otherwise valid components are in the wrong order. \p Form is used to
399 /// specify the output canonical form.
400 LLVM_ABI static std::string
402
403 /// Return the normalized form of this triple's string.
404 std::string normalize(CanonicalForm Form = CanonicalForm::ANY) const {
405 return normalize(Data, Form);
406 }
407
408 /// @}
409 /// @name Typed Component Access
410 /// @{
411
412 /// Get the parsed architecture type of this triple.
413 ArchType getArch() const { return Arch; }
414
415 /// get the parsed subarchitecture type for this triple.
416 SubArchType getSubArch() const { return SubArch; }
417
418 /// Get the parsed vendor type of this triple.
419 VendorType getVendor() const { return Vendor; }
420
421 /// Get the parsed operating system type of this triple.
422 OSType getOS() const { return OS; }
423
424 /// Does this triple have the optional environment (fourth) component?
425 bool hasEnvironment() const {
426 return getEnvironmentName() != "";
427 }
428
429 /// Get the parsed environment type of this triple.
430 EnvironmentType getEnvironment() const { return Environment; }
431
432 /// Parse the version number from the OS name component of the
433 /// triple, if present.
434 ///
435 /// For example, "fooos1.2.3" would return (1, 2, 3).
437
438 /// Get the object format for this triple.
439 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
440
441 /// Parse the version number from the OS name component of the triple, if
442 /// present.
443 ///
444 /// For example, "fooos1.2.3" would return (1, 2, 3).
446
447 /// Return just the major version number, this is specialized because it is a
448 /// common query.
449 unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
450
451 /// Parse the version number as with getOSVersion and then translate generic
452 /// "darwin" versions to the corresponding OS X versions. This may also be
453 /// called with IOS triples but the OS X version number is just set to a
454 /// constant 10.4.0 in that case. Returns true if successful.
456
457 /// Parse the version number as with getOSVersion. This should only be called
458 /// with IOS or generic triples.
460
461 /// Parse the version number as with getOSVersion. This should only be called
462 /// with WatchOS or generic triples.
464
465 /// Parse the version number as with getOSVersion.
467
468 /// Parse the Vulkan version number from the OSVersion and SPIR-V version
469 /// (SubArch). This should only be called with Vulkan SPIR-V triples.
471
472 /// Parse the DXIL version number from the OSVersion and DXIL version
473 /// (SubArch). This should only be called with DXIL triples.
475
476 /// @}
477 /// @name Direct Component Access
478 /// @{
479
480 const std::string &str() const { return Data; }
481
482 const std::string &getTriple() const { return Data; }
483
484 /// Whether the triple is empty / default constructed.
485 bool empty() const { return Data.empty(); }
486
487 /// Get the architecture (first) component of the triple.
489
490 /// Get the vendor (second) component of the triple.
492
493 /// Get the operating system (third) component of the triple.
495
496 /// Get the optional environment (fourth) component of the triple, or "" if
497 /// empty.
499
500 /// Get the operating system and optional environment components as a single
501 /// string (separated by a '-' if the environment component is present).
503
504 /// Get the version component of the environment component as a single
505 /// string (the version after the environment).
506 ///
507 /// For example, "fooos1.2.3" would return "1.2.3".
509
510 /// @}
511 /// @name Convenience Predicates
512 /// @{
513
514 /// Returns the pointer width of this architecture.
516
517 /// Returns the pointer width of this architecture.
518 unsigned getArchPointerBitWidth() const {
520 }
521
522 /// Returns the trampoline size in bytes for this configuration.
523 LLVM_ABI unsigned getTrampolineSize() const;
524
525 /// Test whether the architecture is 64-bit
526 ///
527 /// Note that this tests for 64-bit pointer width, and nothing else. Note
528 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
529 /// 16-bit. The inner details of pointer width for particular architectures
530 /// is not summed up in the triple, and so only a coarse grained predicate
531 /// system is provided.
532 LLVM_ABI bool isArch64Bit() const;
533
534 /// Test whether the architecture is 32-bit
535 ///
536 /// Note that this tests for 32-bit pointer width, and nothing else.
537 LLVM_ABI bool isArch32Bit() const;
538
539 /// Test whether the architecture is 16-bit
540 ///
541 /// Note that this tests for 16-bit pointer width, and nothing else.
542 LLVM_ABI bool isArch16Bit() const;
543
544 /// Helper function for doing comparisons against version numbers included in
545 /// the target triple.
546 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
547 unsigned Micro = 0) const {
548 if (Minor == 0) {
549 return getOSVersion() < VersionTuple(Major);
550 }
551 if (Micro == 0) {
552 return getOSVersion() < VersionTuple(Major, Minor);
553 }
554 return getOSVersion() < VersionTuple(Major, Minor, Micro);
555 }
556
557 bool isOSVersionLT(const Triple &Other) const {
558 return getOSVersion() < Other.getOSVersion();
559 }
560
561 /// Comparison function for checking OS X version compatibility, which handles
562 /// supporting skewed version numbering schemes used by the "darwin" triples.
563 LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
564 unsigned Micro = 0) const;
565
566 /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
567 /// and "osx" as OS X triples.
568 bool isMacOSX() const {
569 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
570 }
571
572 /// Is this an iOS triple.
573 /// Note: This identifies tvOS as a variant of iOS. If that ever
574 /// changes, i.e., if the two operating systems diverge or their version
575 /// numbers get out of sync, that will need to be changed.
576 /// watchOS has completely different version numbers so it is not included.
577 bool isiOS() const {
578 return getOS() == Triple::IOS || isTvOS();
579 }
580
581 /// Is this an Apple tvOS triple.
582 bool isTvOS() const {
583 return getOS() == Triple::TvOS;
584 }
585
586 /// Is this an Apple watchOS triple.
587 bool isWatchOS() const {
588 return getOS() == Triple::WatchOS;
589 }
590
591 bool isWatchABI() const {
593 }
594
595 /// Is this an Apple XROS triple.
596 bool isXROS() const { return getOS() == Triple::XROS; }
597
598 /// Is this an Apple BridgeOS triple.
599 bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }
600
601 /// Is this an Apple DriverKit triple.
602 bool isDriverKit() const { return getOS() == Triple::DriverKit; }
603
604 bool isOSzOS() const { return getOS() == Triple::ZOS; }
605
606 /// Is this an Apple MachO triple.
607 bool isAppleMachO() const {
608 return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
609 }
610
611 /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
612 /// bridgeOS).
613 bool isOSDarwin() const {
614 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
615 isBridgeOS();
616 }
617
620 }
621
623 return getEnvironment() == Triple::MacABI;
624 }
625
626 /// Returns true for targets that run on a macOS machine.
627 bool isTargetMachineMac() const {
628 return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
630 }
631
632 bool isOSNetBSD() const {
633 return getOS() == Triple::NetBSD;
634 }
635
636 bool isOSOpenBSD() const {
637 return getOS() == Triple::OpenBSD;
638 }
639
640 bool isOSFreeBSD() const {
641 return getOS() == Triple::FreeBSD;
642 }
643
644 bool isOSFuchsia() const {
645 return getOS() == Triple::Fuchsia;
646 }
647
648 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
649
650 bool isOSSolaris() const {
651 return getOS() == Triple::Solaris;
652 }
653
654 bool isOSIAMCU() const {
655 return getOS() == Triple::ELFIAMCU;
656 }
657
658 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
659
660 bool isGNUEnvironment() const {
662 return Env == Triple::GNU || Env == Triple::GNUT64 ||
663 Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
664 Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
665 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
666 Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
667 Env == Triple::GNUSF || Env == Triple::GNUX32;
668 }
669
670 /// Tests whether the OS is Haiku.
671 bool isOSHaiku() const {
672 return getOS() == Triple::Haiku;
673 }
674
675 /// Tests whether the OS is UEFI.
676 bool isUEFI() const {
677 return getOS() == Triple::UEFI;
678 }
679
680 /// Tests whether the OS is Windows.
681 bool isOSWindows() const {
682 return getOS() == Triple::Win32;
683 }
684
685 /// Checks if the environment is MSVC.
687 return isOSWindows() && getEnvironment() == Triple::MSVC;
688 }
689
690 /// Checks if the environment could be MSVC.
695
696 // Checks if we're using the Windows Arm64EC ABI.
697 bool isWindowsArm64EC() const {
698 return getArch() == Triple::aarch64 &&
700 }
701
704 }
705
708 }
709
712 }
713
715 return isOSWindows() && getEnvironment() == Triple::GNU;
716 }
717
718 /// Tests for either Cygwin or MinGW OS
719 bool isOSCygMing() const {
721 }
722
723 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
728
729 /// Tests whether the OS is Linux.
730 bool isOSLinux() const {
731 return getOS() == Triple::Linux;
732 }
733
734 /// Tests whether the OS is kFreeBSD.
735 bool isOSKFreeBSD() const {
736 return getOS() == Triple::KFreeBSD;
737 }
738
739 /// Tests whether the OS is Hurd.
740 bool isOSHurd() const {
741 return getOS() == Triple::Hurd;
742 }
743
744 /// Tests whether the OS is WASI.
745 bool isOSWASI() const {
746 return getOS() == Triple::WASI;
747 }
748
749 /// Tests whether the OS is Emscripten.
750 bool isOSEmscripten() const {
751 return getOS() == Triple::Emscripten;
752 }
753
754 /// Tests whether the OS uses glibc.
755 bool isOSGlibc() const {
756 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
757 getOS() == Triple::Hurd) &&
758 !isAndroid();
759 }
760
761 /// Tests whether the OS is AIX.
762 bool isOSAIX() const {
763 return getOS() == Triple::AIX;
764 }
765
766 bool isOSSerenity() const {
767 return getOS() == Triple::Serenity;
768 }
769
770 /// Tests whether the OS uses the ELF binary format.
771 bool isOSBinFormatELF() const {
772 return getObjectFormat() == Triple::ELF;
773 }
774
775 /// Tests whether the OS uses the COFF binary format.
776 bool isOSBinFormatCOFF() const {
777 return getObjectFormat() == Triple::COFF;
778 }
779
780 /// Tests whether the OS uses the GOFF binary format.
781 bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
782
783 /// Tests whether the environment is MachO.
784 bool isOSBinFormatMachO() const {
785 return getObjectFormat() == Triple::MachO;
786 }
787
788 /// Tests whether the OS uses the Wasm binary format.
789 bool isOSBinFormatWasm() const {
790 return getObjectFormat() == Triple::Wasm;
791 }
792
793 /// Tests whether the OS uses the XCOFF binary format.
794 bool isOSBinFormatXCOFF() const {
795 return getObjectFormat() == Triple::XCOFF;
796 }
797
798 /// Tests whether the OS uses the DXContainer binary format.
801 }
802
803 /// Tests whether the target uses WALI Wasm
804 bool isWALI() const {
805 return getArch() == Triple::wasm32 && isOSLinux() &&
807 }
808
809 /// Tests whether the target is the PS4 platform.
810 bool isPS4() const {
811 return getArch() == Triple::x86_64 &&
812 getVendor() == Triple::SCEI &&
813 getOS() == Triple::PS4;
814 }
815
816 /// Tests whether the target is the PS5 platform.
817 bool isPS5() const {
818 return getArch() == Triple::x86_64 &&
819 getVendor() == Triple::SCEI &&
820 getOS() == Triple::PS5;
821 }
822
823 /// Tests whether the target is the PS4 or PS5 platform.
824 bool isPS() const { return isPS4() || isPS5(); }
825
826 /// Tests whether the target is Android
827 bool isAndroid() const { return getEnvironment() == Triple::Android; }
828
829 bool isAndroidVersionLT(unsigned Major) const {
830 assert(isAndroid() && "Not an Android triple!");
831
833
834 // 64-bit targets did not exist before API level 21 (Lollipop).
835 if (isArch64Bit() && Version.getMajor() < 21)
836 return VersionTuple(21) < VersionTuple(Major);
837
838 return Version < VersionTuple(Major);
839 }
840
841 /// Tests whether the environment is musl-libc
854
855 /// Tests whether the target is OHOS
856 /// LiteOS default enviroment is also OHOS, but omited on triple.
857 bool isOHOSFamily() const { return isOpenHOS() || isOSLiteOS(); }
858
859 bool isOpenHOS() const { return getEnvironment() == Triple::OpenHOS; }
860
861 bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
862
863 /// Tests whether the target is DXIL.
864 bool isDXIL() const {
865 return getArch() == Triple::dxil;
866 }
867
868 bool isShaderModelOS() const {
869 return getOS() == Triple::ShaderModel;
870 }
871
872 bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
873
874 bool isOSManagarm() const { return getOS() == Triple::Managarm; }
875
878 return Env == Triple::Pixel || Env == Triple::Vertex ||
879 Env == Triple::Geometry || Env == Triple::Hull ||
880 Env == Triple::Domain || Env == Triple::Compute ||
881 Env == Triple::Library || Env == Triple::RayGeneration ||
882 Env == Triple::Intersection || Env == Triple::AnyHit ||
883 Env == Triple::ClosestHit || Env == Triple::Miss ||
884 Env == Triple::Callable || Env == Triple::Mesh ||
886 }
887
888 /// Tests whether the target is SPIR (32- or 64-bit).
889 bool isSPIR() const {
890 return getArch() == Triple::spir || getArch() == Triple::spir64;
891 }
892
893 /// Tests whether the target is SPIR-V (32/64-bit/Logical).
894 bool isSPIRV() const {
895 return getArch() == Triple::spirv32 || getArch() == Triple::spirv64 ||
897 }
898
899 // Tests whether the target is SPIR-V or SPIR.
900 bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
901
902 /// Tests whether the target is SPIR-V Logical
903 bool isSPIRVLogical() const {
904 return getArch() == Triple::spirv;
905 }
906
907 /// Tests whether the target is NVPTX (32- or 64-bit).
908 bool isNVPTX() const {
909 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
910 }
911
912 /// Tests whether the target is AMDGCN
913 bool isAMDGCN() const { return getArch() == Triple::amdgcn; }
914
915 bool isAMDGPU() const { return getArch() == Triple::r600 || isAMDGCN(); }
916
917 /// Tests whether the target is Thumb (little and big endian).
918 bool isThumb() const {
919 return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
920 }
921
922 /// Tests whether the target is ARM (little and big endian).
923 bool isARM() const {
924 return getArch() == Triple::arm || getArch() == Triple::armeb;
925 }
926
927 /// Tests whether the target supports the EHABI exception
928 /// handling standard.
943
944 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
945 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
946 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
947 // even for GNUEABI, so we can make a distinction here and still conform to
948 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
949 // FIXME: The Darwin exception is temporary, while we move users to
950 // "*-*-*-macho" triples as quickly as possible.
951 bool isTargetAEABI() const {
952 return (getEnvironment() == Triple::EABI ||
954 !isOSDarwin() && !isOSWindows();
955 }
956
964
965 bool isTargetMuslAEABI() const {
966 return (getEnvironment() == Triple::MuslEABI ||
969 !isOSDarwin() && !isOSWindows();
970 }
971
972 /// Tests whether the target is T32.
973 bool isArmT32() const {
974 switch (getSubArch()) {
986 return false;
987 default:
988 return true;
989 }
990 }
991
992 /// Tests whether the target is an M-class.
993 bool isArmMClass() const {
994 switch (getSubArch()) {
1001 return true;
1002 default:
1003 return false;
1004 }
1005 }
1006
1007 /// Tests whether the target is AArch64 (little and big endian).
1008 bool isAArch64() const {
1009 return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
1011 }
1012
1013 /// Tests whether the target is AArch64 and pointers are the size specified by
1014 /// \p PointerWidth.
1015 bool isAArch64(int PointerWidth) const {
1016 assert(PointerWidth == 64 || PointerWidth == 32);
1017 if (!isAArch64())
1018 return false;
1019 return getArch() == Triple::aarch64_32 ||
1021 ? PointerWidth == 32
1022 : PointerWidth == 64;
1023 }
1024
1025 /// Tests whether the target is 32-bit LoongArch.
1026 bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
1027
1028 /// Tests whether the target is 64-bit LoongArch.
1029 bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
1030
1031 /// Tests whether the target is LoongArch (32- and 64-bit).
1032 bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
1033
1034 /// Tests whether the target is MIPS 32-bit (little and big endian).
1035 bool isMIPS32() const {
1036 return getArch() == Triple::mips || getArch() == Triple::mipsel;
1037 }
1038
1039 /// Tests whether the target is MIPS 64-bit (little and big endian).
1040 bool isMIPS64() const {
1041 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
1042 }
1043
1044 /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
1045 bool isMIPS() const {
1046 return isMIPS32() || isMIPS64();
1047 }
1048
1049 /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
1050 bool isPPC() const {
1051 return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
1053 }
1054
1055 /// Tests whether the target is 32-bit PowerPC (little and big endian).
1056 bool isPPC32() const {
1057 return getArch() == Triple::ppc || getArch() == Triple::ppcle;
1058 }
1059
1060 /// Tests whether the target is 64-bit PowerPC (little and big endian).
1061 bool isPPC64() const {
1062 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
1063 }
1064
1065 /// Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
1066 bool isPPC64ELFv2ABI() const {
1067 return (getArch() == Triple::ppc64 &&
1068 ((getOS() == Triple::FreeBSD &&
1069 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1070 getOS() == Triple::OpenBSD || isMusl()));
1071 }
1072
1073 /// Tests whether the target 32-bit PowerPC uses Secure PLT.
1074 bool isPPC32SecurePlt() const {
1075 return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
1076 ((getOS() == Triple::FreeBSD &&
1077 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1079 isMusl()));
1080 }
1081
1082 /// Tests whether the target is 32-bit RISC-V.
1083 bool isRISCV32() const {
1085 }
1086
1087 /// Tests whether the target is 64-bit RISC-V.
1088 bool isRISCV64() const {
1090 }
1091
1092 /// Tests whether the target is RISC-V (32- and 64-bit).
1093 bool isRISCV() const { return isRISCV32() || isRISCV64(); }
1094
1095 /// Tests whether the target is 32-bit SPARC (little and big endian).
1096 bool isSPARC32() const {
1097 return getArch() == Triple::sparc || getArch() == Triple::sparcel;
1098 }
1099
1100 /// Tests whether the target is 64-bit SPARC (big endian).
1101 bool isSPARC64() const { return getArch() == Triple::sparcv9; }
1102
1103 /// Tests whether the target is SPARC.
1104 bool isSPARC() const { return isSPARC32() || isSPARC64(); }
1105
1106 /// Tests whether the target is SystemZ.
1107 bool isSystemZ() const {
1108 return getArch() == Triple::systemz;
1109 }
1110
1111 /// Tests whether the target is x86 (32- or 64-bit).
1112 bool isX86() const {
1113 return getArch() == Triple::x86 || getArch() == Triple::x86_64;
1114 }
1115
1116 /// Tests whether the target is x86 (32-bit).
1117 bool isX86_32() const { return getArch() == Triple::x86; }
1118
1119 /// Tests whether the target is x86 (64-bit).
1120 bool isX86_64() const { return getArch() == Triple::x86_64; }
1121
1122 /// Tests whether the target is VE
1123 bool isVE() const {
1124 return getArch() == Triple::ve;
1125 }
1126
1127 /// Tests whether the target is wasm (32- and 64-bit).
1128 bool isWasm() const {
1129 return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
1130 }
1131
1132 // Tests whether the target is CSKY
1133 bool isCSKY() const {
1134 return getArch() == Triple::csky;
1135 }
1136
1137 /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
1138 bool isArm64e() const {
1139 return getArch() == Triple::aarch64 &&
1141 }
1142
1143 // Tests whether the target is N32.
1144 bool isABIN32() const {
1146 return Env == Triple::GNUABIN32 || Env == Triple::MuslABIN32;
1147 }
1148
1149 /// Tests whether the target is X32.
1150 bool isX32() const {
1152 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
1153 }
1154
1155 /// Tests whether the target is eBPF.
1156 bool isBPF() const {
1157 return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
1158 }
1159
1160 /// Tests if the target forces 64-bit time_t on a 32-bit architecture.
1161 bool isTime64ABI() const {
1163 return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1164 Env == Triple::GNUEABIHFT64;
1165 }
1166
1167 /// Tests if the target forces hardfloat.
1168 bool isHardFloatABI() const {
1170 return Env == llvm::Triple::GNUEABIHF ||
1172 Env == llvm::Triple::MuslEABIHF ||
1173 Env == llvm::Triple::EABIHF;
1174 }
1175
1176 /// Tests whether the target supports comdat
1177 bool supportsCOMDAT() const {
1178 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
1180 }
1181
1182 /// Tests whether the target uses emulated TLS as default.
1183 ///
1184 /// Note: Android API level 29 (10) introduced ELF TLS.
1186 return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
1188 }
1189
1190 /// True if the target uses TLSDESC by default.
1191 bool hasDefaultTLSDESC() const {
1192 return isAArch64() || (isAndroid() && isRISCV64()) || isOSFuchsia();
1193 }
1194
1195 /// Tests whether the target uses -data-sections as default.
1197 return isOSBinFormatXCOFF() || isWasm();
1198 }
1199
1200 /// Tests if the environment supports dllimport/export annotations.
1201 bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
1202
1203 /// @}
1204 /// @name Mutators
1205 /// @{
1206
1207 /// Set the architecture (first) component of the triple to a known type.
1208 LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch = NoSubArch);
1209
1210 /// Set the vendor (second) component of the triple to a known type.
1211 LLVM_ABI void setVendor(VendorType Kind);
1212
1213 /// Set the operating system (third) component of the triple to a known type.
1214 LLVM_ABI void setOS(OSType Kind);
1215
1216 /// Set the environment (fourth) component of the triple to a known type.
1217 LLVM_ABI void setEnvironment(EnvironmentType Kind);
1218
1219 /// Set the object file format.
1220 LLVM_ABI void setObjectFormat(ObjectFormatType Kind);
1221
1222 /// Set all components to the new triple \p Str.
1223 LLVM_ABI void setTriple(const Twine &Str);
1224
1225 /// Set the architecture (first) component of the triple by name.
1226 LLVM_ABI void setArchName(StringRef Str);
1227
1228 /// Set the vendor (second) component of the triple by name.
1230
1231 /// Set the operating system (third) component of the triple by name.
1232 LLVM_ABI void setOSName(StringRef Str);
1233
1234 /// Set the optional environment (fourth) component of the triple by name.
1236
1237 /// Set the operating system and optional environment components with a single
1238 /// string.
1240
1241 /// @}
1242 /// @name Helpers to build variants of a particular triple.
1243 /// @{
1244
1245 /// Form a triple with a 32-bit variant of the current architecture.
1246 ///
1247 /// This can be used to move across "families" of architectures where useful.
1248 ///
1249 /// \returns A new triple with a 32-bit architecture or an unknown
1250 /// architecture if no such variant can be found.
1252
1253 /// Form a triple with a 64-bit variant of the current architecture.
1254 ///
1255 /// This can be used to move across "families" of architectures where useful.
1256 ///
1257 /// \returns A new triple with a 64-bit architecture or an unknown
1258 /// architecture if no such variant can be found.
1260
1261 /// Form a triple with a big endian variant of the current architecture.
1262 ///
1263 /// This can be used to move across "families" of architectures where useful.
1264 ///
1265 /// \returns A new triple with a big endian architecture or an unknown
1266 /// architecture if no such variant can be found.
1268
1269 /// Form a triple with a little endian variant of the current architecture.
1270 ///
1271 /// This can be used to move across "families" of architectures where useful.
1272 ///
1273 /// \returns A new triple with a little endian architecture or an unknown
1274 /// architecture if no such variant can be found.
1276
1277 /// Tests whether the target triple is little endian.
1278 ///
1279 /// \returns true if the triple is little endian, false otherwise.
1280 LLVM_ABI bool isLittleEndian() const;
1281
1282 /// Test whether target triples are compatible.
1283 LLVM_ABI bool isCompatibleWith(const Triple &Other) const;
1284
1285 /// Test whether the target triple is for a GPU.
1286 bool isGPU() const { return isSPIRV() || isNVPTX() || isAMDGPU(); }
1287
1288 /// Merge target triples.
1289 LLVM_ABI std::string merge(const Triple &Other) const;
1290
1291 /// Some platforms have different minimum supported OS versions that
1292 /// varies by the architecture specified in the triple. This function
1293 /// returns the minimum supported OS version for this triple if one an exists,
1294 /// or an invalid version tuple if this triple doesn't have one.
1296
1297 /// @}
1298 /// @name Static helpers for IDs.
1299 /// @{
1300
1301 /// Get the canonical name for the \p Kind architecture.
1302 LLVM_ABI static StringRef getArchTypeName(ArchType Kind);
1303
1304 /// Get the architecture name based on \p Kind and \p SubArch.
1305 LLVM_ABI static StringRef getArchName(ArchType Kind,
1306 SubArchType SubArch = NoSubArch);
1307
1308 /// Get the "prefix" canonical name for the \p Kind architecture. This is the
1309 /// prefix used by the architecture specific builtins, and is suitable for
1310 /// passing to \see Intrinsic::getIntrinsicForClangBuiltin().
1311 ///
1312 /// \return - The architecture prefix, or 0 if none is defined.
1313 LLVM_ABI static StringRef getArchTypePrefix(ArchType Kind);
1314
1315 /// Get the canonical name for the \p Kind vendor.
1316 LLVM_ABI static StringRef getVendorTypeName(VendorType Kind);
1317
1318 /// Get the canonical name for the \p Kind operating system.
1319 LLVM_ABI static StringRef getOSTypeName(OSType Kind);
1320
1321 /// Get the canonical name for the \p Kind environment.
1322 LLVM_ABI static StringRef getEnvironmentTypeName(EnvironmentType Kind);
1323
1324 /// Get the name for the \p Object format.
1325 LLVM_ABI static StringRef
1326 getObjectFormatTypeName(ObjectFormatType ObjectFormat);
1327
1328 /// @}
1329 /// @name Static helpers for converting alternate architecture names.
1330 /// @{
1331
1332 /// The canonical type for the given LLVM architecture name (e.g., "x86").
1333 LLVM_ABI static ArchType getArchTypeForLLVMName(StringRef Str);
1334
1335 /// @}
1336
1337 /// Returns a canonicalized OS version number for the specified OS.
1338 LLVM_ABI static VersionTuple
1339 getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version,
1340 bool IsInValidRange);
1341
1342 /// Returns whether an OS version is invalid and would not map to an Apple OS.
1343 LLVM_ABI static bool isValidVersionForOS(OSType OSKind,
1344 const VersionTuple &Version);
1345
1347
1348 /// Compute the LLVM IR data layout string based on the triple. Some targets
1349 /// customize the layout based on the ABIName string.
1350 LLVM_ABI std::string computeDataLayout(StringRef ABIName = "") const;
1351};
1352
1353} // End llvm namespace
1354
1355
1356#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:2178
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1455
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1050
bool isOSDragonFly() const
Definition Triple.h:648
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1400
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1566
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1673
bool isTargetMachineMac() const
Returns true for targets that run on a macOS machine.
Definition Triple.h:627
bool isArmT32() const
Tests whether the target is T32.
Definition Triple.h:973
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1665
bool isAndroidVersionLT(unsigned Major) const
Definition Triple.h:829
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:1803
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:719
bool isWatchABI() const
Definition Triple.h:591
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:302
@ LastEnvironmentType
Definition Triple.h:317
@ UnknownEnvironment
Definition Triple.h:254
@ RootSignature
Definition Triple.h:310
@ Amplification
Definition Triple.h:309
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:918
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition Triple.h:810
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1120
bool isPPC64ELFv2ABI() const
Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
Definition Triple.h:1066
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:2232
bool isOSWASI() const
Tests whether the OS is WASI.
Definition Triple.h:745
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition Triple.h:889
CanonicalForm
Canonical form.
Definition Triple.h:388
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition Triple.h:789
bool isDriverKit() const
Is this an Apple DriverKit triple.
Definition Triple.h:602
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:518
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2039
bool isOSHurd() const
Tests whether the OS is Hurd.
Definition Triple.h:740
bool isHardFloatABI() const
Tests if the target forces hardfloat.
Definition Triple.h:1168
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1156
bool isX32() const
Tests whether the target is X32.
Definition Triple.h:1150
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition Triple.cpp:263
Triple(const char *Str)
Definition Triple.h:363
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:439
bool isAArch64(int PointerWidth) const
Tests whether the target is AArch64 and pointers are the size specified by PointerWidth.
Definition Triple.h:1015
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:416
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1112
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1138
std::string normalize(CanonicalForm Form=CanonicalForm::ANY) const
Return the normalized form of this triple's string.
Definition Triple.h:404
bool isTargetEHABICompatible() const
Tests whether the target supports the EHABI exception handling standard.
Definition Triple.h:929
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:781
bool isWindowsGNUEnvironment() const
Definition Triple.h:714
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1677
bool isOSNetBSD() const
Definition Triple.h:632
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:1694
bool isAndroid() const
Tests whether the target is Android.
Definition Triple.h:827
bool hasDefaultTLSDESC() const
True if the target uses TLSDESC by default.
Definition Triple.h:1191
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:1886
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition Triple.h:724
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition Triple.h:784
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2082
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1657
bool isABIN32() const
Definition Triple.h:1144
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1405
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition Triple.h:1177
bool isWindowsCoreCLREnvironment() const
Definition Triple.h:702
bool isSPIROrSPIRV() const
Definition Triple.h:900
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2314
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition Triple.h:1040
@ loongarch32
Definition Triple.h:64
@ renderscript64
Definition Triple.h:111
@ UnknownArch
Definition Triple.h:50
@ loongarch64
Definition Triple.h:65
@ renderscript32
Definition Triple.h:110
bool hasDefaultDataSections() const
Tests whether the target uses -data-sections as default.
Definition Triple.h:1196
bool isTargetGNUAEABI() const
Definition Triple.h:957
bool isOSSolaris() const
Definition Triple.h:650
bool isRISCV32() const
Tests whether the target is 32-bit RISC-V.
Definition Triple.h:1083
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition Triple.h:735
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1641
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:422
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1428
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:1172
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:444
bool isOSVersionLT(const Triple &Other) const
Definition Triple.h:557
bool isPPC32() const
Tests whether the target is 32-bit PowerPC (little and big endian).
Definition Triple.h:1056
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:413
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:1773
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:776
bool isRISCV64() const
Tests whether the target is 64-bit RISC-V.
Definition Triple.h:1088
bool isCSKY() const
Definition Triple.h:1133
bool isLoongArch64() const
Tests whether the target is 64-bit LoongArch.
Definition Triple.h:1029
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1411
bool isSPARC32() const
Tests whether the target is 32-bit SPARC (little and big endian).
Definition Triple.h:1096
bool isSimulatorEnvironment() const
Definition Triple.h:618
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1628
const std::string & str() const
Definition Triple.h:480
bool isOSzOS() const
Definition Triple.h:604
bool isOSSerenity() const
Definition Triple.h:766
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:857
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:430
bool isOSOpenBSD() const
Definition Triple.h:636
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1603
bool isOSUnknown() const
Definition Triple.h:658
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1591
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition Triple.h:1035
bool isShaderModelOS() const
Definition Triple.h:868
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:676
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:681
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:842
const std::string & getTriple() const
Definition Triple.h:482
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:799
bool isGPU() const
Test whether the target triple is for a GPU.
Definition Triple.h:1286
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition Triple.h:794
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:289
bool isTargetMuslAEABI() const
Definition Triple.h:965
@ UnknownObjectFormat
Definition Triple.h:320
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:923
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2169
bool isArmMClass() const
Tests whether the target is an M-class.
Definition Triple.h:993
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:730
bool isBridgeOS() const
Is this an Apple BridgeOS triple.
Definition Triple.h:599
bool isOSManagarm() const
Definition Triple.h:874
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1093
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition Triple.h:913
bool isAMDGPU() const
Definition Triple.h:915
bool isLoongArch32() const
Tests whether the target is 32-bit LoongArch.
Definition Triple.h:1026
bool isOSLiteOS() const
Definition Triple.h:861
@ UnknownVendor
Definition Triple.h:188
@ ImaginationTechnologies
Definition Triple.h:195
@ LastVendorType
Definition Triple.h:205
@ MipsTechnologies
Definition Triple.h:196
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:908
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:762
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2195
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1791
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1417
@ ARMSubArch_v6t2
Definition Triple.h:149
@ MipsSubArch_r6
Definition Triple.h:161
@ DXILSubArch_v1_2
Definition Triple.h:177
@ ARMSubArch_v7
Definition Triple.h:140
@ ARMSubArch_v8m_mainline
Definition Triple.h:138
@ ARMSubArch_v9_6a
Definition Triple.h:119
@ ARMSubArch_v8r
Definition Triple.h:136
@ ARMSubArch_v9_1a
Definition Triple.h:124
@ DXILSubArch_v1_1
Definition Triple.h:176
@ LatestDXILSubArch
Definition Triple.h:185
@ SPIRVSubArch_v10
Definition Triple.h:166
@ SPIRVSubArch_v13
Definition Triple.h:169
@ ARMSubArch_v7k
Definition Triple.h:144
@ ARMSubArch_v8_7a
Definition Triple.h:128
@ ARMSubArch_v8
Definition Triple.h:135
@ SPIRVSubArch_v16
Definition Triple.h:172
@ ARMSubArch_v8_1a
Definition Triple.h:134
@ ARMSubArch_v9_2a
Definition Triple.h:123
@ DXILSubArch_v1_3
Definition Triple.h:178
@ SPIRVSubArch_v15
Definition Triple.h:171
@ ARMSubArch_v7m
Definition Triple.h:142
@ ARMSubArch_v9_7a
Definition Triple.h:118
@ ARMSubArch_v6k
Definition Triple.h:148
@ ARMSubArch_v5
Definition Triple.h:150
@ AArch64SubArch_arm64e
Definition Triple.h:154
@ ARMSubArch_v6
Definition Triple.h:146
@ ARMSubArch_v9_5a
Definition Triple.h:120
@ ARMSubArch_v7ve
Definition Triple.h:145
@ ARMSubArch_v8m_baseline
Definition Triple.h:137
@ ARMSubArch_v8_8a
Definition Triple.h:127
@ ARMSubArch_v8_2a
Definition Triple.h:133
@ ARMSubArch_v7s
Definition Triple.h:143
@ DXILSubArch_v1_0
Definition Triple.h:175
@ DXILSubArch_v1_7
Definition Triple.h:182
@ KalimbaSubArch_v3
Definition Triple.h:157
@ DXILSubArch_v1_5
Definition Triple.h:180
@ ARMSubArch_v8_4a
Definition Triple.h:131
@ ARMSubArch_v8_9a
Definition Triple.h:126
@ ARMSubArch_v7em
Definition Triple.h:141
@ SPIRVSubArch_v12
Definition Triple.h:168
@ SPIRVSubArch_v14
Definition Triple.h:170
@ KalimbaSubArch_v4
Definition Triple.h:158
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:139
@ ARMSubArch_v8_3a
Definition Triple.h:132
@ AArch64SubArch_arm64ec
Definition Triple.h:155
@ ARMSubArch_v8_6a
Definition Triple.h:129
@ ARMSubArch_v5te
Definition Triple.h:151
@ KalimbaSubArch_v5
Definition Triple.h:159
@ ARMSubArch_v4t
Definition Triple.h:152
@ DXILSubArch_v1_6
Definition Triple.h:181
@ DXILSubArch_v1_8
Definition Triple.h:183
@ ARMSubArch_v9_4a
Definition Triple.h:121
@ ARMSubArch_v8_5a
Definition Triple.h:130
@ ARMSubArch_v6m
Definition Triple.h:147
@ ARMSubArch_v9_3a
Definition Triple.h:122
@ DXILSubArch_v1_9
Definition Triple.h:184
@ ARMSubArch_v9
Definition Triple.h:125
@ DXILSubArch_v1_4
Definition Triple.h:179
@ SPIRVSubArch_v11
Definition Triple.h:167
@ PPCSubArch_spe
Definition Triple.h:163
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:1469
bool isSPARC64() const
Tests whether the target is 64-bit SPARC (big endian).
Definition Triple.h:1101
bool isWindowsCygwinEnvironment() const
Definition Triple.h:710
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:2283
Triple(StringRef Str)
Definition Triple.h:362
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:568
Triple(const std::string &Str)
Definition Triple.h:364
bool isOSFreeBSD() const
Definition Triple.h:640
bool isXROS() const
Is this an Apple XROS triple.
Definition Triple.h:596
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1689
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1653
bool isX86_32() const
Tests whether the target is x86 (32-bit).
Definition Triple.h:1117
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1681
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:419
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1104
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition Triple.h:1061
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:613
bool hasDLLImportExport() const
Tests if the environment supports dllimport/export annotations.
Definition Triple.h:1201
bool isSPIRVLogical() const
Tests whether the target is SPIR-V Logical.
Definition Triple.h:903
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:341
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:546
bool isTvOS() const
Is this an Apple tvOS triple.
Definition Triple.h:582
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition Triple.h:750
bool isWindowsArm64EC() const
Definition Triple.h:697
bool operator==(const Triple &Other) const
Definition Triple.h:372
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition Triple.h:587
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:485
bool isiOS() const
Is this an iOS triple.
Definition Triple.h:577
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1045
bool isWALI() const
Tests whether the target uses WALI Wasm.
Definition Triple.h:804
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition Triple.h:755
bool isTargetAEABI() const
Definition Triple.h:951
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:824
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1128
bool isVulkanOS() const
Definition Triple.h:872
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1396
bool isOSIAMCU() const
Definition Triple.h:654
bool isOpenHOS() const
Definition Triple.h:859
bool isMacCatalystEnvironment() const
Definition Triple.h:622
bool isPS5() const
Tests whether the target is the PS5 platform.
Definition Triple.h:817
bool isSPIRV() const
Tests whether the target is SPIR-V (32/64-bit/Logical).
Definition Triple.h:894
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1008
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:414
bool isAppleMachO() const
Is this an Apple MachO triple.
Definition Triple.h:607
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:1799
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:1969
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1517
bool hasDefaultEmulatedTLS() const
Tests whether the target uses emulated TLS as default.
Definition Triple.h:1185
bool isSystemZ() const
Tests whether the target is SystemZ.
Definition Triple.h:1107
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:1432
bool isPPC32SecurePlt() const
Tests whether the target 32-bit PowerPC uses Secure PLT.
Definition Triple.h:1074
bool isTime64ABI() const
Tests if the target forces 64-bit time_t on a 32-bit architecture.
Definition Triple.h:1161
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:1795
bool operator!=(const Triple &Other) const
Definition Triple.h:379
unsigned getOSMajorVersion() const
Return just the major version number, this is specialized because it is a common query.
Definition Triple.h:449
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2134
bool isOSFuchsia() const
Definition Triple.h:644
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:771
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:691
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:425
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition Triple.h:686
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition Triple.cpp:173
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition Triple.h:671
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition Triple.cpp:1645
bool isDXIL() const
Tests whether the target is DXIL.
Definition Triple.h:864
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1649
bool isGNUEnvironment() const
Definition Triple.h:660
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1032
bool isShaderStageEnvironment() const
Definition Triple.h:876
bool isWindowsItaniumEnvironment() const
Definition Triple.h:706
bool isVE() const
Tests whether the target is VE.
Definition Triple.h:1123
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
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302
@ Other
Any other memory.
Definition ModRef.h:68
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:867