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