blob: d2508ac1ef3aca73fd1e4f9a958cc2293ba070bd [file] [log] [blame]
Daniel Dunbar23e97b02009-04-01 21:53:23 +00001//===--- Triple.cpp - Target triple helper class --------------------------===//
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#include "llvm/ADT/Triple.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000011#include "llvm/ADT/STLExtras.h"
Jeffrey Yasskin0b228732009-10-06 21:45:26 +000012#include "llvm/ADT/SmallString.h"
Chandler Carruth06accda2012-02-12 09:27:38 +000013#include "llvm/ADT/StringSwitch.h"
David Blaikie4d6ccb52012-01-20 21:51:11 +000014#include "llvm/Support/ErrorHandling.h"
Mikhail Glushenkov70748752009-04-02 01:11:37 +000015#include <cstring>
Daniel Dunbar23e97b02009-04-01 21:53:23 +000016using namespace llvm;
17
Daniel Dunbar23e97b02009-04-01 21:53:23 +000018const char *Triple::getArchTypeName(ArchType Kind) {
19 switch (Kind) {
Daniel Dunbar23e97b02009-04-01 21:53:23 +000020 case UnknownArch: return "unknown";
Jim Grosbache509aa92010-12-17 02:10:59 +000021
Tim Northover72062f52013-01-31 12:12:40 +000022 case aarch64: return "aarch64";
Daniel Dunbar6337f152009-07-26 04:23:03 +000023 case arm: return "arm";
Tony Linthicumb4b54152011-12-12 21:14:40 +000024 case hexagon: return "hexagon";
Daniel Dunbar6337f152009-07-26 04:23:03 +000025 case mips: return "mips";
26 case mipsel: return "mipsel";
Akira Hatanaka70303682011-09-20 18:09:37 +000027 case mips64: return "mips64";
28 case mips64el:return "mips64el";
Daniel Dunbar6337f152009-07-26 04:23:03 +000029 case msp430: return "msp430";
Daniel Dunbar8c2f1d72009-07-26 04:52:45 +000030 case ppc64: return "powerpc64";
31 case ppc: return "powerpc";
Anton Korobeynikov74156592012-03-09 10:09:36 +000032 case r600: return "r600";
Daniel Dunbar6337f152009-07-26 04:23:03 +000033 case sparc: return "sparc";
Chris Lattner87c06d62010-02-04 06:34:01 +000034 case sparcv9: return "sparcv9";
Eli Friedman74db89e2009-08-19 20:46:03 +000035 case tce: return "tce";
Daniel Dunbar6337f152009-07-26 04:23:03 +000036 case thumb: return "thumb";
37 case x86: return "i386";
38 case x86_64: return "x86_64";
Daniel Dunbar8c2f1d72009-07-26 04:52:45 +000039 case xcore: return "xcore";
Wesley Pecka70f28c2010-02-23 19:15:24 +000040 case mblaze: return "mblaze";
Justin Holewinski49683f32012-05-04 20:18:50 +000041 case nvptx: return "nvptx";
42 case nvptx64: return "nvptx64";
Ivan Krasin38fb2db2011-08-23 16:59:00 +000043 case le32: return "le32";
Tobias Grosser05d71382011-08-29 15:44:55 +000044 case amdil: return "amdil";
Micah Villmowe53d6052012-10-01 17:01:31 +000045 case spir: return "spir";
Guy Benyeiac39a032012-11-15 10:35:47 +000046 case spir64: return "spir64";
Daniel Dunbar23e97b02009-04-01 21:53:23 +000047 }
48
David Blaikie4d6ccb52012-01-20 21:51:11 +000049 llvm_unreachable("Invalid ArchType!");
Daniel Dunbar23e97b02009-04-01 21:53:23 +000050}
51
Daniel Dunbar688b55b2009-08-24 09:53:06 +000052const char *Triple::getArchTypePrefix(ArchType Kind) {
53 switch (Kind) {
54 default:
55 return 0;
56
Tim Northover72062f52013-01-31 12:12:40 +000057 case aarch64: return "aarch64";
58
Daniel Dunbar688b55b2009-08-24 09:53:06 +000059 case arm:
60 case thumb: return "arm";
61
Daniel Dunbar688b55b2009-08-24 09:53:06 +000062 case ppc64:
63 case ppc: return "ppc";
64
Wesley Pecka70f28c2010-02-23 19:15:24 +000065 case mblaze: return "mblaze";
66
Benjamin Kramerd5dbc8c2012-06-28 19:09:53 +000067 case mips:
68 case mipsel:
69 case mips64:
70 case mips64el:return "mips";
71
72 case hexagon: return "hexagon";
Tony Linthicumb4b54152011-12-12 21:14:40 +000073
Anton Korobeynikov74156592012-03-09 10:09:36 +000074 case r600: return "r600";
75
Chris Lattner87c06d62010-02-04 06:34:01 +000076 case sparcv9:
Daniel Dunbar688b55b2009-08-24 09:53:06 +000077 case sparc: return "sparc";
78
79 case x86:
80 case x86_64: return "x86";
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000081
Daniel Dunbar688b55b2009-08-24 09:53:06 +000082 case xcore: return "xcore";
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000083
Justin Holewinski49683f32012-05-04 20:18:50 +000084 case nvptx: return "nvptx";
85 case nvptx64: return "nvptx";
Ivan Krasin38fb2db2011-08-23 16:59:00 +000086 case le32: return "le32";
Tobias Grosser05d71382011-08-29 15:44:55 +000087 case amdil: return "amdil";
Micah Villmowe53d6052012-10-01 17:01:31 +000088 case spir: return "spir";
Guy Benyeiac39a032012-11-15 10:35:47 +000089 case spir64: return "spir";
Daniel Dunbar688b55b2009-08-24 09:53:06 +000090 }
91}
92
Daniel Dunbar23e97b02009-04-01 21:53:23 +000093const char *Triple::getVendorTypeName(VendorType Kind) {
94 switch (Kind) {
95 case UnknownVendor: return "unknown";
96
97 case Apple: return "apple";
Chris Lattner56ce0f42009-08-14 18:48:13 +000098 case PC: return "pc";
John Thompson6046cff2011-03-15 21:51:56 +000099 case SCEI: return "scei";
Hal Finkela47406c2012-04-02 18:31:33 +0000100 case BGP: return "bgp";
101 case BGQ: return "bgq";
Hal Finkeld939cd62012-08-28 02:10:30 +0000102 case Freescale: return "fsl";
Duncan Sands2e522d02012-10-12 11:08:57 +0000103 case IBM: return "ibm";
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000104 }
105
David Blaikie4d6ccb52012-01-20 21:51:11 +0000106 llvm_unreachable("Invalid VendorType!");
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000107}
108
109const char *Triple::getOSTypeName(OSType Kind) {
110 switch (Kind) {
111 case UnknownOS: return "unknown";
112
Duncan Sands852cd112009-06-19 14:40:01 +0000113 case AuroraUX: return "auroraux";
Daniel Dunbar6337f152009-07-26 04:23:03 +0000114 case Cygwin: return "cygwin";
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000115 case Darwin: return "darwin";
Daniel Dunbar7eaf0572009-05-22 02:24:11 +0000116 case DragonFly: return "dragonfly";
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000117 case FreeBSD: return "freebsd";
Daniel Dunbar0dde4c02011-04-19 20:19:27 +0000118 case IOS: return "ios";
Duncan Sands652b48b2011-07-26 15:30:04 +0000119 case KFreeBSD: return "kfreebsd";
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000120 case Linux: return "linux";
Edward O'Callaghancc9fa812009-11-19 11:59:00 +0000121 case Lv2: return "lv2";
Daniel Dunbar1af39472011-04-19 23:34:12 +0000122 case MacOSX: return "macosx";
Daniel Dunbar6337f152009-07-26 04:23:03 +0000123 case MinGW32: return "mingw32";
Chris Lattnerb8ac8412009-07-13 20:22:23 +0000124 case NetBSD: return "netbsd";
Duncan Sandscd1267d2009-06-29 13:36:13 +0000125 case OpenBSD: return "openbsd";
Daniel Dunbarfdb0b7b2009-08-18 04:43:27 +0000126 case Solaris: return "solaris";
Daniel Dunbar6337f152009-07-26 04:23:03 +0000127 case Win32: return "win32";
Chris Lattnera43fc342009-10-16 02:06:30 +0000128 case Haiku: return "haiku";
Chris Lattner29269d02010-07-07 15:52:27 +0000129 case Minix: return "minix";
Douglas Gregor6ced1d12011-07-01 22:41:06 +0000130 case RTEMS: return "rtems";
Eli Benderskyf659c0d2012-12-04 18:37:26 +0000131 case NaCl: return "nacl";
Hal Finkela47406c2012-04-02 18:31:33 +0000132 case CNK: return "cnk";
Eric Christopherb0f67592012-08-06 20:52:18 +0000133 case Bitrig: return "bitrig";
Duncan Sands2e522d02012-10-12 11:08:57 +0000134 case AIX: return "aix";
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000135 }
136
David Blaikie4d6ccb52012-01-20 21:51:11 +0000137 llvm_unreachable("Invalid OSType");
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000138}
139
Duncan Sands5754a452010-09-16 08:25:48 +0000140const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
141 switch (Kind) {
142 case UnknownEnvironment: return "unknown";
Renato Golin859f8182011-01-21 18:25:47 +0000143 case GNU: return "gnu";
Rafael Espindola8887a0f2012-01-18 23:35:29 +0000144 case GNUEABIHF: return "gnueabihf";
Renato Golin859f8182011-01-21 18:25:47 +0000145 case GNUEABI: return "gnueabi";
Eli Bendersky9dd2a3b2013-01-22 18:02:49 +0000146 case GNUX32: return "gnux32";
Renato Golin859f8182011-01-21 18:25:47 +0000147 case EABI: return "eabi";
Evan Cheng2bffee22011-02-01 01:14:13 +0000148 case MachO: return "macho";
Logan Chien43bf7092012-09-02 09:29:46 +0000149 case Android: return "android";
Andrew Kaylor7bbd6e32012-10-02 18:38:34 +0000150 case ELF: return "elf";
Duncan Sands5754a452010-09-16 08:25:48 +0000151 }
152
David Blaikie4d6ccb52012-01-20 21:51:11 +0000153 llvm_unreachable("Invalid EnvironmentType!");
Duncan Sands5754a452010-09-16 08:25:48 +0000154}
155
Daniel Dunbar2928c832009-11-06 10:58:06 +0000156Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
Chandler Carruth06accda2012-02-12 09:27:38 +0000157 return StringSwitch<Triple::ArchType>(Name)
Tim Northover72062f52013-01-31 12:12:40 +0000158 .Case("aarch64", aarch64)
Chandler Carruth06accda2012-02-12 09:27:38 +0000159 .Case("arm", arm)
Chandler Carruth06accda2012-02-12 09:27:38 +0000160 .Case("mips", mips)
161 .Case("mipsel", mipsel)
162 .Case("mips64", mips64)
163 .Case("mips64el", mips64el)
164 .Case("msp430", msp430)
165 .Case("ppc64", ppc64)
166 .Case("ppc32", ppc)
167 .Case("ppc", ppc)
168 .Case("mblaze", mblaze)
Anton Korobeynikov74156592012-03-09 10:09:36 +0000169 .Case("r600", r600)
Chandler Carruth06accda2012-02-12 09:27:38 +0000170 .Case("hexagon", hexagon)
171 .Case("sparc", sparc)
172 .Case("sparcv9", sparcv9)
173 .Case("tce", tce)
174 .Case("thumb", thumb)
175 .Case("x86", x86)
176 .Case("x86-64", x86_64)
177 .Case("xcore", xcore)
Justin Holewinski49683f32012-05-04 20:18:50 +0000178 .Case("nvptx", nvptx)
179 .Case("nvptx64", nvptx64)
Chandler Carruth06accda2012-02-12 09:27:38 +0000180 .Case("le32", le32)
181 .Case("amdil", amdil)
Micah Villmowe53d6052012-10-01 17:01:31 +0000182 .Case("spir", spir)
Guy Benyeiac39a032012-11-15 10:35:47 +0000183 .Case("spir64", spir64)
Chandler Carruth06accda2012-02-12 09:27:38 +0000184 .Default(UnknownArch);
Daniel Dunbar3c2d4bf2009-08-03 04:03:51 +0000185}
186
Duncan Sandsbbdca3f2010-03-24 09:05:14 +0000187// Returns architecture name that is understood by the target assembler.
Viktor Kutuzov51cdac02009-11-17 18:48:27 +0000188const char *Triple::getArchNameForAssembler() {
Daniel Dunbare1fe09f2011-04-19 21:12:05 +0000189 if (!isOSDarwin() && getVendor() != Triple::Apple)
Viktor Kutuzov51cdac02009-11-17 18:48:27 +0000190 return NULL;
191
Chandler Carruth06accda2012-02-12 09:27:38 +0000192 return StringSwitch<const char*>(getArchName())
193 .Case("i386", "i386")
194 .Case("x86_64", "x86_64")
195 .Case("powerpc", "ppc")
196 .Case("powerpc64", "ppc64")
197 .Cases("mblaze", "microblaze", "mblaze")
198 .Case("arm", "arm")
199 .Cases("armv4t", "thumbv4t", "armv4t")
200 .Cases("armv5", "armv5e", "thumbv5", "thumbv5e", "armv5")
201 .Cases("armv6", "thumbv6", "armv6")
202 .Cases("armv7", "thumbv7", "armv7")
Anton Korobeynikov74156592012-03-09 10:09:36 +0000203 .Case("r600", "r600")
Justin Holewinski49683f32012-05-04 20:18:50 +0000204 .Case("nvptx", "nvptx")
205 .Case("nvptx64", "nvptx64")
Chandler Carruth06accda2012-02-12 09:27:38 +0000206 .Case("le32", "le32")
207 .Case("amdil", "amdil")
Micah Villmowe53d6052012-10-01 17:01:31 +0000208 .Case("spir", "spir")
Guy Benyeiac39a032012-11-15 10:35:47 +0000209 .Case("spir64", "spir64")
Chandler Carruth06accda2012-02-12 09:27:38 +0000210 .Default(NULL);
Viktor Kutuzov51cdac02009-11-17 18:48:27 +0000211}
212
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000213static Triple::ArchType parseArch(StringRef ArchName) {
214 return StringSwitch<Triple::ArchType>(ArchName)
215 .Cases("i386", "i486", "i586", "i686", Triple::x86)
216 // FIXME: Do we need to support these?
217 .Cases("i786", "i886", "i986", Triple::x86)
218 .Cases("amd64", "x86_64", Triple::x86_64)
219 .Case("powerpc", Triple::ppc)
220 .Cases("powerpc64", "ppu", Triple::ppc64)
221 .Case("mblaze", Triple::mblaze)
Tim Northover72062f52013-01-31 12:12:40 +0000222 .Case("aarch64", Triple::aarch64)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000223 .Cases("arm", "xscale", Triple::arm)
Chandler Carruth0a857712012-02-18 04:34:17 +0000224 // FIXME: It would be good to replace these with explicit names for all the
225 // various suffixes supported.
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000226 .StartsWith("armv", Triple::arm)
227 .Case("thumb", Triple::thumb)
228 .StartsWith("thumbv", Triple::thumb)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000229 .Case("msp430", Triple::msp430)
230 .Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
Chandler Carruthfdf0dc92012-02-22 11:32:54 +0000231 .Cases("mipsel", "mipsallegrexel", Triple::mipsel)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000232 .Cases("mips64", "mips64eb", Triple::mips64)
233 .Case("mips64el", Triple::mips64el)
Anton Korobeynikov74156592012-03-09 10:09:36 +0000234 .Case("r600", Triple::r600)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000235 .Case("hexagon", Triple::hexagon)
236 .Case("sparc", Triple::sparc)
237 .Case("sparcv9", Triple::sparcv9)
238 .Case("tce", Triple::tce)
239 .Case("xcore", Triple::xcore)
Justin Holewinski49683f32012-05-04 20:18:50 +0000240 .Case("nvptx", Triple::nvptx)
241 .Case("nvptx64", Triple::nvptx64)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000242 .Case("le32", Triple::le32)
243 .Case("amdil", Triple::amdil)
Micah Villmowe53d6052012-10-01 17:01:31 +0000244 .Case("spir", Triple::spir)
Guy Benyeiac39a032012-11-15 10:35:47 +0000245 .Case("spir64", Triple::spir64)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000246 .Default(Triple::UnknownArch);
Duncan Sands335db222010-08-12 11:31:39 +0000247}
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000248
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000249static Triple::VendorType parseVendor(StringRef VendorName) {
250 return StringSwitch<Triple::VendorType>(VendorName)
251 .Case("apple", Triple::Apple)
252 .Case("pc", Triple::PC)
253 .Case("scei", Triple::SCEI)
Hal Finkela47406c2012-04-02 18:31:33 +0000254 .Case("bgp", Triple::BGP)
255 .Case("bgq", Triple::BGQ)
Hal Finkeld939cd62012-08-28 02:10:30 +0000256 .Case("fsl", Triple::Freescale)
Duncan Sands2e522d02012-10-12 11:08:57 +0000257 .Case("ibm", Triple::IBM)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000258 .Default(Triple::UnknownVendor);
Duncan Sands335db222010-08-12 11:31:39 +0000259}
260
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000261static Triple::OSType parseOS(StringRef OSName) {
262 return StringSwitch<Triple::OSType>(OSName)
263 .StartsWith("auroraux", Triple::AuroraUX)
264 .StartsWith("cygwin", Triple::Cygwin)
265 .StartsWith("darwin", Triple::Darwin)
266 .StartsWith("dragonfly", Triple::DragonFly)
267 .StartsWith("freebsd", Triple::FreeBSD)
268 .StartsWith("ios", Triple::IOS)
269 .StartsWith("kfreebsd", Triple::KFreeBSD)
270 .StartsWith("linux", Triple::Linux)
271 .StartsWith("lv2", Triple::Lv2)
272 .StartsWith("macosx", Triple::MacOSX)
273 .StartsWith("mingw32", Triple::MinGW32)
274 .StartsWith("netbsd", Triple::NetBSD)
275 .StartsWith("openbsd", Triple::OpenBSD)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000276 .StartsWith("solaris", Triple::Solaris)
277 .StartsWith("win32", Triple::Win32)
278 .StartsWith("haiku", Triple::Haiku)
279 .StartsWith("minix", Triple::Minix)
280 .StartsWith("rtems", Triple::RTEMS)
Eli Benderskyf659c0d2012-12-04 18:37:26 +0000281 .StartsWith("nacl", Triple::NaCl)
Hal Finkela47406c2012-04-02 18:31:33 +0000282 .StartsWith("cnk", Triple::CNK)
Eric Christopherb0f67592012-08-06 20:52:18 +0000283 .StartsWith("bitrig", Triple::Bitrig)
Duncan Sands2e522d02012-10-12 11:08:57 +0000284 .StartsWith("aix", Triple::AIX)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000285 .Default(Triple::UnknownOS);
Duncan Sands335db222010-08-12 11:31:39 +0000286}
287
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000288static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
289 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
290 .StartsWith("eabi", Triple::EABI)
291 .StartsWith("gnueabihf", Triple::GNUEABIHF)
292 .StartsWith("gnueabi", Triple::GNUEABI)
Eli Bendersky9dd2a3b2013-01-22 18:02:49 +0000293 .StartsWith("gnux32", Triple::GNUX32)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000294 .StartsWith("gnu", Triple::GNU)
295 .StartsWith("macho", Triple::MachO)
Logan Chien43bf7092012-09-02 09:29:46 +0000296 .StartsWith("android", Triple::Android)
Andrew Kaylor7bbd6e32012-10-02 18:38:34 +0000297 .StartsWith("elf", Triple::ELF)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000298 .Default(Triple::UnknownEnvironment);
Duncan Sands5754a452010-09-16 08:25:48 +0000299}
300
Chandler Carruthcceb8f42012-02-20 00:02:47 +0000301/// \brief Construct a triple from the string representation provided.
302///
Chandler Carruth0523f412012-02-21 08:31:18 +0000303/// This stores the string representation and parses the various pieces into
304/// enum members.
Chandler Carruth124e51c2012-02-21 03:39:36 +0000305Triple::Triple(const Twine &Str)
306 : Data(Str.str()),
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000307 Arch(parseArch(getArchName())),
308 Vendor(parseVendor(getVendorName())),
309 OS(parseOS(getOSName())),
310 Environment(parseEnvironment(getEnvironmentName())) {
Chandler Carruth124e51c2012-02-21 03:39:36 +0000311}
Chandler Carruthcceb8f42012-02-20 00:02:47 +0000312
313/// \brief Construct a triple from string representations of the architecture,
314/// vendor, and OS.
315///
Chandler Carruth0523f412012-02-21 08:31:18 +0000316/// This joins each argument into a canonical string representation and parses
317/// them into enum members. It leaves the environment unknown and omits it from
318/// the string representation.
Chandler Carruthcceb8f42012-02-20 00:02:47 +0000319Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
320 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000321 Arch(parseArch(ArchStr.str())),
322 Vendor(parseVendor(VendorStr.str())),
323 OS(parseOS(OSStr.str())),
Chandler Carruth124e51c2012-02-21 03:39:36 +0000324 Environment() {
Chandler Carruthcceb8f42012-02-20 00:02:47 +0000325}
326
327/// \brief Construct a triple from string representations of the architecture,
328/// vendor, OS, and environment.
329///
Chandler Carruth0523f412012-02-21 08:31:18 +0000330/// This joins each argument into a canonical string representation and parses
331/// them into enum members.
Chandler Carruthcceb8f42012-02-20 00:02:47 +0000332Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
333 const Twine &EnvironmentStr)
334 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
335 EnvironmentStr).str()),
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000336 Arch(parseArch(ArchStr.str())),
337 Vendor(parseVendor(VendorStr.str())),
338 OS(parseOS(OSStr.str())),
339 Environment(parseEnvironment(EnvironmentStr.str())) {
Chandler Carruthcceb8f42012-02-20 00:02:47 +0000340}
341
Duncan Sands335db222010-08-12 11:31:39 +0000342std::string Triple::normalize(StringRef Str) {
343 // Parse into components.
344 SmallVector<StringRef, 4> Components;
Chandler Carruthdac3d362012-02-21 09:12:48 +0000345 Str.split(Components, "-");
Duncan Sands335db222010-08-12 11:31:39 +0000346
347 // If the first component corresponds to a known architecture, preferentially
348 // use it for the architecture. If the second component corresponds to a
349 // known vendor, preferentially use it for the vendor, etc. This avoids silly
350 // component movement when a component parses as (eg) both a valid arch and a
351 // valid os.
352 ArchType Arch = UnknownArch;
353 if (Components.size() > 0)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000354 Arch = parseArch(Components[0]);
Duncan Sands335db222010-08-12 11:31:39 +0000355 VendorType Vendor = UnknownVendor;
356 if (Components.size() > 1)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000357 Vendor = parseVendor(Components[1]);
Duncan Sands335db222010-08-12 11:31:39 +0000358 OSType OS = UnknownOS;
359 if (Components.size() > 2)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000360 OS = parseOS(Components[2]);
Duncan Sands5754a452010-09-16 08:25:48 +0000361 EnvironmentType Environment = UnknownEnvironment;
362 if (Components.size() > 3)
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000363 Environment = parseEnvironment(Components[3]);
Duncan Sands335db222010-08-12 11:31:39 +0000364
365 // Note which components are already in their final position. These will not
366 // be moved.
Duncan Sands5754a452010-09-16 08:25:48 +0000367 bool Found[4];
Duncan Sands335db222010-08-12 11:31:39 +0000368 Found[0] = Arch != UnknownArch;
369 Found[1] = Vendor != UnknownVendor;
370 Found[2] = OS != UnknownOS;
Duncan Sands5754a452010-09-16 08:25:48 +0000371 Found[3] = Environment != UnknownEnvironment;
Duncan Sands335db222010-08-12 11:31:39 +0000372
373 // If they are not there already, permute the components into their canonical
374 // positions by seeing if they parse as a valid architecture, and if so moving
375 // the component to the architecture position etc.
Duncan Sands5754a452010-09-16 08:25:48 +0000376 for (unsigned Pos = 0; Pos != array_lengthof(Found); ++Pos) {
Duncan Sands335db222010-08-12 11:31:39 +0000377 if (Found[Pos])
378 continue; // Already in the canonical position.
379
380 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
381 // Do not reparse any components that already matched.
Duncan Sands5754a452010-09-16 08:25:48 +0000382 if (Idx < array_lengthof(Found) && Found[Idx])
Duncan Sands335db222010-08-12 11:31:39 +0000383 continue;
384
385 // Does this component parse as valid for the target position?
386 bool Valid = false;
387 StringRef Comp = Components[Idx];
388 switch (Pos) {
Craig Topper85814382012-02-07 05:05:23 +0000389 default: llvm_unreachable("unexpected component type!");
Duncan Sands335db222010-08-12 11:31:39 +0000390 case 0:
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000391 Arch = parseArch(Comp);
Duncan Sands335db222010-08-12 11:31:39 +0000392 Valid = Arch != UnknownArch;
393 break;
394 case 1:
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000395 Vendor = parseVendor(Comp);
Duncan Sands335db222010-08-12 11:31:39 +0000396 Valid = Vendor != UnknownVendor;
397 break;
398 case 2:
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000399 OS = parseOS(Comp);
Duncan Sandsae200c62011-02-02 10:08:38 +0000400 Valid = OS != UnknownOS;
Duncan Sands335db222010-08-12 11:31:39 +0000401 break;
Duncan Sands5754a452010-09-16 08:25:48 +0000402 case 3:
Chandler Carruth4fbf6582012-02-21 08:53:32 +0000403 Environment = parseEnvironment(Comp);
Duncan Sands5754a452010-09-16 08:25:48 +0000404 Valid = Environment != UnknownEnvironment;
405 break;
Duncan Sands335db222010-08-12 11:31:39 +0000406 }
407 if (!Valid)
408 continue; // Nope, try the next component.
409
410 // Move the component to the target position, pushing any non-fixed
411 // components that are in the way to the right. This tends to give
412 // good results in the common cases of a forgotten vendor component
413 // or a wrongly positioned environment.
414 if (Pos < Idx) {
415 // Insert left, pushing the existing components to the right. For
416 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
417 StringRef CurrentComponent(""); // The empty component.
418 // Replace the component we are moving with an empty component.
419 std::swap(CurrentComponent, Components[Idx]);
420 // Insert the component being moved at Pos, displacing any existing
421 // components to the right.
422 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
423 // Skip over any fixed components.
Chandler Carruthc5f18d32012-02-21 09:29:14 +0000424 while (i < array_lengthof(Found) && Found[i])
425 ++i;
Duncan Sands335db222010-08-12 11:31:39 +0000426 // Place the component at the new position, getting the component
427 // that was at this position - it will be moved right.
428 std::swap(CurrentComponent, Components[i]);
429 }
430 } else if (Pos > Idx) {
431 // Push right by inserting empty components until the component at Idx
432 // reaches the target position Pos. For example, pc-a -> -pc-a when
433 // moving pc to the second position.
434 do {
435 // Insert one empty component at Idx.
436 StringRef CurrentComponent(""); // The empty component.
Duncan Sandsae200c62011-02-02 10:08:38 +0000437 for (unsigned i = Idx; i < Components.size();) {
Duncan Sands335db222010-08-12 11:31:39 +0000438 // Place the component at the new position, getting the component
439 // that was at this position - it will be moved right.
440 std::swap(CurrentComponent, Components[i]);
441 // If it was placed on top of an empty component then we are done.
442 if (CurrentComponent.empty())
443 break;
Duncan Sandsae200c62011-02-02 10:08:38 +0000444 // Advance to the next component, skipping any fixed components.
Anders Carlsson15ec6952011-02-05 18:19:35 +0000445 while (++i < array_lengthof(Found) && Found[i])
446 ;
Duncan Sands335db222010-08-12 11:31:39 +0000447 }
448 // The last component was pushed off the end - append it.
449 if (!CurrentComponent.empty())
450 Components.push_back(CurrentComponent);
451
452 // Advance Idx to the component's new position.
Chandler Carruthc5f18d32012-02-21 09:29:14 +0000453 while (++Idx < array_lengthof(Found) && Found[Idx])
454 ;
Duncan Sands335db222010-08-12 11:31:39 +0000455 } while (Idx < Pos); // Add more until the final position is reached.
456 }
457 assert(Pos < Components.size() && Components[Pos] == Comp &&
458 "Component moved wrong!");
459 Found[Pos] = true;
460 break;
461 }
462 }
463
464 // Special case logic goes here. At this point Arch, Vendor and OS have the
465 // correct values for the computed components.
466
467 // Stick the corrected components back together to form the normalized string.
468 std::string Normalized;
469 for (unsigned i = 0, e = Components.size(); i != e; ++i) {
470 if (i) Normalized += '-';
471 Normalized += Components[i];
472 }
473 return Normalized;
474}
475
Daniel Dunbara14d2252009-07-26 03:31:47 +0000476StringRef Triple::getArchName() const {
477 return StringRef(Data).split('-').first; // Isolate first component
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000478}
479
Daniel Dunbara14d2252009-07-26 03:31:47 +0000480StringRef Triple::getVendorName() const {
481 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
482 return Tmp.split('-').first; // Isolate second component
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000483}
484
Daniel Dunbara14d2252009-07-26 03:31:47 +0000485StringRef Triple::getOSName() const {
486 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
487 Tmp = Tmp.split('-').second; // Strip second component
488 return Tmp.split('-').first; // Isolate third component
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000489}
490
Daniel Dunbara14d2252009-07-26 03:31:47 +0000491StringRef Triple::getEnvironmentName() const {
492 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
493 Tmp = Tmp.split('-').second; // Strip second component
494 return Tmp.split('-').second; // Strip third component
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000495}
496
Daniel Dunbara14d2252009-07-26 03:31:47 +0000497StringRef Triple::getOSAndEnvironmentName() const {
498 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
499 return Tmp.split('-').second; // Strip second component
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000500}
501
Chris Lattnerdfc17f72009-08-12 06:19:40 +0000502static unsigned EatNumber(StringRef &Str) {
503 assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000504 unsigned Result = 0;
Jim Grosbache509aa92010-12-17 02:10:59 +0000505
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000506 do {
507 // Consume the leading digit.
Chris Lattnerdfc17f72009-08-12 06:19:40 +0000508 Result = Result*10 + (Str[0] - '0');
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000509
Chris Lattnerdfc17f72009-08-12 06:19:40 +0000510 // Eat the digit.
511 Str = Str.substr(1);
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000512 } while (!Str.empty() && Str[0] >= '0' && Str[0] <= '9');
Jim Grosbache509aa92010-12-17 02:10:59 +0000513
Chris Lattnerdfc17f72009-08-12 06:19:40 +0000514 return Result;
515}
516
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000517void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
518 unsigned &Micro) const {
Chris Lattnerdfc17f72009-08-12 06:19:40 +0000519 StringRef OSName = getOSName();
Jim Grosbache509aa92010-12-17 02:10:59 +0000520
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000521 // Assume that the OS portion of the triple starts with the canonical name.
522 StringRef OSTypeName = getOSTypeName(getOS());
523 if (OSName.startswith(OSTypeName))
524 OSName = OSName.substr(OSTypeName.size());
Jim Grosbache509aa92010-12-17 02:10:59 +0000525
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000526 // Any unset version defaults to 0.
527 Major = Minor = Micro = 0;
Chris Lattnerdfc17f72009-08-12 06:19:40 +0000528
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000529 // Parse up to three components.
530 unsigned *Components[3] = { &Major, &Minor, &Micro };
531 for (unsigned i = 0; i != 3; ++i) {
532 if (OSName.empty() || OSName[0] < '0' || OSName[0] > '9')
533 break;
Chris Lattnerdfc17f72009-08-12 06:19:40 +0000534
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000535 // Consume the leading number.
536 *Components[i] = EatNumber(OSName);
Jim Grosbache509aa92010-12-17 02:10:59 +0000537
Daniel Dunbar087d6a52011-04-19 20:24:34 +0000538 // Consume the separator, if present.
539 if (OSName.startswith("."))
540 OSName = OSName.substr(1);
541 }
Chris Lattnerdfc17f72009-08-12 06:19:40 +0000542}
543
Bob Wilsonbda59fd2012-01-31 22:32:29 +0000544bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
545 unsigned &Micro) const {
546 getOSVersion(Major, Minor, Micro);
547
548 switch (getOS()) {
Craig Topper85814382012-02-07 05:05:23 +0000549 default: llvm_unreachable("unexpected OS for Darwin triple");
Bob Wilsonbda59fd2012-01-31 22:32:29 +0000550 case Darwin:
551 // Default to darwin8, i.e., MacOSX 10.4.
552 if (Major == 0)
553 Major = 8;
554 // Darwin version numbers are skewed from OS X versions.
555 if (Major < 4)
556 return false;
557 Micro = 0;
558 Minor = Major - 4;
559 Major = 10;
560 break;
561 case MacOSX:
562 // Default to 10.4.
563 if (Major == 0) {
564 Major = 10;
565 Minor = 4;
566 }
567 if (Major != 10)
568 return false;
569 break;
570 case IOS:
571 // Ignore the version from the triple. This is only handled because the
572 // the clang driver combines OS X and IOS support into a common Darwin
573 // toolchain that wants to know the OS X version number even when targeting
574 // IOS.
575 Major = 10;
576 Minor = 4;
577 Micro = 0;
578 break;
579 }
580 return true;
581}
582
Chad Rosierecee47e2012-05-09 17:23:48 +0000583void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
584 unsigned &Micro) const {
585 switch (getOS()) {
586 default: llvm_unreachable("unexpected OS for Darwin triple");
587 case Darwin:
588 case MacOSX:
589 // Ignore the version from the triple. This is only handled because the
590 // the clang driver combines OS X and IOS support into a common Darwin
591 // toolchain that wants to know the iOS version number even when targeting
592 // OS X.
Chad Rosier537c2f52012-05-09 18:23:00 +0000593 Major = 3;
Chad Rosierecee47e2012-05-09 17:23:48 +0000594 Minor = 0;
595 Micro = 0;
Chad Rosier26bbdee2012-05-09 17:38:47 +0000596 break;
Chad Rosierecee47e2012-05-09 17:23:48 +0000597 case IOS:
598 getOSVersion(Major, Minor, Micro);
Chad Rosier537c2f52012-05-09 18:23:00 +0000599 // Default to 3.0.
600 if (Major == 0)
601 Major = 3;
Chad Rosierecee47e2012-05-09 17:23:48 +0000602 break;
603 }
604}
605
Daniel Dunbara14d2252009-07-26 03:31:47 +0000606void Triple::setTriple(const Twine &Str) {
Chandler Carruth124e51c2012-02-21 03:39:36 +0000607 *this = Triple(Str);
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000608}
609
610void Triple::setArch(ArchType Kind) {
611 setArchName(getArchTypeName(Kind));
612}
613
614void Triple::setVendor(VendorType Kind) {
615 setVendorName(getVendorTypeName(Kind));
616}
617
618void Triple::setOS(OSType Kind) {
619 setOSName(getOSTypeName(Kind));
620}
621
Duncan Sands5754a452010-09-16 08:25:48 +0000622void Triple::setEnvironment(EnvironmentType Kind) {
623 setEnvironmentName(getEnvironmentTypeName(Kind));
624}
625
Daniel Dunbar2928c832009-11-06 10:58:06 +0000626void Triple::setArchName(StringRef Str) {
Jeffrey Yasskin0b228732009-10-06 21:45:26 +0000627 // Work around a miscompilation bug for Twines in gcc 4.0.3.
628 SmallString<64> Triple;
629 Triple += Str;
630 Triple += "-";
631 Triple += getVendorName();
632 Triple += "-";
633 Triple += getOSAndEnvironmentName();
634 setTriple(Triple.str());
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000635}
636
Daniel Dunbar2928c832009-11-06 10:58:06 +0000637void Triple::setVendorName(StringRef Str) {
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000638 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
639}
640
Daniel Dunbar2928c832009-11-06 10:58:06 +0000641void Triple::setOSName(StringRef Str) {
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000642 if (hasEnvironment())
643 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
644 "-" + getEnvironmentName());
645 else
646 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
647}
648
Daniel Dunbar2928c832009-11-06 10:58:06 +0000649void Triple::setEnvironmentName(StringRef Str) {
650 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000651 "-" + Str);
652}
653
Daniel Dunbar2928c832009-11-06 10:58:06 +0000654void Triple::setOSAndEnvironmentName(StringRef Str) {
Daniel Dunbar23e97b02009-04-01 21:53:23 +0000655 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
656}
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000657
658static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
659 switch (Arch) {
660 case llvm::Triple::UnknownArch:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000661 return 0;
662
663 case llvm::Triple::msp430:
664 return 16;
665
666 case llvm::Triple::amdil:
667 case llvm::Triple::arm:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000668 case llvm::Triple::hexagon:
669 case llvm::Triple::le32:
670 case llvm::Triple::mblaze:
671 case llvm::Triple::mips:
672 case llvm::Triple::mipsel:
Justin Holewinski49683f32012-05-04 20:18:50 +0000673 case llvm::Triple::nvptx:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000674 case llvm::Triple::ppc:
Anton Korobeynikov74156592012-03-09 10:09:36 +0000675 case llvm::Triple::r600:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000676 case llvm::Triple::sparc:
677 case llvm::Triple::tce:
678 case llvm::Triple::thumb:
679 case llvm::Triple::x86:
680 case llvm::Triple::xcore:
Guy Benyeiac39a032012-11-15 10:35:47 +0000681 case llvm::Triple::spir:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000682 return 32;
683
Tim Northover72062f52013-01-31 12:12:40 +0000684 case llvm::Triple::aarch64:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000685 case llvm::Triple::mips64:
686 case llvm::Triple::mips64el:
Justin Holewinski49683f32012-05-04 20:18:50 +0000687 case llvm::Triple::nvptx64:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000688 case llvm::Triple::ppc64:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000689 case llvm::Triple::sparcv9:
690 case llvm::Triple::x86_64:
Guy Benyeiac39a032012-11-15 10:35:47 +0000691 case llvm::Triple::spir64:
Chandler Carruth6f72ac42012-01-31 04:52:32 +0000692 return 64;
693 }
694 llvm_unreachable("Invalid architecture value");
695}
696
697bool Triple::isArch64Bit() const {
698 return getArchPointerBitWidth(getArch()) == 64;
699}
700
701bool Triple::isArch32Bit() const {
702 return getArchPointerBitWidth(getArch()) == 32;
703}
704
705bool Triple::isArch16Bit() const {
706 return getArchPointerBitWidth(getArch()) == 16;
707}
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000708
709Triple Triple::get32BitArchVariant() const {
710 Triple T(*this);
711 switch (getArch()) {
712 case Triple::UnknownArch:
Tim Northover72062f52013-01-31 12:12:40 +0000713 case Triple::aarch64:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000714 case Triple::msp430:
715 T.setArch(UnknownArch);
716 break;
717
718 case Triple::amdil:
Micah Villmowe53d6052012-10-01 17:01:31 +0000719 case Triple::spir:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000720 case Triple::arm:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000721 case Triple::hexagon:
722 case Triple::le32:
723 case Triple::mblaze:
724 case Triple::mips:
725 case Triple::mipsel:
Justin Holewinski49683f32012-05-04 20:18:50 +0000726 case Triple::nvptx:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000727 case Triple::ppc:
Anton Korobeynikov74156592012-03-09 10:09:36 +0000728 case Triple::r600:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000729 case Triple::sparc:
730 case Triple::tce:
731 case Triple::thumb:
732 case Triple::x86:
733 case Triple::xcore:
734 // Already 32-bit.
735 break;
736
737 case Triple::mips64: T.setArch(Triple::mips); break;
738 case Triple::mips64el: T.setArch(Triple::mipsel); break;
Justin Holewinski49683f32012-05-04 20:18:50 +0000739 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000740 case Triple::ppc64: T.setArch(Triple::ppc); break;
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000741 case Triple::sparcv9: T.setArch(Triple::sparc); break;
742 case Triple::x86_64: T.setArch(Triple::x86); break;
Guy Benyeiac39a032012-11-15 10:35:47 +0000743 case Triple::spir64: T.setArch(Triple::spir); break;
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000744 }
745 return T;
746}
747
748Triple Triple::get64BitArchVariant() const {
749 Triple T(*this);
750 switch (getArch()) {
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000751 case Triple::UnknownArch:
752 case Triple::amdil:
753 case Triple::arm:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000754 case Triple::hexagon:
755 case Triple::le32:
756 case Triple::mblaze:
757 case Triple::msp430:
Anton Korobeynikov74156592012-03-09 10:09:36 +0000758 case Triple::r600:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000759 case Triple::tce:
760 case Triple::thumb:
761 case Triple::xcore:
762 T.setArch(UnknownArch);
763 break;
764
Tim Northover72062f52013-01-31 12:12:40 +0000765 case Triple::aarch64:
Guy Benyeiac39a032012-11-15 10:35:47 +0000766 case Triple::spir64:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000767 case Triple::mips64:
768 case Triple::mips64el:
Justin Holewinski49683f32012-05-04 20:18:50 +0000769 case Triple::nvptx64:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000770 case Triple::ppc64:
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000771 case Triple::sparcv9:
772 case Triple::x86_64:
773 // Already 64-bit.
774 break;
775
776 case Triple::mips: T.setArch(Triple::mips64); break;
777 case Triple::mipsel: T.setArch(Triple::mips64el); break;
Justin Holewinski49683f32012-05-04 20:18:50 +0000778 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000779 case Triple::ppc: T.setArch(Triple::ppc64); break;
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000780 case Triple::sparc: T.setArch(Triple::sparcv9); break;
781 case Triple::x86: T.setArch(Triple::x86_64); break;
Guy Benyeiac39a032012-11-15 10:35:47 +0000782 case Triple::spir: T.setArch(Triple::spir64); break;
Chandler Carruth7d5a2892012-02-06 20:46:33 +0000783 }
784 return T;
785}