LLVM 23.0.0git
Triple.h
Go to the documentation of this file.
1//===-- llvm/TargetParser/Triple.h - Target triple helper class--*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TARGETPARSER_TRIPLE_H
10#define LLVM_TARGETPARSER_TRIPLE_H
11
12#include "llvm/ADT/StringRef.h"
15
16// Some system headers or GCC predefined macros conflict with identifiers in
17// this file. Undefine them here.
18#undef NetBSD
19#undef mips
20#undef sparc
21
22namespace llvm {
23enum class ExceptionHandling;
24class Twine;
25
26/// Triple - Helper class for working with autoconf configuration names. For
27/// historical reasons, we also call these 'triples' (they used to contain
28/// exactly three fields).
29///
30/// Configuration names are strings in the canonical form:
31/// ARCHITECTURE-VENDOR-OPERATING_SYSTEM
32/// or
33/// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
34///
35/// This class is used for clients which want to support arbitrary
36/// configuration names, but also want to implement certain special
37/// behavior for particular configurations. This class isolates the mapping
38/// from the components of the configuration name to well known IDs.
39///
40/// At its core the Triple class is designed to be a wrapper for a triple
41/// string; the constructor does not change or normalize the triple string.
42/// Clients that need to handle the non-canonical triples that users often
43/// specify should use the normalize method.
44///
45/// See autoconf/config.guess for a glimpse into what configuration names
46/// look like in practice.
47class Triple {
48public:
49 enum ArchType {
51
52 arm, // ARM (little endian): arm, armv.*, xscale
53 armeb, // ARM (big endian): armeb
54 aarch64, // AArch64 (little endian): aarch64
55 aarch64_be, // AArch64 (big endian): aarch64_be
56 aarch64_32, // AArch64 (little endian) ILP32: aarch64_32
57 arc, // ARC: Synopsys ARC
58 avr, // AVR: Atmel AVR microcontroller
59 bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
60 bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
61 csky, // CSKY: csky
62 dxil, // DXIL 32-bit DirectX bytecode
63 hexagon, // Hexagon: hexagon
64 loongarch32, // LoongArch (32-bit): loongarch32
65 loongarch64, // LoongArch (64-bit): loongarch64
66 m68k, // M68k: Motorola 680x0 family
67 mips, // MIPS: mips, mipsallegrex, mipsr6
68 mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
69 mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
70 mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
71 msp430, // MSP430: msp430
72 ppc, // PPC: powerpc
73 ppcle, // PPCLE: powerpc (little endian)
74 ppc64, // PPC64: powerpc64, ppu
75 ppc64le, // PPC64LE: powerpc64le
76 r600, // R600: AMD GPUs HD2XXX - HD6XXX
77 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
157
161
163
165
166 // SPIR-V sub-arch corresponds to its version.
174
175 // DXIL sub-arch corresponds to its version.
187 };
208 enum OSType {
210
218 Lv2, // PS3
230 CUDA, // NVIDIA CUDA
231 NVCL, // NVIDIA OpenCL
232 AMDHSA, // AMD HSA Runtime
236 TvOS, // Apple tvOS
237 WatchOS, // Apple watchOS
238 BridgeOS, // Apple bridgeOS
239 DriverKit, // Apple DriverKit
240 XROS, // Apple XROS
242 AMDPAL, // AMD PAL Runtime
243 HermitCore, // HermitCore Unikernel/Multikernel
244 Hurd, // GNU/Hurd
245 WASI, // Deprecated alias of WASI 0.1; in the future will be WASI 1.0.
246 WASIp1, // WASI 0.1
247 WASIp2, // WASI 0.2
248 WASIp3, // WASI 0.3
250 ShaderModel, // DirectX ShaderModel
253 Vulkan, // Vulkan SPIR-V
260 };
263
291
296 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
297 MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
298
299 // Shader Stages
300 // The order of these values matters, and must be kept in sync with the
301 // language options enum in Clang. The ordering is enforced in
302 // static_asserts in Triple.cpp and in Clang.
321
325 };
338
339private:
340 std::string Data;
341
342 /// The parsed arch type.
343 ArchType Arch{};
344
345 /// The parsed subarchitecture type.
346 SubArchType SubArch{};
347
348 /// The parsed vendor type.
349 VendorType Vendor{};
350
351 /// The parsed OS type.
352 OSType OS{};
353
354 /// The parsed Environment type.
355 EnvironmentType Environment{};
356
357 /// The object format type.
358 ObjectFormatType ObjectFormat{};
359
360public:
361 /// @name Constructors
362 /// @{
363
364 /// Default constructor is the same as an empty string and leaves all
365 /// triple fields unknown.
366 Triple() = default;
367
368 LLVM_ABI explicit Triple(std::string &&Str);
369 explicit Triple(StringRef Str) : Triple(Str.str()) {}
370 explicit Triple(const char *Str) : Triple(std::string(Str)) {}
371 explicit Triple(const std::string &Str) : Triple(std::string(Str)) {}
372 LLVM_ABI explicit Triple(const Twine &Str);
373
374 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
375 const Twine &OSStr);
376 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
377 const Twine &OSStr, const Twine &EnvironmentStr);
378
379 bool operator==(const Triple &Other) const {
380 return Arch == Other.Arch && SubArch == Other.SubArch &&
381 Vendor == Other.Vendor && OS == Other.OS &&
382 Environment == Other.Environment &&
383 ObjectFormat == Other.ObjectFormat;
384 }
385
386 bool operator!=(const Triple &Other) const {
387 return !(*this == Other);
388 }
389
390 /// @}
391 /// @name Normalization
392 /// @{
393
394 /// Canonical form
395 enum class CanonicalForm {
396 ANY = 0,
397 THREE_IDENT = 3, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM
398 FOUR_IDENT = 4, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
399 FIVE_IDENT = 5, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT-FORMAT
400 };
401
402 /// Turn an arbitrary machine specification into the canonical triple form (or
403 /// something sensible that the Triple class understands if nothing better can
404 /// reasonably be done). In particular, it handles the common case in which
405 /// otherwise valid components are in the wrong order. \p Form is used to
406 /// specify the output canonical form.
407 LLVM_ABI static std::string
409
410 /// Return the normalized form of this triple's string.
411 std::string normalize(CanonicalForm Form = CanonicalForm::ANY) const {
412 return normalize(Data, Form);
413 }
414
415 /// @}
416 /// @name Typed Component Access
417 /// @{
418
419 /// Get the parsed architecture type of this triple.
420 ArchType getArch() const { return Arch; }
421
422 /// get the parsed subarchitecture type for this triple.
423 SubArchType getSubArch() const { return SubArch; }
424
425 /// Get the parsed vendor type of this triple.
426 VendorType getVendor() const { return Vendor; }
427
428 /// Get the parsed operating system type of this triple.
429 OSType getOS() const { return OS; }
430
431 /// Does this triple have the optional environment (fourth) component?
432 bool hasEnvironment() const {
433 return getEnvironmentName() != "";
434 }
435
436 /// Get the parsed environment type of this triple.
437 EnvironmentType getEnvironment() const { return Environment; }
438
439 /// Parse the version number from the OS name component of the
440 /// triple, if present.
441 ///
442 /// For example, "fooos1.2.3" would return (1, 2, 3).
444
445 /// Get the object format for this triple.
446 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
447
448 /// Parse the version number from the OS name component of the triple, if
449 /// present.
450 ///
451 /// For example, "fooos1.2.3" would return (1, 2, 3).
453
454 /// Return just the major version number, this is specialized because it is a
455 /// common query.
456 unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
457
458 /// Parse the version number as with getOSVersion and then translate generic
459 /// "darwin" versions to the corresponding OS X versions. This may also be
460 /// called with IOS triples but the OS X version number is just set to a
461 /// constant 10.4.0 in that case. Returns true if successful.
463
464 /// Parse the version number as with getOSVersion. This should only be called
465 /// with IOS or generic triples.
467
468 /// Parse the version number as with getOSVersion. This should only be called
469 /// with WatchOS or generic triples.
471
472 /// Parse the version number as with getOSVersion.
474
475 /// Parse the Vulkan version number from the OSVersion and SPIR-V version
476 /// (SubArch). This should only be called with Vulkan SPIR-V triples.
478
479 /// Parse the DXIL version number from the OSVersion and DXIL version
480 /// (SubArch). This should only be called with DXIL triples.
482
483 /// @}
484 /// @name Direct Component Access
485 /// @{
486
487 const std::string &str() const { return Data; }
488
489 const std::string &getTriple() const { return Data; }
490
491 /// Whether the triple is empty / default constructed.
492 bool empty() const { return Data.empty(); }
493
494 /// Get the architecture (first) component of the triple.
496
497 /// Get the vendor (second) component of the triple.
499
500 /// Get the operating system (third) component of the triple.
502
503 /// Get the optional environment (fourth) component of the triple, or "" if
504 /// empty.
506
507 /// Get the operating system and optional environment components as a single
508 /// string (separated by a '-' if the environment component is present).
510
511 /// Get the version component of the environment component as a single
512 /// string (the version after the environment).
513 ///
514 /// For example, "fooos1.2.3" would return "1.2.3".
516
517 /// @}
518 /// @name Convenience Predicates
519 /// @{
520
521 /// Returns the pointer width of this architecture.
523
524 /// Returns the pointer width of this architecture.
525 unsigned getArchPointerBitWidth() const {
527 }
528
529 /// Returns the trampoline size in bytes for this configuration.
530 LLVM_ABI unsigned getTrampolineSize() const;
531
532 /// Test whether the architecture is 64-bit
533 ///
534 /// Note that this tests for 64-bit pointer width, and nothing else. Note
535 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
536 /// 16-bit. The inner details of pointer width for particular architectures
537 /// is not summed up in the triple, and so only a coarse grained predicate
538 /// system is provided.
539 LLVM_ABI bool isArch64Bit() const;
540
541 /// Test whether the architecture is 32-bit
542 ///
543 /// Note that this tests for 32-bit pointer width, and nothing else.
544 LLVM_ABI bool isArch32Bit() const;
545
546 /// Test whether the architecture is 16-bit
547 ///
548 /// Note that this tests for 16-bit pointer width, and nothing else.
549 LLVM_ABI bool isArch16Bit() const;
550
551 /// Helper function for doing comparisons against version numbers included in
552 /// the target triple.
553 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
554 unsigned Micro = 0) const {
555 if (Minor == 0) {
556 return getOSVersion() < VersionTuple(Major);
557 }
558 if (Micro == 0) {
559 return getOSVersion() < VersionTuple(Major, Minor);
560 }
561 return getOSVersion() < VersionTuple(Major, Minor, Micro);
562 }
563
564 bool isOSVersionGE(unsigned Major, unsigned Minor = 0,
565 unsigned Micro = 0) const {
566 return !isOSVersionLT(Major, Minor, Micro);
567 }
568
569 bool isOSVersionLT(const Triple &Other) const {
570 return getOSVersion() < Other.getOSVersion();
571 }
572
573 bool isOSVersionGE(const Triple &Other) const {
574 return getOSVersion() >= Other.getOSVersion();
575 }
576
577 /// Comparison function for checking OS X version compatibility, which handles
578 /// supporting skewed version numbering schemes used by the "darwin" triples.
579 LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
580 unsigned Micro = 0) const;
581
582 bool isMacOSXVersionGE(unsigned Major, unsigned Minor = 0,
583 unsigned Micro = 0) const {
584 return !isMacOSXVersionLT(Major, Minor, Micro);
585 }
586
587 /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
588 /// and "osx" as OS X triples.
589 bool isMacOSX() const {
590 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
591 }
592
593 /// Is this an iOS triple.
594 /// Note: This identifies tvOS as a variant of iOS. If that ever
595 /// changes, i.e., if the two operating systems diverge or their version
596 /// numbers get out of sync, that will need to be changed.
597 /// watchOS has completely different version numbers so it is not included.
598 bool isiOS() const {
599 return getOS() == Triple::IOS || isTvOS();
600 }
601
602 /// Is this an Apple tvOS triple.
603 bool isTvOS() const {
604 return getOS() == Triple::TvOS;
605 }
606
607 /// Is this an Apple watchOS triple.
608 bool isWatchOS() const {
609 return getOS() == Triple::WatchOS;
610 }
611
612 bool isWatchABI() const {
614 }
615
616 /// Is this an Apple XROS triple.
617 bool isXROS() const { return getOS() == Triple::XROS; }
618
619 /// Is this an Apple BridgeOS triple.
620 bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }
621
622 /// Is this an Apple DriverKit triple.
623 bool isDriverKit() const { return getOS() == Triple::DriverKit; }
624
625 bool isOSzOS() const { return getOS() == Triple::ZOS; }
626
627 /// Is this an Apple MachO triple.
628 bool isAppleMachO() const {
629 return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
630 }
631
632 /// Is this an Apple firmware triple.
633 bool isAppleFirmware() const {
634 return (getVendor() == Triple::Apple) && isOSFirmware();
635 }
636
637 /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
638 /// bridgeOS).
639 bool isOSDarwin() const {
640 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
642 // Apple firmware isn't necessarily a Darwin based OS, but for most intents
643 // and purposes it can be treated like a Darwin OS in the compiler.
644 }
645
648 }
649
651 return getEnvironment() == Triple::MacABI;
652 }
653
654 /// Returns true for targets that run on a macOS machine.
655 bool isTargetMachineMac() const {
656 return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
658 }
659
660 bool isOSNetBSD() const {
661 return getOS() == Triple::NetBSD;
662 }
663
664 bool isOSOpenBSD() const {
665 return getOS() == Triple::OpenBSD;
666 }
667
668 bool isOSFreeBSD() const {
669 return getOS() == Triple::FreeBSD;
670 }
671
672 bool isOSFuchsia() const {
673 return getOS() == Triple::Fuchsia;
674 }
675
676 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
677
678 bool isOSSolaris() const {
679 return getOS() == Triple::Solaris;
680 }
681
682 bool isOSIAMCU() const {
683 return getOS() == Triple::ELFIAMCU;
684 }
685
686 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
687
688 bool isGNUEnvironment() const {
690 return Env == Triple::GNU || Env == Triple::GNUT64 ||
691 Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
692 Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
693 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
694 Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
695 Env == Triple::GNUSF || Env == Triple::GNUX32;
696 }
697
698 /// Tests whether the OS is Haiku.
699 bool isOSHaiku() const {
700 return getOS() == Triple::Haiku;
701 }
702
703 /// Tests whether the OS is UEFI.
704 bool isUEFI() const {
705 return getOS() == Triple::UEFI;
706 }
707
708 /// Tests whether the OS is Windows.
709 bool isOSWindows() const {
710 return getOS() == Triple::Win32;
711 }
712
713 /// Checks if the environment is MSVC.
715 return isOSWindows() && getEnvironment() == Triple::MSVC;
716 }
717
718 /// Checks if the environment could be MSVC.
723
724 // Checks if we're using the Windows Arm64EC ABI.
725 bool isWindowsArm64EC() const {
726 return getArch() == Triple::aarch64 &&
728 }
729
732 }
733
736 }
737
740 }
741
743 return isOSWindows() && getEnvironment() == Triple::GNU;
744 }
745
746 /// Tests for either Cygwin or MinGW OS
747 bool isOSCygMing() const {
749 }
750
751 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
756
757 /// Tests whether the OS is Linux.
758 bool isOSLinux() const {
759 return getOS() == Triple::Linux;
760 }
761
762 /// Tests whether the OS is kFreeBSD.
763 bool isOSKFreeBSD() const {
764 return getOS() == Triple::KFreeBSD;
765 }
766
767 /// Tests whether the OS is Hurd.
768 bool isOSHurd() const {
769 return getOS() == Triple::Hurd;
770 }
771
772 /// Tests whether the OS is WASI.
773 bool isOSWASI() const {
774 return getOS() == Triple::WASI || getOS() == Triple::WASIp1 ||
776 }
777
778 /// Tests whether the OS is Emscripten.
779 bool isOSEmscripten() const {
780 return getOS() == Triple::Emscripten;
781 }
782
783 /// Tests whether the OS uses glibc.
784 bool isOSGlibc() const {
785 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
786 getOS() == Triple::Hurd) &&
788 }
789
790 /// Tests whether the OS is AIX.
791 bool isOSAIX() const {
792 return getOS() == Triple::AIX;
793 }
794
795 bool isOSSerenity() const {
796 return getOS() == Triple::Serenity;
797 }
798
799 /// Tests whether the OS is QURT.
800 bool isOSQurt() const { return getOS() == Triple::QURT; }
801
802 /// Tests whether the OS uses the ELF binary format.
803 bool isOSBinFormatELF() const {
804 return getObjectFormat() == Triple::ELF;
805 }
806
807 /// Tests whether the OS uses the COFF binary format.
808 bool isOSBinFormatCOFF() const {
809 return getObjectFormat() == Triple::COFF;
810 }
811
812 /// Tests whether the OS uses the GOFF binary format.
813 bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
814
815 /// Tests whether the environment is MachO.
816 bool isOSBinFormatMachO() const {
817 return getObjectFormat() == Triple::MachO;
818 }
819
820 /// Tests whether the OS uses the Wasm binary format.
821 bool isOSBinFormatWasm() const {
822 return getObjectFormat() == Triple::Wasm;
823 }
824
825 /// Tests whether the OS uses the XCOFF binary format.
826 bool isOSBinFormatXCOFF() const {
827 return getObjectFormat() == Triple::XCOFF;
828 }
829
830 /// Tests whether the OS uses the DXContainer binary format.
833 }
834
835 /// Tests whether the target uses WALI Wasm
836 bool isWALI() const {
837 return getArch() == Triple::wasm32 && isOSLinux() &&
839 }
840
841 /// Tests whether the target is the PS4 platform.
842 bool isPS4() const {
843 return getArch() == Triple::x86_64 &&
844 getVendor() == Triple::SCEI &&
845 getOS() == Triple::PS4;
846 }
847
848 /// Tests whether the target is the PS5 platform.
849 bool isPS5() const {
850 return getArch() == Triple::x86_64 &&
851 getVendor() == Triple::SCEI &&
852 getOS() == Triple::PS5;
853 }
854
855 /// Tests whether the target is the PS4 or PS5 platform.
856 bool isPS() const { return isPS4() || isPS5(); }
857
858 /// Tests whether the target is Android
859 bool isAndroid() const { return getEnvironment() == Triple::Android; }
860
861 bool isAndroidVersionLT(unsigned Major) const {
862 assert(isAndroid() && "Not an Android triple!");
863
865
866 // 64-bit targets did not exist before API level 21 (Lollipop).
867 if (isArch64Bit() && Version.getMajor() < 21)
868 return VersionTuple(21) < VersionTuple(Major);
869
870 return Version < VersionTuple(Major);
871 }
872
873 /// Tests whether the environment is musl-libc
886
887 /// Tests whether the target is OHOS
888 /// LiteOS default enviroment is also OHOS, but omited on triple.
889 bool isOHOSFamily() const { return isOpenHOS() || isOSLiteOS(); }
890
891 bool isOpenHOS() const { return getEnvironment() == Triple::OpenHOS; }
892
893 bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
894
895 /// Tests whether the target is DXIL.
896 bool isDXIL() const {
897 return getArch() == Triple::dxil;
898 }
899
900 bool isShaderModelOS() const {
901 return getOS() == Triple::ShaderModel;
902 }
903
904 bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
905
906 bool isOSManagarm() const { return getOS() == Triple::Managarm; }
907
908 bool isOSFirmware() const { return getOS() == Triple::Firmware; }
909
912 return Env == Triple::Pixel || Env == Triple::Vertex ||
913 Env == Triple::Geometry || Env == Triple::Hull ||
914 Env == Triple::Domain || Env == Triple::Compute ||
915 Env == Triple::Library || Env == Triple::RayGeneration ||
916 Env == Triple::Intersection || Env == Triple::AnyHit ||
917 Env == Triple::ClosestHit || Env == Triple::Miss ||
918 Env == Triple::Callable || Env == Triple::Mesh ||
920 }
921
922 /// Tests whether the target is SPIR (32- or 64-bit).
923 bool isSPIR() const {
924 return getArch() == Triple::spir || getArch() == Triple::spir64;
925 }
926
927 /// Tests whether the target is SPIR-V (32/64-bit/Logical).
928 bool isSPIRV() const {
929 return getArch() == Triple::spirv32 || getArch() == Triple::spirv64 ||
931 }
932
933 // Tests whether the target is SPIR-V or SPIR.
934 bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
935
936 /// Tests whether the target is SPIR-V Logical
937 bool isSPIRVLogical() const {
938 return getArch() == Triple::spirv;
939 }
940
941 /// Tests whether the target is NVPTX (32- or 64-bit).
942 bool isNVPTX() const {
943 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
944 }
945
946 /// Tests whether the target is AMDGCN
947 bool isAMDGCN() const { return getArch() == Triple::amdgcn; }
948
949 bool isAMDGPU() const { return getArch() == Triple::r600 || isAMDGCN(); }
950
951 /// Tests whether the target is Thumb (little and big endian).
952 bool isThumb() const {
953 return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
954 }
955
956 /// Tests whether the target is ARM (little and big endian).
957 bool isARM() const {
958 return getArch() == Triple::arm || getArch() == Triple::armeb;
959 }
960
961 /// Tests whether the target is LFI.
962 bool isLFI() const {
963 return getArch() == Triple::aarch64 &&
965 }
966
967 /// Tests whether the target supports the EHABI exception
968 /// handling standard.
983
984 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
985 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
986 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
987 // even for GNUEABI, so we can make a distinction here and still conform to
988 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
989 // FIXME: The Darwin exception is temporary, while we move users to
990 // "*-*-*-macho" triples as quickly as possible.
991 bool isTargetAEABI() const {
992 return (getEnvironment() == Triple::EABI ||
994 !isOSDarwin() && !isOSWindows();
995 }
996
1004
1005 bool isTargetMuslAEABI() const {
1006 return (getEnvironment() == Triple::MuslEABI ||
1009 !isOSDarwin() && !isOSWindows();
1010 }
1011
1012 /// Tests whether the target is T32.
1013 bool isArmT32() const {
1014 switch (getSubArch()) {
1026 return false;
1027 default:
1028 return true;
1029 }
1030 }
1031
1032 /// Tests whether the target is an M-class.
1033 bool isArmMClass() const {
1034 switch (getSubArch()) {
1041 return true;
1042 default:
1043 return false;
1044 }
1045 }
1046
1047 /// Tests whether the target is AArch64 (little and big endian).
1048 bool isAArch64() const {
1049 return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
1051 }
1052
1053 /// Tests whether the target is AArch64 and pointers are the size specified by
1054 /// \p PointerWidth.
1055 bool isAArch64(int PointerWidth) const {
1056 assert(PointerWidth == 64 || PointerWidth == 32);
1057 if (!isAArch64())
1058 return false;
1059 return getArch() == Triple::aarch64_32 ||
1061 ? PointerWidth == 32
1062 : PointerWidth == 64;
1063 }
1064
1065 bool isAVR() const { return getArch() == Triple::avr; }
1066
1067 /// Tests whether the target is 32-bit LoongArch.
1068 bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
1069
1070 /// Tests whether the target is 64-bit LoongArch.
1071 bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
1072
1073 /// Tests whether the target is LoongArch (32- and 64-bit).
1074 bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
1075
1076 /// Tests whether the target is MIPS 32-bit (little and big endian).
1077 bool isMIPS32() const {
1078 return getArch() == Triple::mips || getArch() == Triple::mipsel;
1079 }
1080
1081 /// Tests whether the target is MIPS 64-bit (little and big endian).
1082 bool isMIPS64() const {
1083 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
1084 }
1085
1086 /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
1087 bool isMIPS() const {
1088 return isMIPS32() || isMIPS64();
1089 }
1090
1091 /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
1092 bool isPPC() const {
1093 return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
1095 }
1096
1097 /// Tests whether the target is 32-bit PowerPC (little and big endian).
1098 bool isPPC32() const {
1099 return getArch() == Triple::ppc || getArch() == Triple::ppcle;
1100 }
1101
1102 /// Tests whether the target is 64-bit PowerPC (little and big endian).
1103 bool isPPC64() const {
1104 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
1105 }
1106
1107 /// Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
1108 bool isPPC64ELFv2ABI() const {
1109 return (getArch() == Triple::ppc64 &&
1110 ((getOS() == Triple::FreeBSD &&
1111 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1112 getOS() == Triple::OpenBSD || isMusl()));
1113 }
1114
1115 /// Tests whether the target 32-bit PowerPC uses Secure PLT.
1116 bool isPPC32SecurePlt() const {
1117 return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
1118 ((getOS() == Triple::FreeBSD &&
1119 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1121 isMusl()));
1122 }
1123
1124 /// Tests whether the target is 32-bit RISC-V.
1125 bool isRISCV32() const {
1127 }
1128
1129 /// Tests whether the target is 64-bit RISC-V.
1130 bool isRISCV64() const {
1132 }
1133
1134 /// Tests whether the target is RISC-V (32- and 64-bit).
1135 bool isRISCV() const { return isRISCV32() || isRISCV64(); }
1136
1137 /// Tests whether the target is 32-bit SPARC (little and big endian).
1138 bool isSPARC32() const {
1139 return getArch() == Triple::sparc || getArch() == Triple::sparcel;
1140 }
1141
1142 /// Tests whether the target is 64-bit SPARC (big endian).
1143 bool isSPARC64() const { return getArch() == Triple::sparcv9; }
1144
1145 /// Tests whether the target is SPARC.
1146 bool isSPARC() const { return isSPARC32() || isSPARC64(); }
1147
1148 /// Tests whether the target is SystemZ.
1149 bool isSystemZ() const {
1150 return getArch() == Triple::systemz;
1151 }
1152
1153 /// Tests whether the target is x86 (32- or 64-bit).
1154 bool isX86() const {
1155 return getArch() == Triple::x86 || getArch() == Triple::x86_64;
1156 }
1157
1158 /// Tests whether the target is x86 (32-bit).
1159 bool isX86_32() const { return getArch() == Triple::x86; }
1160
1161 /// Tests whether the target is x86 (64-bit).
1162 bool isX86_64() const { return getArch() == Triple::x86_64; }
1163
1164 /// Tests whether the target is VE
1165 bool isVE() const {
1166 return getArch() == Triple::ve;
1167 }
1168
1169 /// Tests whether the target is wasm (32- and 64-bit).
1170 bool isWasm() const {
1171 return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
1172 }
1173
1174 // Tests whether the target is CSKY
1175 bool isCSKY() const {
1176 return getArch() == Triple::csky;
1177 }
1178
1179 /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
1180 bool isArm64e() const {
1181 return getArch() == Triple::aarch64 &&
1183 }
1184
1185 // Tests whether the target is N32.
1186 bool isABIN32() const {
1188 return Env == Triple::GNUABIN32 || Env == Triple::MuslABIN32;
1189 }
1190
1191 /// Tests whether the target is X32.
1192 bool isX32() const {
1194 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
1195 }
1196
1197 /// Tests whether the target is eBPF.
1198 bool isBPF() const {
1199 return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
1200 }
1201
1202 /// Tests if the target forces 64-bit time_t on a 32-bit architecture.
1203 bool isTime64ABI() const {
1205 return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1206 Env == Triple::GNUEABIHFT64;
1207 }
1208
1209 /// Tests if the target forces hardfloat.
1210 bool isHardFloatABI() const {
1212 return Env == llvm::Triple::GNUEABIHF ||
1214 Env == llvm::Triple::MuslEABIHF ||
1215 Env == llvm::Triple::EABIHF;
1216 }
1217
1218 /// Tests whether the target supports comdat
1219 bool supportsCOMDAT() const {
1220 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
1222 }
1223
1224 /// Tests whether the target uses emulated TLS as default.
1225 ///
1226 /// Note: Android API level 29 (10) introduced ELF TLS.
1228 return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
1230 }
1231
1232 /// True if the target uses TLSDESC by default.
1233 bool hasDefaultTLSDESC() const {
1234 return isAArch64() || (isAndroid() && isRISCV64()) || isOSFuchsia();
1235 }
1236
1237 /// Tests whether the target uses -data-sections as default.
1239 return isOSBinFormatXCOFF() || isWasm();
1240 }
1241
1242 /// Returns the default wchar_t size (in bytes) for this target triple.
1243 unsigned getDefaultWCharSize() const;
1244
1245 /// Tests if the environment supports dllimport/export annotations.
1246 bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
1247
1248 /// @}
1249 /// @name Mutators
1250 /// @{
1251
1252 /// Set the architecture (first) component of the triple to a known type.
1253 LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch = NoSubArch);
1254
1255 /// Set the vendor (second) component of the triple to a known type.
1256 LLVM_ABI void setVendor(VendorType Kind);
1257
1258 /// Set the operating system (third) component of the triple to a known type.
1259 LLVM_ABI void setOS(OSType Kind);
1260
1261 /// Set the environment (fourth) component of the triple to a known type.
1262 LLVM_ABI void setEnvironment(EnvironmentType Kind);
1263
1264 /// Set the object file format.
1265 LLVM_ABI void setObjectFormat(ObjectFormatType Kind);
1266
1267 /// Set all components to the new triple \p Str.
1268 LLVM_ABI void setTriple(const Twine &Str);
1269
1270 /// Set the architecture (first) component of the triple by name.
1271 LLVM_ABI void setArchName(StringRef Str);
1272
1273 /// Set the vendor (second) component of the triple by name.
1275
1276 /// Set the operating system (third) component of the triple by name.
1277 LLVM_ABI void setOSName(StringRef Str);
1278
1279 /// Set the optional environment (fourth) component of the triple by name.
1281
1282 /// Set the operating system and optional environment components with a single
1283 /// string.
1285
1286 /// @}
1287 /// @name Helpers to build variants of a particular triple.
1288 /// @{
1289
1290 /// Form a triple with a 32-bit variant of the current architecture.
1291 ///
1292 /// This can be used to move across "families" of architectures where useful.
1293 ///
1294 /// \returns A new triple with a 32-bit architecture or an unknown
1295 /// architecture if no such variant can be found.
1297
1298 /// Form a triple with a 64-bit variant of the current architecture.
1299 ///
1300 /// This can be used to move across "families" of architectures where useful.
1301 ///
1302 /// \returns A new triple with a 64-bit architecture or an unknown
1303 /// architecture if no such variant can be found.
1305
1306 /// Form a triple with a big endian variant of the current architecture.
1307 ///
1308 /// This can be used to move across "families" of architectures where useful.
1309 ///
1310 /// \returns A new triple with a big endian architecture or an unknown
1311 /// architecture if no such variant can be found.
1313
1314 /// Form a triple with a little endian variant of the current architecture.
1315 ///
1316 /// This can be used to move across "families" of architectures where useful.
1317 ///
1318 /// \returns A new triple with a little endian architecture or an unknown
1319 /// architecture if no such variant can be found.
1321
1322 /// Tests whether the target triple is little endian.
1323 ///
1324 /// \returns true if the triple is little endian, false otherwise.
1325 LLVM_ABI bool isLittleEndian() const;
1326
1327 /// Test whether target triples are compatible.
1328 LLVM_ABI bool isCompatibleWith(const Triple &Other) const;
1329
1330 /// Test whether the target triple is for a GPU.
1331 bool isGPU() const { return isSPIRV() || isNVPTX() || isAMDGPU(); }
1332
1333 /// Merge target triples.
1334 LLVM_ABI std::string merge(const Triple &Other) const;
1335
1336 /// Some platforms have different minimum supported OS versions that
1337 /// varies by the architecture specified in the triple. This function
1338 /// returns the minimum supported OS version for this triple if one an exists,
1339 /// or an invalid version tuple if this triple doesn't have one.
1341
1342 /// @}
1343 /// @name Static helpers for IDs.
1344 /// @{
1345
1346 /// Get the canonical name for the \p Kind architecture.
1347 LLVM_ABI static StringRef getArchTypeName(ArchType Kind);
1348
1349 /// Get the architecture name based on \p Kind and \p SubArch.
1350 LLVM_ABI static StringRef getArchName(ArchType Kind,
1351 SubArchType SubArch = NoSubArch);
1352
1353 /// Get the "prefix" canonical name for the \p Kind architecture. This is the
1354 /// prefix used by the architecture specific builtins, and is suitable for
1355 /// passing to \see Intrinsic::getIntrinsicForClangBuiltin().
1356 ///
1357 /// \return - The architecture prefix, or 0 if none is defined.
1358 LLVM_ABI static StringRef getArchTypePrefix(ArchType Kind);
1359
1360 /// Get the canonical name for the \p Kind vendor.
1361 LLVM_ABI static StringRef getVendorTypeName(VendorType Kind);
1362
1363 /// Get the canonical name for the \p Kind operating system.
1364 LLVM_ABI static StringRef getOSTypeName(OSType Kind);
1365
1366 /// Get the canonical name for the \p Kind environment.
1367 LLVM_ABI static StringRef getEnvironmentTypeName(EnvironmentType Kind);
1368
1369 /// Get the name for the \p Object format.
1370 LLVM_ABI static StringRef
1371 getObjectFormatTypeName(ObjectFormatType ObjectFormat);
1372
1373 /// @}
1374 /// @name Static helpers for converting alternate architecture names.
1375 /// @{
1376
1377 /// The canonical type for the given LLVM architecture name (e.g., "x86").
1378 LLVM_ABI static ArchType getArchTypeForLLVMName(StringRef Str);
1379
1380 /// @}
1381
1382 /// Returns a canonicalized OS version number for the specified OS.
1383 LLVM_ABI static VersionTuple
1384 getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version,
1385 bool IsInValidRange);
1386
1387 /// Returns whether an OS version is invalid and would not map to an Apple OS.
1388 LLVM_ABI static bool isValidVersionForOS(OSType OSKind,
1389 const VersionTuple &Version);
1390
1392
1393 /// Compute the LLVM IR data layout string based on the triple. Some targets
1394 /// customize the layout based on the ABIName string.
1395 LLVM_ABI std::string computeDataLayout(StringRef ABIName = "") const;
1396};
1397
1398} // End llvm namespace
1399
1400
1401#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:2224
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1485
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1092
bool isOSDragonFly() const
Definition Triple.h:676
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1430
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1600
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1709
bool isTargetMachineMac() const
Returns true for targets that run on a macOS machine.
Definition Triple.h:655
bool isArmT32() const
Tests whether the target is T32.
Definition Triple.h:1013
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1701
bool isAndroidVersionLT(unsigned Major) const
Definition Triple.h:861
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:1839
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:747
bool isWatchABI() const
Definition Triple.h:612
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:310
@ LastEnvironmentType
Definition Triple.h:324
@ UnknownEnvironment
Definition Triple.h:262
@ RootSignature
Definition Triple.h:318
@ Amplification
Definition Triple.h:317
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:952
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition Triple.h:842
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1162
bool isPPC64ELFv2ABI() const
Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
Definition Triple.h:1108
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:2278
bool isOSWASI() const
Tests whether the OS is WASI.
Definition Triple.h:773
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition Triple.h:923
CanonicalForm
Canonical form.
Definition Triple.h:395
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition Triple.h:821
bool isOSQurt() const
Tests whether the OS is QURT.
Definition Triple.h:800
bool isDriverKit() const
Is this an Apple DriverKit triple.
Definition Triple.h:623
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:525
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2075
bool isOSHurd() const
Tests whether the OS is Hurd.
Definition Triple.h:768
bool isHardFloatABI() const
Tests if the target forces hardfloat.
Definition Triple.h:1210
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1198
bool isX32() const
Tests whether the target is X32.
Definition Triple.h:1192
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition Triple.cpp:265
Triple(const char *Str)
Definition Triple.h:370
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:446
bool isAArch64(int PointerWidth) const
Tests whether the target is AArch64 and pointers are the size specified by PointerWidth.
Definition Triple.h:1055
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:423
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1154
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1180
std::string normalize(CanonicalForm Form=CanonicalForm::ANY) const
Return the normalized form of this triple's string.
Definition Triple.h:411
bool isTargetEHABICompatible() const
Tests whether the target supports the EHABI exception handling standard.
Definition Triple.h:969
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:813
bool isWindowsGNUEnvironment() const
Definition Triple.h:742
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1713
bool isOSNetBSD() const
Definition Triple.h:660
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:1730
bool isAndroid() const
Tests whether the target is Android.
Definition Triple.h:859
bool hasDefaultTLSDESC() const
True if the target uses TLSDESC by default.
Definition Triple.h:1233
bool isLFI() const
Tests whether the target is LFI.
Definition Triple.h:962
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:1922
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition Triple.h:752
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition Triple.h:816
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2118
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1693
bool isABIN32() const
Definition Triple.h:1186
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1435
bool isAVR() const
Definition Triple.h:1065
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition Triple.h:1219
bool isWindowsCoreCLREnvironment() const
Definition Triple.h:730
bool isSPIROrSPIRV() const
Definition Triple.h:934
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2360
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition Triple.h:1082
@ 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:1238
bool isTargetGNUAEABI() const
Definition Triple.h:997
bool isOSSolaris() const
Definition Triple.h:678
bool isRISCV32() const
Tests whether the target is 32-bit RISC-V.
Definition Triple.h:1125
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition Triple.h:763
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1677
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:429
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1458
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:1196
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:458
bool isOSVersionLT(const Triple &Other) const
Definition Triple.h:569
bool isPPC32() const
Tests whether the target is 32-bit PowerPC (little and big endian).
Definition Triple.h:1098
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:420
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:1809
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:808
bool isRISCV64() const
Tests whether the target is 64-bit RISC-V.
Definition Triple.h:1130
bool isCSKY() const
Definition Triple.h:1175
bool isLoongArch64() const
Tests whether the target is 64-bit LoongArch.
Definition Triple.h:1071
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1441
bool isSPARC32() const
Tests whether the target is 32-bit SPARC (little and big endian).
Definition Triple.h:1138
bool isSimulatorEnvironment() const
Definition Triple.h:646
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1664
const std::string & str() const
Definition Triple.h:487
bool isOSzOS() const
Definition Triple.h:625
bool isOSSerenity() const
Definition Triple.h:795
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:889
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:437
bool isOSOpenBSD() const
Definition Triple.h:664
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1639
bool isOSUnknown() const
Definition Triple.h:686
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1627
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition Triple.h:1077
bool isShaderModelOS() const
Definition Triple.h:900
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:704
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:709
bool isOSFirmware() const
Definition Triple.h:908
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:874
const std::string & getTriple() const
Definition Triple.h:489
static LLVM_ABI StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition Triple.cpp:24
bool isOSVersionGE(const Triple &Other) const
Definition Triple.h:573
bool isOSBinFormatDXContainer() const
Tests whether the OS uses the DXContainer binary format.
Definition Triple.h:831
bool isGPU() const
Test whether the target triple is for a GPU.
Definition Triple.h:1331
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition Triple.h:826
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:291
bool isTargetMuslAEABI() const
Definition Triple.h:1005
@ UnknownObjectFormat
Definition Triple.h:327
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:957
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2215
bool isArmMClass() const
Tests whether the target is an M-class.
Definition Triple.h:1033
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:758
bool isBridgeOS() const
Is this an Apple BridgeOS triple.
Definition Triple.h:620
bool isOSManagarm() const
Definition Triple.h:906
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1135
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition Triple.h:947
bool isAMDGPU() const
Definition Triple.h:949
bool isLoongArch32() const
Tests whether the target is 32-bit LoongArch.
Definition Triple.h:1068
bool isOSLiteOS() const
Definition Triple.h:893
@ UnknownVendor
Definition Triple.h:189
@ ImaginationTechnologies
Definition Triple.h:196
@ LastVendorType
Definition Triple.h:206
@ MipsTechnologies
Definition Triple.h:197
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:942
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:791
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2241
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1827
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1447
@ ARMSubArch_v6t2
Definition Triple.h:149
@ MipsSubArch_r6
Definition Triple.h:162
@ DXILSubArch_v1_2
Definition Triple.h:178
@ 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:177
@ LatestDXILSubArch
Definition Triple.h:186
@ SPIRVSubArch_v10
Definition Triple.h:167
@ SPIRVSubArch_v13
Definition Triple.h:170
@ ARMSubArch_v7k
Definition Triple.h:144
@ ARMSubArch_v8_7a
Definition Triple.h:128
@ ARMSubArch_v8
Definition Triple.h:135
@ SPIRVSubArch_v16
Definition Triple.h:173
@ ARMSubArch_v8_1a
Definition Triple.h:134
@ ARMSubArch_v9_2a
Definition Triple.h:123
@ DXILSubArch_v1_3
Definition Triple.h:179
@ SPIRVSubArch_v15
Definition Triple.h:172
@ 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:176
@ DXILSubArch_v1_7
Definition Triple.h:183
@ KalimbaSubArch_v3
Definition Triple.h:158
@ DXILSubArch_v1_5
Definition Triple.h:181
@ 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:169
@ SPIRVSubArch_v14
Definition Triple.h:171
@ KalimbaSubArch_v4
Definition Triple.h:159
@ 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:160
@ ARMSubArch_v4t
Definition Triple.h:152
@ DXILSubArch_v1_6
Definition Triple.h:182
@ DXILSubArch_v1_8
Definition Triple.h:184
@ ARMSubArch_v9_4a
Definition Triple.h:121
@ ARMSubArch_v8_5a
Definition Triple.h:130
@ AArch64SubArch_lfi
Definition Triple.h:156
@ ARMSubArch_v6m
Definition Triple.h:147
@ ARMSubArch_v9_3a
Definition Triple.h:122
@ DXILSubArch_v1_9
Definition Triple.h:185
@ ARMSubArch_v9
Definition Triple.h:125
@ DXILSubArch_v1_4
Definition Triple.h:180
@ SPIRVSubArch_v11
Definition Triple.h:168
@ PPCSubArch_spe
Definition Triple.h:164
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:1499
bool isSPARC64() const
Tests whether the target is 64-bit SPARC (big endian).
Definition Triple.h:1143
bool isWindowsCygwinEnvironment() const
Definition Triple.h:738
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:2329
Triple(StringRef Str)
Definition Triple.h:369
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:589
Triple(const std::string &Str)
Definition Triple.h:371
bool isOSFreeBSD() const
Definition Triple.h:668
bool isXROS() const
Is this an Apple XROS triple.
Definition Triple.h:617
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1725
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1689
bool isX86_32() const
Tests whether the target is x86 (32-bit).
Definition Triple.h:1159
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1717
bool isAppleFirmware() const
Is this an Apple firmware triple.
Definition Triple.h:633
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:426
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1146
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition Triple.h:1103
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:639
bool hasDLLImportExport() const
Tests if the environment supports dllimport/export annotations.
Definition Triple.h:1246
bool isSPIRVLogical() const
Tests whether the target is SPIR-V Logical.
Definition Triple.h:937
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:357
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:553
bool isTvOS() const
Is this an Apple tvOS triple.
Definition Triple.h:603
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition Triple.h:779
bool isWindowsArm64EC() const
Definition Triple.h:725
bool isOSVersionGE(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Definition Triple.h:564
bool operator==(const Triple &Other) const
Definition Triple.h:379
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition Triple.h:608
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:492
bool isiOS() const
Is this an iOS triple.
Definition Triple.h:598
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1087
bool isMacOSXVersionGE(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Definition Triple.h:582
bool isWALI() const
Tests whether the target uses WALI Wasm.
Definition Triple.h:836
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition Triple.h:784
bool isTargetAEABI() const
Definition Triple.h:991
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:856
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1170
bool isVulkanOS() const
Definition Triple.h:904
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1426
bool isOSIAMCU() const
Definition Triple.h:682
bool isOpenHOS() const
Definition Triple.h:891
bool isMacCatalystEnvironment() const
Definition Triple.h:650
bool isPS5() const
Tests whether the target is the PS5 platform.
Definition Triple.h:849
bool isSPIRV() const
Tests whether the target is SPIR-V (32/64-bit/Logical).
Definition Triple.h:928
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1048
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:428
bool isAppleMachO() const
Is this an Apple MachO triple.
Definition Triple.h:628
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:1835
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2005
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1549
bool hasDefaultEmulatedTLS() const
Tests whether the target uses emulated TLS as default.
Definition Triple.h:1227
bool isSystemZ() const
Tests whether the target is SystemZ.
Definition Triple.h:1149
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:1462
bool isPPC32SecurePlt() const
Tests whether the target 32-bit PowerPC uses Secure PLT.
Definition Triple.h:1116
bool isTime64ABI() const
Tests if the target forces 64-bit time_t on a 32-bit architecture.
Definition Triple.h:1203
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:1831
bool operator!=(const Triple &Other) const
Definition Triple.h:386
unsigned getOSMajorVersion() const
Return just the major version number, this is specialized because it is a common query.
Definition Triple.h:456
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2180
bool isOSFuchsia() const
Definition Triple.h:672
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:803
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:719
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:432
unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2170
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition Triple.h:714
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition Triple.cpp:175
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition Triple.h:699
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition Triple.cpp:1681
bool isDXIL() const
Tests whether the target is DXIL.
Definition Triple.h:896
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1685
bool isGNUEnvironment() const
Definition Triple.h:688
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1074
bool isShaderStageEnvironment() const
Definition Triple.h:910
bool isWindowsItaniumEnvironment() const
Definition Triple.h:734
bool isVE() const
Tests whether the target is VE.
Definition Triple.h:1165
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.
Definition Types.h:26
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:870