1//===-- llvm/ADT/Triple.h - Target triple helper class ----------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_ADT_TRIPLE_H
11#define LLVM_ADT_TRIPLE_H
12
13#include "llvm/ADT/Twine.h"
14
15// Some system headers or GCC predefined macros conflict with identifiers in
16// this file.  Undefine them here.
17#undef NetBSD
18#undef mips
19#undef sparc
20
21namespace llvm {
22
23/// Triple - Helper class for working with autoconf configuration names. For
24/// historical reasons, we also call these 'triples' (they used to contain
25/// exactly three fields).
26///
27/// Configuration names are strings in the canonical form:
28///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM
29/// or
30///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
31///
32/// This class is used for clients which want to support arbitrary
33/// configuration names, but also want to implement certain special
34/// behavior for particular configurations. This class isolates the mapping
35/// from the components of the configuration name to well known IDs.
36///
37/// At its core the Triple class is designed to be a wrapper for a triple
38/// string; the constructor does not change or normalize the triple string.
39/// Clients that need to handle the non-canonical triples that users often
40/// specify should use the normalize method.
41///
42/// See autoconf/config.guess for a glimpse into what configuration names
43/// look like in practice.
44class Triple {
45public:
46  enum ArchType {
47    UnknownArch,
48
49    arm,            // ARM (little endian): arm, armv.*, xscale
50    armeb,          // ARM (big endian): armeb
51    aarch64,        // AArch64 (little endian): aarch64
52    aarch64_be,     // AArch64 (big endian): aarch64_be
53    avr,            // AVR: Atmel AVR microcontroller
54    bpfel,          // eBPF or extended BPF or 64-bit BPF (little endian)
55    bpfeb,          // eBPF or extended BPF or 64-bit BPF (big endian)
56    hexagon,        // Hexagon: hexagon
57    mips,           // MIPS: mips, mipsallegrex
58    mipsel,         // MIPSEL: mipsel, mipsallegrexel
59    mips64,         // MIPS64: mips64
60    mips64el,       // MIPS64EL: mips64el
61    msp430,         // MSP430: msp430
62    nios2,          // NIOSII: nios2
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
99  };
100  enum SubArchType {
101    NoSubArch,
102
103    ARMSubArch_v8_2a,
104    ARMSubArch_v8_1a,
105    ARMSubArch_v8,
106    ARMSubArch_v8r,
107    ARMSubArch_v8m_baseline,
108    ARMSubArch_v8m_mainline,
109    ARMSubArch_v7,
110    ARMSubArch_v7em,
111    ARMSubArch_v7m,
112    ARMSubArch_v7s,
113    ARMSubArch_v7k,
114    ARMSubArch_v7ve,
115    ARMSubArch_v6,
116    ARMSubArch_v6m,
117    ARMSubArch_v6k,
118    ARMSubArch_v6t2,
119    ARMSubArch_v5,
120    ARMSubArch_v5te,
121    ARMSubArch_v4t,
122
123    KalimbaSubArch_v3,
124    KalimbaSubArch_v4,
125    KalimbaSubArch_v5
126  };
127  enum VendorType {
128    UnknownVendor,
129
130    Apple,
131    PC,
132    SCEI,
133    BGP,
134    BGQ,
135    Freescale,
136    IBM,
137    ImaginationTechnologies,
138    MipsTechnologies,
139    NVIDIA,
140    CSR,
141    Myriad,
142    AMD,
143    Mesa,
144    SUSE,
145    LastVendorType = SUSE
146  };
147  enum OSType {
148    UnknownOS,
149
150    Ananas,
151    CloudABI,
152    Darwin,
153    DragonFly,
154    FreeBSD,
155    Fuchsia,
156    IOS,
157    KFreeBSD,
158    Linux,
159    Lv2,        // PS3
160    MacOSX,
161    NetBSD,
162    OpenBSD,
163    Solaris,
164    Win32,
165    Haiku,
166    Minix,
167    RTEMS,
168    NaCl,       // Native Client
169    CNK,        // BG/P Compute-Node Kernel
170    Bitrig,
171    AIX,
172    CUDA,       // NVIDIA CUDA
173    NVCL,       // NVIDIA OpenCL
174    AMDHSA,     // AMD HSA Runtime
175    PS4,
176    ELFIAMCU,
177    TvOS,       // Apple tvOS
178    WatchOS,    // Apple watchOS
179    Mesa3D,
180    Contiki,
181    LastOSType = Contiki
182  };
183  enum EnvironmentType {
184    UnknownEnvironment,
185
186    GNU,
187    GNUABI64,
188    GNUEABI,
189    GNUEABIHF,
190    GNUX32,
191    CODE16,
192    EABI,
193    EABIHF,
194    Android,
195    Musl,
196    MuslEABI,
197    MuslEABIHF,
198
199    MSVC,
200    Itanium,
201    Cygnus,
202    AMDOpenCL,
203    CoreCLR,
204    OpenCL,
205    LastEnvironmentType = OpenCL
206  };
207  enum ObjectFormatType {
208    UnknownObjectFormat,
209
210    COFF,
211    ELF,
212    MachO,
213    Wasm,
214  };
215
216private:
217  std::string Data;
218
219  /// The parsed arch type.
220  ArchType Arch;
221
222  /// The parsed subarchitecture type.
223  SubArchType SubArch;
224
225  /// The parsed vendor type.
226  VendorType Vendor;
227
228  /// The parsed OS type.
229  OSType OS;
230
231  /// The parsed Environment type.
232  EnvironmentType Environment;
233
234  /// The object format type.
235  ObjectFormatType ObjectFormat;
236
237public:
238  /// @name Constructors
239  /// @{
240
241  /// Default constructor is the same as an empty string and leaves all
242  /// triple fields unknown.
243  Triple()
244      : Data(), Arch(), SubArch(), Vendor(), OS(), Environment(),
245        ObjectFormat() {}
246
247  explicit Triple(const Twine &Str);
248  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
249  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
250         const Twine &EnvironmentStr);
251
252  bool operator==(const Triple &Other) const {
253    return Arch == Other.Arch && SubArch == Other.SubArch &&
254           Vendor == Other.Vendor && OS == Other.OS &&
255           Environment == Other.Environment &&
256           ObjectFormat == Other.ObjectFormat;
257  }
258
259  bool operator!=(const Triple &Other) const {
260    return !(*this == Other);
261  }
262
263  /// @}
264  /// @name Normalization
265  /// @{
266
267  /// normalize - Turn an arbitrary machine specification into the canonical
268  /// triple form (or something sensible that the Triple class understands if
269  /// nothing better can reasonably be done).  In particular, it handles the
270  /// common case in which otherwise valid components are in the wrong order.
271  static std::string normalize(StringRef Str);
272
273  /// Return the normalized form of this triple's string.
274  std::string normalize() const { return normalize(Data); }
275
276  /// @}
277  /// @name Typed Component Access
278  /// @{
279
280  /// getArch - Get the parsed architecture type of this triple.
281  ArchType getArch() const { return Arch; }
282
283  /// getSubArch - get the parsed subarchitecture type for this triple.
284  SubArchType getSubArch() const { return SubArch; }
285
286  /// getVendor - Get the parsed vendor type of this triple.
287  VendorType getVendor() const { return Vendor; }
288
289  /// getOS - Get the parsed operating system type of this triple.
290  OSType getOS() const { return OS; }
291
292  /// hasEnvironment - Does this triple have the optional environment
293  /// (fourth) component?
294  bool hasEnvironment() const {
295    return getEnvironmentName() != "";
296  }
297
298  /// getEnvironment - Get the parsed environment type of this triple.
299  EnvironmentType getEnvironment() const { return Environment; }
300
301  /// Parse the version number from the OS name component of the
302  /// triple, if present.
303  ///
304  /// For example, "fooos1.2.3" would return (1, 2, 3).
305  ///
306  /// If an entry is not defined, it will be returned as 0.
307  void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
308                             unsigned &Micro) const;
309
310  /// getFormat - Get the object format for this triple.
311  ObjectFormatType getObjectFormat() const { return ObjectFormat; }
312
313  /// getOSVersion - Parse the version number from the OS name component of the
314  /// triple, if present.
315  ///
316  /// For example, "fooos1.2.3" would return (1, 2, 3).
317  ///
318  /// If an entry is not defined, it will be returned as 0.
319  void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
320
321  /// getOSMajorVersion - Return just the major version number, this is
322  /// specialized because it is a common query.
323  unsigned getOSMajorVersion() const {
324    unsigned Maj, Min, Micro;
325    getOSVersion(Maj, Min, Micro);
326    return Maj;
327  }
328
329  /// getMacOSXVersion - Parse the version number as with getOSVersion and then
330  /// translate generic "darwin" versions to the corresponding OS X versions.
331  /// This may also be called with IOS triples but the OS X version number is
332  /// just set to a constant 10.4.0 in that case.  Returns true if successful.
333  bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
334                        unsigned &Micro) const;
335
336  /// getiOSVersion - Parse the version number as with getOSVersion.  This should
337  /// only be called with IOS or generic triples.
338  void getiOSVersion(unsigned &Major, unsigned &Minor,
339                     unsigned &Micro) const;
340
341  /// getWatchOSVersion - Parse the version number as with getOSVersion.  This
342  /// should only be called with WatchOS or generic triples.
343  void getWatchOSVersion(unsigned &Major, unsigned &Minor,
344                         unsigned &Micro) const;
345
346  /// @}
347  /// @name Direct Component Access
348  /// @{
349
350  const std::string &str() const { return Data; }
351
352  const std::string &getTriple() const { return Data; }
353
354  /// getArchName - Get the architecture (first) component of the
355  /// triple.
356  StringRef getArchName() const;
357
358  /// getVendorName - Get the vendor (second) component of the triple.
359  StringRef getVendorName() const;
360
361  /// getOSName - Get the operating system (third) component of the
362  /// triple.
363  StringRef getOSName() const;
364
365  /// getEnvironmentName - Get the optional environment (fourth)
366  /// component of the triple, or "" if empty.
367  StringRef getEnvironmentName() const;
368
369  /// getOSAndEnvironmentName - Get the operating system and optional
370  /// environment components as a single string (separated by a '-'
371  /// if the environment component is present).
372  StringRef getOSAndEnvironmentName() const;
373
374  /// @}
375  /// @name Convenience Predicates
376  /// @{
377
378  /// Test whether the architecture is 64-bit
379  ///
380  /// Note that this tests for 64-bit pointer width, and nothing else. Note
381  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
382  /// 16-bit. The inner details of pointer width for particular architectures
383  /// is not summed up in the triple, and so only a coarse grained predicate
384  /// system is provided.
385  bool isArch64Bit() const;
386
387  /// Test whether the architecture is 32-bit
388  ///
389  /// Note that this tests for 32-bit pointer width, and nothing else.
390  bool isArch32Bit() const;
391
392  /// Test whether the architecture is 16-bit
393  ///
394  /// Note that this tests for 16-bit pointer width, and nothing else.
395  bool isArch16Bit() const;
396
397  /// isOSVersionLT - Helper function for doing comparisons against version
398  /// numbers included in the target triple.
399  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
400                     unsigned Micro = 0) const {
401    unsigned LHS[3];
402    getOSVersion(LHS[0], LHS[1], LHS[2]);
403
404    if (LHS[0] != Major)
405      return LHS[0] < Major;
406    if (LHS[1] != Minor)
407      return LHS[1] < Minor;
408    if (LHS[2] != Micro)
409      return LHS[1] < Micro;
410
411    return false;
412  }
413
414  bool isOSVersionLT(const Triple &Other) const {
415    unsigned RHS[3];
416    Other.getOSVersion(RHS[0], RHS[1], RHS[2]);
417    return isOSVersionLT(RHS[0], RHS[1], RHS[2]);
418  }
419
420  /// isMacOSXVersionLT - Comparison function for checking OS X version
421  /// compatibility, which handles supporting skewed version numbering schemes
422  /// used by the "darwin" triples.
423  bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
424                         unsigned Micro = 0) const {
425    assert(isMacOSX() && "Not an OS X triple!");
426
427    // If this is OS X, expect a sane version number.
428    if (getOS() == Triple::MacOSX)
429      return isOSVersionLT(Major, Minor, Micro);
430
431    // Otherwise, compare to the "Darwin" number.
432    assert(Major == 10 && "Unexpected major version");
433    return isOSVersionLT(Minor + 4, Micro, 0);
434  }
435
436  /// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
437  /// "darwin" and "osx" as OS X triples.
438  bool isMacOSX() const {
439    return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
440  }
441
442  /// Is this an iOS triple.
443  /// Note: This identifies tvOS as a variant of iOS. If that ever
444  /// changes, i.e., if the two operating systems diverge or their version
445  /// numbers get out of sync, that will need to be changed.
446  /// watchOS has completely different version numbers so it is not included.
447  bool isiOS() const {
448    return getOS() == Triple::IOS || isTvOS();
449  }
450
451  /// Is this an Apple tvOS triple.
452  bool isTvOS() const {
453    return getOS() == Triple::TvOS;
454  }
455
456  /// Is this an Apple watchOS triple.
457  bool isWatchOS() const {
458    return getOS() == Triple::WatchOS;
459  }
460
461  bool isWatchABI() const {
462    return getSubArch() == Triple::ARMSubArch_v7k;
463  }
464
465  /// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
466  bool isOSDarwin() const {
467    return isMacOSX() || isiOS() || isWatchOS();
468  }
469
470  bool isOSNetBSD() const {
471    return getOS() == Triple::NetBSD;
472  }
473
474  bool isOSOpenBSD() const {
475    return getOS() == Triple::OpenBSD;
476  }
477
478  bool isOSFreeBSD() const {
479    return getOS() == Triple::FreeBSD;
480  }
481
482  bool isOSFuchsia() const {
483    return getOS() == Triple::Fuchsia;
484  }
485
486  bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
487
488  bool isOSSolaris() const {
489    return getOS() == Triple::Solaris;
490  }
491
492  bool isOSBitrig() const {
493    return getOS() == Triple::Bitrig;
494  }
495
496  bool isOSIAMCU() const {
497    return getOS() == Triple::ELFIAMCU;
498  }
499
500  bool isGNUEnvironment() const {
501    EnvironmentType Env = getEnvironment();
502    return Env == Triple::GNU || Env == Triple::GNUABI64 ||
503           Env == Triple::GNUEABI || Env == Triple::GNUEABIHF ||
504           Env == Triple::GNUX32;
505  }
506
507  bool isOSContiki() const {
508    return getOS() == Triple::Contiki;
509  }
510
511  /// Checks if the environment could be MSVC.
512  bool isWindowsMSVCEnvironment() const {
513    return getOS() == Triple::Win32 &&
514           (getEnvironment() == Triple::UnknownEnvironment ||
515            getEnvironment() == Triple::MSVC);
516  }
517
518  /// Checks if the environment is MSVC.
519  bool isKnownWindowsMSVCEnvironment() const {
520    return getOS() == Triple::Win32 && getEnvironment() == Triple::MSVC;
521  }
522
523  bool isWindowsCoreCLREnvironment() const {
524    return getOS() == Triple::Win32 && getEnvironment() == Triple::CoreCLR;
525  }
526
527  bool isWindowsItaniumEnvironment() const {
528    return getOS() == Triple::Win32 && getEnvironment() == Triple::Itanium;
529  }
530
531  bool isWindowsCygwinEnvironment() const {
532    return getOS() == Triple::Win32 && getEnvironment() == Triple::Cygnus;
533  }
534
535  bool isWindowsGNUEnvironment() const {
536    return getOS() == Triple::Win32 && getEnvironment() == Triple::GNU;
537  }
538
539  /// Tests for either Cygwin or MinGW OS
540  bool isOSCygMing() const {
541    return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment();
542  }
543
544  /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
545  bool isOSMSVCRT() const {
546    return isWindowsMSVCEnvironment() || isWindowsGNUEnvironment() ||
547           isWindowsItaniumEnvironment();
548  }
549
550  /// Tests whether the OS is Windows.
551  bool isOSWindows() const {
552    return getOS() == Triple::Win32;
553  }
554
555  /// Tests whether the OS is NaCl (Native Client)
556  bool isOSNaCl() const {
557    return getOS() == Triple::NaCl;
558  }
559
560  /// Tests whether the OS is Linux.
561  bool isOSLinux() const {
562    return getOS() == Triple::Linux;
563  }
564
565  /// Tests whether the OS is kFreeBSD.
566  bool isOSKFreeBSD() const {
567    return getOS() == Triple::KFreeBSD;
568  }
569
570  /// Tests whether the OS uses glibc.
571  bool isOSGlibc() const {
572    return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD) &&
573           !isAndroid();
574  }
575
576  /// Tests whether the OS uses the ELF binary format.
577  bool isOSBinFormatELF() const {
578    return getObjectFormat() == Triple::ELF;
579  }
580
581  /// Tests whether the OS uses the COFF binary format.
582  bool isOSBinFormatCOFF() const {
583    return getObjectFormat() == Triple::COFF;
584  }
585
586  /// Tests whether the environment is MachO.
587  bool isOSBinFormatMachO() const {
588    return getObjectFormat() == Triple::MachO;
589  }
590
591  /// Tests whether the OS uses the Wasm binary format.
592  bool isOSBinFormatWasm() const {
593    return getObjectFormat() == Triple::Wasm;
594  }
595
596  /// Tests whether the target is the PS4 CPU
597  bool isPS4CPU() const {
598    return getArch() == Triple::x86_64 &&
599           getVendor() == Triple::SCEI &&
600           getOS() == Triple::PS4;
601  }
602
603  /// Tests whether the target is the PS4 platform
604  bool isPS4() const {
605    return getVendor() == Triple::SCEI &&
606           getOS() == Triple::PS4;
607  }
608
609  /// Tests whether the target is Android
610  bool isAndroid() const { return getEnvironment() == Triple::Android; }
611
612  bool isAndroidVersionLT(unsigned Major) const {
613    assert(isAndroid() && "Not an Android triple!");
614
615    unsigned Env[3];
616    getEnvironmentVersion(Env[0], Env[1], Env[2]);
617
618    // 64-bit targets did not exist before API level 21 (Lollipop).
619    if (isArch64Bit() && Env[0] < 21)
620      Env[0] = 21;
621
622    return Env[0] < Major;
623  }
624
625  /// Tests whether the environment is musl-libc
626  bool isMusl() const {
627    return getEnvironment() == Triple::Musl ||
628           getEnvironment() == Triple::MuslEABI ||
629           getEnvironment() == Triple::MuslEABIHF;
630  }
631
632  /// Tests whether the target is NVPTX (32- or 64-bit).
633  bool isNVPTX() const {
634    return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
635  }
636
637  /// Tests whether the target is Thumb (little and big endian).
638  bool isThumb() const {
639    return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
640  }
641
642  /// Tests whether the target is ARM (little and big endian).
643  bool isARM() const {
644    return getArch() == Triple::arm || getArch() == Triple::armeb;
645  }
646
647  /// Tests wether the target supports comdat
648  bool supportsCOMDAT() const { return !isOSBinFormatMachO(); }
649
650  /// @}
651  /// @name Mutators
652  /// @{
653
654  /// setArch - Set the architecture (first) component of the triple
655  /// to a known type.
656  void setArch(ArchType Kind);
657
658  /// setVendor - Set the vendor (second) component of the triple to a
659  /// known type.
660  void setVendor(VendorType Kind);
661
662  /// setOS - Set the operating system (third) component of the triple
663  /// to a known type.
664  void setOS(OSType Kind);
665
666  /// setEnvironment - Set the environment (fourth) component of the triple
667  /// to a known type.
668  void setEnvironment(EnvironmentType Kind);
669
670  /// setObjectFormat - Set the object file format
671  void setObjectFormat(ObjectFormatType Kind);
672
673  /// setTriple - Set all components to the new triple \p Str.
674  void setTriple(const Twine &Str);
675
676  /// setArchName - Set the architecture (first) component of the
677  /// triple by name.
678  void setArchName(StringRef Str);
679
680  /// setVendorName - Set the vendor (second) component of the triple
681  /// by name.
682  void setVendorName(StringRef Str);
683
684  /// setOSName - Set the operating system (third) component of the
685  /// triple by name.
686  void setOSName(StringRef Str);
687
688  /// setEnvironmentName - Set the optional environment (fourth)
689  /// component of the triple by name.
690  void setEnvironmentName(StringRef Str);
691
692  /// setOSAndEnvironmentName - Set the operating system and optional
693  /// environment components with a single string.
694  void setOSAndEnvironmentName(StringRef Str);
695
696  /// @}
697  /// @name Helpers to build variants of a particular triple.
698  /// @{
699
700  /// Form a triple with a 32-bit variant of the current architecture.
701  ///
702  /// This can be used to move across "families" of architectures where useful.
703  ///
704  /// \returns A new triple with a 32-bit architecture or an unknown
705  ///          architecture if no such variant can be found.
706  llvm::Triple get32BitArchVariant() const;
707
708  /// Form a triple with a 64-bit variant of the current architecture.
709  ///
710  /// This can be used to move across "families" of architectures where useful.
711  ///
712  /// \returns A new triple with a 64-bit architecture or an unknown
713  ///          architecture if no such variant can be found.
714  llvm::Triple get64BitArchVariant() const;
715
716  /// Form a triple with a big endian variant of the current architecture.
717  ///
718  /// This can be used to move across "families" of architectures where useful.
719  ///
720  /// \returns A new triple with a big endian architecture or an unknown
721  ///          architecture if no such variant can be found.
722  llvm::Triple getBigEndianArchVariant() const;
723
724  /// Form a triple with a little endian variant of the current architecture.
725  ///
726  /// This can be used to move across "families" of architectures where useful.
727  ///
728  /// \returns A new triple with a little endian architecture or an unknown
729  ///          architecture if no such variant can be found.
730  llvm::Triple getLittleEndianArchVariant() const;
731
732  /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
733  ///
734  /// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
735  /// string then the triple's arch name is used.
736  StringRef getARMCPUForArch(StringRef Arch = StringRef()) const;
737
738  /// Tests whether the target triple is little endian.
739  ///
740  /// \returns true if the triple is little endian, false otherwise.
741  bool isLittleEndian() const;
742
743  /// Test whether target triples are compatible.
744  bool isCompatibleWith(const Triple &Other) const;
745
746  /// Merge target triples.
747  std::string merge(const Triple &Other) const;
748
749  /// @}
750  /// @name Static helpers for IDs.
751  /// @{
752
753  /// getArchTypeName - Get the canonical name for the \p Kind architecture.
754  static StringRef getArchTypeName(ArchType Kind);
755
756  /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind
757  /// architecture. This is the prefix used by the architecture specific
758  /// builtins, and is suitable for passing to \see
759  /// Intrinsic::getIntrinsicForGCCBuiltin().
760  ///
761  /// \return - The architecture prefix, or 0 if none is defined.
762  static StringRef getArchTypePrefix(ArchType Kind);
763
764  /// getVendorTypeName - Get the canonical name for the \p Kind vendor.
765  static StringRef getVendorTypeName(VendorType Kind);
766
767  /// getOSTypeName - Get the canonical name for the \p Kind operating system.
768  static StringRef getOSTypeName(OSType Kind);
769
770  /// getEnvironmentTypeName - Get the canonical name for the \p Kind
771  /// environment.
772  static StringRef getEnvironmentTypeName(EnvironmentType Kind);
773
774  /// @}
775  /// @name Static helpers for converting alternate architecture names.
776  /// @{
777
778  /// getArchTypeForLLVMName - The canonical type for the given LLVM
779  /// architecture name (e.g., "x86").
780  static ArchType getArchTypeForLLVMName(StringRef Str);
781
782  /// @}
783};
784
785} // End llvm namespace
786
787
788#endif
789