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