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