LLVM 22.0.0git
Triple.h
Go to the documentation of this file.
1//===-- llvm/TargetParser/Triple.h - Target triple helper class--*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TARGETPARSER_TRIPLE_H
10#define LLVM_TARGETPARSER_TRIPLE_H
11
12#include "llvm/ADT/StringRef.h"
15
16// Some system headers or GCC predefined macros conflict with identifiers in
17// this file. Undefine them here.
18#undef NetBSD
19#undef mips
20#undef sparc
21
22namespace llvm {
23enum class ExceptionHandling;
24class Twine;
25
26/// Triple - Helper class for working with autoconf configuration names. For
27/// historical reasons, we also call these 'triples' (they used to contain
28/// exactly three fields).
29///
30/// Configuration names are strings in the canonical form:
31/// ARCHITECTURE-VENDOR-OPERATING_SYSTEM
32/// or
33/// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
34///
35/// This class is used for clients which want to support arbitrary
36/// configuration names, but also want to implement certain special
37/// behavior for particular configurations. This class isolates the mapping
38/// from the components of the configuration name to well known IDs.
39///
40/// At its core the Triple class is designed to be a wrapper for a triple
41/// string; the constructor does not change or normalize the triple string.
42/// Clients that need to handle the non-canonical triples that users often
43/// specify should use the normalize method.
44///
45/// See autoconf/config.guess for a glimpse into what configuration names
46/// look like in practice.
47class Triple {
48public:
49 enum ArchType {
51
52 arm, // ARM (little endian): arm, armv.*, xscale
53 armeb, // ARM (big endian): armeb
54 aarch64, // AArch64 (little endian): aarch64
55 aarch64_be, // AArch64 (big endian): aarch64_be
56 aarch64_32, // AArch64 (little endian) ILP32: aarch64_32
57 arc, // ARC: Synopsys ARC
58 avr, // AVR: Atmel AVR microcontroller
59 bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
60 bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
61 csky, // CSKY: csky
62 dxil, // DXIL 32-bit DirectX bytecode
63 hexagon, // Hexagon: hexagon
64 loongarch32, // LoongArch (32-bit): loongarch32
65 loongarch64, // LoongArch (64-bit): loongarch64
66 m68k, // M68k: Motorola 680x0 family
67 mips, // MIPS: mips, mipsallegrex, mipsr6
68 mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
69 mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
70 mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
71 msp430, // MSP430: msp430
72 ppc, // PPC: powerpc
73 ppcle, // PPCLE: powerpc (little endian)
74 ppc64, // PPC64: powerpc64, ppu
75 ppc64le, // PPC64LE: powerpc64le
76 r600, // R600: AMD GPUs HD2XXX - HD6XXX
77 amdgcn, // AMDGCN: AMD GCN GPUs
78 riscv32, // RISC-V (32-bit, little endian): riscv32
79 riscv64, // RISC-V (64-bit, little endian): riscv64
80 riscv32be, // RISC-V (32-bit, big endian): riscv32be
81 riscv64be, // RISC-V (64-bit, big endian): riscv64be
82 sparc, // Sparc: sparc
83 sparcv9, // Sparcv9: Sparcv9
84 sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
85 systemz, // SystemZ: s390x
86 tce, // TCE (http://tce.cs.tut.fi/): tce
87 tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
88 thumb, // Thumb (little endian): thumb, thumbv.*
89 thumbeb, // Thumb (big endian): thumbeb
90 x86, // X86: i[3-9]86
91 x86_64, // X86-64: amd64, x86_64
92 xcore, // XCore: xcore
93 xtensa, // Tensilica: Xtensa
94 nvptx, // NVPTX: 32-bit
95 nvptx64, // NVPTX: 64-bit
96 amdil, // AMDIL
97 amdil64, // AMDIL with 64-bit pointers
98 hsail, // AMD HSAIL
99 hsail64, // AMD HSAIL with 64-bit pointers
100 spir, // SPIR: standard portable IR for OpenCL 32-bit version
101 spir64, // SPIR: standard portable IR for OpenCL 64-bit version
102 spirv, // SPIR-V with logical memory layout.
103 spirv32, // SPIR-V with 32-bit pointers
104 spirv64, // SPIR-V with 64-bit pointers
105 kalimba, // Kalimba: generic kalimba
106 shave, // SHAVE: Movidius vector VLIW processors
107 lanai, // Lanai: Lanai 32-bit
108 wasm32, // WebAssembly with 32-bit pointers
109 wasm64, // WebAssembly with 64-bit pointers
110 renderscript32, // 32-bit RenderScript
111 renderscript64, // 64-bit RenderScript
112 ve, // NEC SX-Aurora Vector Engine
114 };
206 enum OSType {
208
216 Lv2, // PS3
228 CUDA, // NVIDIA CUDA
229 NVCL, // NVIDIA OpenCL
230 AMDHSA, // AMD HSA Runtime
234 TvOS, // Apple tvOS
235 WatchOS, // Apple watchOS
236 BridgeOS, // Apple bridgeOS
237 DriverKit, // Apple DriverKit
238 XROS, // Apple XROS
240 AMDPAL, // AMD PAL Runtime
241 HermitCore, // HermitCore Unikernel/Multikernel
242 Hurd, // GNU/Hurd
243 WASI, // Experimental WebAssembly OS
245 ShaderModel, // DirectX ShaderModel
248 Vulkan, // Vulkan SPIR-V
251 };
254
281
286 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
287 MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
288
289 // Shader Stages
290 // The order of these values matters, and must be kept in sync with the
291 // language options enum in Clang. The ordering is enforced in
292 // static_asserts in Triple.cpp and in Clang.
312
316 };
329
330private:
331 std::string Data;
332
333 /// The parsed arch type.
334 ArchType Arch{};
335
336 /// The parsed subarchitecture type.
337 SubArchType SubArch{};
338
339 /// The parsed vendor type.
340 VendorType Vendor{};
341
342 /// The parsed OS type.
343 OSType OS{};
344
345 /// The parsed Environment type.
346 EnvironmentType Environment{};
347
348 /// The object format type.
349 ObjectFormatType ObjectFormat{};
350
351public:
352 /// @name Constructors
353 /// @{
354
355 /// Default constructor is the same as an empty string and leaves all
356 /// triple fields unknown.
357 Triple() = default;
358
359 LLVM_ABI explicit Triple(std::string &&Str);
360 explicit Triple(StringRef Str) : Triple(Str.str()) {}
361 explicit Triple(const char *Str) : Triple(std::string(Str)) {}
362 explicit Triple(const std::string &Str) : Triple(std::string(Str)) {}
363 LLVM_ABI explicit Triple(const Twine &Str);
364
365 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
366 const Twine &OSStr);
367 LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr,
368 const Twine &OSStr, const Twine &EnvironmentStr);
369
370 bool operator==(const Triple &Other) const {
371 return Arch == Other.Arch && SubArch == Other.SubArch &&
372 Vendor == Other.Vendor && OS == Other.OS &&
373 Environment == Other.Environment &&
374 ObjectFormat == Other.ObjectFormat;
375 }
376
377 bool operator!=(const Triple &Other) const {
378 return !(*this == Other);
379 }
380
381 /// @}
382 /// @name Normalization
383 /// @{
384
385 /// Canonical form
386 enum class CanonicalForm {
387 ANY = 0,
388 THREE_IDENT = 3, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM
389 FOUR_IDENT = 4, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
390 FIVE_IDENT = 5, // ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT-FORMAT
391 };
392
393 /// Turn an arbitrary machine specification into the canonical triple form (or
394 /// something sensible that the Triple class understands if nothing better can
395 /// reasonably be done). In particular, it handles the common case in which
396 /// otherwise valid components are in the wrong order. \p Form is used to
397 /// specify the output canonical form.
398 LLVM_ABI static std::string
400
401 /// Return the normalized form of this triple's string.
402 std::string normalize(CanonicalForm Form = CanonicalForm::ANY) const {
403 return normalize(Data, Form);
404 }
405
406 /// @}
407 /// @name Typed Component Access
408 /// @{
409
410 /// Get the parsed architecture type of this triple.
411 ArchType getArch() const { return Arch; }
412
413 /// get the parsed subarchitecture type for this triple.
414 SubArchType getSubArch() const { return SubArch; }
415
416 /// Get the parsed vendor type of this triple.
417 VendorType getVendor() const { return Vendor; }
418
419 /// Get the parsed operating system type of this triple.
420 OSType getOS() const { return OS; }
421
422 /// Does this triple have the optional environment (fourth) component?
423 bool hasEnvironment() const {
424 return getEnvironmentName() != "";
425 }
426
427 /// Get the parsed environment type of this triple.
428 EnvironmentType getEnvironment() const { return Environment; }
429
430 /// Parse the version number from the OS name component of the
431 /// triple, if present.
432 ///
433 /// For example, "fooos1.2.3" would return (1, 2, 3).
435
436 /// Get the object format for this triple.
437 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
438
439 /// Parse the version number from the OS name component of the triple, if
440 /// present.
441 ///
442 /// For example, "fooos1.2.3" would return (1, 2, 3).
444
445 /// Return just the major version number, this is specialized because it is a
446 /// common query.
447 unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
448
449 /// Parse the version number as with getOSVersion and then translate generic
450 /// "darwin" versions to the corresponding OS X versions. This may also be
451 /// called with IOS triples but the OS X version number is just set to a
452 /// constant 10.4.0 in that case. Returns true if successful.
454
455 /// Parse the version number as with getOSVersion. This should only be called
456 /// with IOS or generic triples.
458
459 /// Parse the version number as with getOSVersion. This should only be called
460 /// with WatchOS or generic triples.
462
463 /// Parse the version number as with getOSVersion.
465
466 /// Parse the Vulkan version number from the OSVersion and SPIR-V version
467 /// (SubArch). This should only be called with Vulkan SPIR-V triples.
469
470 /// Parse the DXIL version number from the OSVersion and DXIL version
471 /// (SubArch). This should only be called with DXIL triples.
473
474 /// @}
475 /// @name Direct Component Access
476 /// @{
477
478 const std::string &str() const { return Data; }
479
480 const std::string &getTriple() const { return Data; }
481
482 /// Whether the triple is empty / default constructed.
483 bool empty() const { return Data.empty(); }
484
485 /// Get the architecture (first) component of the triple.
487
488 /// Get the vendor (second) component of the triple.
490
491 /// Get the operating system (third) component of the triple.
493
494 /// Get the optional environment (fourth) component of the triple, or "" if
495 /// empty.
497
498 /// Get the operating system and optional environment components as a single
499 /// string (separated by a '-' if the environment component is present).
501
502 /// Get the version component of the environment component as a single
503 /// string (the version after the environment).
504 ///
505 /// For example, "fooos1.2.3" would return "1.2.3".
507
508 /// @}
509 /// @name Convenience Predicates
510 /// @{
511
512 /// Returns the pointer width of this architecture.
514
515 /// Returns the pointer width of this architecture.
516 unsigned getArchPointerBitWidth() const {
518 }
519
520 /// Returns the trampoline size in bytes for this configuration.
521 LLVM_ABI unsigned getTrampolineSize() const;
522
523 /// Test whether the architecture is 64-bit
524 ///
525 /// Note that this tests for 64-bit pointer width, and nothing else. Note
526 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
527 /// 16-bit. The inner details of pointer width for particular architectures
528 /// is not summed up in the triple, and so only a coarse grained predicate
529 /// system is provided.
530 LLVM_ABI bool isArch64Bit() const;
531
532 /// Test whether the architecture is 32-bit
533 ///
534 /// Note that this tests for 32-bit pointer width, and nothing else.
535 LLVM_ABI bool isArch32Bit() const;
536
537 /// Test whether the architecture is 16-bit
538 ///
539 /// Note that this tests for 16-bit pointer width, and nothing else.
540 LLVM_ABI bool isArch16Bit() const;
541
542 /// Helper function for doing comparisons against version numbers included in
543 /// the target triple.
544 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
545 unsigned Micro = 0) const {
546 if (Minor == 0) {
547 return getOSVersion() < VersionTuple(Major);
548 }
549 if (Micro == 0) {
550 return getOSVersion() < VersionTuple(Major, Minor);
551 }
552 return getOSVersion() < VersionTuple(Major, Minor, Micro);
553 }
554
555 bool isOSVersionLT(const Triple &Other) const {
556 return getOSVersion() < Other.getOSVersion();
557 }
558
559 /// Comparison function for checking OS X version compatibility, which handles
560 /// supporting skewed version numbering schemes used by the "darwin" triples.
561 LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
562 unsigned Micro = 0) const;
563
564 /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
565 /// and "osx" as OS X triples.
566 bool isMacOSX() const {
567 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
568 }
569
570 /// Is this an iOS triple.
571 /// Note: This identifies tvOS as a variant of iOS. If that ever
572 /// changes, i.e., if the two operating systems diverge or their version
573 /// numbers get out of sync, that will need to be changed.
574 /// watchOS has completely different version numbers so it is not included.
575 bool isiOS() const {
576 return getOS() == Triple::IOS || isTvOS();
577 }
578
579 /// Is this an Apple tvOS triple.
580 bool isTvOS() const {
581 return getOS() == Triple::TvOS;
582 }
583
584 /// Is this an Apple watchOS triple.
585 bool isWatchOS() const {
586 return getOS() == Triple::WatchOS;
587 }
588
589 bool isWatchABI() const {
591 }
592
593 /// Is this an Apple XROS triple.
594 bool isXROS() const { return getOS() == Triple::XROS; }
595
596 /// Is this an Apple BridgeOS triple.
597 bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }
598
599 /// Is this an Apple DriverKit triple.
600 bool isDriverKit() const { return getOS() == Triple::DriverKit; }
601
602 bool isOSzOS() const { return getOS() == Triple::ZOS; }
603
604 /// Is this an Apple MachO triple.
605 bool isAppleMachO() const {
606 return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
607 }
608
609 /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
610 /// bridgeOS).
611 bool isOSDarwin() const {
612 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
613 isBridgeOS();
614 }
615
618 }
619
621 return getEnvironment() == Triple::MacABI;
622 }
623
624 /// Returns true for targets that run on a macOS machine.
625 bool isTargetMachineMac() const {
626 return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
628 }
629
630 bool isOSNetBSD() const {
631 return getOS() == Triple::NetBSD;
632 }
633
634 bool isOSOpenBSD() const {
635 return getOS() == Triple::OpenBSD;
636 }
637
638 bool isOSFreeBSD() const {
639 return getOS() == Triple::FreeBSD;
640 }
641
642 bool isOSFuchsia() const {
643 return getOS() == Triple::Fuchsia;
644 }
645
646 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
647
648 bool isOSSolaris() const {
649 return getOS() == Triple::Solaris;
650 }
651
652 bool isOSIAMCU() const {
653 return getOS() == Triple::ELFIAMCU;
654 }
655
656 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
657
658 bool isGNUEnvironment() const {
660 return Env == Triple::GNU || Env == Triple::GNUT64 ||
661 Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
662 Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
663 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
664 Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
665 Env == Triple::GNUSF || Env == Triple::GNUX32;
666 }
667
668 /// Tests whether the OS is Haiku.
669 bool isOSHaiku() const {
670 return getOS() == Triple::Haiku;
671 }
672
673 /// Tests whether the OS is UEFI.
674 bool isUEFI() const {
675 return getOS() == Triple::UEFI;
676 }
677
678 /// Tests whether the OS is Windows.
679 bool isOSWindows() const {
680 return getOS() == Triple::Win32;
681 }
682
683 /// Checks if the environment is MSVC.
685 return isOSWindows() && getEnvironment() == Triple::MSVC;
686 }
687
688 /// Checks if the environment could be MSVC.
693
694 // Checks if we're using the Windows Arm64EC ABI.
695 bool isWindowsArm64EC() const {
696 return getArch() == Triple::aarch64 &&
698 }
699
702 }
703
706 }
707
710 }
711
713 return isOSWindows() && getEnvironment() == Triple::GNU;
714 }
715
716 /// Tests for either Cygwin or MinGW OS
717 bool isOSCygMing() const {
719 }
720
721 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
726
727 /// Tests whether the OS is Linux.
728 bool isOSLinux() const {
729 return getOS() == Triple::Linux;
730 }
731
732 /// Tests whether the OS is kFreeBSD.
733 bool isOSKFreeBSD() const {
734 return getOS() == Triple::KFreeBSD;
735 }
736
737 /// Tests whether the OS is Hurd.
738 bool isOSHurd() const {
739 return getOS() == Triple::Hurd;
740 }
741
742 /// Tests whether the OS is WASI.
743 bool isOSWASI() const {
744 return getOS() == Triple::WASI;
745 }
746
747 /// Tests whether the OS is Emscripten.
748 bool isOSEmscripten() const {
749 return getOS() == Triple::Emscripten;
750 }
751
752 /// Tests whether the OS uses glibc.
753 bool isOSGlibc() const {
754 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
755 getOS() == Triple::Hurd) &&
756 !isAndroid();
757 }
758
759 /// Tests whether the OS is AIX.
760 bool isOSAIX() const {
761 return getOS() == Triple::AIX;
762 }
763
764 bool isOSSerenity() const {
765 return getOS() == Triple::Serenity;
766 }
767
768 /// Tests whether the OS uses the ELF binary format.
769 bool isOSBinFormatELF() const {
770 return getObjectFormat() == Triple::ELF;
771 }
772
773 /// Tests whether the OS uses the COFF binary format.
774 bool isOSBinFormatCOFF() const {
775 return getObjectFormat() == Triple::COFF;
776 }
777
778 /// Tests whether the OS uses the GOFF binary format.
779 bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
780
781 /// Tests whether the environment is MachO.
782 bool isOSBinFormatMachO() const {
783 return getObjectFormat() == Triple::MachO;
784 }
785
786 /// Tests whether the OS uses the Wasm binary format.
787 bool isOSBinFormatWasm() const {
788 return getObjectFormat() == Triple::Wasm;
789 }
790
791 /// Tests whether the OS uses the XCOFF binary format.
792 bool isOSBinFormatXCOFF() const {
793 return getObjectFormat() == Triple::XCOFF;
794 }
795
796 /// Tests whether the OS uses the DXContainer binary format.
799 }
800
801 /// Tests whether the target is the PS4 platform.
802 bool isPS4() const {
803 return getArch() == Triple::x86_64 &&
804 getVendor() == Triple::SCEI &&
805 getOS() == Triple::PS4;
806 }
807
808 /// Tests whether the target is the PS5 platform.
809 bool isPS5() const {
810 return getArch() == Triple::x86_64 &&
811 getVendor() == Triple::SCEI &&
812 getOS() == Triple::PS5;
813 }
814
815 /// Tests whether the target is the PS4 or PS5 platform.
816 bool isPS() const { return isPS4() || isPS5(); }
817
818 /// Tests whether the target is Android
819 bool isAndroid() const { return getEnvironment() == Triple::Android; }
820
821 bool isAndroidVersionLT(unsigned Major) const {
822 assert(isAndroid() && "Not an Android triple!");
823
825
826 // 64-bit targets did not exist before API level 21 (Lollipop).
827 if (isArch64Bit() && Version.getMajor() < 21)
828 return VersionTuple(21) < VersionTuple(Major);
829
830 return Version < VersionTuple(Major);
831 }
832
833 /// Tests whether the environment is musl-libc
845
846 /// Tests whether the target is OHOS
847 /// LiteOS default enviroment is also OHOS, but omited on triple.
848 bool isOHOSFamily() const { return isOpenHOS() || isOSLiteOS(); }
849
850 bool isOpenHOS() const { return getEnvironment() == Triple::OpenHOS; }
851
852 bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
853
854 /// Tests whether the target is DXIL.
855 bool isDXIL() const {
856 return getArch() == Triple::dxil;
857 }
858
859 bool isShaderModelOS() const {
860 return getOS() == Triple::ShaderModel;
861 }
862
863 bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
864
865 bool isOSManagarm() const { return getOS() == Triple::Managarm; }
866
869 return Env == Triple::Pixel || Env == Triple::Vertex ||
870 Env == Triple::Geometry || Env == Triple::Hull ||
871 Env == Triple::Domain || Env == Triple::Compute ||
872 Env == Triple::Library || Env == Triple::RayGeneration ||
873 Env == Triple::Intersection || Env == Triple::AnyHit ||
874 Env == Triple::ClosestHit || Env == Triple::Miss ||
875 Env == Triple::Callable || Env == Triple::Mesh ||
877 }
878
879 /// Tests whether the target is SPIR (32- or 64-bit).
880 bool isSPIR() const {
881 return getArch() == Triple::spir || getArch() == Triple::spir64;
882 }
883
884 /// Tests whether the target is SPIR-V (32/64-bit/Logical).
885 bool isSPIRV() const {
886 return getArch() == Triple::spirv32 || getArch() == Triple::spirv64 ||
888 }
889
890 // Tests whether the target is SPIR-V or SPIR.
891 bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
892
893 /// Tests whether the target is SPIR-V Logical
894 bool isSPIRVLogical() const {
895 return getArch() == Triple::spirv;
896 }
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 supports the EHABI exception
919 /// handling standard.
933
934 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
935 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
936 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
937 // even for GNUEABI, so we can make a distinction here and still conform to
938 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
939 // FIXME: The Darwin exception is temporary, while we move users to
940 // "*-*-*-macho" triples as quickly as possible.
941 bool isTargetAEABI() const {
942 return (getEnvironment() == Triple::EABI ||
944 !isOSDarwin() && !isOSWindows();
945 }
946
954
955 bool isTargetMuslAEABI() const {
956 return (getEnvironment() == Triple::MuslEABI ||
959 !isOSDarwin() && !isOSWindows();
960 }
961
962 /// Tests whether the target is T32.
963 bool isArmT32() const {
964 switch (getSubArch()) {
976 return false;
977 default:
978 return true;
979 }
980 }
981
982 /// Tests whether the target is an M-class.
983 bool isArmMClass() const {
984 switch (getSubArch()) {
991 return true;
992 default:
993 return false;
994 }
995 }
996
997 /// Tests whether the target is AArch64 (little and big endian).
998 bool isAArch64() const {
1001 }
1002
1003 /// Tests whether the target is AArch64 and pointers are the size specified by
1004 /// \p PointerWidth.
1005 bool isAArch64(int PointerWidth) const {
1006 assert(PointerWidth == 64 || PointerWidth == 32);
1007 if (!isAArch64())
1008 return false;
1009 return getArch() == Triple::aarch64_32 ||
1011 ? PointerWidth == 32
1012 : PointerWidth == 64;
1013 }
1014
1015 /// Tests whether the target is 32-bit LoongArch.
1016 bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
1017
1018 /// Tests whether the target is 64-bit LoongArch.
1019 bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
1020
1021 /// Tests whether the target is LoongArch (32- and 64-bit).
1022 bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
1023
1024 /// Tests whether the target is MIPS 32-bit (little and big endian).
1025 bool isMIPS32() const {
1026 return getArch() == Triple::mips || getArch() == Triple::mipsel;
1027 }
1028
1029 /// Tests whether the target is MIPS 64-bit (little and big endian).
1030 bool isMIPS64() const {
1031 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
1032 }
1033
1034 /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
1035 bool isMIPS() const {
1036 return isMIPS32() || isMIPS64();
1037 }
1038
1039 /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
1040 bool isPPC() const {
1041 return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
1043 }
1044
1045 /// Tests whether the target is 32-bit PowerPC (little and big endian).
1046 bool isPPC32() const {
1047 return getArch() == Triple::ppc || getArch() == Triple::ppcle;
1048 }
1049
1050 /// Tests whether the target is 64-bit PowerPC (little and big endian).
1051 bool isPPC64() const {
1052 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
1053 }
1054
1055 /// Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
1056 bool isPPC64ELFv2ABI() const {
1057 return (getArch() == Triple::ppc64 &&
1058 ((getOS() == Triple::FreeBSD &&
1059 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1060 getOS() == Triple::OpenBSD || isMusl()));
1061 }
1062
1063 /// Tests whether the target 32-bit PowerPC uses Secure PLT.
1064 bool isPPC32SecurePlt() const {
1065 return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
1066 ((getOS() == Triple::FreeBSD &&
1067 (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
1069 isMusl()));
1070 }
1071
1072 /// Tests whether the target is 32-bit RISC-V.
1073 bool isRISCV32() const {
1075 }
1076
1077 /// Tests whether the target is 64-bit RISC-V.
1078 bool isRISCV64() const {
1080 }
1081
1082 /// Tests whether the target is RISC-V (32- and 64-bit).
1083 bool isRISCV() const { return isRISCV32() || isRISCV64(); }
1084
1085 /// Tests whether the target is 32-bit SPARC (little and big endian).
1086 bool isSPARC32() const {
1087 return getArch() == Triple::sparc || getArch() == Triple::sparcel;
1088 }
1089
1090 /// Tests whether the target is 64-bit SPARC (big endian).
1091 bool isSPARC64() const { return getArch() == Triple::sparcv9; }
1092
1093 /// Tests whether the target is SPARC.
1094 bool isSPARC() const { return isSPARC32() || isSPARC64(); }
1095
1096 /// Tests whether the target is SystemZ.
1097 bool isSystemZ() const {
1098 return getArch() == Triple::systemz;
1099 }
1100
1101 /// Tests whether the target is x86 (32- or 64-bit).
1102 bool isX86() const {
1103 return getArch() == Triple::x86 || getArch() == Triple::x86_64;
1104 }
1105
1106 /// Tests whether the target is VE
1107 bool isVE() const {
1108 return getArch() == Triple::ve;
1109 }
1110
1111 /// Tests whether the target is wasm (32- and 64-bit).
1112 bool isWasm() const {
1113 return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
1114 }
1115
1116 // Tests whether the target is CSKY
1117 bool isCSKY() const {
1118 return getArch() == Triple::csky;
1119 }
1120
1121 /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
1122 bool isArm64e() const {
1123 return getArch() == Triple::aarch64 &&
1125 }
1126
1127 // Tests whether the target is N32.
1128 bool isABIN32() const {
1130 return Env == Triple::GNUABIN32 || Env == Triple::MuslABIN32;
1131 }
1132
1133 /// Tests whether the target is X32.
1134 bool isX32() const {
1136 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
1137 }
1138
1139 /// Tests whether the target is eBPF.
1140 bool isBPF() const {
1141 return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
1142 }
1143
1144 /// Tests if the target forces 64-bit time_t on a 32-bit architecture.
1145 bool isTime64ABI() const {
1147 return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1148 Env == Triple::GNUEABIHFT64;
1149 }
1150
1151 /// Tests if the target forces hardfloat.
1152 bool isHardFloatABI() const {
1154 return Env == llvm::Triple::GNUEABIHF ||
1156 Env == llvm::Triple::MuslEABIHF ||
1157 Env == llvm::Triple::EABIHF;
1158 }
1159
1160 /// Tests whether the target supports comdat
1161 bool supportsCOMDAT() const {
1162 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
1164 }
1165
1166 /// Tests whether the target uses emulated TLS as default.
1167 ///
1168 /// Note: Android API level 29 (10) introduced ELF TLS.
1170 return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
1172 }
1173
1174 /// True if the target uses TLSDESC by default.
1175 bool hasDefaultTLSDESC() const {
1176 return isAArch64() || (isAndroid() && isRISCV64()) || isOSFuchsia();
1177 }
1178
1179 /// Tests whether the target uses -data-sections as default.
1181 return isOSBinFormatXCOFF() || isWasm();
1182 }
1183
1184 /// Tests if the environment supports dllimport/export annotations.
1185 bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
1186
1187 /// @}
1188 /// @name Mutators
1189 /// @{
1190
1191 /// Set the architecture (first) component of the triple to a known type.
1192 LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch = NoSubArch);
1193
1194 /// Set the vendor (second) component of the triple to a known type.
1195 LLVM_ABI void setVendor(VendorType Kind);
1196
1197 /// Set the operating system (third) component of the triple to a known type.
1198 LLVM_ABI void setOS(OSType Kind);
1199
1200 /// Set the environment (fourth) component of the triple to a known type.
1201 LLVM_ABI void setEnvironment(EnvironmentType Kind);
1202
1203 /// Set the object file format.
1204 LLVM_ABI void setObjectFormat(ObjectFormatType Kind);
1205
1206 /// Set all components to the new triple \p Str.
1207 LLVM_ABI void setTriple(const Twine &Str);
1208
1209 /// Set the architecture (first) component of the triple by name.
1210 LLVM_ABI void setArchName(StringRef Str);
1211
1212 /// Set the vendor (second) component of the triple by name.
1214
1215 /// Set the operating system (third) component of the triple by name.
1216 LLVM_ABI void setOSName(StringRef Str);
1217
1218 /// Set the optional environment (fourth) component of the triple by name.
1220
1221 /// Set the operating system and optional environment components with a single
1222 /// string.
1224
1225 /// @}
1226 /// @name Helpers to build variants of a particular triple.
1227 /// @{
1228
1229 /// Form a triple with a 32-bit variant of the current architecture.
1230 ///
1231 /// This can be used to move across "families" of architectures where useful.
1232 ///
1233 /// \returns A new triple with a 32-bit architecture or an unknown
1234 /// architecture if no such variant can be found.
1236
1237 /// Form a triple with a 64-bit variant of the current architecture.
1238 ///
1239 /// This can be used to move across "families" of architectures where useful.
1240 ///
1241 /// \returns A new triple with a 64-bit architecture or an unknown
1242 /// architecture if no such variant can be found.
1244
1245 /// Form a triple with a big endian 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 big endian architecture or an unknown
1250 /// architecture if no such variant can be found.
1252
1253 /// Form a triple with a little endian 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 little endian architecture or an unknown
1258 /// architecture if no such variant can be found.
1260
1261 /// Tests whether the target triple is little endian.
1262 ///
1263 /// \returns true if the triple is little endian, false otherwise.
1264 LLVM_ABI bool isLittleEndian() const;
1265
1266 /// Test whether target triples are compatible.
1267 LLVM_ABI bool isCompatibleWith(const Triple &Other) const;
1268
1269 /// Test whether the target triple is for a GPU.
1270 bool isGPU() const { return isSPIRV() || isNVPTX() || isAMDGPU(); }
1271
1272 /// Merge target triples.
1273 LLVM_ABI std::string merge(const Triple &Other) const;
1274
1275 /// Some platforms have different minimum supported OS versions that
1276 /// varies by the architecture specified in the triple. This function
1277 /// returns the minimum supported OS version for this triple if one an exists,
1278 /// or an invalid version tuple if this triple doesn't have one.
1280
1281 /// @}
1282 /// @name Static helpers for IDs.
1283 /// @{
1284
1285 /// Get the canonical name for the \p Kind architecture.
1286 LLVM_ABI static StringRef getArchTypeName(ArchType Kind);
1287
1288 /// Get the architecture name based on \p Kind and \p SubArch.
1289 LLVM_ABI static StringRef getArchName(ArchType Kind,
1290 SubArchType SubArch = NoSubArch);
1291
1292 /// Get the "prefix" canonical name for the \p Kind architecture. This is the
1293 /// prefix used by the architecture specific builtins, and is suitable for
1294 /// passing to \see Intrinsic::getIntrinsicForClangBuiltin().
1295 ///
1296 /// \return - The architecture prefix, or 0 if none is defined.
1297 LLVM_ABI static StringRef getArchTypePrefix(ArchType Kind);
1298
1299 /// Get the canonical name for the \p Kind vendor.
1300 LLVM_ABI static StringRef getVendorTypeName(VendorType Kind);
1301
1302 /// Get the canonical name for the \p Kind operating system.
1303 LLVM_ABI static StringRef getOSTypeName(OSType Kind);
1304
1305 /// Get the canonical name for the \p Kind environment.
1306 LLVM_ABI static StringRef getEnvironmentTypeName(EnvironmentType Kind);
1307
1308 /// Get the name for the \p Object format.
1309 LLVM_ABI static StringRef
1310 getObjectFormatTypeName(ObjectFormatType ObjectFormat);
1311
1312 /// @}
1313 /// @name Static helpers for converting alternate architecture names.
1314 /// @{
1315
1316 /// The canonical type for the given LLVM architecture name (e.g., "x86").
1317 LLVM_ABI static ArchType getArchTypeForLLVMName(StringRef Str);
1318
1319 /// @}
1320
1321 /// Returns a canonicalized OS version number for the specified OS.
1322 LLVM_ABI static VersionTuple
1323 getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version,
1324 bool IsInValidRange);
1325
1326 /// Returns whether an OS version is invalid and would not map to an Apple OS.
1327 LLVM_ABI static bool isValidVersionForOS(OSType OSKind,
1328 const VersionTuple &Version);
1329
1331};
1332
1333} // End llvm namespace
1334
1335
1336#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:2171
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1448
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1040
bool isOSDragonFly() const
Definition Triple.h:646
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1393
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1559
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1666
bool isTargetMachineMac() const
Returns true for targets that run on a macOS machine.
Definition Triple.h:625
bool isArmT32() const
Tests whether the target is T32.
Definition Triple.h:963
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1658
bool isAndroidVersionLT(unsigned Major) const
Definition Triple.h:821
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:1796
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:717
bool isWatchABI() const
Definition Triple.h:589
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:300
@ LastEnvironmentType
Definition Triple.h:315
@ UnknownEnvironment
Definition Triple.h:253
@ RootSignature
Definition Triple.h:308
@ Amplification
Definition Triple.h:307
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:802
bool isPPC64ELFv2ABI() const
Tests whether the target 64-bit PowerPC big endian ABI is ELFv2.
Definition Triple.h:1056
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:2225
bool isOSWASI() const
Tests whether the OS is WASI.
Definition Triple.h:743
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition Triple.h:880
CanonicalForm
Canonical form.
Definition Triple.h:386
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition Triple.h:787
bool isDriverKit() const
Is this an Apple DriverKit triple.
Definition Triple.h:600
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:516
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2032
bool isOSHurd() const
Tests whether the OS is Hurd.
Definition Triple.h:738
bool isHardFloatABI() const
Tests if the target forces hardfloat.
Definition Triple.h:1152
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1140
bool isX32() const
Tests whether the target is X32.
Definition Triple.h:1134
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition Triple.cpp:263
Triple(const char *Str)
Definition Triple.h:361
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:437
bool isAArch64(int PointerWidth) const
Tests whether the target is AArch64 and pointers are the size specified by PointerWidth.
Definition Triple.h:1005
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:414
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1102
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1122
std::string normalize(CanonicalForm Form=CanonicalForm::ANY) const
Return the normalized form of this triple's string.
Definition Triple.h:402
bool isTargetEHABICompatible() const
Tests whether the target supports the EHABI exception handling standard.
Definition Triple.h:920
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:779
bool isWindowsGNUEnvironment() const
Definition Triple.h:712
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1670
bool isOSNetBSD() const
Definition Triple.h:630
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1687
bool isAndroid() const
Tests whether the target is Android.
Definition Triple.h:819
bool hasDefaultTLSDESC() const
True if the target uses TLSDESC by default.
Definition Triple.h:1175
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:1879
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition Triple.h:722
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition Triple.h:782
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2075
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1650
bool isABIN32() const
Definition Triple.h:1128
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1398
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition Triple.h:1161
bool isWindowsCoreCLREnvironment() const
Definition Triple.h:700
bool isSPIROrSPIRV() const
Definition Triple.h:891
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2307
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition Triple.h:1030
@ 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:1180
bool isTargetGNUAEABI() const
Definition Triple.h:947
bool isOSSolaris() const
Definition Triple.h:648
bool isRISCV32() const
Tests whether the target is 32-bit RISC-V.
Definition Triple.h:1073
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition Triple.h:733
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1634
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:420
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1421
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:1165
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:442
bool isOSVersionLT(const Triple &Other) const
Definition Triple.h:555
bool isPPC32() const
Tests whether the target is 32-bit PowerPC (little and big endian).
Definition Triple.h:1046
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:411
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:1766
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:774
bool isRISCV64() const
Tests whether the target is 64-bit RISC-V.
Definition Triple.h:1078
bool isCSKY() const
Definition Triple.h:1117
bool isLoongArch64() const
Tests whether the target is 64-bit LoongArch.
Definition Triple.h:1019
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1404
bool isSPARC32() const
Tests whether the target is 32-bit SPARC (little and big endian).
Definition Triple.h:1086
bool isSimulatorEnvironment() const
Definition Triple.h:616
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1621
const std::string & str() const
Definition Triple.h:478
bool isOSzOS() const
Definition Triple.h:602
bool isOSSerenity() const
Definition Triple.h:764
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:848
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:428
bool isOSOpenBSD() const
Definition Triple.h:634
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1596
bool isOSUnknown() const
Definition Triple.h:656
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1584
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition Triple.h:1025
bool isShaderModelOS() const
Definition Triple.h:859
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:674
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:679
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:834
const std::string & getTriple() const
Definition Triple.h:480
static LLVM_ABI StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition Triple.cpp:24
bool isOSBinFormatDXContainer() const
Tests whether the OS uses the DXContainer binary format.
Definition Triple.h:797
bool isGPU() const
Test whether the target triple is for a GPU.
Definition Triple.h:1270
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition Triple.h:792
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:289
bool isTargetMuslAEABI() const
Definition Triple.h:955
@ UnknownObjectFormat
Definition Triple.h:318
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:2162
bool isArmMClass() const
Tests whether the target is an M-class.
Definition Triple.h:983
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:728
bool isBridgeOS() const
Is this an Apple BridgeOS triple.
Definition Triple.h:597
bool isOSManagarm() const
Definition Triple.h:865
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1083
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:1016
bool isOSLiteOS() const
Definition Triple.h:852
@ UnknownVendor
Definition Triple.h:187
@ ImaginationTechnologies
Definition Triple.h:194
@ LastVendorType
Definition Triple.h:204
@ MipsTechnologies
Definition Triple.h:195
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:760
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2188
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1784
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1410
@ ARMSubArch_v6t2
Definition Triple.h:148
@ MipsSubArch_r6
Definition Triple.h:160
@ DXILSubArch_v1_2
Definition Triple.h:176
@ ARMSubArch_v7
Definition Triple.h:139
@ ARMSubArch_v8m_mainline
Definition Triple.h:137
@ ARMSubArch_v9_6a
Definition Triple.h:118
@ ARMSubArch_v8r
Definition Triple.h:135
@ ARMSubArch_v9_1a
Definition Triple.h:123
@ DXILSubArch_v1_1
Definition Triple.h:175
@ LatestDXILSubArch
Definition Triple.h:184
@ SPIRVSubArch_v10
Definition Triple.h:165
@ SPIRVSubArch_v13
Definition Triple.h:168
@ ARMSubArch_v7k
Definition Triple.h:143
@ ARMSubArch_v8_7a
Definition Triple.h:127
@ ARMSubArch_v8
Definition Triple.h:134
@ SPIRVSubArch_v16
Definition Triple.h:171
@ ARMSubArch_v8_1a
Definition Triple.h:133
@ ARMSubArch_v9_2a
Definition Triple.h:122
@ DXILSubArch_v1_3
Definition Triple.h:177
@ SPIRVSubArch_v15
Definition Triple.h:170
@ ARMSubArch_v7m
Definition Triple.h:141
@ ARMSubArch_v6k
Definition Triple.h:147
@ ARMSubArch_v5
Definition Triple.h:149
@ AArch64SubArch_arm64e
Definition Triple.h:153
@ ARMSubArch_v6
Definition Triple.h:145
@ ARMSubArch_v9_5a
Definition Triple.h:119
@ ARMSubArch_v7ve
Definition Triple.h:144
@ ARMSubArch_v8m_baseline
Definition Triple.h:136
@ ARMSubArch_v8_8a
Definition Triple.h:126
@ ARMSubArch_v8_2a
Definition Triple.h:132
@ ARMSubArch_v7s
Definition Triple.h:142
@ DXILSubArch_v1_0
Definition Triple.h:174
@ DXILSubArch_v1_7
Definition Triple.h:181
@ KalimbaSubArch_v3
Definition Triple.h:156
@ DXILSubArch_v1_5
Definition Triple.h:179
@ ARMSubArch_v8_4a
Definition Triple.h:130
@ ARMSubArch_v8_9a
Definition Triple.h:125
@ ARMSubArch_v7em
Definition Triple.h:140
@ SPIRVSubArch_v12
Definition Triple.h:167
@ SPIRVSubArch_v14
Definition Triple.h:169
@ KalimbaSubArch_v4
Definition Triple.h:157
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:138
@ ARMSubArch_v8_3a
Definition Triple.h:131
@ AArch64SubArch_arm64ec
Definition Triple.h:154
@ ARMSubArch_v8_6a
Definition Triple.h:128
@ ARMSubArch_v5te
Definition Triple.h:150
@ KalimbaSubArch_v5
Definition Triple.h:158
@ ARMSubArch_v4t
Definition Triple.h:151
@ DXILSubArch_v1_6
Definition Triple.h:180
@ DXILSubArch_v1_8
Definition Triple.h:182
@ ARMSubArch_v9_4a
Definition Triple.h:120
@ ARMSubArch_v8_5a
Definition Triple.h:129
@ ARMSubArch_v6m
Definition Triple.h:146
@ ARMSubArch_v9_3a
Definition Triple.h:121
@ DXILSubArch_v1_9
Definition Triple.h:183
@ ARMSubArch_v9
Definition Triple.h:124
@ DXILSubArch_v1_4
Definition Triple.h:178
@ SPIRVSubArch_v11
Definition Triple.h:166
@ PPCSubArch_spe
Definition Triple.h:162
LLVM_ABI bool getMacOSXVersion(VersionTuple &Version) const
Parse the version number as with getOSVersion and then translate generic "darwin" versions to the cor...
Definition Triple.cpp:1462
bool isSPARC64() const
Tests whether the target is 64-bit SPARC (big endian).
Definition Triple.h:1091
bool isWindowsCygwinEnvironment() const
Definition Triple.h:708
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:2276
Triple(StringRef Str)
Definition Triple.h:360
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:566
Triple(const std::string &Str)
Definition Triple.h:362
bool isOSFreeBSD() const
Definition Triple.h:638
bool isXROS() const
Is this an Apple XROS triple.
Definition Triple.h:594
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1682
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1646
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1674
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:417
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1094
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition Triple.h:1051
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:611
bool hasDLLImportExport() const
Tests if the environment supports dllimport/export annotations.
Definition Triple.h:1185
bool isSPIRVLogical() const
Tests whether the target is SPIR-V Logical.
Definition Triple.h:894
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:341
bool isOSVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Helper function for doing comparisons against version numbers included in the target triple.
Definition Triple.h:544
bool isTvOS() const
Is this an Apple tvOS triple.
Definition Triple.h:580
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition Triple.h:748
bool isWindowsArm64EC() const
Definition Triple.h:695
bool operator==(const Triple &Other) const
Definition Triple.h:370
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition Triple.h:585
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:483
bool isiOS() const
Is this an iOS triple.
Definition Triple.h:575
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1035
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition Triple.h:753
bool isTargetAEABI() const
Definition Triple.h:941
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:816
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1112
bool isVulkanOS() const
Definition Triple.h:863
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1389
bool isOSIAMCU() const
Definition Triple.h:652
bool isOpenHOS() const
Definition Triple.h:850
bool isMacCatalystEnvironment() const
Definition Triple.h:620
bool isPS5() const
Tests whether the target is the PS5 platform.
Definition Triple.h:809
bool isSPIRV() const
Tests whether the target is SPIR-V (32/64-bit/Logical).
Definition Triple.h:885
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:998
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:412
bool isAppleMachO() const
Is this an Apple MachO triple.
Definition Triple.h:605
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:1792
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:1962
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1510
bool hasDefaultEmulatedTLS() const
Tests whether the target uses emulated TLS as default.
Definition Triple.h:1169
bool isSystemZ() const
Tests whether the target is SystemZ.
Definition Triple.h:1097
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:1425
bool isPPC32SecurePlt() const
Tests whether the target 32-bit PowerPC uses Secure PLT.
Definition Triple.h:1064
bool isTime64ABI() const
Tests if the target forces 64-bit time_t on a 32-bit architecture.
Definition Triple.h:1145
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:1788
bool operator!=(const Triple &Other) const
Definition Triple.h:377
unsigned getOSMajorVersion() const
Return just the major version number, this is specialized because it is a common query.
Definition Triple.h:447
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2127
bool isOSFuchsia() const
Definition Triple.h:642
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:769
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:689
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:423
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition Triple.h:684
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition Triple.cpp:173
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition Triple.h:669
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition Triple.cpp:1638
bool isDXIL() const
Tests whether the target is DXIL.
Definition Triple.h:855
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1642
bool isGNUEnvironment() const
Definition Triple.h:658
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1022
bool isShaderStageEnvironment() const
Definition Triple.h:867
bool isWindowsItaniumEnvironment() const
Definition Triple.h:704
bool isVE() const
Tests whether the target is VE.
Definition Triple.h:1107
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getMajor() const
Retrieve the major version number.
This is an optimization pass for GlobalISel generic memory operations.
ExceptionHandling
Definition CodeGen.h:53
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302
@ Other
Any other memory.
Definition ModRef.h:68
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:851