[DWARF] Fix referencing Range List Tables from CUs for DWARF64.
[llvm-complete.git] / include / llvm / ADT / Triple.h
blobedeb31efab80132181c339fdb25d43ee368a3808
1 //===-- llvm/ADT/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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_ADT_TRIPLE_H
10 #define LLVM_ADT_TRIPLE_H
12 #include "llvm/ADT/Twine.h"
14 // Some system headers or GCC predefined macros conflict with identifiers in
15 // this file. Undefine them here.
16 #undef NetBSD
17 #undef mips
18 #undef sparc
20 namespace llvm {
22 /// Triple - Helper class for working with autoconf configuration names. For
23 /// historical reasons, we also call these 'triples' (they used to contain
24 /// exactly three fields).
25 ///
26 /// Configuration names are strings in the canonical form:
27 /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM
28 /// or
29 /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
30 ///
31 /// This class is used for clients which want to support arbitrary
32 /// configuration names, but also want to implement certain special
33 /// behavior for particular configurations. This class isolates the mapping
34 /// from the components of the configuration name to well known IDs.
35 ///
36 /// At its core the Triple class is designed to be a wrapper for a triple
37 /// string; the constructor does not change or normalize the triple string.
38 /// Clients that need to handle the non-canonical triples that users often
39 /// specify should use the normalize method.
40 ///
41 /// See autoconf/config.guess for a glimpse into what configuration names
42 /// look like in practice.
43 class Triple {
44 public:
45 enum ArchType {
46 UnknownArch,
48 arm, // ARM (little endian): arm, armv.*, xscale
49 armeb, // ARM (big endian): armeb
50 aarch64, // AArch64 (little endian): aarch64
51 aarch64_be, // AArch64 (big endian): aarch64_be
52 aarch64_32, // AArch64 (little endian) ILP32: aarch64_32
53 arc, // ARC: Synopsys ARC
54 avr, // AVR: Atmel AVR microcontroller
55 bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
56 bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
57 hexagon, // Hexagon: hexagon
58 mips, // MIPS: mips, mipsallegrex, mipsr6
59 mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
60 mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
61 mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
62 msp430, // MSP430: msp430
63 ppc, // PPC: powerpc
64 ppc64, // PPC64: powerpc64, ppu
65 ppc64le, // PPC64LE: powerpc64le
66 r600, // R600: AMD GPUs HD2XXX - HD6XXX
67 amdgcn, // AMDGCN: AMD GCN GPUs
68 riscv32, // RISC-V (32-bit): riscv32
69 riscv64, // RISC-V (64-bit): riscv64
70 sparc, // Sparc: sparc
71 sparcv9, // Sparcv9: Sparcv9
72 sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
73 systemz, // SystemZ: s390x
74 tce, // TCE (http://tce.cs.tut.fi/): tce
75 tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
76 thumb, // Thumb (little endian): thumb, thumbv.*
77 thumbeb, // Thumb (big endian): thumbeb
78 x86, // X86: i[3-9]86
79 x86_64, // X86-64: amd64, x86_64
80 xcore, // XCore: xcore
81 nvptx, // NVPTX: 32-bit
82 nvptx64, // NVPTX: 64-bit
83 le32, // le32: generic little-endian 32-bit CPU (PNaCl)
84 le64, // le64: generic little-endian 64-bit CPU (PNaCl)
85 amdil, // AMDIL
86 amdil64, // AMDIL with 64-bit pointers
87 hsail, // AMD HSAIL
88 hsail64, // AMD HSAIL with 64-bit pointers
89 spir, // SPIR: standard portable IR for OpenCL 32-bit version
90 spir64, // SPIR: standard portable IR for OpenCL 64-bit version
91 kalimba, // Kalimba: generic kalimba
92 shave, // SHAVE: Movidius vector VLIW processors
93 lanai, // Lanai: Lanai 32-bit
94 wasm32, // WebAssembly with 32-bit pointers
95 wasm64, // WebAssembly with 64-bit pointers
96 renderscript32, // 32-bit RenderScript
97 renderscript64, // 64-bit RenderScript
98 LastArchType = renderscript64
100 enum SubArchType {
101 NoSubArch,
103 ARMSubArch_v8_5a,
104 ARMSubArch_v8_4a,
105 ARMSubArch_v8_3a,
106 ARMSubArch_v8_2a,
107 ARMSubArch_v8_1a,
108 ARMSubArch_v8,
109 ARMSubArch_v8r,
110 ARMSubArch_v8m_baseline,
111 ARMSubArch_v8m_mainline,
112 ARMSubArch_v8_1m_mainline,
113 ARMSubArch_v7,
114 ARMSubArch_v7em,
115 ARMSubArch_v7m,
116 ARMSubArch_v7s,
117 ARMSubArch_v7k,
118 ARMSubArch_v7ve,
119 ARMSubArch_v6,
120 ARMSubArch_v6m,
121 ARMSubArch_v6k,
122 ARMSubArch_v6t2,
123 ARMSubArch_v5,
124 ARMSubArch_v5te,
125 ARMSubArch_v4t,
127 KalimbaSubArch_v3,
128 KalimbaSubArch_v4,
129 KalimbaSubArch_v5,
131 MipsSubArch_r6
133 enum VendorType {
134 UnknownVendor,
136 Apple,
138 SCEI,
139 BGP,
140 BGQ,
141 Freescale,
142 IBM,
143 ImaginationTechnologies,
144 MipsTechnologies,
145 NVIDIA,
146 CSR,
147 Myriad,
148 AMD,
149 Mesa,
150 SUSE,
151 OpenEmbedded,
152 LastVendorType = OpenEmbedded
154 enum OSType {
155 UnknownOS,
157 Ananas,
158 CloudABI,
159 Darwin,
160 DragonFly,
161 FreeBSD,
162 Fuchsia,
163 IOS,
164 KFreeBSD,
165 Linux,
166 Lv2, // PS3
167 MacOSX,
168 NetBSD,
169 OpenBSD,
170 Solaris,
171 Win32,
172 Haiku,
173 Minix,
174 RTEMS,
175 NaCl, // Native Client
176 CNK, // BG/P Compute-Node Kernel
177 AIX,
178 CUDA, // NVIDIA CUDA
179 NVCL, // NVIDIA OpenCL
180 AMDHSA, // AMD HSA Runtime
181 PS4,
182 ELFIAMCU,
183 TvOS, // Apple tvOS
184 WatchOS, // Apple watchOS
185 Mesa3D,
186 Contiki,
187 AMDPAL, // AMD PAL Runtime
188 HermitCore, // HermitCore Unikernel/Multikernel
189 Hurd, // GNU/Hurd
190 WASI, // Experimental WebAssembly OS
191 Emscripten,
192 LastOSType = Emscripten
194 enum EnvironmentType {
195 UnknownEnvironment,
197 GNU,
198 GNUABIN32,
199 GNUABI64,
200 GNUEABI,
201 GNUEABIHF,
202 GNUX32,
203 CODE16,
204 EABI,
205 EABIHF,
206 ELFv1,
207 ELFv2,
208 Android,
209 Musl,
210 MuslEABI,
211 MuslEABIHF,
213 MSVC,
214 Itanium,
215 Cygnus,
216 CoreCLR,
217 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
218 MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
219 LastEnvironmentType = MacABI
221 enum ObjectFormatType {
222 UnknownObjectFormat,
224 COFF,
225 ELF,
226 MachO,
227 Wasm,
228 XCOFF,
231 private:
232 std::string Data;
234 /// The parsed arch type.
235 ArchType Arch;
237 /// The parsed subarchitecture type.
238 SubArchType SubArch;
240 /// The parsed vendor type.
241 VendorType Vendor;
243 /// The parsed OS type.
244 OSType OS;
246 /// The parsed Environment type.
247 EnvironmentType Environment;
249 /// The object format type.
250 ObjectFormatType ObjectFormat;
252 public:
253 /// @name Constructors
254 /// @{
256 /// Default constructor is the same as an empty string and leaves all
257 /// triple fields unknown.
258 Triple()
259 : Data(), Arch(), SubArch(), Vendor(), OS(), Environment(),
260 ObjectFormat() {}
262 explicit Triple(const Twine &Str);
263 Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
264 Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
265 const Twine &EnvironmentStr);
267 bool operator==(const Triple &Other) const {
268 return Arch == Other.Arch && SubArch == Other.SubArch &&
269 Vendor == Other.Vendor && OS == Other.OS &&
270 Environment == Other.Environment &&
271 ObjectFormat == Other.ObjectFormat;
274 bool operator!=(const Triple &Other) const {
275 return !(*this == Other);
278 /// @}
279 /// @name Normalization
280 /// @{
282 /// normalize - Turn an arbitrary machine specification into the canonical
283 /// triple form (or something sensible that the Triple class understands if
284 /// nothing better can reasonably be done). In particular, it handles the
285 /// common case in which otherwise valid components are in the wrong order.
286 static std::string normalize(StringRef Str);
288 /// Return the normalized form of this triple's string.
289 std::string normalize() const { return normalize(Data); }
291 /// @}
292 /// @name Typed Component Access
293 /// @{
295 /// getArch - Get the parsed architecture type of this triple.
296 ArchType getArch() const { return Arch; }
298 /// getSubArch - get the parsed subarchitecture type for this triple.
299 SubArchType getSubArch() const { return SubArch; }
301 /// getVendor - Get the parsed vendor type of this triple.
302 VendorType getVendor() const { return Vendor; }
304 /// getOS - Get the parsed operating system type of this triple.
305 OSType getOS() const { return OS; }
307 /// hasEnvironment - Does this triple have the optional environment
308 /// (fourth) component?
309 bool hasEnvironment() const {
310 return getEnvironmentName() != "";
313 /// getEnvironment - Get the parsed environment type of this triple.
314 EnvironmentType getEnvironment() const { return Environment; }
316 /// Parse the version number from the OS name component of the
317 /// triple, if present.
319 /// For example, "fooos1.2.3" would return (1, 2, 3).
321 /// If an entry is not defined, it will be returned as 0.
322 void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
323 unsigned &Micro) const;
325 /// getFormat - Get the object format for this triple.
326 ObjectFormatType getObjectFormat() const { return ObjectFormat; }
328 /// getOSVersion - Parse the version number from the OS name component of the
329 /// triple, if present.
331 /// For example, "fooos1.2.3" would return (1, 2, 3).
333 /// If an entry is not defined, it will be returned as 0.
334 void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
336 /// getOSMajorVersion - Return just the major version number, this is
337 /// specialized because it is a common query.
338 unsigned getOSMajorVersion() const {
339 unsigned Maj, Min, Micro;
340 getOSVersion(Maj, Min, Micro);
341 return Maj;
344 /// getMacOSXVersion - Parse the version number as with getOSVersion and then
345 /// translate generic "darwin" versions to the corresponding OS X versions.
346 /// This may also be called with IOS triples but the OS X version number is
347 /// just set to a constant 10.4.0 in that case. Returns true if successful.
348 bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
349 unsigned &Micro) const;
351 /// getiOSVersion - Parse the version number as with getOSVersion. This should
352 /// only be called with IOS or generic triples.
353 void getiOSVersion(unsigned &Major, unsigned &Minor,
354 unsigned &Micro) const;
356 /// getWatchOSVersion - Parse the version number as with getOSVersion. This
357 /// should only be called with WatchOS or generic triples.
358 void getWatchOSVersion(unsigned &Major, unsigned &Minor,
359 unsigned &Micro) const;
361 /// @}
362 /// @name Direct Component Access
363 /// @{
365 const std::string &str() const { return Data; }
367 const std::string &getTriple() const { return Data; }
369 /// getArchName - Get the architecture (first) component of the
370 /// triple.
371 StringRef getArchName() const;
373 /// getVendorName - Get the vendor (second) component of the triple.
374 StringRef getVendorName() const;
376 /// getOSName - Get the operating system (third) component of the
377 /// triple.
378 StringRef getOSName() const;
380 /// getEnvironmentName - Get the optional environment (fourth)
381 /// component of the triple, or "" if empty.
382 StringRef getEnvironmentName() const;
384 /// getOSAndEnvironmentName - Get the operating system and optional
385 /// environment components as a single string (separated by a '-'
386 /// if the environment component is present).
387 StringRef getOSAndEnvironmentName() const;
389 /// @}
390 /// @name Convenience Predicates
391 /// @{
393 /// Test whether the architecture is 64-bit
395 /// Note that this tests for 64-bit pointer width, and nothing else. Note
396 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
397 /// 16-bit. The inner details of pointer width for particular architectures
398 /// is not summed up in the triple, and so only a coarse grained predicate
399 /// system is provided.
400 bool isArch64Bit() const;
402 /// Test whether the architecture is 32-bit
404 /// Note that this tests for 32-bit pointer width, and nothing else.
405 bool isArch32Bit() const;
407 /// Test whether the architecture is 16-bit
409 /// Note that this tests for 16-bit pointer width, and nothing else.
410 bool isArch16Bit() const;
412 /// isOSVersionLT - Helper function for doing comparisons against version
413 /// numbers included in the target triple.
414 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
415 unsigned Micro = 0) const {
416 unsigned LHS[3];
417 getOSVersion(LHS[0], LHS[1], LHS[2]);
419 if (LHS[0] != Major)
420 return LHS[0] < Major;
421 if (LHS[1] != Minor)
422 return LHS[1] < Minor;
423 if (LHS[2] != Micro)
424 return LHS[2] < Micro;
426 return false;
429 bool isOSVersionLT(const Triple &Other) const {
430 unsigned RHS[3];
431 Other.getOSVersion(RHS[0], RHS[1], RHS[2]);
432 return isOSVersionLT(RHS[0], RHS[1], RHS[2]);
435 /// isMacOSXVersionLT - Comparison function for checking OS X version
436 /// compatibility, which handles supporting skewed version numbering schemes
437 /// used by the "darwin" triples.
438 bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
439 unsigned Micro = 0) const {
440 assert(isMacOSX() && "Not an OS X triple!");
442 // If this is OS X, expect a sane version number.
443 if (getOS() == Triple::MacOSX)
444 return isOSVersionLT(Major, Minor, Micro);
446 // Otherwise, compare to the "Darwin" number.
447 assert(Major == 10 && "Unexpected major version");
448 return isOSVersionLT(Minor + 4, Micro, 0);
451 /// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
452 /// "darwin" and "osx" as OS X triples.
453 bool isMacOSX() const {
454 return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
457 /// Is this an iOS triple.
458 /// Note: This identifies tvOS as a variant of iOS. If that ever
459 /// changes, i.e., if the two operating systems diverge or their version
460 /// numbers get out of sync, that will need to be changed.
461 /// watchOS has completely different version numbers so it is not included.
462 bool isiOS() const {
463 return getOS() == Triple::IOS || isTvOS();
466 /// Is this an Apple tvOS triple.
467 bool isTvOS() const {
468 return getOS() == Triple::TvOS;
471 /// Is this an Apple watchOS triple.
472 bool isWatchOS() const {
473 return getOS() == Triple::WatchOS;
476 bool isWatchABI() const {
477 return getSubArch() == Triple::ARMSubArch_v7k;
480 /// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
481 bool isOSDarwin() const {
482 return isMacOSX() || isiOS() || isWatchOS();
485 bool isSimulatorEnvironment() const {
486 return getEnvironment() == Triple::Simulator;
489 bool isMacCatalystEnvironment() const {
490 return getEnvironment() == Triple::MacABI;
493 bool isOSNetBSD() const {
494 return getOS() == Triple::NetBSD;
497 bool isOSOpenBSD() const {
498 return getOS() == Triple::OpenBSD;
501 bool isOSFreeBSD() const {
502 return getOS() == Triple::FreeBSD;
505 bool isOSFuchsia() const {
506 return getOS() == Triple::Fuchsia;
509 bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
511 bool isOSSolaris() const {
512 return getOS() == Triple::Solaris;
515 bool isOSIAMCU() const {
516 return getOS() == Triple::ELFIAMCU;
519 bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
521 bool isGNUEnvironment() const {
522 EnvironmentType Env = getEnvironment();
523 return Env == Triple::GNU || Env == Triple::GNUABIN32 ||
524 Env == Triple::GNUABI64 || Env == Triple::GNUEABI ||
525 Env == Triple::GNUEABIHF || Env == Triple::GNUX32;
528 bool isOSContiki() const {
529 return getOS() == Triple::Contiki;
532 /// Tests whether the OS is Haiku.
533 bool isOSHaiku() const {
534 return getOS() == Triple::Haiku;
537 /// Tests whether the OS is Windows.
538 bool isOSWindows() const {
539 return getOS() == Triple::Win32;
542 /// Checks if the environment is MSVC.
543 bool isKnownWindowsMSVCEnvironment() const {
544 return isOSWindows() && getEnvironment() == Triple::MSVC;
547 /// Checks if the environment could be MSVC.
548 bool isWindowsMSVCEnvironment() const {
549 return isKnownWindowsMSVCEnvironment() ||
550 (isOSWindows() && getEnvironment() == Triple::UnknownEnvironment);
553 bool isWindowsCoreCLREnvironment() const {
554 return isOSWindows() && getEnvironment() == Triple::CoreCLR;
557 bool isWindowsItaniumEnvironment() const {
558 return isOSWindows() && getEnvironment() == Triple::Itanium;
561 bool isWindowsCygwinEnvironment() const {
562 return isOSWindows() && getEnvironment() == Triple::Cygnus;
565 bool isWindowsGNUEnvironment() const {
566 return isOSWindows() && getEnvironment() == Triple::GNU;
569 /// Tests for either Cygwin or MinGW OS
570 bool isOSCygMing() const {
571 return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment();
574 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
575 bool isOSMSVCRT() const {
576 return isWindowsMSVCEnvironment() || isWindowsGNUEnvironment() ||
577 isWindowsItaniumEnvironment();
580 /// Tests whether the OS is NaCl (Native Client)
581 bool isOSNaCl() const {
582 return getOS() == Triple::NaCl;
585 /// Tests whether the OS is Linux.
586 bool isOSLinux() const {
587 return getOS() == Triple::Linux;
590 /// Tests whether the OS is kFreeBSD.
591 bool isOSKFreeBSD() const {
592 return getOS() == Triple::KFreeBSD;
595 /// Tests whether the OS is Hurd.
596 bool isOSHurd() const {
597 return getOS() == Triple::Hurd;
600 /// Tests whether the OS is WASI.
601 bool isOSWASI() const {
602 return getOS() == Triple::WASI;
605 /// Tests whether the OS is Emscripten.
606 bool isOSEmscripten() const {
607 return getOS() == Triple::Emscripten;
610 /// Tests whether the OS uses glibc.
611 bool isOSGlibc() const {
612 return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
613 getOS() == Triple::Hurd) &&
614 !isAndroid();
617 /// Tests whether the OS is AIX.
618 bool isOSAIX() const {
619 return getOS() == Triple::AIX;
622 /// Tests whether the OS uses the ELF binary format.
623 bool isOSBinFormatELF() const {
624 return getObjectFormat() == Triple::ELF;
627 /// Tests whether the OS uses the COFF binary format.
628 bool isOSBinFormatCOFF() const {
629 return getObjectFormat() == Triple::COFF;
632 /// Tests whether the environment is MachO.
633 bool isOSBinFormatMachO() const {
634 return getObjectFormat() == Triple::MachO;
637 /// Tests whether the OS uses the Wasm binary format.
638 bool isOSBinFormatWasm() const {
639 return getObjectFormat() == Triple::Wasm;
642 /// Tests whether the OS uses the XCOFF binary format.
643 bool isOSBinFormatXCOFF() const {
644 return getObjectFormat() == Triple::XCOFF;
647 /// Tests whether the target is the PS4 CPU
648 bool isPS4CPU() const {
649 return getArch() == Triple::x86_64 &&
650 getVendor() == Triple::SCEI &&
651 getOS() == Triple::PS4;
654 /// Tests whether the target is the PS4 platform
655 bool isPS4() const {
656 return getVendor() == Triple::SCEI &&
657 getOS() == Triple::PS4;
660 /// Tests whether the target is Android
661 bool isAndroid() const { return getEnvironment() == Triple::Android; }
663 bool isAndroidVersionLT(unsigned Major) const {
664 assert(isAndroid() && "Not an Android triple!");
666 unsigned Env[3];
667 getEnvironmentVersion(Env[0], Env[1], Env[2]);
669 // 64-bit targets did not exist before API level 21 (Lollipop).
670 if (isArch64Bit() && Env[0] < 21)
671 Env[0] = 21;
673 return Env[0] < Major;
676 /// Tests whether the environment is musl-libc
677 bool isMusl() const {
678 return getEnvironment() == Triple::Musl ||
679 getEnvironment() == Triple::MuslEABI ||
680 getEnvironment() == Triple::MuslEABIHF;
683 /// Tests whether the target is SPIR (32- or 64-bit).
684 bool isSPIR() const {
685 return getArch() == Triple::spir || getArch() == Triple::spir64;
688 /// Tests whether the target is NVPTX (32- or 64-bit).
689 bool isNVPTX() const {
690 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
693 /// Tests whether the target is Thumb (little and big endian).
694 bool isThumb() const {
695 return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
698 /// Tests whether the target is ARM (little and big endian).
699 bool isARM() const {
700 return getArch() == Triple::arm || getArch() == Triple::armeb;
703 /// Tests whether the target is AArch64 (little and big endian).
704 bool isAArch64() const {
705 return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be;
708 /// Tests whether the target is MIPS 32-bit (little and big endian).
709 bool isMIPS32() const {
710 return getArch() == Triple::mips || getArch() == Triple::mipsel;
713 /// Tests whether the target is MIPS 64-bit (little and big endian).
714 bool isMIPS64() const {
715 return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
718 /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
719 bool isMIPS() const {
720 return isMIPS32() || isMIPS64();
723 /// Tests whether the target is 64-bit PowerPC (little and big endian).
724 bool isPPC64() const {
725 return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
728 /// Tests whether the target is RISC-V (32- and 64-bit).
729 bool isRISCV() const {
730 return getArch() == Triple::riscv32 || getArch() == Triple::riscv64;
733 /// Tests whether the target supports comdat
734 bool supportsCOMDAT() const {
735 return !isOSBinFormatMachO();
738 /// Tests whether the target uses emulated TLS as default.
739 bool hasDefaultEmulatedTLS() const {
740 return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
743 /// @}
744 /// @name Mutators
745 /// @{
747 /// setArch - Set the architecture (first) component of the triple
748 /// to a known type.
749 void setArch(ArchType Kind);
751 /// setVendor - Set the vendor (second) component of the triple to a
752 /// known type.
753 void setVendor(VendorType Kind);
755 /// setOS - Set the operating system (third) component of the triple
756 /// to a known type.
757 void setOS(OSType Kind);
759 /// setEnvironment - Set the environment (fourth) component of the triple
760 /// to a known type.
761 void setEnvironment(EnvironmentType Kind);
763 /// setObjectFormat - Set the object file format
764 void setObjectFormat(ObjectFormatType Kind);
766 /// setTriple - Set all components to the new triple \p Str.
767 void setTriple(const Twine &Str);
769 /// setArchName - Set the architecture (first) component of the
770 /// triple by name.
771 void setArchName(StringRef Str);
773 /// setVendorName - Set the vendor (second) component of the triple
774 /// by name.
775 void setVendorName(StringRef Str);
777 /// setOSName - Set the operating system (third) component of the
778 /// triple by name.
779 void setOSName(StringRef Str);
781 /// setEnvironmentName - Set the optional environment (fourth)
782 /// component of the triple by name.
783 void setEnvironmentName(StringRef Str);
785 /// setOSAndEnvironmentName - Set the operating system and optional
786 /// environment components with a single string.
787 void setOSAndEnvironmentName(StringRef Str);
789 /// @}
790 /// @name Helpers to build variants of a particular triple.
791 /// @{
793 /// Form a triple with a 32-bit variant of the current architecture.
795 /// This can be used to move across "families" of architectures where useful.
797 /// \returns A new triple with a 32-bit architecture or an unknown
798 /// architecture if no such variant can be found.
799 llvm::Triple get32BitArchVariant() const;
801 /// Form a triple with a 64-bit variant of the current architecture.
803 /// This can be used to move across "families" of architectures where useful.
805 /// \returns A new triple with a 64-bit architecture or an unknown
806 /// architecture if no such variant can be found.
807 llvm::Triple get64BitArchVariant() const;
809 /// Form a triple with a big endian variant of the current architecture.
811 /// This can be used to move across "families" of architectures where useful.
813 /// \returns A new triple with a big endian architecture or an unknown
814 /// architecture if no such variant can be found.
815 llvm::Triple getBigEndianArchVariant() const;
817 /// Form a triple with a little endian variant of the current architecture.
819 /// This can be used to move across "families" of architectures where useful.
821 /// \returns A new triple with a little endian architecture or an unknown
822 /// architecture if no such variant can be found.
823 llvm::Triple getLittleEndianArchVariant() const;
825 /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
827 /// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
828 /// string then the triple's arch name is used.
829 StringRef getARMCPUForArch(StringRef Arch = StringRef()) const;
831 /// Tests whether the target triple is little endian.
833 /// \returns true if the triple is little endian, false otherwise.
834 bool isLittleEndian() const;
836 /// Test whether target triples are compatible.
837 bool isCompatibleWith(const Triple &Other) const;
839 /// Merge target triples.
840 std::string merge(const Triple &Other) const;
842 /// @}
843 /// @name Static helpers for IDs.
844 /// @{
846 /// getArchTypeName - Get the canonical name for the \p Kind architecture.
847 static StringRef getArchTypeName(ArchType Kind);
849 /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind
850 /// architecture. This is the prefix used by the architecture specific
851 /// builtins, and is suitable for passing to \see
852 /// Intrinsic::getIntrinsicForGCCBuiltin().
854 /// \return - The architecture prefix, or 0 if none is defined.
855 static StringRef getArchTypePrefix(ArchType Kind);
857 /// getVendorTypeName - Get the canonical name for the \p Kind vendor.
858 static StringRef getVendorTypeName(VendorType Kind);
860 /// getOSTypeName - Get the canonical name for the \p Kind operating system.
861 static StringRef getOSTypeName(OSType Kind);
863 /// getEnvironmentTypeName - Get the canonical name for the \p Kind
864 /// environment.
865 static StringRef getEnvironmentTypeName(EnvironmentType Kind);
867 /// @}
868 /// @name Static helpers for converting alternate architecture names.
869 /// @{
871 /// getArchTypeForLLVMName - The canonical type for the given LLVM
872 /// architecture name (e.g., "x86").
873 static ArchType getArchTypeForLLVMName(StringRef Str);
875 /// @}
878 } // End llvm namespace
881 #endif