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 // OpenASIP (http://openasip.org) / big endian 32b targets: tce
88 // OpenASIP (http://openasip.org) / little endian 32b targets: tcele
90 // OpenASIP (http://openasip.org) / little endian 64b targets: tcele
92 thumb, // Thumb (little endian): thumb, thumbv.*
93 thumbeb, // Thumb (big endian): thumbeb
94 x86, // X86: i[3-9]86
95 x86_64, // X86-64: amd64, x86_64
96 xcore, // XCore: xcore
97 xtensa, // Tensilica: Xtensa
98 nvptx, // NVPTX: 32-bit
99 nvptx64, // NVPTX: 64-bit
100 amdil, // AMDIL
101 amdil64, // AMDIL with 64-bit pointers
102 hsail, // AMD HSAIL
103 hsail64, // AMD HSAIL with 64-bit pointers
104 spir, // SPIR: standard portable IR for OpenCL 32-bit version
105 spir64, // SPIR: standard portable IR for OpenCL 64-bit version
106 spirv, // SPIR-V with logical memory layout.
107 spirv32, // SPIR-V with 32-bit pointers
108 spirv64, // SPIR-V with 64-bit pointers
109 kalimba, // Kalimba: generic kalimba
110 shave, // SHAVE: Movidius vector VLIW processors
111 lanai, // Lanai: Lanai 32-bit
112 wasm32, // WebAssembly with 32-bit pointers
113 wasm64, // WebAssembly with 64-bit pointers
114 renderscript32, // 32-bit RenderScript
115 renderscript64, // 64-bit RenderScript
116 ve, // NEC SX-Aurora Vector Engine
118 };
121
157
161
165
167
169
170 // SPIR-V sub-arch corresponds to its version.
178
179 // DXIL sub-arch corresponds to its version.
191 };
212 enum OSType {
214
222 Lv2, // PS3
234 CUDA, // NVIDIA CUDA
235 NVCL, // NVIDIA OpenCL
236 AMDHSA, // AMD HSA Runtime
240 TvOS, // Apple tvOS
241 WatchOS, // Apple watchOS
242 BridgeOS, // Apple bridgeOS
243 DriverKit, // Apple DriverKit
244 XROS, // Apple XROS
246 AMDPAL, // AMD PAL Runtime
247 HermitCore, // HermitCore Unikernel/Multikernel
248 Hurd, // GNU/Hurd
249 WASI, // Deprecated alias of WASI 0.1; in the future will be WASI 1.0.
250 WASIp1, // WASI 0.1
251 WASIp2, // WASI 0.2
252 WASIp3, // WASI 0.3
254 ShaderModel, // DirectX ShaderModel
257 Vulkan, // Vulkan SPIR-V
264 };
267
295
300 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
301 MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
302
303 // Shader Stages
304 // The order of these values matters, and must be kept in sync with the
305 // language options enum in Clang. The ordering is enforced in
306 // static_asserts in Triple.cpp and in Clang.
325
329 };
342
343private:
344 std::string Data;
345
346 /// The parsed arch type.
347 ArchType Arch{};
348
349 /// The parsed subarchitecture type.
350 SubArchType SubArch{};
351
352 /// The parsed vendor type.
353 VendorType Vendor{};
354
355 /// The parsed OS type.
356 OSType OS{};
357
358 /// The parsed Environment type.
359 EnvironmentType Environment{};
360
361 /// The object format type.
362 ObjectFormatType ObjectFormat{};
363
364public:
365 /// @name Constructors
366 /// @{
367
368 /// Default constructor is the same as an empty string and leaves all
369 /// triple fields unknown.
370 Triple() = default;
371
372 LLVM_ABI explicit Triple(std::string &&Str);
373 explicit Triple(StringRef Str) : Triple(Str.str()) {}
374 explicit Triple(const char *Str) : Triple(std::string(Str)) {}
375 explicit Triple(const std::string &Str) : Triple(std::string(Str)) {}
376 LLVM_ABI explicit Triple(const Twine &Str);
377
378 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
379 const Twine &OSStr);
380 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
381 const Twine &OSStr, const Twine &EnvironmentStr);
382 LLVM_ABI Triple(ArchType A, SubArchType SA = NoSubArch,
383 VendorType V = UnknownVendor, OSType OS = UnknownOS);
384 LLVM_ABI Triple(ArchType A, SubArchType SA, VendorType V, OSType OS,
385 EnvironmentType E);
386 LLVM_ABI Triple(ArchType A, SubArchType SA, VendorType V, OSType OS,
387 EnvironmentType E, ObjectFormatType OF);
388
389 bool operator==(const Triple &Other) const {
390 return Arch == Other.Arch && SubArch == Other.SubArch &&
391 Vendor == Other.Vendor && OS == Other.OS &&
392 Environment == Other.Environment &&
393 ObjectFormat == Other.ObjectFormat;
394 }
395
396 bool operator!=(const Triple &Other) const { return !(*this == Other); }
397
398 bool operator<(const Triple &Other) const {
399 return std::tie(Arch, SubArch, Vendor, OS, Environment, ObjectFormat,
400 Data) < std::tie(Other.Arch, Other.SubArch, Other.Vendor,
401 Other.OS, Other.Environment,
402 Other.ObjectFormat, Other.Data);
403 }
404
405 /// @}
406 /// @name Normalization
407 /// @{
408
409 /// Canonical form
410 enum class CanonicalForm {
411 ANY = 0,
412 THREE_IDENT = 3, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM
413 FOUR_IDENT = 4, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
414 FIVE_IDENT = 5, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT-FORMAT
415 };
416
417 /// Turn an arbitrary machine specification into the canonical triple form (or
418 /// something sensible that the Triple class understands if nothing better can
419 /// reasonably be done). In particular, it handles the common case in which
420 /// otherwise valid components are in the wrong order. \p Form is used to
421 /// specify the output canonical form.
422 LLVM_ABI static std::string
424
425 /// Return the normalized form of this triple's string.
426 std::string normalize(CanonicalForm Form = CanonicalForm::ANY) const {
427 return normalize(Data, Form);
428 }
429
430 /// @}
431 /// @name Typed Component Access
432 /// @{
433
434 /// Get the parsed architecture type of this triple.
435 ArchType getArch() const { return Arch; }
436
437 /// get the parsed subarchitecture type for this triple.
438 SubArchType getSubArch() const { return SubArch; }
439
440 /// Get the parsed vendor type of this triple.
441 VendorType getVendor() const { return Vendor; }
442
443 /// Get the parsed operating system type of this triple.
444 OSType getOS() const { return OS; }
445
446 /// Does this triple have the optional environment (fourth) component?
447 bool hasEnvironment() const { return getEnvironmentName() != ""; }
448
449 /// Get the parsed environment type of this triple.
450 EnvironmentType getEnvironment() const { return Environment; }
451
452 /// Parse the version number from the OS name component of the
453 /// triple, if present.
454 ///
455 /// For example, "fooos1.2.3" would return (1, 2, 3).
457
458 /// Get the object format for this triple.
459 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
460
461 /// Parse the version number from the OS name component of the triple, if
462 /// present.
463 ///
464 /// For example, "fooos1.2.3" would return (1, 2, 3).
466
467 /// Return just the major version number, this is specialized because it is a
468 /// common query.
469 unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
470
471 /// Parse the version number as with getOSVersion and then translate generic
472 /// "darwin" versions to the corresponding OS X versions. This may also be
473 /// called with IOS triples but the OS X version number is just set to a
474 /// constant 10.4.0 in that case. Returns true if successful.
476
477 /// Parse the version number as with getOSVersion. This should only be called
478 /// with IOS or generic triples.
480
481 /// Parse the version number as with getOSVersion. This should only be called
482 /// with WatchOS or generic triples.
484
485 /// Parse the version number as with getOSVersion.
487
488 /// Parse the Vulkan version number from the OSVersion and SPIR-V version
489 /// (SubArch). This should only be called with Vulkan SPIR-V triples.
491
492 /// Parse the DXIL version number from the OSVersion and DXIL version
493 /// (SubArch). This should only be called with DXIL triples.
495
496 /// @}
497 /// @name Direct Component Access
498 /// @{
499
500 const std::string &str() const { return Data; }
501
502 const std::string &getTriple() const { return Data; }
503
504 /// Whether the triple is empty / default constructed.
505 bool empty() const { return Data.empty(); }
506
507 /// Get the architecture (first) component of the triple.
509
510 /// Get the vendor (second) component of the triple.
512
513 /// Get the operating system (third) component of the triple.
515
516 /// Get the optional environment (fourth) component of the triple, or "" if
517 /// empty.
519
520 /// Get the operating system and optional environment components as a single
521 /// string (separated by a '-' if the environment component is present).
523
524 /// Get the version component of the environment component as a single
525 /// string (the version after the environment).
526 ///
527 /// For example, "fooos1.2.3" would return "1.2.3".
529
530 /// @}
531 /// @name Convenience Predicates
532 /// @{
533
534 /// Returns the pointer width of this architecture.
536
537 /// Returns the pointer width of this architecture.
538 unsigned getArchPointerBitWidth() const {
540 }
541
542 /// Returns the trampoline size in bytes for this configuration.
543 LLVM_ABI unsigned getTrampolineSize() const;
544
545 /// Test whether the architecture is 64-bit
546 ///
547 /// Note that this tests for 64-bit pointer width, and nothing else. Note
548 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
549 /// 16-bit. The inner details of pointer width for particular architectures
550 /// is not summed up in the triple, and so only a coarse grained predicate
551 /// system is provided.
552 LLVM_ABI bool isArch64Bit() const;
553
554 /// Test whether the architecture is 32-bit
555 ///
556 /// Note that this tests for 32-bit pointer width, and nothing else.
557 LLVM_ABI bool isArch32Bit() const;
558
559 /// Test whether the architecture is 16-bit
560 ///
561 /// Note that this tests for 16-bit pointer width, and nothing else.
562 LLVM_ABI bool isArch16Bit() const;
563
564 /// Helper function for doing comparisons against version numbers included in
565 /// the target triple.
566 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
567 unsigned Micro = 0) const {
568 if (Minor == 0) {
569 return getOSVersion() < VersionTuple(Major);
570 }
571 if (Micro == 0) {
572 return getOSVersion() < VersionTuple(Major, Minor);
573 }
574 return getOSVersion() < VersionTuple(Major, Minor, Micro);
575 }
576
577 bool isOSVersionGE(unsigned Major, unsigned Minor = 0,
578 unsigned Micro = 0) const {
579 return !isOSVersionLT(Major, Minor, Micro);
580 }
581
582 bool isOSVersionLT(const Triple &Other) const {
583 return getOSVersion() < Other.getOSVersion();
584 }
585
586 bool isOSVersionGE(const Triple &Other) const {
587 return getOSVersion() >= Other.getOSVersion();
588 }
589
590 /// Comparison function for checking OS X version compatibility, which handles
591 /// supporting skewed version numbering schemes used by the "darwin" triples.
592 LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
593 unsigned Micro = 0) const;
594
595 bool isMacOSXVersionGE(unsigned Major, unsigned Minor = 0,
596 unsigned Micro = 0) const {
597 return !isMacOSXVersionLT(Major, Minor, Micro);
598 }
599
600 /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
601 /// and "osx" as OS X triples.
602 bool isMacOSX() const {
603 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
604 }
605
606 /// Is this an iOS triple.
607 /// Note: This identifies tvOS as a variant of iOS. If that ever
608 /// changes, i.e., if the two operating systems diverge or their version
609 /// numbers get out of sync, that will need to be changed.
610 /// watchOS has completely different version numbers so it is not included.
611 bool isiOS() const { return getOS() == Triple::IOS || isTvOS(); }
612
613 /// Is this an Apple tvOS triple.
614 bool isTvOS() const { return getOS() == Triple::TvOS; }
615
616 /// Is this an Apple watchOS triple.
617 bool isWatchOS() const { return getOS() == Triple::WatchOS; }
618
619 bool isWatchABI() const { return getSubArch() == Triple::ARMSubArch_v7k; }
620
621 /// Is this an Apple XROS triple.
622 bool isXROS() const { return getOS() == Triple::XROS; }
623
624 /// Is this an Apple BridgeOS triple.
625 bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }
626
627 /// Is this an Apple DriverKit triple.
628 bool isDriverKit() const { return getOS() == Triple::DriverKit; }
629
630 bool isOSzOS() const { return getOS() == Triple::ZOS; }
631
632 /// Is this an Apple MachO triple.
633 bool isAppleMachO() const {
634 return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
635 }
636
637 /// Is this an Apple firmware triple.
638 bool isAppleFirmware() const {
639 return (getVendor() == Triple::Apple) && isOSFirmware();
640 }
641
642 /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
643 /// bridgeOS).
644 bool isOSDarwin() const {
645 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
647 // Apple firmware isn't necessarily a Darwin based OS, but for most intents
648 // and purposes it can be treated like a Darwin OS in the compiler.
649 }
650
653 }
654
656 return getEnvironment() == Triple::MacABI;
657 }
658
659 /// Returns true for targets that run on a macOS machine.
660 bool isTargetMachineMac() const {
661 return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
663 }
664
665 bool isOSNetBSD() const { return getOS() == Triple::NetBSD; }
666
667 bool isOSOpenBSD() const { return getOS() == Triple::OpenBSD; }
668
669 bool isOSFreeBSD() const { return getOS() == Triple::FreeBSD; }
670
671 bool isOSFuchsia() const { return getOS() == Triple::Fuchsia; }
672
673 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
674
675 bool isOSSolaris() const { return getOS() == Triple::Solaris; }
676
677 bool isOSIAMCU() const { return getOS() == Triple::ELFIAMCU; }
678
679 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
680
681 bool isGNUEnvironment() const {
683 return Env == Triple::GNU || Env == Triple::GNUT64 ||
684 Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
685 Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
686 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
687 Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
688 Env == Triple::GNUSF || Env == Triple::GNUX32;
689 }
690
691 /// Tests whether the OS is Haiku.
692 bool isOSHaiku() const { return getOS() == Triple::Haiku; }
693
694 /// Tests whether the OS is UEFI.
695 bool isUEFI() const { return getOS() == Triple::UEFI; }
696
697 /// Tests whether the OS is Windows.
698 bool isOSWindows() const { return getOS() == Triple::Win32; }
699
700 /// Checks if the environment is MSVC.
702 return isOSWindows() && getEnvironment() == Triple::MSVC;
703 }
704
705 /// Checks if the environment could be MSVC.
710
711 // Checks if we're using the Windows Arm64EC ABI.
712 bool isWindowsArm64EC() const {
713 return getArch() == Triple::aarch64 &&
715 }
716
719 }
720
723 }
724
727 }
728
730 return isOSWindows() && getEnvironment() == Triple::GNU;
731 }
732
733 /// Tests for either Cygwin or MinGW OS
734 bool isOSCygMing() const {
736 }
737
738 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
743
744 /// Tests whether the OS is Linux.
745 bool isOSLinux() const { return getOS() == Triple::Linux; }
746
747 /// Tests whether the OS is kFreeBSD.
748 bool isOSKFreeBSD() const { return getOS() == Triple::KFreeBSD; }
749
750 /// Tests whether the OS is Hurd.
751 bool isOSHurd() const { return getOS() == Triple::Hurd; }
752
753 /// Tests whether the OS is WASI.
754 bool isOSWASI() const {
755 return getOS() == Triple::WASI || getOS() == Triple::WASIp1 ||
757 }
758
759 /// Tests whether the OS is Emscripten.
760 bool isOSEmscripten() const { return getOS() == Triple::Emscripten; }
761
762 /// Tests whether the OS uses glibc.
763 bool isOSGlibc() const {
764 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
765 getOS() == Triple::Hurd) &&
767 }
768
769 /// Tests whether the OS is AIX.
770 bool isOSAIX() const { return getOS() == Triple::AIX; }
771
772 bool isOSSerenity() const { return getOS() == Triple::Serenity; }
773
774 /// Tests whether the OS is QURT.
775 bool isOSQurt() const { return getOS() == Triple::QURT; }
776
777 /// Tests whether the OS uses the ELF binary format.
778 bool isOSBinFormatELF() const { return getObjectFormat() == Triple::ELF; }
779
780 /// Tests whether the OS uses the COFF binary format.
781 bool isOSBinFormatCOFF() const { return getObjectFormat() == Triple::COFF; }
782
783 /// Tests whether the OS uses the GOFF binary format.
784 bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
785
786 /// Tests whether the environment is MachO.
788
789 /// Tests whether the OS uses the Wasm binary format.
790 bool isOSBinFormatWasm() const { return getObjectFormat() == Triple::Wasm; }
791
792 /// Tests whether the OS uses the XCOFF binary format.
794
795 /// Tests whether the OS uses the DXContainer binary format.
798 }
799
800 /// Tests whether the target uses WALI Wasm
801 bool isWALI() const {
802 return getArch() == Triple::wasm32 && isOSLinux() &&
804 }
805
806 /// Tests whether the target is the PS4 platform.
807 bool isPS4() const {
808 return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
809 getOS() == Triple::PS4;
810 }
811
812 /// Tests whether the target is the PS5 platform.
813 bool isPS5() const {
814 return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
815 getOS() == Triple::PS5;
816 }
817
818 /// Tests whether the target is the PS4 or PS5 platform.
819 bool isPS() const { return isPS4() || isPS5(); }
820
821 /// Tests whether the target is Android
822 bool isAndroid() const { return getEnvironment() == Triple::Android; }
823
824 bool isAndroidVersionLT(unsigned Major) const {
825 assert(isAndroid() && "Not an Android triple!");
826
828
829 // 64-bit targets did not exist before API level 21 (Lollipop).
830 if (isArch64Bit() && Version.getMajor() < 21)
831 return VersionTuple(21) < VersionTuple(Major);
832
833 return Version < VersionTuple(Major);
834 }
835
836 /// Tests whether the environment is musl-libc
849
850 /// Tests whether the target is OHOS
851 /// LiteOS default enviroment is also OHOS, but omited on triple.
852 bool isOHOSFamily() const { return isOpenHOS() || isOSLiteOS(); }
853
854 bool isOpenHOS() const { return getEnvironment() == Triple::OpenHOS; }
855
856 bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
857
858 /// Tests whether the target is DXIL.
859 bool isDXIL() const { return getArch() == Triple::dxil; }
860
861 bool isShaderModelOS() const { return getOS() == Triple::ShaderModel; }
862
863 bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
864
865 bool isOSManagarm() const { return getOS() == Triple::Managarm; }
866
867 bool isOSFirmware() const { return getOS() == Triple::Firmware; }
868
871 return Env == Triple::Pixel || Env == Triple::Vertex ||
872 Env == Triple::Geometry || Env == Triple::Hull ||
873 Env == Triple::Domain || Env == Triple::Compute ||
874 Env == Triple::Library || Env == Triple::RayGeneration ||
875 Env == Triple::Intersection || Env == Triple::AnyHit ||
876 Env == Triple::ClosestHit || Env == Triple::Miss ||
877 Env == Triple::Callable || Env == Triple::Mesh ||
879 }
880
881 /// Tests whether the target is SPIR (32- or 64-bit).
882 bool isSPIR() const {
883 return getArch() == Triple::spir || getArch() == Triple::spir64;
884 }
885
886 /// Tests whether the target is SPIR-V (32/64-bit/Logical).
887 bool isSPIRV() const {
888 return getArch() == Triple::spirv32 || getArch() == Triple::spirv64 ||
890 }
891
892 // Tests whether the target is SPIR-V or SPIR.
893 bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
894
895 /// Tests whether the target is SPIR-V Logical
896 bool isSPIRVLogical() const { return getArch() == Triple::spirv; }
897
898 /// Tests whether the target is NVPTX (32- or 64-bit).
899 bool isNVPTX() const {
900 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
901 }
902
903 /// Tests whether the target is AMDGCN
904 bool isAMDGCN() const { return getArch() == Triple::amdgcn; }
905
906 bool isAMDGPU() const { return getArch() == Triple::r600 || isAMDGCN(); }
907
908 /// Tests whether the target is Thumb (little and big endian).
909 bool isThumb() const {
910 return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
911 }
912
913 /// Tests whether the target is ARM (little and big endian).
914 bool isARM() const {
915 return getArch() == Triple::arm || getArch() == Triple::armeb;
916 }
917
918 /// Tests whether the target is LFI.
919 bool isLFI() const {
920 return getArch() == Triple::aarch64 &&
922 }
923
924 /// Tests whether the target supports the EHABI exception
925 /// handling standard.
940
941 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
942 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
943 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
944 // even for GNUEABI, so we can make a distinction here and still conform to
945 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
946 // FIXME: The Darwin exception is temporary, while we move users to
947 // "*-*-*-macho" triples as quickly as possible.
948 bool isTargetAEABI() const {
949 return (getEnvironment() == Triple::EABI ||
951 !isOSDarwin() && !isOSWindows();
952 }
953
961
962 bool isTargetMuslAEABI() const {
963 return (getEnvironment() == Triple::MuslEABI ||
966 !isOSDarwin() && !isOSWindows();
967 }
968
969 /// Tests whether the target is T32.
970 bool isArmT32() const {
971 switch (getSubArch()) {
983 return false;
984 default:
985 return true;
986 }
987 }
988
989 /// Tests whether the target is an M-class.
990 bool isArmMClass() const {
991 switch (getSubArch()) {
998 return true;
999 default:
1000 return false;
1001 }
1002 }
1003
1004 /// Tests whether the target is AArch64 (little and big endian).
1005 bool isAArch64() const {
1006 return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
1008 }
1009
1010 /// Tests whether the target is AArch64 and pointers are the size specified by
1011 /// \p PointerWidth.
1012 bool isAArch64(int PointerWidth) const {
1013 assert(PointerWidth == 64 || PointerWidth == 32);
1014 if (!isAArch64())
1015 return false;
1016 return getArch() == Triple::aarch64_32 ||
1018 ? PointerWidth == 32
1019 : PointerWidth == 64;
1020 }
1021
1022 bool isAVR() const { return getArch() == Triple::avr; }
1023
1024 /// Tests whether the target is 32-bit LoongArch.
1025 bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
1026
1027 /// Tests whether the target is 64-bit LoongArch.
1028 bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
1029
1030 /// Tests whether the target is LoongArch (32- and 64-bit).
1031 bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
1032
1033 /// Tests whether the target is MIPS 32-bit (little and big endian).
1034 bool isMIPS32() const {
1035 return getArch() == Triple::mips || getArch() == Triple::mipsel;
1036 }
1037
1038 /// Tests whether the target is MIPS 64-bit (little and big endian).
1039 bool isMIPS64() const {
1040 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
1041 }
1042
1043 /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
1044 bool isMIPS() const { return isMIPS32() || isMIPS64(); }
1045
1046 /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
1047 bool isPPC() const {
1048 return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
1050 }
1051
1052 /// Tests whether the target is 32-bit PowerPC (little and big endian).
1053 bool isPPC32() const {
1054 return getArch() == Triple::ppc || getArch() == Triple::ppcle;
1055 }
1056
1057 /// Tests whether the target is 64-bit PowerPC (little and big endian).
1058 bool isPPC64() const {
1059 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
1060 }
1061
1062 /// Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
1063 bool isPPC64ELFv2ABI() const {
1064 return (getArch() == Triple::ppc64 &&
1065 ((getOS() == Triple::FreeBSD &&
1066 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1067 getOS() == Triple::OpenBSD || isMusl()));
1068 }
1069
1070 /// Tests whether the target 32-bit PowerPC uses Secure PLT.
1071 bool isPPC32SecurePlt() const {
1072 return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
1073 ((getOS() == Triple::FreeBSD &&
1074 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1076 isMusl()));
1077 }
1078
1079 /// Tests whether the target is 32-bit RISC-V.
1080 bool isRISCV32() const {
1082 }
1083
1084 /// Tests whether the target is 64-bit RISC-V.
1085 bool isRISCV64() const {
1087 }
1088
1089 /// Tests whether the target is RISC-V (32- and 64-bit).
1090 bool isRISCV() const { return isRISCV32() || isRISCV64(); }
1091
1092 /// Tests whether the target is 32-bit SPARC (little and big endian).
1093 bool isSPARC32() const {
1094 return getArch() == Triple::sparc || getArch() == Triple::sparcel;
1095 }
1096
1097 /// Tests whether the target is 64-bit SPARC (big endian).
1098 bool isSPARC64() const { return getArch() == Triple::sparcv9; }
1099
1100 /// Tests whether the target is SPARC.
1101 bool isSPARC() const { return isSPARC32() || isSPARC64(); }
1102
1103 /// Tests whether the target is SystemZ.
1104 bool isSystemZ() const { return getArch() == Triple::systemz; }
1105
1106 /// Tests whether the target is x86 (32- or 64-bit).
1107 bool isX86() const {
1108 return getArch() == Triple::x86 || getArch() == Triple::x86_64;
1109 }
1110
1111 /// Tests whether the target is x86 (32-bit).
1112 bool isX86_32() const { return getArch() == Triple::x86; }
1113
1114 /// Tests whether the target is x86 (64-bit).
1115 bool isX86_64() const { return getArch() == Triple::x86_64; }
1116
1117 /// Tests whether the target is VE
1118 bool isVE() const { return getArch() == Triple::ve; }
1119
1120 /// Tests whether the target is wasm (32- and 64-bit).
1121 bool isWasm() const {
1122 return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
1123 }
1124
1125 // Tests whether the target is CSKY
1126 bool isCSKY() const { return getArch() == Triple::csky; }
1127
1128 /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
1129 bool isArm64e() const {
1130 return getArch() == Triple::aarch64 &&
1132 }
1133
1134 // Tests whether the target is N32.
1135 bool isABIN32() const {
1137 return Env == Triple::GNUABIN32 || Env == Triple::MuslABIN32;
1138 }
1139
1140 /// Tests whether the target is X32.
1141 bool isX32() const {
1143 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
1144 }
1145
1146 /// Tests whether the target is eBPF.
1147 bool isBPF() const {
1148 return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
1149 }
1150
1151 /// Tests whether MSVC linker or UEFI targets.
1152 /// Used to default to -mincremental-linker-compatible if we are
1153 /// targeting the MSVC linker or *-uefi triples.
1157
1158 /// Tests if the target forces 64-bit time_t on a 32-bit architecture.
1159 bool isTime64ABI() const {
1161 return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1162 Env == Triple::GNUEABIHFT64;
1163 }
1164
1165 /// Tests if the target forces hardfloat.
1166 bool isHardFloatABI() const {
1168 return Env == llvm::Triple::GNUEABIHF ||
1171 }
1172
1173 /// Tests whether the target supports comdat
1174 bool supportsCOMDAT() const {
1175 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
1177 }
1178
1179 /// Tests whether the target uses emulated TLS as default.
1180 ///
1181 /// Note: Android API level 29 (10) introduced ELF TLS.
1183 return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
1185 }
1186
1187 /// True if the target uses TLSDESC by default.
1188 bool hasDefaultTLSDESC() const {
1189 return isAArch64() || (isAndroid() && isRISCV64()) || isOSFuchsia();
1190 }
1191
1192 /// Tests whether the target uses -data-sections as default.
1194 return isOSBinFormatXCOFF() || isWasm();
1195 }
1196
1197 /// Returns the default wchar_t size (in bytes) for this target triple.
1198 unsigned getDefaultWCharSize() const;
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 /// Parse anything recognized as an architecture for the first field of the
1336 /// triple.
1337 LLVM_ABI static ArchType parseArch(StringRef Str);
1338
1339 /// @}
1340
1341 /// Returns a canonicalized OS version number for the specified OS.
1342 LLVM_ABI static VersionTuple
1343 getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version,
1344 bool IsInValidRange);
1345
1346 /// Returns whether an OS version is invalid and would not map to an Apple OS.
1347 LLVM_ABI static bool isValidVersionForOS(OSType OSKind,
1348 const VersionTuple &Version);
1349
1351
1352 /// Compute the LLVM IR data layout string based on the triple. Some targets
1353 /// customize the layout based on the ABIName string.
1354 LLVM_ABI std::string computeDataLayout(StringRef ABIName = "") const;
1355};
1356
1357} // namespace llvm
1358
1359#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h: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:2546
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1711
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1047
bool isOSDragonFly() const
Definition Triple.h:673
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1656
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1828
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1936
bool isTargetMachineMac() const
Returns true for targets that run on a macOS machine.
Definition Triple.h:660
bool isArmT32() const
Tests whether the target is T32.
Definition Triple.h:970
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1927
bool isAndroidVersionLT(unsigned Major) const
Definition Triple.h:824
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:2067
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:734
bool isWatchABI() const
Definition Triple.h:619
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:314
@ LastEnvironmentType
Definition Triple.h:328
@ UnknownEnvironment
Definition Triple.h:266
@ RootSignature
Definition Triple.h:322
@ Amplification
Definition Triple.h:321
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:909
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition Triple.h:807
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1115
bool isPPC64ELFv2ABI() const
Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
Definition Triple.h:1063
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:2600
bool isOSWASI() const
Tests whether the OS is WASI.
Definition Triple.h:754
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition Triple.h:882
CanonicalForm
Canonical form.
Definition Triple.h:410
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition Triple.h:790
bool isOSQurt() const
Tests whether the OS is QURT.
Definition Triple.h:775
bool isDriverKit() const
Is this an Apple DriverKit triple.
Definition Triple.h:628
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:538
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2384
bool isOSHurd() const
Tests whether the OS is Hurd.
Definition Triple.h:751
bool isHardFloatABI() const
Tests if the target forces hardfloat.
Definition Triple.h:1166
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1147
bool isX32() const
Tests whether the target is X32.
Definition Triple.h:1141
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition Triple.cpp:357
Triple(const char *Str)
Definition Triple.h:374
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:459
bool isAArch64(int PointerWidth) const
Tests whether the target is AArch64 and pointers are the size specified by PointerWidth.
Definition Triple.h:1012
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:438
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1107
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1129
std::string normalize(CanonicalForm Form=CanonicalForm::ANY) const
Return the normalized form of this triple's string.
Definition Triple.h:426
bool isTargetEHABICompatible() const
Tests whether the target supports the EHABI exception handling standard.
Definition Triple.h:926
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:784
bool isWindowsGNUEnvironment() const
Definition Triple.h:729
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1940
bool isOSNetBSD() const
Definition Triple.h:665
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:1957
bool isAndroid() const
Tests whether the target is Android.
Definition Triple.h:822
bool hasDefaultTLSDESC() const
True if the target uses TLSDESC by default.
Definition Triple.h:1188
bool isLFI() const
Tests whether the target is LFI.
Definition Triple.h:919
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:2181
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition Triple.h:739
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition Triple.h:787
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2439
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1918
bool isABIN32() const
Definition Triple.h:1135
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1661
bool isAVR() const
Definition Triple.h:1022
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition Triple.h:1174
bool isWindowsCoreCLREnvironment() const
Definition Triple.h:717
bool isSPIROrSPIRV() const
Definition Triple.h:893
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2682
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition Triple.h:1039
@ loongarch32
Definition Triple.h:64
@ renderscript64
Definition Triple.h:115
@ UnknownArch
Definition Triple.h:50
@ loongarch64
Definition Triple.h:65
@ renderscript32
Definition Triple.h:114
bool hasDefaultDataSections() const
Tests whether the target uses -data-sections as default.
Definition Triple.h:1193
bool isTargetGNUAEABI() const
Definition Triple.h:954
bool isOSSolaris() const
Definition Triple.h:675
bool isRISCV32() const
Tests whether the target is 32-bit RISC-V.
Definition Triple.h:1080
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition Triple.h:748
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1906
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:444
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1684
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:1421
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:657
bool isOSVersionLT(const Triple &Other) const
Definition Triple.h:582
bool isPPC32() const
Tests whether the target is 32-bit PowerPC (little and big endian).
Definition Triple.h:1053
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:435
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:2037
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:781
bool isRISCV64() const
Tests whether the target is 64-bit RISC-V.
Definition Triple.h:1085
bool isCSKY() const
Definition Triple.h:1126
bool isLoongArch64() const
Tests whether the target is 64-bit LoongArch.
Definition Triple.h:1028
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1667
bool isSPARC32() const
Tests whether the target is 32-bit SPARC (little and big endian).
Definition Triple.h:1093
bool isSimulatorEnvironment() const
Definition Triple.h:651
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1893
const std::string & str() const
Definition Triple.h:500
bool isOSzOS() const
Definition Triple.h:630
bool isOSSerenity() const
Definition Triple.h:772
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:852
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:450
bool isOSOpenBSD() const
Definition Triple.h:667
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1868
bool isOSUnknown() const
Definition Triple.h:679
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1856
static LLVM_ABI ArchType parseArch(StringRef Str)
Parse anything recognized as an architecture for the first field of the triple.
Definition Triple.cpp:795
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition Triple.h:1034
bool isShaderModelOS() const
Definition Triple.h:861
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:695
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:698
bool isOSFirmware() const
Definition Triple.h:867
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:837
const std::string & getTriple() const
Definition Triple.h:502
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:586
bool isOSBinFormatDXContainer() const
Tests whether the OS uses the DXContainer binary format.
Definition Triple.h:796
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:793
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:397
bool isTargetMuslAEABI() const
Definition Triple.h:962
@ UnknownObjectFormat
Definition Triple.h:331
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:914
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2537
bool isArmMClass() const
Tests whether the target is an M-class.
Definition Triple.h:990
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:745
bool isBridgeOS() const
Is this an Apple BridgeOS triple.
Definition Triple.h:625
bool isOSManagarm() const
Definition Triple.h:865
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1090
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition Triple.h:904
bool isAMDGPU() const
Definition Triple.h:906
bool isLoongArch32() const
Tests whether the target is 32-bit LoongArch.
Definition Triple.h:1025
bool isOSLiteOS() const
Definition Triple.h:856
@ UnknownVendor
Definition Triple.h:193
@ ImaginationTechnologies
Definition Triple.h:200
@ LastVendorType
Definition Triple.h:210
@ MipsTechnologies
Definition Triple.h:201
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:899
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:770
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2563
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:2055
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1673
@ ARMSubArch_v6t2
Definition Triple.h:153
@ MipsSubArch_r6
Definition Triple.h:166
@ DXILSubArch_v1_2
Definition Triple.h:182
@ ARMSubArch_v7
Definition Triple.h:144
@ ARMSubArch_v8m_mainline
Definition Triple.h:142
@ ARMSubArch_v9_6a
Definition Triple.h:123
@ ARMSubArch_v8r
Definition Triple.h:140
@ ARMSubArch_v9_1a
Definition Triple.h:128
@ DXILSubArch_v1_1
Definition Triple.h:181
@ LatestDXILSubArch
Definition Triple.h:190
@ SPIRVSubArch_v10
Definition Triple.h:171
@ SPIRVSubArch_v13
Definition Triple.h:174
@ ARMSubArch_v7k
Definition Triple.h:148
@ ARMSubArch_v8_7a
Definition Triple.h:132
@ ARMSubArch_v8
Definition Triple.h:139
@ SPIRVSubArch_v16
Definition Triple.h:177
@ ARMSubArch_v8_1a
Definition Triple.h:138
@ ARMSubArch_v9_2a
Definition Triple.h:127
@ DXILSubArch_v1_3
Definition Triple.h:183
@ SPIRVSubArch_v15
Definition Triple.h:176
@ ARMSubArch_v7m
Definition Triple.h:146
@ ARMSubArch_v9_7a
Definition Triple.h:122
@ ARMSubArch_v6k
Definition Triple.h:152
@ ARMSubArch_v5
Definition Triple.h:154
@ AArch64SubArch_arm64e
Definition Triple.h:158
@ ARMSubArch_v6
Definition Triple.h:150
@ ARMSubArch_v9_5a
Definition Triple.h:124
@ ARMSubArch_v7ve
Definition Triple.h:149
@ ARMSubArch_v8m_baseline
Definition Triple.h:141
@ ARMSubArch_v8_8a
Definition Triple.h:131
@ ARMSubArch_v8_2a
Definition Triple.h:137
@ ARMSubArch_v7s
Definition Triple.h:147
@ DXILSubArch_v1_0
Definition Triple.h:180
@ DXILSubArch_v1_7
Definition Triple.h:187
@ KalimbaSubArch_v3
Definition Triple.h:162
@ DXILSubArch_v1_5
Definition Triple.h:185
@ ARMSubArch_v8_4a
Definition Triple.h:135
@ ARMSubArch_v8_9a
Definition Triple.h:130
@ ARMSubArch_v7em
Definition Triple.h:145
@ SPIRVSubArch_v12
Definition Triple.h:173
@ SPIRVSubArch_v14
Definition Triple.h:175
@ KalimbaSubArch_v4
Definition Triple.h:163
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:143
@ ARMSubArch_v8_3a
Definition Triple.h:136
@ AArch64SubArch_arm64ec
Definition Triple.h:159
@ ARMSubArch_v8_6a
Definition Triple.h:133
@ ARMSubArch_v5te
Definition Triple.h:155
@ KalimbaSubArch_v5
Definition Triple.h:164
@ ARMSubArch_v4t
Definition Triple.h:156
@ DXILSubArch_v1_6
Definition Triple.h:186
@ DXILSubArch_v1_8
Definition Triple.h:188
@ ARMSubArch_v9_4a
Definition Triple.h:125
@ ARMSubArch_v8_5a
Definition Triple.h:134
@ AArch64SubArch_lfi
Definition Triple.h:160
@ ARMSubArch_v6m
Definition Triple.h:151
@ ARMSubArch_v9_3a
Definition Triple.h:126
@ DXILSubArch_v1_9
Definition Triple.h:189
@ ARMSubArch_v9
Definition Triple.h:129
@ DXILSubArch_v1_4
Definition Triple.h:184
@ SPIRVSubArch_v11
Definition Triple.h:172
@ PPCSubArch_spe
Definition Triple.h:168
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:1725
bool isSPARC64() const
Tests whether the target is 64-bit SPARC (big endian).
Definition Triple.h:1098
bool isWindowsCygwinEnvironment() const
Definition Triple.h:725
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:2651
Triple(StringRef Str)
Definition Triple.h:373
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:602
Triple(const std::string &Str)
Definition Triple.h:375
bool isOSFreeBSD() const
Definition Triple.h:669
bool isXROS() const
Is this an Apple XROS triple.
Definition Triple.h:622
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1952
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1916
bool isX86_32() const
Tests whether the target is x86 (32-bit).
Definition Triple.h:1112
bool operator<(const Triple &Other) const
Definition Triple.h:398
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1944
bool isAppleFirmware() const
Is this an Apple firmware triple.
Definition Triple.h:638
bool isDefaultIncrementalLinkerCompatibleByDefault() const
Tests whether MSVC linker or UEFI targets.
Definition Triple.h:1154
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:441
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1101
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition Triple.h:1058
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:644
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:896
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:503
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:566
bool isTvOS() const
Is this an Apple tvOS triple.
Definition Triple.h:614
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition Triple.h:760
bool isWindowsArm64EC() const
Definition Triple.h:712
bool isOSVersionGE(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Definition Triple.h:577
bool operator==(const Triple &Other) const
Definition Triple.h:389
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition Triple.h:617
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:505
bool isiOS() const
Is this an iOS triple.
Definition Triple.h:611
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1044
bool isMacOSXVersionGE(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Definition Triple.h:595
bool isWALI() const
Tests whether the target uses WALI Wasm.
Definition Triple.h:801
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition Triple.h:763
bool isTargetAEABI() const
Definition Triple.h:948
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:819
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1121
bool isVulkanOS() const
Definition Triple.h:863
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1652
bool isOSIAMCU() const
Definition Triple.h:677
bool isOpenHOS() const
Definition Triple.h:854
bool isMacCatalystEnvironment() const
Definition Triple.h:655
bool isPS5() const
Tests whether the target is the PS5 platform.
Definition Triple.h:813
bool isSPIRV() const
Tests whether the target is SPIR-V (32/64-bit/Logical).
Definition Triple.h:887
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1005
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:618
bool isAppleMachO() const
Is this an Apple MachO triple.
Definition Triple.h:633
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:2063
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2301
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1776
bool hasDefaultEmulatedTLS() const
Tests whether the target uses emulated TLS as default.
Definition Triple.h:1182
bool isSystemZ() const
Tests whether the target is SystemZ.
Definition Triple.h:1104
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:1688
bool isPPC32SecurePlt() const
Tests whether the target 32-bit PowerPC uses Secure PLT.
Definition Triple.h:1071
bool isTime64ABI() const
Tests if the target forces 64-bit time_t on a 32-bit architecture.
Definition Triple.h:1159
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:2059
bool operator!=(const Triple &Other) const
Definition Triple.h:396
unsigned getOSMajorVersion() const
Return just the major version number, this is specialized because it is a common query.
Definition Triple.h:469
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2502
bool isOSFuchsia() const
Definition Triple.h:671
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:778
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:706
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:447
unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2492
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition Triple.h:701
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition Triple.cpp:237
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition Triple.h:692
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition Triple.cpp:1908
bool isDXIL() const
Tests whether the target is DXIL.
Definition Triple.h:859
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1912
bool isGNUEnvironment() const
Definition Triple.h:681
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1031
bool isShaderStageEnvironment() const
Definition Triple.h:869
bool isWindowsItaniumEnvironment() const
Definition Triple.h:721
bool isVE() const
Tests whether the target is VE.
Definition Triple.h:1118
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:334
@ Other
Any other memory.
Definition ModRef.h:68
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:221
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870