123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//===-- llvm/ADT/Triple.h - Target triple helper class ----------*- C++ -*-===//
223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//
323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//                     The LLVM Compiler Infrastructure
423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//
523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar// This file is distributed under the University of Illinois Open Source
623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar// License. See LICENSE.TXT for details.
723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//
823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//===----------------------------------------------------------------------===//
923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
1023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar#ifndef LLVM_ADT_TRIPLE_H
1123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar#define LLVM_ADT_TRIPLE_H
1223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
13b7fbcc9696e38ca26c7eb67077c04b51c846c9cbChris Lattner#include "llvm/ADT/Twine.h"
1423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
15be1f788676ff6a71bc0324ac38af7626fdcf92b2Chris Lattner// Some system headers or GCC predefined macros conflict with identifiers in
16be1f788676ff6a71bc0324ac38af7626fdcf92b2Chris Lattner// this file.  Undefine them here.
17be1f788676ff6a71bc0324ac38af7626fdcf92b2Chris Lattner#undef mips
18be1f788676ff6a71bc0324ac38af7626fdcf92b2Chris Lattner#undef sparc
19be1f788676ff6a71bc0324ac38af7626fdcf92b2Chris Lattner
2023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbarnamespace llvm {
2123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
226f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// Triple - Helper class for working with autoconf configuration names. For
236f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// historical reasons, we also call these 'triples' (they used to contain
246f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// exactly three fields).
2523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar///
266f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// Configuration names are strings in the canonical form:
2723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM
2823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar/// or
2923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
3023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar///
3123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar/// This class is used for clients which want to support arbitrary
326f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// configuration names, but also want to implement certain special
336f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// behavior for particular configurations. This class isolates the mapping
346f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// from the components of the configuration name to well known IDs.
3523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar///
36651aa689cc37d5932fac0e096aa8b536f282aa21Daniel Dunbar/// At its core the Triple class is designed to be a wrapper for a triple
37335db223926931db204bf54d4accac6677b8e6b1Duncan Sands/// string; the constructor does not change or normalize the triple string.
38335db223926931db204bf54d4accac6677b8e6b1Duncan Sands/// Clients that need to handle the non-canonical triples that users often
39335db223926931db204bf54d4accac6677b8e6b1Duncan Sands/// specify should use the normalize method.
40651aa689cc37d5932fac0e096aa8b536f282aa21Daniel Dunbar///
416f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// See autoconf/config.guess for a glimpse into what configuration names
426f43379e23e96442a6d3a747ce921cacebcfe9acRichard Smith/// look like in practice.
4323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbarclass Triple {
4423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbarpublic:
4523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  enum ArchType {
4623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar    UnknownArch,
47ce8ca9ab0cc42be4f2ff5ed5d349eac5c90f9b04Jim Grosbach
48bbc65149945b1a2eac179f6d7b920f00102942fdJia Liu    arm,     // ARM: arm, armv.*, xscale
4972062f5744557e270a38192554c3126ea5f97434Tim Northover    aarch64, // AArch64: aarch64
50b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    hexagon, // Hexagon: hexagon
51bf4fc28303e00064fb24db1394010782299f5220Daniel Dunbar    mips,    // MIPS: mips, mipsallegrex
52fdf0dc9e0bb5c0b848286e6c96bfc9a390d26775Chandler Carruth    mipsel,  // MIPSEL: mipsel, mipsallegrexel
5370303688bc489a316cb0892499ac4024088fa58aAkira Hatanaka    mips64,  // MIPS64: mips64
5470303688bc489a316cb0892499ac4024088fa58aAkira Hatanaka    mips64el,// MIPS64EL: mips64el
55b2bacd926309a6cd89507b182f5c4ace010884fcMisha Brukman    msp430,  // MSP430: msp430
56bf4fc28303e00064fb24db1394010782299f5220Daniel Dunbar    ppc,     // PPC: powerpc
57cc9fa81fe1675b29fa813945c52abee692229143Edward O'Callaghan    ppc64,   // PPC64: powerpc64, ppu
58f38cc38fa647d4e72c053c39bbe0cdec1342535fBill Schmidt    ppc64le, // PPC64LE: powerpc64le
597415659bf8b8523ab8b706caa461984a199dc3c8Anton Korobeynikov    r600,    // R600: AMD GPUs HD2XXX - HD6XXX
60bf4fc28303e00064fb24db1394010782299f5220Daniel Dunbar    sparc,   // Sparc: sparc
6187c06d617917f4a388fbe9db81198e13cde3e431Chris Lattner    sparcv9, // Sparcv9: Sparcv9
620512910867e77125b63054da2860a7812604c22eRichard Sandiford    systemz, // SystemZ: s390x
6374db89e30fbd97808786026e56bcf1edb37469c7Eli Friedman    tce,     // TCE (http://tce.cs.tut.fi/): tce
64bf4fc28303e00064fb24db1394010782299f5220Daniel Dunbar    thumb,   // Thumb: thumb, thumbv.*
65bf4fc28303e00064fb24db1394010782299f5220Daniel Dunbar    x86,     // X86: i[3-9]86
66bf4fc28303e00064fb24db1394010782299f5220Daniel Dunbar    x86_64,  // X86-64: amd64, x86_64
67bf4fc28303e00064fb24db1394010782299f5220Daniel Dunbar    xcore,   // XCore: xcore
6849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    nvptx,   // NVPTX: 32-bit
6949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    nvptx64, // NVPTX: 64-bit
7038fb2db6c9f64a59875d034e2a2cab27603c1884Ivan Krasin    le32,    // le32: generic little-endian 32-bit CPU (PNaCl / Emscripten)
71e53d6051b7e173722351a5647bfd71eebee3d837Micah Villmow    amdil,   // amdil: amd IL
72ac39a035351a20928e087617e412aa6ce510181fGuy Benyei    spir,    // SPIR: standard portable IR for OpenCL 32-bit version
73ac39a035351a20928e087617e412aa6ce510181fGuy Benyei    spir64   // SPIR: standard portable IR for OpenCL 64-bit version
7423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  };
7523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  enum VendorType {
7623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar    UnknownVendor,
7723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
78ce8ca9ab0cc42be4f2ff5ed5d349eac5c90f9b04Jim Grosbach    Apple,
796046cffbaf584b5d6bd7baf827794a5f91a07a9bJohn Thompson    PC,
80a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel    SCEI,
81a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel    BGP,
82d939cd68f40e6fa0ccd6bee6391374b66abd71a1Hal Finkel    BGQ,
832e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands    Freescale,
840ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski    IBM,
850ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski    NVIDIA
8623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  };
8723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  enum OSType {
8823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar    UnknownOS,
8923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
90852cd112edef55ff6fe334eeaeff153209f85666Duncan Sands    AuroraUX,
916337f15b5a73c3eeb644d59cf34d37d4a278f5f7Daniel Dunbar    Cygwin,
9223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar    Darwin,
937eaf057e54e9b5f0469057c71d81dcfee90d9e12Daniel Dunbar    DragonFly,
9423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar    FreeBSD,
950dde4c00ee3b3514fcbabb7bca6b1f1189c4c5b9Daniel Dunbar    IOS,
96652b48bf231521642c53221a7d10a0acf2030f48Duncan Sands    KFreeBSD,
97cd1267d2d68f03026aed21e22f7e28efd510ec5fDuncan Sands    Linux,
98cc9fa81fe1675b29fa813945c52abee692229143Edward O'Callaghan    Lv2,        // PS3
991af394766fe4e725d5af2fe82c2ad9cfcbc7dd34Daniel Dunbar    MacOSX,
1006904f05e607b6bbdfa96a2ebb628ebf3a1f21455NAKAMURA Takumi    MinGW32,    // i*86-pc-mingw32, *-w64-mingw32
101b8ac841c9a275cc8d4e1a92dd06cc99323e35fa2Chris Lattner    NetBSD,
1026337f15b5a73c3eeb644d59cf34d37d4a278f5f7Daniel Dunbar    OpenBSD,
103fdb0b7b555aaea054f85f654275fce56e5d7d1d3Daniel Dunbar    Solaris,
104a43fc3452b4c5a853054b6b671eacbdd05039130Chris Lattner    Win32,
10529269d03af6dc3feb69d0230831a059f39c03700Chris Lattner    Haiku,
1066ced1d12dd7ee18d65a6df6e66c9662753a5876dDouglas Gregor    Minix,
107fb23462889ff2dcd016a4b4169ebce94a878218eIvan Krasin    RTEMS,
1088181827d1b04f7bc6939ab099acc09ef2b247061Eli Bendersky    NaCl,       // Native Client
109f659c0de6c7a4684a2a30c344ce6827ea87032d8Eli Bendersky    CNK,        // BG/P Compute-Node Kernel
1102e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands    Bitrig,
1110ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski    AIX,
1120ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski    CUDA,       // NVIDIA CUDA
1130ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski    NVCL        // NVIDIA OpenCL
11423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  };
1155754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  enum EnvironmentType {
116859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin    UnknownEnvironment,
117859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin
118859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin    GNU,
119859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin    GNUEABI,
1208887a0f34152b63a84e759b76694d6928d01b4eeRafael Espindola    GNUEABIHF,
1219dd2a3b1f2c253e20262535bb89b1ab6cc680eceEli Bendersky    GNUX32,
1222bffee2ee725047137d2523e31db9ecc7b246cbbEvan Cheng    EABI,
123fd553c2cb54ee01d56f5d80d70a5d52220286fccChandler Carruth    MachO,
1247bbd6e366b39157445cc921024a987e61ea68c00Andrew Kaylor    Android,
1257bbd6e366b39157445cc921024a987e61ea68c00Andrew Kaylor    ELF
1265754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  };
127ce8ca9ab0cc42be4f2ff5ed5d349eac5c90f9b04Jim Grosbach
12823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbarprivate:
12923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  std::string Data;
13023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
131124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  /// The parsed arch type.
132124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  ArchType Arch;
13323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
13423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// The parsed vendor type.
135124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  VendorType Vendor;
13623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
13723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// The parsed OS type.
138124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  OSType OS;
13923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
1405754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  /// The parsed Environment type.
141124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  EnvironmentType Environment;
1425754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands
14323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbarpublic:
14423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @name Constructors
14523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @{
146ce8ca9ab0cc42be4f2ff5ed5d349eac5c90f9b04Jim Grosbach
1470523f41841d0860b2e175a4b20d1ecefd7295c4aChandler Carruth  /// \brief Default constructor is the same as an empty string and leaves all
1480523f41841d0860b2e175a4b20d1ecefd7295c4aChandler Carruth  /// triple fields unknown.
149124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  Triple() : Data(), Arch(), Vendor(), OS(), Environment() {}
15023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
151cceb8f44a0ca3a9c57ab3a7f4947b2abda531cefChandler Carruth  explicit Triple(const Twine &Str);
152cceb8f44a0ca3a9c57ab3a7f4947b2abda531cefChandler Carruth  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
153b7fbcc9696e38ca26c7eb67077c04b51c846c9cbChris Lattner  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
154cceb8f44a0ca3a9c57ab3a7f4947b2abda531cefChandler Carruth         const Twine &EnvironmentStr);
1555754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands
15623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @}
157335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  /// @name Normalization
158335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  /// @{
159335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
160335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  /// normalize - Turn an arbitrary machine specification into the canonical
161335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  /// triple form (or something sensible that the Triple class understands if
162335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  /// nothing better can reasonably be done).  In particular, it handles the
163335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  /// common case in which otherwise valid components are in the wrong order.
164335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  static std::string normalize(StringRef Str);
165335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
166335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  /// @}
16723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @name Typed Component Access
16823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @{
169ce8ca9ab0cc42be4f2ff5ed5d349eac5c90f9b04Jim Grosbach
17023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// getArch - Get the parsed architecture type of this triple.
171124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  ArchType getArch() const { return Arch; }
172ce8ca9ab0cc42be4f2ff5ed5d349eac5c90f9b04Jim Grosbach
17323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// getVendor - Get the parsed vendor type of this triple.
174124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  VendorType getVendor() const { return Vendor; }
175ce8ca9ab0cc42be4f2ff5ed5d349eac5c90f9b04Jim Grosbach
17623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// getOS - Get the parsed operating system type of this triple.
177124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  OSType getOS() const { return OS; }
17823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
17923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// hasEnvironment - Does this triple have the optional environment
18023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// (fourth) component?
18123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  bool hasEnvironment() const {
18223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar    return getEnvironmentName() != "";
18323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  }
18423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
1855754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  /// getEnvironment - Get the parsed environment type of this triple.
186124e51c0d2b521b0fb3aaaf2443403cd451b7857Chandler Carruth  EnvironmentType getEnvironment() const { return Environment; }
1875754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands
188f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// getOSVersion - Parse the version number from the OS name component of the
189f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// triple, if present.
190f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  ///
191f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// For example, "fooos1.2.3" would return (1, 2, 3).
192f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  ///
193f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// If an entry is not defined, it will be returned as 0.
194f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
195f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth
196f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// getOSMajorVersion - Return just the major version number, this is
197f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// specialized because it is a common query.
198f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  unsigned getOSMajorVersion() const {
199f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth    unsigned Maj, Min, Micro;
200f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth    getOSVersion(Maj, Min, Micro);
201f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth    return Maj;
202f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  }
203f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth
204bda59fdd71033a8ddfa30ec4b514753017f3da5cBob Wilson  /// getMacOSXVersion - Parse the version number as with getOSVersion and then
205bda59fdd71033a8ddfa30ec4b514753017f3da5cBob Wilson  /// translate generic "darwin" versions to the corresponding OS X versions.
206bda59fdd71033a8ddfa30ec4b514753017f3da5cBob Wilson  /// This may also be called with IOS triples but the OS X version number is
207bda59fdd71033a8ddfa30ec4b514753017f3da5cBob Wilson  /// just set to a constant 10.4.0 in that case.  Returns true if successful.
208bda59fdd71033a8ddfa30ec4b514753017f3da5cBob Wilson  bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
209bda59fdd71033a8ddfa30ec4b514753017f3da5cBob Wilson                        unsigned &Micro) const;
210bda59fdd71033a8ddfa30ec4b514753017f3da5cBob Wilson
211ecee47eab409f6a6fada7ace3d9bee0a0146ac3fChad Rosier  /// getiOSVersion - Parse the version number as with getOSVersion.  This should
212ecee47eab409f6a6fada7ace3d9bee0a0146ac3fChad Rosier  /// only be called with IOS triples.
213ecee47eab409f6a6fada7ace3d9bee0a0146ac3fChad Rosier  void getiOSVersion(unsigned &Major, unsigned &Minor,
214ecee47eab409f6a6fada7ace3d9bee0a0146ac3fChad Rosier                     unsigned &Micro) const;
215ecee47eab409f6a6fada7ace3d9bee0a0146ac3fChad Rosier
21623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @}
21723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @name Direct Component Access
21823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @{
21923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
2203691393b86c6849525dcdfb096d9da816ac1545eDaniel Dunbar  const std::string &str() const { return Data; }
2213691393b86c6849525dcdfb096d9da816ac1545eDaniel Dunbar
22223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  const std::string &getTriple() const { return Data; }
22323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
22423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// getArchName - Get the architecture (first) component of the
22523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// triple.
226a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  StringRef getArchName() const;
22723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
22823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// getVendorName - Get the vendor (second) component of the triple.
229a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  StringRef getVendorName() const;
23023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
23123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// getOSName - Get the operating system (third) component of the
23223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// triple.
233a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  StringRef getOSName() const;
23423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
23523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// getEnvironmentName - Get the optional environment (fourth)
23623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// component of the triple, or "" if empty.
237a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  StringRef getEnvironmentName() const;
23823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
23923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// getOSAndEnvironmentName - Get the operating system and optional
24023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// environment components as a single string (separated by a '-'
24123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// if the environment component is present).
242a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  StringRef getOSAndEnvironmentName() const;
24323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
244f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// @}
245f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// @name Convenience Predicates
246f95b2dafc9a6ae88c6085aceeaf7a34af09df93bChandler Carruth  /// @{
247ce8ca9ab0cc42be4f2ff5ed5d349eac5c90f9b04Jim Grosbach
2486f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// \brief Test whether the architecture is 64-bit
2496f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  ///
2506f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// Note that this tests for 64-bit pointer width, and nothing else. Note
2516f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
2526f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// 16-bit. The inner details of pointer width for particular architectures
2536f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// is not summed up in the triple, and so only a coarse grained predicate
2546f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// system is provided.
2556f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  bool isArch64Bit() const;
2566f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
2576f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// \brief Test whether the architecture is 32-bit
2586f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  ///
2596f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// Note that this tests for 32-bit pointer width, and nothing else.
2606f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  bool isArch32Bit() const;
2616f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
2626f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// \brief Test whether the architecture is 16-bit
2636f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  ///
2646f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  /// Note that this tests for 16-bit pointer width, and nothing else.
2656f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  bool isArch16Bit() const;
2666f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
267e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar  /// isOSVersionLT - Helper function for doing comparisons against version
268e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar  /// numbers included in the target triple.
2694860fe0ad0447f8545bdbc1b327e82cb1ba41a51Daniel Dunbar  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
2704860fe0ad0447f8545bdbc1b327e82cb1ba41a51Daniel Dunbar                     unsigned Micro = 0) const {
2718974153870928527826ea5bad3359377b66666ccDaniel Dunbar    unsigned LHS[3];
2728974153870928527826ea5bad3359377b66666ccDaniel Dunbar    getOSVersion(LHS[0], LHS[1], LHS[2]);
2738974153870928527826ea5bad3359377b66666ccDaniel Dunbar
2748974153870928527826ea5bad3359377b66666ccDaniel Dunbar    if (LHS[0] != Major)
2758974153870928527826ea5bad3359377b66666ccDaniel Dunbar      return LHS[0] < Major;
2768974153870928527826ea5bad3359377b66666ccDaniel Dunbar    if (LHS[1] != Minor)
2778974153870928527826ea5bad3359377b66666ccDaniel Dunbar      return LHS[1] < Minor;
2788974153870928527826ea5bad3359377b66666ccDaniel Dunbar    if (LHS[2] != Micro)
2798974153870928527826ea5bad3359377b66666ccDaniel Dunbar      return LHS[1] < Micro;
2808974153870928527826ea5bad3359377b66666ccDaniel Dunbar
2818974153870928527826ea5bad3359377b66666ccDaniel Dunbar    return false;
2828974153870928527826ea5bad3359377b66666ccDaniel Dunbar  }
2838974153870928527826ea5bad3359377b66666ccDaniel Dunbar
28469f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  /// isMacOSXVersionLT - Comparison function for checking OS X version
28569f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  /// compatibility, which handles supporting skewed version numbering schemes
28669f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  /// used by the "darwin" triples.
28769f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  unsigned isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
288aa7507d68dcc04f3118a05b5dff4123ded03253eBill Wendling                             unsigned Micro = 0) const {
28969f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    assert(isMacOSX() && "Not an OS X triple!");
29069f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth
29169f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    // If this is OS X, expect a sane version number.
29269f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    if (getOS() == Triple::MacOSX)
29369f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth      return isOSVersionLT(Major, Minor, Micro);
29469f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth
29569f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    // Otherwise, compare to the "Darwin" number.
29669f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    assert(Major == 10 && "Unexpected major version");
29769f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    return isOSVersionLT(Minor + 4, Micro, 0);
29869f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  }
29969f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth
300558692fd0a31d4d3ae4fd09a3a02f80da2e44e5cDaniel Dunbar  /// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
3014860fe0ad0447f8545bdbc1b327e82cb1ba41a51Daniel Dunbar  /// "darwin" and "osx" as OS X triples.
302558692fd0a31d4d3ae4fd09a3a02f80da2e44e5cDaniel Dunbar  bool isMacOSX() const {
303398a5ca9cdf6256775904d957d6c40b63d45636cDaniel Dunbar    return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
3044860fe0ad0447f8545bdbc1b327e82cb1ba41a51Daniel Dunbar  }
3054860fe0ad0447f8545bdbc1b327e82cb1ba41a51Daniel Dunbar
306e502bba8c6dde1d95cc350c7935a1aea0b41465fMichael Gottesman  /// Is this an iOS triple.
307e502bba8c6dde1d95cc350c7935a1aea0b41465fMichael Gottesman  bool isiOS() const {
308e502bba8c6dde1d95cc350c7935a1aea0b41465fMichael Gottesman    return getOS() == Triple::IOS;
309e502bba8c6dde1d95cc350c7935a1aea0b41465fMichael Gottesman  }
310e502bba8c6dde1d95cc350c7935a1aea0b41465fMichael Gottesman
311e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar  /// isOSDarwin - Is this a "Darwin" OS (OS X or iOS).
312e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar  bool isOSDarwin() const {
313e502bba8c6dde1d95cc350c7935a1aea0b41465fMichael Gottesman    return isMacOSX() || isiOS();
314e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar  }
315e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar
31669f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  /// \brief Tests for either Cygwin or MinGW OS
31769f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  bool isOSCygMing() const {
31869f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    return getOS() == Triple::Cygwin || getOS() == Triple::MinGW32;
31969f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  }
32069f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth
321e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar  /// isOSWindows - Is this a "Windows" OS.
322e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar  bool isOSWindows() const {
32369f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    return getOS() == Triple::Win32 || isOSCygMing();
324e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar  }
325e1fe09f6826f158def69cff89f3ce4e67e199bb5Daniel Dunbar
326105fdbb1312bac8c46ba2e28e9d6a70c0af151c8Eli Bendersky  /// \brief Tests whether the OS is NaCl (Native Client)
327105fdbb1312bac8c46ba2e28e9d6a70c0af151c8Eli Bendersky  bool isOSNaCl() const {
328105fdbb1312bac8c46ba2e28e9d6a70c0af151c8Eli Bendersky    return getOS() == Triple::NaCl;
329105fdbb1312bac8c46ba2e28e9d6a70c0af151c8Eli Bendersky  }
330105fdbb1312bac8c46ba2e28e9d6a70c0af151c8Eli Bendersky
33169f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  /// \brief Tests whether the OS uses the ELF binary format.
33269f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  bool isOSBinFormatELF() const {
33369f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    return !isOSDarwin() && !isOSWindows();
33469f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  }
3354860fe0ad0447f8545bdbc1b327e82cb1ba41a51Daniel Dunbar
33669f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  /// \brief Tests whether the OS uses the COFF binary format.
33769f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  bool isOSBinFormatCOFF() const {
33869f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    return isOSWindows();
33969f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  }
3404860fe0ad0447f8545bdbc1b327e82cb1ba41a51Daniel Dunbar
34169f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  /// \brief Tests whether the environment is MachO.
34269f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  // FIXME: Should this be an OSBinFormat predicate?
34369f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth  bool isEnvironmentMachO() const {
34469f44692bf5fea1d908fc06487e173837d06ea58Chandler Carruth    return getEnvironment() == Triple::MachO || isOSDarwin();
3454860fe0ad0447f8545bdbc1b327e82cb1ba41a51Daniel Dunbar  }
3464d59ff95d8f28089dce9997a38a334c18f50a641Eric Christopher
34723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @}
34823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @name Mutators
34923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @{
35023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
35123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// setArch - Set the architecture (first) component of the triple
35223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// to a known type.
35323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  void setArch(ArchType Kind);
35423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
35523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// setVendor - Set the vendor (second) component of the triple to a
35623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// known type.
35723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  void setVendor(VendorType Kind);
35823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
35923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// setOS - Set the operating system (third) component of the triple
36023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// to a known type.
36123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  void setOS(OSType Kind);
36223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
3635754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  /// setEnvironment - Set the environment (fourth) component of the triple
3645754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  /// to a known type.
3655754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  void setEnvironment(EnvironmentType Kind);
3665754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands
3672d9eb72178af8e79dc6432cd1b7d29bde16da1b9Dmitri Gribenko  /// setTriple - Set all components to the new triple \p Str.
368a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  void setTriple(const Twine &Str);
36923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
37023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// setArchName - Set the architecture (first) component of the
37123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// triple by name.
3722928c83b010f7cfdb0f819199d806f6942a7d995Daniel Dunbar  void setArchName(StringRef Str);
37323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
37423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// setVendorName - Set the vendor (second) component of the triple
37523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// by name.
3762928c83b010f7cfdb0f819199d806f6942a7d995Daniel Dunbar  void setVendorName(StringRef Str);
37723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
37823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// setOSName - Set the operating system (third) component of the
37923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// triple by name.
3802928c83b010f7cfdb0f819199d806f6942a7d995Daniel Dunbar  void setOSName(StringRef Str);
38123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
38223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// setEnvironmentName - Set the optional environment (fourth)
38323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// component of the triple by name.
3842928c83b010f7cfdb0f819199d806f6942a7d995Daniel Dunbar  void setEnvironmentName(StringRef Str);
38523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
38623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// setOSAndEnvironmentName - Set the operating system and optional
38723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// environment components with a single string.
3882928c83b010f7cfdb0f819199d806f6942a7d995Daniel Dunbar  void setOSAndEnvironmentName(StringRef Str);
38923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
3900764e39a921ae424e2ac8c7ba114b67040eba8f6Eric Christopher  /// getArchNameForAssembler - Get an architecture name that is understood by
3910764e39a921ae424e2ac8c7ba114b67040eba8f6Eric Christopher  /// the target assembler.
39251cdac02c4125b8545728eb30ab5f54e437d6377Viktor Kutuzov  const char *getArchNameForAssembler();
39351cdac02c4125b8545728eb30ab5f54e437d6377Viktor Kutuzov
39423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @}
3957d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// @name Helpers to build variants of a particular triple.
3967d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// @{
3977d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
3987d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// \brief Form a triple with a 32-bit variant of the current architecture.
3997d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  ///
4007d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// This can be used to move across "families" of architectures where useful.
4017d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  ///
4027d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// \returns A new triple with a 32-bit architecture or an unknown
4037d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  ///          architecture if no such variant can be found.
4047d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  llvm::Triple get32BitArchVariant() const;
4057d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
4067d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// \brief Form a triple with a 64-bit variant of the current architecture.
4077d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  ///
4087d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// This can be used to move across "families" of architectures where useful.
4097d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  ///
4107d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// \returns A new triple with a 64-bit architecture or an unknown
4117d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  ///          architecture if no such variant can be found.
4127d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  llvm::Triple get64BitArchVariant() const;
4137d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
4147d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  /// @}
41523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @name Static helpers for IDs.
41623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @{
41723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
4182d9eb72178af8e79dc6432cd1b7d29bde16da1b9Dmitri Gribenko  /// getArchTypeName - Get the canonical name for the \p Kind architecture.
41923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  static const char *getArchTypeName(ArchType Kind);
42023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
4212d9eb72178af8e79dc6432cd1b7d29bde16da1b9Dmitri Gribenko  /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind
422688b55b436b4a3a036f0827dc484b5f219ace1a3Daniel Dunbar  /// architecture. This is the prefix used by the architecture specific
423688b55b436b4a3a036f0827dc484b5f219ace1a3Daniel Dunbar  /// builtins, and is suitable for passing to \see
424688b55b436b4a3a036f0827dc484b5f219ace1a3Daniel Dunbar  /// Intrinsic::getIntrinsicForGCCBuiltin().
425688b55b436b4a3a036f0827dc484b5f219ace1a3Daniel Dunbar  ///
426688b55b436b4a3a036f0827dc484b5f219ace1a3Daniel Dunbar  /// \return - The architecture prefix, or 0 if none is defined.
427688b55b436b4a3a036f0827dc484b5f219ace1a3Daniel Dunbar  static const char *getArchTypePrefix(ArchType Kind);
428688b55b436b4a3a036f0827dc484b5f219ace1a3Daniel Dunbar
4292d9eb72178af8e79dc6432cd1b7d29bde16da1b9Dmitri Gribenko  /// getVendorTypeName - Get the canonical name for the \p Kind vendor.
43023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  static const char *getVendorTypeName(VendorType Kind);
43123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
4322d9eb72178af8e79dc6432cd1b7d29bde16da1b9Dmitri Gribenko  /// getOSTypeName - Get the canonical name for the \p Kind operating system.
43323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  static const char *getOSTypeName(OSType Kind);
43423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
4352d9eb72178af8e79dc6432cd1b7d29bde16da1b9Dmitri Gribenko  /// getEnvironmentTypeName - Get the canonical name for the \p Kind
4365754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  /// environment.
4375754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  static const char *getEnvironmentTypeName(EnvironmentType Kind);
4385754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands
439baf9b562309ae0f82774a6a3b4ffb9417a43a032Daniel Dunbar  /// @}
440baf9b562309ae0f82774a6a3b4ffb9417a43a032Daniel Dunbar  /// @name Static helpers for converting alternate architecture names.
441baf9b562309ae0f82774a6a3b4ffb9417a43a032Daniel Dunbar  /// @{
442baf9b562309ae0f82774a6a3b4ffb9417a43a032Daniel Dunbar
4433c2d4bf97fa96fe171883cd80e4ea93fc43563e6Daniel Dunbar  /// getArchTypeForLLVMName - The canonical type for the given LLVM
4443c2d4bf97fa96fe171883cd80e4ea93fc43563e6Daniel Dunbar  /// architecture name (e.g., "x86").
4452928c83b010f7cfdb0f819199d806f6942a7d995Daniel Dunbar  static ArchType getArchTypeForLLVMName(StringRef Str);
4463c2d4bf97fa96fe171883cd80e4ea93fc43563e6Daniel Dunbar
44723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  /// @}
44823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar};
44923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
45023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar} // End llvm namespace
45123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
45223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
45323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar#endif
454