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