1 //===--- Triple.cpp - Target triple helper class --------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/ADT/Triple.h"
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ADT/SmallString.h"
13 #include "llvm/ADT/StringSwitch.h"
14 #include "llvm/Support/ErrorHandling.h"
18 const char *Triple::getArchTypeName(ArchType Kind) {
20 case UnknownArch: return "unknown";
22 case aarch64: return "aarch64";
23 case aarch64_be: return "aarch64_be";
24 case arm: return "arm";
25 case armeb: return "armeb";
26 case hexagon: return "hexagon";
27 case mips: return "mips";
28 case mipsel: return "mipsel";
29 case mips64: return "mips64";
30 case mips64el: return "mips64el";
31 case msp430: return "msp430";
32 case ppc64: return "powerpc64";
33 case ppc64le: return "powerpc64le";
34 case ppc: return "powerpc";
35 case r600: return "r600";
36 case sparc: return "sparc";
37 case sparcv9: return "sparcv9";
38 case systemz: return "s390x";
39 case tce: return "tce";
40 case thumb: return "thumb";
41 case thumbeb: return "thumbeb";
42 case x86: return "i386";
43 case x86_64: return "x86_64";
44 case xcore: return "xcore";
45 case nvptx: return "nvptx";
46 case nvptx64: return "nvptx64";
47 case le32: return "le32";
48 case amdil: return "amdil";
49 case spir: return "spir";
50 case spir64: return "spir64";
53 llvm_unreachable("Invalid ArchType!");
56 const char *Triple::getArchTypePrefix(ArchType Kind) {
62 case aarch64_be: return "aarch64";
67 case thumbeb: return "arm";
71 case ppc: return "ppc";
76 case mips64el: return "mips";
78 case hexagon: return "hexagon";
80 case r600: return "r600";
83 case sparc: return "sparc";
85 case systemz: return "systemz";
88 case x86_64: return "x86";
90 case xcore: return "xcore";
92 case nvptx: return "nvptx";
93 case nvptx64: return "nvptx";
94 case le32: return "le32";
95 case amdil: return "amdil";
96 case spir: return "spir";
97 case spir64: return "spir";
101 const char *Triple::getVendorTypeName(VendorType Kind) {
103 case UnknownVendor: return "unknown";
105 case Apple: return "apple";
106 case PC: return "pc";
107 case SCEI: return "scei";
108 case BGP: return "bgp";
109 case BGQ: return "bgq";
110 case Freescale: return "fsl";
111 case IBM: return "ibm";
112 case NVIDIA: return "nvidia";
115 llvm_unreachable("Invalid VendorType!");
118 const char *Triple::getOSTypeName(OSType Kind) {
120 case UnknownOS: return "unknown";
122 case AuroraUX: return "auroraux";
123 case Cygwin: return "cygwin";
124 case Darwin: return "darwin";
125 case DragonFly: return "dragonfly";
126 case FreeBSD: return "freebsd";
127 case IOS: return "ios";
128 case KFreeBSD: return "kfreebsd";
129 case Linux: return "linux";
130 case Lv2: return "lv2";
131 case MacOSX: return "macosx";
132 case MinGW32: return "mingw32";
133 case NetBSD: return "netbsd";
134 case OpenBSD: return "openbsd";
135 case Solaris: return "solaris";
136 case Win32: return "windows";
137 case Haiku: return "haiku";
138 case Minix: return "minix";
139 case RTEMS: return "rtems";
140 case NaCl: return "nacl";
141 case CNK: return "cnk";
142 case Bitrig: return "bitrig";
143 case AIX: return "aix";
144 case CUDA: return "cuda";
145 case NVCL: return "nvcl";
148 llvm_unreachable("Invalid OSType");
151 const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
153 case UnknownEnvironment: return "unknown";
154 case GNU: return "gnu";
155 case GNUEABIHF: return "gnueabihf";
156 case GNUEABI: return "gnueabi";
157 case GNUX32: return "gnux32";
158 case CODE16: return "code16";
159 case EABI: return "eabi";
160 case EABIHF: return "eabihf";
161 case Android: return "android";
162 case MSVC: return "msvc";
163 case Itanium: return "itanium";
164 case Cygnus: return "cygnus";
167 llvm_unreachable("Invalid EnvironmentType!");
170 Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
171 return StringSwitch<Triple::ArchType>(Name)
172 .Case("aarch64", aarch64)
173 .Case("aarch64_be", aarch64_be)
175 .Case("armeb", armeb)
177 .Case("mipsel", mipsel)
178 .Case("mips64", mips64)
179 .Case("mips64el", mips64el)
180 .Case("msp430", msp430)
181 .Case("ppc64", ppc64)
184 .Case("ppc64le", ppc64le)
186 .Case("hexagon", hexagon)
187 .Case("sparc", sparc)
188 .Case("sparcv9", sparcv9)
189 .Case("systemz", systemz)
191 .Case("thumb", thumb)
192 .Case("thumbeb", thumbeb)
194 .Case("x86-64", x86_64)
195 .Case("xcore", xcore)
196 .Case("nvptx", nvptx)
197 .Case("nvptx64", nvptx64)
199 .Case("amdil", amdil)
201 .Case("spir64", spir64)
202 .Default(UnknownArch);
205 // Returns architecture name that is understood by the target assembler.
206 const char *Triple::getArchNameForAssembler() {
207 if (!isOSDarwin() && getVendor() != Triple::Apple)
210 return StringSwitch<const char*>(getArchName())
211 .Case("i386", "i386")
212 .Case("x86_64", "x86_64")
213 .Case("powerpc", "ppc")
214 .Case("powerpc64", "ppc64")
215 .Case("powerpc64le", "ppc64le")
217 .Cases("armv4t", "thumbv4t", "armv4t")
218 .Cases("armv5", "armv5e", "thumbv5", "thumbv5e", "armv5")
219 .Cases("armv6", "thumbv6", "armv6")
220 .Cases("armv7", "thumbv7", "armv7")
221 .Case("armeb", "armeb")
222 .Case("r600", "r600")
223 .Case("nvptx", "nvptx")
224 .Case("nvptx64", "nvptx64")
225 .Case("le32", "le32")
226 .Case("amdil", "amdil")
227 .Case("spir", "spir")
228 .Case("spir64", "spir64")
232 static Triple::ArchType parseArch(StringRef ArchName) {
233 return StringSwitch<Triple::ArchType>(ArchName)
234 .Cases("i386", "i486", "i586", "i686", Triple::x86)
235 // FIXME: Do we need to support these?
236 .Cases("i786", "i886", "i986", Triple::x86)
237 .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
238 .Case("powerpc", Triple::ppc)
239 .Cases("powerpc64", "ppu", Triple::ppc64)
240 .Case("powerpc64le", Triple::ppc64le)
241 .Case("aarch64", Triple::aarch64)
242 .Case("aarch64_be", Triple::aarch64_be)
243 .Cases("arm", "xscale", Triple::arm)
244 // FIXME: It would be good to replace these with explicit names for all the
245 // various suffixes supported.
246 .StartsWith("armv", Triple::arm)
247 .Case("armeb", Triple::armeb)
248 .StartsWith("armebv", Triple::armeb)
249 .Case("thumb", Triple::thumb)
250 .StartsWith("thumbv", Triple::thumb)
251 .Case("thumbeb", Triple::thumbeb)
252 .StartsWith("thumbebv", Triple::thumbeb)
253 .Case("msp430", Triple::msp430)
254 .Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
255 .Cases("mipsel", "mipsallegrexel", Triple::mipsel)
256 .Cases("mips64", "mips64eb", Triple::mips64)
257 .Case("mips64el", Triple::mips64el)
258 .Case("r600", Triple::r600)
259 .Case("hexagon", Triple::hexagon)
260 .Case("s390x", Triple::systemz)
261 .Case("sparc", Triple::sparc)
262 .Cases("sparcv9", "sparc64", Triple::sparcv9)
263 .Case("tce", Triple::tce)
264 .Case("xcore", Triple::xcore)
265 .Case("nvptx", Triple::nvptx)
266 .Case("nvptx64", Triple::nvptx64)
267 .Case("le32", Triple::le32)
268 .Case("amdil", Triple::amdil)
269 .Case("spir", Triple::spir)
270 .Case("spir64", Triple::spir64)
271 .Default(Triple::UnknownArch);
274 static Triple::VendorType parseVendor(StringRef VendorName) {
275 return StringSwitch<Triple::VendorType>(VendorName)
276 .Case("apple", Triple::Apple)
277 .Case("pc", Triple::PC)
278 .Case("scei", Triple::SCEI)
279 .Case("bgp", Triple::BGP)
280 .Case("bgq", Triple::BGQ)
281 .Case("fsl", Triple::Freescale)
282 .Case("ibm", Triple::IBM)
283 .Case("nvidia", Triple::NVIDIA)
284 .Default(Triple::UnknownVendor);
287 static Triple::OSType parseOS(StringRef OSName) {
288 return StringSwitch<Triple::OSType>(OSName)
289 .StartsWith("auroraux", Triple::AuroraUX)
290 .StartsWith("cygwin", Triple::Cygwin)
291 .StartsWith("darwin", Triple::Darwin)
292 .StartsWith("dragonfly", Triple::DragonFly)
293 .StartsWith("freebsd", Triple::FreeBSD)
294 .StartsWith("ios", Triple::IOS)
295 .StartsWith("kfreebsd", Triple::KFreeBSD)
296 .StartsWith("linux", Triple::Linux)
297 .StartsWith("lv2", Triple::Lv2)
298 .StartsWith("macosx", Triple::MacOSX)
299 .StartsWith("mingw32", Triple::MinGW32)
300 .StartsWith("netbsd", Triple::NetBSD)
301 .StartsWith("openbsd", Triple::OpenBSD)
302 .StartsWith("solaris", Triple::Solaris)
303 .StartsWith("win32", Triple::Win32)
304 .StartsWith("windows", Triple::Win32)
305 .StartsWith("haiku", Triple::Haiku)
306 .StartsWith("minix", Triple::Minix)
307 .StartsWith("rtems", Triple::RTEMS)
308 .StartsWith("nacl", Triple::NaCl)
309 .StartsWith("cnk", Triple::CNK)
310 .StartsWith("bitrig", Triple::Bitrig)
311 .StartsWith("aix", Triple::AIX)
312 .StartsWith("cuda", Triple::CUDA)
313 .StartsWith("nvcl", Triple::NVCL)
314 .Default(Triple::UnknownOS);
317 static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
318 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
319 .StartsWith("eabihf", Triple::EABIHF)
320 .StartsWith("eabi", Triple::EABI)
321 .StartsWith("gnueabihf", Triple::GNUEABIHF)
322 .StartsWith("gnueabi", Triple::GNUEABI)
323 .StartsWith("gnux32", Triple::GNUX32)
324 .StartsWith("code16", Triple::CODE16)
325 .StartsWith("gnu", Triple::GNU)
326 .StartsWith("android", Triple::Android)
327 .StartsWith("msvc", Triple::MSVC)
328 .StartsWith("itanium", Triple::Itanium)
329 .StartsWith("cygnus", Triple::Cygnus)
330 .Default(Triple::UnknownEnvironment);
333 static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
334 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
335 .EndsWith("coff", Triple::COFF)
336 .EndsWith("elf", Triple::ELF)
337 .EndsWith("macho", Triple::MachO)
338 .Default(Triple::UnknownObjectFormat);
341 static const char *getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
343 case Triple::UnknownObjectFormat: return "";
344 case Triple::COFF: return "coff";
345 case Triple::ELF: return "elf";
346 case Triple::MachO: return "macho";
348 llvm_unreachable("unknown object format type");
351 static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
353 return Triple::MachO;
354 else if (T.isOSWindows())
359 /// \brief Construct a triple from the string representation provided.
361 /// This stores the string representation and parses the various pieces into
363 Triple::Triple(const Twine &Str)
365 Arch(parseArch(getArchName())),
366 Vendor(parseVendor(getVendorName())),
367 OS(parseOS(getOSName())),
368 Environment(parseEnvironment(getEnvironmentName())),
369 ObjectFormat(parseFormat(getEnvironmentName())) {
370 if (ObjectFormat == Triple::UnknownObjectFormat)
371 ObjectFormat = getDefaultFormat(*this);
374 /// \brief Construct a triple from string representations of the architecture,
377 /// This joins each argument into a canonical string representation and parses
378 /// them into enum members. It leaves the environment unknown and omits it from
379 /// the string representation.
380 Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
381 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
382 Arch(parseArch(ArchStr.str())),
383 Vendor(parseVendor(VendorStr.str())),
384 OS(parseOS(OSStr.str())),
385 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
386 ObjectFormat = getDefaultFormat(*this);
389 /// \brief Construct a triple from string representations of the architecture,
390 /// vendor, OS, and environment.
392 /// This joins each argument into a canonical string representation and parses
393 /// them into enum members.
394 Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
395 const Twine &EnvironmentStr)
396 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
397 EnvironmentStr).str()),
398 Arch(parseArch(ArchStr.str())),
399 Vendor(parseVendor(VendorStr.str())),
400 OS(parseOS(OSStr.str())),
401 Environment(parseEnvironment(EnvironmentStr.str())),
402 ObjectFormat(parseFormat(EnvironmentStr.str())) {
403 if (ObjectFormat == Triple::UnknownObjectFormat)
404 ObjectFormat = getDefaultFormat(*this);
407 std::string Triple::normalize(StringRef Str) {
408 // Parse into components.
409 SmallVector<StringRef, 4> Components;
410 Str.split(Components, "-");
412 // If the first component corresponds to a known architecture, preferentially
413 // use it for the architecture. If the second component corresponds to a
414 // known vendor, preferentially use it for the vendor, etc. This avoids silly
415 // component movement when a component parses as (eg) both a valid arch and a
417 ArchType Arch = UnknownArch;
418 if (Components.size() > 0)
419 Arch = parseArch(Components[0]);
420 VendorType Vendor = UnknownVendor;
421 if (Components.size() > 1)
422 Vendor = parseVendor(Components[1]);
423 OSType OS = UnknownOS;
424 if (Components.size() > 2)
425 OS = parseOS(Components[2]);
426 EnvironmentType Environment = UnknownEnvironment;
427 if (Components.size() > 3)
428 Environment = parseEnvironment(Components[3]);
429 ObjectFormatType ObjectFormat = UnknownObjectFormat;
431 // Note which components are already in their final position. These will not
434 Found[0] = Arch != UnknownArch;
435 Found[1] = Vendor != UnknownVendor;
436 Found[2] = OS != UnknownOS;
437 Found[3] = Environment != UnknownEnvironment;
439 // If they are not there already, permute the components into their canonical
440 // positions by seeing if they parse as a valid architecture, and if so moving
441 // the component to the architecture position etc.
442 for (unsigned Pos = 0; Pos != array_lengthof(Found); ++Pos) {
444 continue; // Already in the canonical position.
446 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
447 // Do not reparse any components that already matched.
448 if (Idx < array_lengthof(Found) && Found[Idx])
451 // Does this component parse as valid for the target position?
453 StringRef Comp = Components[Idx];
455 default: llvm_unreachable("unexpected component type!");
457 Arch = parseArch(Comp);
458 Valid = Arch != UnknownArch;
461 Vendor = parseVendor(Comp);
462 Valid = Vendor != UnknownVendor;
466 Valid = OS != UnknownOS;
469 Environment = parseEnvironment(Comp);
470 Valid = Environment != UnknownEnvironment;
472 ObjectFormat = parseFormat(Comp);
473 Valid = ObjectFormat != UnknownObjectFormat;
478 continue; // Nope, try the next component.
480 // Move the component to the target position, pushing any non-fixed
481 // components that are in the way to the right. This tends to give
482 // good results in the common cases of a forgotten vendor component
483 // or a wrongly positioned environment.
485 // Insert left, pushing the existing components to the right. For
486 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
487 StringRef CurrentComponent(""); // The empty component.
488 // Replace the component we are moving with an empty component.
489 std::swap(CurrentComponent, Components[Idx]);
490 // Insert the component being moved at Pos, displacing any existing
491 // components to the right.
492 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
493 // Skip over any fixed components.
494 while (i < array_lengthof(Found) && Found[i])
496 // Place the component at the new position, getting the component
497 // that was at this position - it will be moved right.
498 std::swap(CurrentComponent, Components[i]);
500 } else if (Pos > Idx) {
501 // Push right by inserting empty components until the component at Idx
502 // reaches the target position Pos. For example, pc-a -> -pc-a when
503 // moving pc to the second position.
505 // Insert one empty component at Idx.
506 StringRef CurrentComponent(""); // The empty component.
507 for (unsigned i = Idx; i < Components.size();) {
508 // Place the component at the new position, getting the component
509 // that was at this position - it will be moved right.
510 std::swap(CurrentComponent, Components[i]);
511 // If it was placed on top of an empty component then we are done.
512 if (CurrentComponent.empty())
514 // Advance to the next component, skipping any fixed components.
515 while (++i < array_lengthof(Found) && Found[i])
518 // The last component was pushed off the end - append it.
519 if (!CurrentComponent.empty())
520 Components.push_back(CurrentComponent);
522 // Advance Idx to the component's new position.
523 while (++Idx < array_lengthof(Found) && Found[Idx])
525 } while (Idx < Pos); // Add more until the final position is reached.
527 assert(Pos < Components.size() && Components[Pos] == Comp &&
528 "Component moved wrong!");
534 // Special case logic goes here. At this point Arch, Vendor and OS have the
535 // correct values for the computed components.
537 if (OS == Triple::Win32) {
538 Components.resize(4);
539 Components[2] = "windows";
540 if (Environment == UnknownEnvironment && ObjectFormat == UnknownObjectFormat)
541 Components[3] = "msvc";
542 } else if (OS == Triple::MinGW32) {
543 Components.resize(4);
544 Components[2] = "windows";
545 Components[3] = (ObjectFormat == Triple::ELF) ? "gnuelf" : "gnu";
546 } else if (OS == Triple::Cygwin) {
547 Components.resize(4);
548 Components[2] = "windows";
549 Components[3] = "cygnus";
552 // Stick the corrected components back together to form the normalized string.
553 std::string Normalized;
554 for (unsigned i = 0, e = Components.size(); i != e; ++i) {
555 if (i) Normalized += '-';
556 Normalized += Components[i];
561 StringRef Triple::getArchName() const {
562 return StringRef(Data).split('-').first; // Isolate first component
565 StringRef Triple::getVendorName() const {
566 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
567 return Tmp.split('-').first; // Isolate second component
570 StringRef Triple::getOSName() const {
571 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
572 Tmp = Tmp.split('-').second; // Strip second component
573 return Tmp.split('-').first; // Isolate third component
576 StringRef Triple::getEnvironmentName() const {
577 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
578 Tmp = Tmp.split('-').second; // Strip second component
579 return Tmp.split('-').second; // Strip third component
582 StringRef Triple::getOSAndEnvironmentName() const {
583 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
584 return Tmp.split('-').second; // Strip second component
587 static unsigned EatNumber(StringRef &Str) {
588 assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
592 // Consume the leading digit.
593 Result = Result*10 + (Str[0] - '0');
597 } while (!Str.empty() && Str[0] >= '0' && Str[0] <= '9');
602 void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
603 unsigned &Micro) const {
604 StringRef OSName = getOSName();
606 // Assume that the OS portion of the triple starts with the canonical name.
607 StringRef OSTypeName = getOSTypeName(getOS());
608 if (OSName.startswith(OSTypeName))
609 OSName = OSName.substr(OSTypeName.size());
611 // Any unset version defaults to 0.
612 Major = Minor = Micro = 0;
614 // Parse up to three components.
615 unsigned *Components[3] = { &Major, &Minor, &Micro };
616 for (unsigned i = 0; i != 3; ++i) {
617 if (OSName.empty() || OSName[0] < '0' || OSName[0] > '9')
620 // Consume the leading number.
621 *Components[i] = EatNumber(OSName);
623 // Consume the separator, if present.
624 if (OSName.startswith("."))
625 OSName = OSName.substr(1);
629 bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
630 unsigned &Micro) const {
631 getOSVersion(Major, Minor, Micro);
634 default: llvm_unreachable("unexpected OS for Darwin triple");
636 // Default to darwin8, i.e., MacOSX 10.4.
639 // Darwin version numbers are skewed from OS X versions.
656 // Ignore the version from the triple. This is only handled because the
657 // the clang driver combines OS X and IOS support into a common Darwin
658 // toolchain that wants to know the OS X version number even when targeting
668 void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
669 unsigned &Micro) const {
671 default: llvm_unreachable("unexpected OS for Darwin triple");
674 // Ignore the version from the triple. This is only handled because the
675 // the clang driver combines OS X and IOS support into a common Darwin
676 // toolchain that wants to know the iOS version number even when targeting
683 getOSVersion(Major, Minor, Micro);
691 void Triple::setTriple(const Twine &Str) {
695 void Triple::setArch(ArchType Kind) {
696 setArchName(getArchTypeName(Kind));
699 void Triple::setVendor(VendorType Kind) {
700 setVendorName(getVendorTypeName(Kind));
703 void Triple::setOS(OSType Kind) {
704 setOSName(getOSTypeName(Kind));
707 void Triple::setEnvironment(EnvironmentType Kind) {
708 setEnvironmentName(getEnvironmentTypeName(Kind));
711 void Triple::setObjectFormat(ObjectFormatType Kind) {
712 setEnvironmentName(getObjectFormatTypeName(Kind));
715 void Triple::setArchName(StringRef Str) {
716 // Work around a miscompilation bug for Twines in gcc 4.0.3.
717 SmallString<64> Triple;
720 Triple += getVendorName();
722 Triple += getOSAndEnvironmentName();
723 setTriple(Triple.str());
726 void Triple::setVendorName(StringRef Str) {
727 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
730 void Triple::setOSName(StringRef Str) {
731 if (hasEnvironment())
732 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
733 "-" + getEnvironmentName());
735 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
738 void Triple::setEnvironmentName(StringRef Str) {
739 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
743 void Triple::setOSAndEnvironmentName(StringRef Str) {
744 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
747 static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
749 case llvm::Triple::UnknownArch:
752 case llvm::Triple::msp430:
755 case llvm::Triple::amdil:
756 case llvm::Triple::arm:
757 case llvm::Triple::armeb:
758 case llvm::Triple::hexagon:
759 case llvm::Triple::le32:
760 case llvm::Triple::mips:
761 case llvm::Triple::mipsel:
762 case llvm::Triple::nvptx:
763 case llvm::Triple::ppc:
764 case llvm::Triple::r600:
765 case llvm::Triple::sparc:
766 case llvm::Triple::tce:
767 case llvm::Triple::thumb:
768 case llvm::Triple::thumbeb:
769 case llvm::Triple::x86:
770 case llvm::Triple::xcore:
771 case llvm::Triple::spir:
774 case llvm::Triple::aarch64:
775 case llvm::Triple::aarch64_be:
776 case llvm::Triple::mips64:
777 case llvm::Triple::mips64el:
778 case llvm::Triple::nvptx64:
779 case llvm::Triple::ppc64:
780 case llvm::Triple::ppc64le:
781 case llvm::Triple::sparcv9:
782 case llvm::Triple::systemz:
783 case llvm::Triple::x86_64:
784 case llvm::Triple::spir64:
787 llvm_unreachable("Invalid architecture value");
790 bool Triple::isArch64Bit() const {
791 return getArchPointerBitWidth(getArch()) == 64;
794 bool Triple::isArch32Bit() const {
795 return getArchPointerBitWidth(getArch()) == 32;
798 bool Triple::isArch16Bit() const {
799 return getArchPointerBitWidth(getArch()) == 16;
802 Triple Triple::get32BitArchVariant() const {
805 case Triple::UnknownArch:
806 case Triple::aarch64:
807 case Triple::aarch64_be:
809 case Triple::systemz:
810 case Triple::ppc64le:
811 T.setArch(UnknownArch);
818 case Triple::hexagon:
828 case Triple::thumbeb:
834 case Triple::mips64: T.setArch(Triple::mips); break;
835 case Triple::mips64el: T.setArch(Triple::mipsel); break;
836 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
837 case Triple::ppc64: T.setArch(Triple::ppc); break;
838 case Triple::sparcv9: T.setArch(Triple::sparc); break;
839 case Triple::x86_64: T.setArch(Triple::x86); break;
840 case Triple::spir64: T.setArch(Triple::spir); break;
845 Triple Triple::get64BitArchVariant() const {
848 case Triple::UnknownArch:
852 case Triple::hexagon:
858 case Triple::thumbeb:
860 T.setArch(UnknownArch);
863 case Triple::aarch64:
864 case Triple::aarch64_be:
867 case Triple::mips64el:
868 case Triple::nvptx64:
870 case Triple::ppc64le:
871 case Triple::sparcv9:
872 case Triple::systemz:
877 case Triple::mips: T.setArch(Triple::mips64); break;
878 case Triple::mipsel: T.setArch(Triple::mips64el); break;
879 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
880 case Triple::ppc: T.setArch(Triple::ppc64); break;
881 case Triple::sparc: T.setArch(Triple::sparcv9); break;
882 case Triple::x86: T.setArch(Triple::x86_64); break;
883 case Triple::spir: T.setArch(Triple::spir64); break;