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 hexagon: return "hexagon";
26 case mips: return "mips";
27 case mipsel: return "mipsel";
28 case mips64: return "mips64";
29 case mips64el: return "mips64el";
30 case msp430: return "msp430";
31 case ppc64: return "powerpc64";
32 case ppc64le: return "powerpc64le";
33 case ppc: return "powerpc";
34 case r600: return "r600";
35 case sparc: return "sparc";
36 case sparcv9: return "sparcv9";
37 case systemz: return "s390x";
38 case tce: return "tce";
39 case thumb: return "thumb";
40 case x86: return "i386";
41 case x86_64: return "x86_64";
42 case xcore: return "xcore";
43 case nvptx: return "nvptx";
44 case nvptx64: return "nvptx64";
45 case le32: return "le32";
46 case amdil: return "amdil";
47 case spir: return "spir";
48 case spir64: return "spir64";
51 llvm_unreachable("Invalid ArchType!");
54 const char *Triple::getArchTypePrefix(ArchType Kind) {
60 case aarch64_be: return "aarch64";
63 case thumb: return "arm";
67 case ppc: return "ppc";
72 case mips64el: return "mips";
74 case hexagon: return "hexagon";
76 case r600: return "r600";
79 case sparc: return "sparc";
81 case systemz: return "systemz";
84 case x86_64: return "x86";
86 case xcore: return "xcore";
88 case nvptx: return "nvptx";
89 case nvptx64: return "nvptx";
90 case le32: return "le32";
91 case amdil: return "amdil";
92 case spir: return "spir";
93 case spir64: return "spir";
97 const char *Triple::getVendorTypeName(VendorType Kind) {
99 case UnknownVendor: return "unknown";
101 case Apple: return "apple";
102 case PC: return "pc";
103 case SCEI: return "scei";
104 case BGP: return "bgp";
105 case BGQ: return "bgq";
106 case Freescale: return "fsl";
107 case IBM: return "ibm";
108 case NVIDIA: return "nvidia";
111 llvm_unreachable("Invalid VendorType!");
114 const char *Triple::getOSTypeName(OSType Kind) {
116 case UnknownOS: return "unknown";
118 case AuroraUX: return "auroraux";
119 case Cygwin: return "cygwin";
120 case Darwin: return "darwin";
121 case DragonFly: return "dragonfly";
122 case FreeBSD: return "freebsd";
123 case IOS: return "ios";
124 case KFreeBSD: return "kfreebsd";
125 case Linux: return "linux";
126 case Lv2: return "lv2";
127 case MacOSX: return "macosx";
128 case MinGW32: return "mingw32";
129 case NetBSD: return "netbsd";
130 case OpenBSD: return "openbsd";
131 case Solaris: return "solaris";
132 case Win32: return "windows";
133 case Haiku: return "haiku";
134 case Minix: return "minix";
135 case RTEMS: return "rtems";
136 case NaCl: return "nacl";
137 case CNK: return "cnk";
138 case Bitrig: return "bitrig";
139 case AIX: return "aix";
140 case CUDA: return "cuda";
141 case NVCL: return "nvcl";
144 llvm_unreachable("Invalid OSType");
147 const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
149 case UnknownEnvironment: return "unknown";
150 case GNU: return "gnu";
151 case GNUEABIHF: return "gnueabihf";
152 case GNUEABI: return "gnueabi";
153 case GNUX32: return "gnux32";
154 case CODE16: return "code16";
155 case EABI: return "eabi";
156 case EABIHF: return "eabihf";
157 case Android: return "android";
158 case MSVC: return "msvc";
159 case Itanium: return "itanium";
160 case Cygnus: return "cygnus";
163 llvm_unreachable("Invalid EnvironmentType!");
166 Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
167 return StringSwitch<Triple::ArchType>(Name)
168 .Case("aarch64", aarch64)
169 .Case("aarch64_be", aarch64_be)
172 .Case("mipsel", mipsel)
173 .Case("mips64", mips64)
174 .Case("mips64el", mips64el)
175 .Case("msp430", msp430)
176 .Case("ppc64", ppc64)
179 .Case("ppc64le", ppc64le)
181 .Case("hexagon", hexagon)
182 .Case("sparc", sparc)
183 .Case("sparcv9", sparcv9)
184 .Case("systemz", systemz)
186 .Case("thumb", thumb)
188 .Case("x86-64", x86_64)
189 .Case("xcore", xcore)
190 .Case("nvptx", nvptx)
191 .Case("nvptx64", nvptx64)
193 .Case("amdil", amdil)
195 .Case("spir64", spir64)
196 .Default(UnknownArch);
199 // Returns architecture name that is understood by the target assembler.
200 const char *Triple::getArchNameForAssembler() {
201 if (!isOSDarwin() && getVendor() != Triple::Apple)
204 return StringSwitch<const char*>(getArchName())
205 .Case("i386", "i386")
206 .Case("x86_64", "x86_64")
207 .Case("powerpc", "ppc")
208 .Case("powerpc64", "ppc64")
209 .Case("powerpc64le", "ppc64le")
211 .Cases("armv4t", "thumbv4t", "armv4t")
212 .Cases("armv5", "armv5e", "thumbv5", "thumbv5e", "armv5")
213 .Cases("armv6", "thumbv6", "armv6")
214 .Cases("armv7", "thumbv7", "armv7")
215 .Case("r600", "r600")
216 .Case("nvptx", "nvptx")
217 .Case("nvptx64", "nvptx64")
218 .Case("le32", "le32")
219 .Case("amdil", "amdil")
220 .Case("spir", "spir")
221 .Case("spir64", "spir64")
225 static Triple::ArchType parseArch(StringRef ArchName) {
226 return StringSwitch<Triple::ArchType>(ArchName)
227 .Cases("i386", "i486", "i586", "i686", Triple::x86)
228 // FIXME: Do we need to support these?
229 .Cases("i786", "i886", "i986", Triple::x86)
230 .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
231 .Case("powerpc", Triple::ppc)
232 .Cases("powerpc64", "ppu", Triple::ppc64)
233 .Case("powerpc64le", Triple::ppc64le)
234 .Case("aarch64", Triple::aarch64)
235 .Case("aarch64_be", Triple::aarch64_be)
236 .Cases("arm", "xscale", Triple::arm)
237 // FIXME: It would be good to replace these with explicit names for all the
238 // various suffixes supported.
239 .StartsWith("armv", Triple::arm)
240 .Case("thumb", Triple::thumb)
241 .StartsWith("thumbv", Triple::thumb)
242 .Case("msp430", Triple::msp430)
243 .Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
244 .Cases("mipsel", "mipsallegrexel", Triple::mipsel)
245 .Cases("mips64", "mips64eb", Triple::mips64)
246 .Case("mips64el", Triple::mips64el)
247 .Case("r600", Triple::r600)
248 .Case("hexagon", Triple::hexagon)
249 .Case("s390x", Triple::systemz)
250 .Case("sparc", Triple::sparc)
251 .Cases("sparcv9", "sparc64", Triple::sparcv9)
252 .Case("tce", Triple::tce)
253 .Case("xcore", Triple::xcore)
254 .Case("nvptx", Triple::nvptx)
255 .Case("nvptx64", Triple::nvptx64)
256 .Case("le32", Triple::le32)
257 .Case("amdil", Triple::amdil)
258 .Case("spir", Triple::spir)
259 .Case("spir64", Triple::spir64)
260 .Default(Triple::UnknownArch);
263 static Triple::VendorType parseVendor(StringRef VendorName) {
264 return StringSwitch<Triple::VendorType>(VendorName)
265 .Case("apple", Triple::Apple)
266 .Case("pc", Triple::PC)
267 .Case("scei", Triple::SCEI)
268 .Case("bgp", Triple::BGP)
269 .Case("bgq", Triple::BGQ)
270 .Case("fsl", Triple::Freescale)
271 .Case("ibm", Triple::IBM)
272 .Case("nvidia", Triple::NVIDIA)
273 .Default(Triple::UnknownVendor);
276 static Triple::OSType parseOS(StringRef OSName) {
277 return StringSwitch<Triple::OSType>(OSName)
278 .StartsWith("auroraux", Triple::AuroraUX)
279 .StartsWith("cygwin", Triple::Cygwin)
280 .StartsWith("darwin", Triple::Darwin)
281 .StartsWith("dragonfly", Triple::DragonFly)
282 .StartsWith("freebsd", Triple::FreeBSD)
283 .StartsWith("ios", Triple::IOS)
284 .StartsWith("kfreebsd", Triple::KFreeBSD)
285 .StartsWith("linux", Triple::Linux)
286 .StartsWith("lv2", Triple::Lv2)
287 .StartsWith("macosx", Triple::MacOSX)
288 .StartsWith("mingw32", Triple::MinGW32)
289 .StartsWith("netbsd", Triple::NetBSD)
290 .StartsWith("openbsd", Triple::OpenBSD)
291 .StartsWith("solaris", Triple::Solaris)
292 .StartsWith("win32", Triple::Win32)
293 .StartsWith("windows", Triple::Win32)
294 .StartsWith("haiku", Triple::Haiku)
295 .StartsWith("minix", Triple::Minix)
296 .StartsWith("rtems", Triple::RTEMS)
297 .StartsWith("nacl", Triple::NaCl)
298 .StartsWith("cnk", Triple::CNK)
299 .StartsWith("bitrig", Triple::Bitrig)
300 .StartsWith("aix", Triple::AIX)
301 .StartsWith("cuda", Triple::CUDA)
302 .StartsWith("nvcl", Triple::NVCL)
303 .Default(Triple::UnknownOS);
306 static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
307 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
308 .StartsWith("eabihf", Triple::EABIHF)
309 .StartsWith("eabi", Triple::EABI)
310 .StartsWith("gnueabihf", Triple::GNUEABIHF)
311 .StartsWith("gnueabi", Triple::GNUEABI)
312 .StartsWith("gnux32", Triple::GNUX32)
313 .StartsWith("code16", Triple::CODE16)
314 .StartsWith("gnu", Triple::GNU)
315 .StartsWith("android", Triple::Android)
316 .StartsWith("msvc", Triple::MSVC)
317 .StartsWith("itanium", Triple::Itanium)
318 .StartsWith("cygnus", Triple::Cygnus)
319 .Default(Triple::UnknownEnvironment);
322 static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
323 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
324 .EndsWith("coff", Triple::COFF)
325 .EndsWith("elf", Triple::ELF)
326 .EndsWith("macho", Triple::MachO)
327 .Default(Triple::UnknownObjectFormat);
330 static const char *getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
332 case Triple::UnknownObjectFormat: return "";
333 case Triple::COFF: return "coff";
334 case Triple::ELF: return "elf";
335 case Triple::MachO: return "macho";
337 llvm_unreachable("unknown object format type");
340 static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
342 return Triple::MachO;
343 else if (T.isOSWindows())
348 /// \brief Construct a triple from the string representation provided.
350 /// This stores the string representation and parses the various pieces into
352 Triple::Triple(const Twine &Str)
354 Arch(parseArch(getArchName())),
355 Vendor(parseVendor(getVendorName())),
356 OS(parseOS(getOSName())),
357 Environment(parseEnvironment(getEnvironmentName())),
358 ObjectFormat(parseFormat(getEnvironmentName())) {
359 if (ObjectFormat == Triple::UnknownObjectFormat)
360 ObjectFormat = getDefaultFormat(*this);
363 /// \brief Construct a triple from string representations of the architecture,
366 /// This joins each argument into a canonical string representation and parses
367 /// them into enum members. It leaves the environment unknown and omits it from
368 /// the string representation.
369 Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
370 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
371 Arch(parseArch(ArchStr.str())),
372 Vendor(parseVendor(VendorStr.str())),
373 OS(parseOS(OSStr.str())),
374 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
375 ObjectFormat = getDefaultFormat(*this);
378 /// \brief Construct a triple from string representations of the architecture,
379 /// vendor, OS, and environment.
381 /// This joins each argument into a canonical string representation and parses
382 /// them into enum members.
383 Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
384 const Twine &EnvironmentStr)
385 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
386 EnvironmentStr).str()),
387 Arch(parseArch(ArchStr.str())),
388 Vendor(parseVendor(VendorStr.str())),
389 OS(parseOS(OSStr.str())),
390 Environment(parseEnvironment(EnvironmentStr.str())),
391 ObjectFormat(parseFormat(EnvironmentStr.str())) {
392 if (ObjectFormat == Triple::UnknownObjectFormat)
393 ObjectFormat = getDefaultFormat(*this);
396 std::string Triple::normalize(StringRef Str) {
397 // Parse into components.
398 SmallVector<StringRef, 4> Components;
399 Str.split(Components, "-");
401 // If the first component corresponds to a known architecture, preferentially
402 // use it for the architecture. If the second component corresponds to a
403 // known vendor, preferentially use it for the vendor, etc. This avoids silly
404 // component movement when a component parses as (eg) both a valid arch and a
406 ArchType Arch = UnknownArch;
407 if (Components.size() > 0)
408 Arch = parseArch(Components[0]);
409 VendorType Vendor = UnknownVendor;
410 if (Components.size() > 1)
411 Vendor = parseVendor(Components[1]);
412 OSType OS = UnknownOS;
413 if (Components.size() > 2)
414 OS = parseOS(Components[2]);
415 EnvironmentType Environment = UnknownEnvironment;
416 if (Components.size() > 3)
417 Environment = parseEnvironment(Components[3]);
418 ObjectFormatType ObjectFormat = UnknownObjectFormat;
420 // Note which components are already in their final position. These will not
423 Found[0] = Arch != UnknownArch;
424 Found[1] = Vendor != UnknownVendor;
425 Found[2] = OS != UnknownOS;
426 Found[3] = Environment != UnknownEnvironment;
428 // If they are not there already, permute the components into their canonical
429 // positions by seeing if they parse as a valid architecture, and if so moving
430 // the component to the architecture position etc.
431 for (unsigned Pos = 0; Pos != array_lengthof(Found); ++Pos) {
433 continue; // Already in the canonical position.
435 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
436 // Do not reparse any components that already matched.
437 if (Idx < array_lengthof(Found) && Found[Idx])
440 // Does this component parse as valid for the target position?
442 StringRef Comp = Components[Idx];
444 default: llvm_unreachable("unexpected component type!");
446 Arch = parseArch(Comp);
447 Valid = Arch != UnknownArch;
450 Vendor = parseVendor(Comp);
451 Valid = Vendor != UnknownVendor;
455 Valid = OS != UnknownOS;
458 Environment = parseEnvironment(Comp);
459 Valid = Environment != UnknownEnvironment;
461 ObjectFormat = parseFormat(Comp);
462 Valid = ObjectFormat != UnknownObjectFormat;
467 continue; // Nope, try the next component.
469 // Move the component to the target position, pushing any non-fixed
470 // components that are in the way to the right. This tends to give
471 // good results in the common cases of a forgotten vendor component
472 // or a wrongly positioned environment.
474 // Insert left, pushing the existing components to the right. For
475 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
476 StringRef CurrentComponent(""); // The empty component.
477 // Replace the component we are moving with an empty component.
478 std::swap(CurrentComponent, Components[Idx]);
479 // Insert the component being moved at Pos, displacing any existing
480 // components to the right.
481 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
482 // Skip over any fixed components.
483 while (i < array_lengthof(Found) && Found[i])
485 // Place the component at the new position, getting the component
486 // that was at this position - it will be moved right.
487 std::swap(CurrentComponent, Components[i]);
489 } else if (Pos > Idx) {
490 // Push right by inserting empty components until the component at Idx
491 // reaches the target position Pos. For example, pc-a -> -pc-a when
492 // moving pc to the second position.
494 // Insert one empty component at Idx.
495 StringRef CurrentComponent(""); // The empty component.
496 for (unsigned i = Idx; i < Components.size();) {
497 // Place the component at the new position, getting the component
498 // that was at this position - it will be moved right.
499 std::swap(CurrentComponent, Components[i]);
500 // If it was placed on top of an empty component then we are done.
501 if (CurrentComponent.empty())
503 // Advance to the next component, skipping any fixed components.
504 while (++i < array_lengthof(Found) && Found[i])
507 // The last component was pushed off the end - append it.
508 if (!CurrentComponent.empty())
509 Components.push_back(CurrentComponent);
511 // Advance Idx to the component's new position.
512 while (++Idx < array_lengthof(Found) && Found[Idx])
514 } while (Idx < Pos); // Add more until the final position is reached.
516 assert(Pos < Components.size() && Components[Pos] == Comp &&
517 "Component moved wrong!");
523 // Special case logic goes here. At this point Arch, Vendor and OS have the
524 // correct values for the computed components.
526 if (OS == Triple::Win32) {
527 Components.resize(4);
528 Components[2] = "windows";
529 if (Environment == UnknownEnvironment && ObjectFormat == UnknownObjectFormat)
530 Components[3] = "msvc";
531 } else if (OS == Triple::MinGW32) {
532 Components.resize(4);
533 Components[2] = "windows";
534 Components[3] = (ObjectFormat == Triple::ELF) ? "gnuelf" : "gnu";
535 } else if (OS == Triple::Cygwin) {
536 Components.resize(4);
537 Components[2] = "windows";
538 Components[3] = "cygnus";
541 // Stick the corrected components back together to form the normalized string.
542 std::string Normalized;
543 for (unsigned i = 0, e = Components.size(); i != e; ++i) {
544 if (i) Normalized += '-';
545 Normalized += Components[i];
550 StringRef Triple::getArchName() const {
551 return StringRef(Data).split('-').first; // Isolate first component
554 StringRef Triple::getVendorName() const {
555 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
556 return Tmp.split('-').first; // Isolate second component
559 StringRef Triple::getOSName() const {
560 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
561 Tmp = Tmp.split('-').second; // Strip second component
562 return Tmp.split('-').first; // Isolate third component
565 StringRef Triple::getEnvironmentName() const {
566 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
567 Tmp = Tmp.split('-').second; // Strip second component
568 return Tmp.split('-').second; // Strip third component
571 StringRef Triple::getOSAndEnvironmentName() const {
572 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
573 return Tmp.split('-').second; // Strip second component
576 static unsigned EatNumber(StringRef &Str) {
577 assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
581 // Consume the leading digit.
582 Result = Result*10 + (Str[0] - '0');
586 } while (!Str.empty() && Str[0] >= '0' && Str[0] <= '9');
591 void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
592 unsigned &Micro) const {
593 StringRef OSName = getOSName();
595 // Assume that the OS portion of the triple starts with the canonical name.
596 StringRef OSTypeName = getOSTypeName(getOS());
597 if (OSName.startswith(OSTypeName))
598 OSName = OSName.substr(OSTypeName.size());
600 // Any unset version defaults to 0.
601 Major = Minor = Micro = 0;
603 // Parse up to three components.
604 unsigned *Components[3] = { &Major, &Minor, &Micro };
605 for (unsigned i = 0; i != 3; ++i) {
606 if (OSName.empty() || OSName[0] < '0' || OSName[0] > '9')
609 // Consume the leading number.
610 *Components[i] = EatNumber(OSName);
612 // Consume the separator, if present.
613 if (OSName.startswith("."))
614 OSName = OSName.substr(1);
618 bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
619 unsigned &Micro) const {
620 getOSVersion(Major, Minor, Micro);
623 default: llvm_unreachable("unexpected OS for Darwin triple");
625 // Default to darwin8, i.e., MacOSX 10.4.
628 // Darwin version numbers are skewed from OS X versions.
645 // Ignore the version from the triple. This is only handled because the
646 // the clang driver combines OS X and IOS support into a common Darwin
647 // toolchain that wants to know the OS X version number even when targeting
657 void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
658 unsigned &Micro) const {
660 default: llvm_unreachable("unexpected OS for Darwin triple");
663 // Ignore the version from the triple. This is only handled because the
664 // the clang driver combines OS X and IOS support into a common Darwin
665 // toolchain that wants to know the iOS version number even when targeting
672 getOSVersion(Major, Minor, Micro);
680 void Triple::setTriple(const Twine &Str) {
684 void Triple::setArch(ArchType Kind) {
685 setArchName(getArchTypeName(Kind));
688 void Triple::setVendor(VendorType Kind) {
689 setVendorName(getVendorTypeName(Kind));
692 void Triple::setOS(OSType Kind) {
693 setOSName(getOSTypeName(Kind));
696 void Triple::setEnvironment(EnvironmentType Kind) {
697 setEnvironmentName(getEnvironmentTypeName(Kind));
700 void Triple::setObjectFormat(ObjectFormatType Kind) {
701 setEnvironmentName(getObjectFormatTypeName(Kind));
704 void Triple::setArchName(StringRef Str) {
705 // Work around a miscompilation bug for Twines in gcc 4.0.3.
706 SmallString<64> Triple;
709 Triple += getVendorName();
711 Triple += getOSAndEnvironmentName();
712 setTriple(Triple.str());
715 void Triple::setVendorName(StringRef Str) {
716 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
719 void Triple::setOSName(StringRef Str) {
720 if (hasEnvironment())
721 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
722 "-" + getEnvironmentName());
724 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
727 void Triple::setEnvironmentName(StringRef Str) {
728 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
732 void Triple::setOSAndEnvironmentName(StringRef Str) {
733 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
736 static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
738 case llvm::Triple::UnknownArch:
741 case llvm::Triple::msp430:
744 case llvm::Triple::amdil:
745 case llvm::Triple::arm:
746 case llvm::Triple::hexagon:
747 case llvm::Triple::le32:
748 case llvm::Triple::mips:
749 case llvm::Triple::mipsel:
750 case llvm::Triple::nvptx:
751 case llvm::Triple::ppc:
752 case llvm::Triple::r600:
753 case llvm::Triple::sparc:
754 case llvm::Triple::tce:
755 case llvm::Triple::thumb:
756 case llvm::Triple::x86:
757 case llvm::Triple::xcore:
758 case llvm::Triple::spir:
761 case llvm::Triple::aarch64:
762 case llvm::Triple::aarch64_be:
763 case llvm::Triple::mips64:
764 case llvm::Triple::mips64el:
765 case llvm::Triple::nvptx64:
766 case llvm::Triple::ppc64:
767 case llvm::Triple::ppc64le:
768 case llvm::Triple::sparcv9:
769 case llvm::Triple::systemz:
770 case llvm::Triple::x86_64:
771 case llvm::Triple::spir64:
774 llvm_unreachable("Invalid architecture value");
777 bool Triple::isArch64Bit() const {
778 return getArchPointerBitWidth(getArch()) == 64;
781 bool Triple::isArch32Bit() const {
782 return getArchPointerBitWidth(getArch()) == 32;
785 bool Triple::isArch16Bit() const {
786 return getArchPointerBitWidth(getArch()) == 16;
789 Triple Triple::get32BitArchVariant() const {
792 case Triple::UnknownArch:
793 case Triple::aarch64:
794 case Triple::aarch64_be:
796 case Triple::systemz:
797 case Triple::ppc64le:
798 T.setArch(UnknownArch);
804 case Triple::hexagon:
819 case Triple::mips64: T.setArch(Triple::mips); break;
820 case Triple::mips64el: T.setArch(Triple::mipsel); break;
821 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
822 case Triple::ppc64: T.setArch(Triple::ppc); break;
823 case Triple::sparcv9: T.setArch(Triple::sparc); break;
824 case Triple::x86_64: T.setArch(Triple::x86); break;
825 case Triple::spir64: T.setArch(Triple::spir); break;
830 Triple Triple::get64BitArchVariant() const {
833 case Triple::UnknownArch:
836 case Triple::hexagon:
843 T.setArch(UnknownArch);
846 case Triple::aarch64:
847 case Triple::aarch64_be:
850 case Triple::mips64el:
851 case Triple::nvptx64:
853 case Triple::ppc64le:
854 case Triple::sparcv9:
855 case Triple::systemz:
860 case Triple::mips: T.setArch(Triple::mips64); break;
861 case Triple::mipsel: T.setArch(Triple::mips64el); break;
862 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
863 case Triple::ppc: T.setArch(Triple::ppc64); break;
864 case Triple::sparc: T.setArch(Triple::sparcv9); break;
865 case Triple::x86: T.setArch(Triple::x86_64); break;
866 case Triple::spir: T.setArch(Triple::spir64); break;