LLVM  13.0.0git
Triple.cpp
Go to the documentation of this file.
1 //===--- Triple.cpp - Target triple helper class --------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/ADT/Triple.h"
10 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/ADT/StringExtras.h"
13 #include "llvm/ADT/StringSwitch.h"
15 #include "llvm/Support/Host.h"
19 #include <cassert>
20 #include <cstring>
21 using namespace llvm;
22 
24  switch (Kind) {
25  case UnknownArch: return "unknown";
26 
27  case aarch64: return "aarch64";
28  case aarch64_32: return "aarch64_32";
29  case aarch64_be: return "aarch64_be";
30  case amdgcn: return "amdgcn";
31  case amdil64: return "amdil64";
32  case amdil: return "amdil";
33  case arc: return "arc";
34  case arm: return "arm";
35  case armeb: return "armeb";
36  case avr: return "avr";
37  case bpfeb: return "bpfeb";
38  case bpfel: return "bpfel";
39  case csky: return "csky";
40  case hexagon: return "hexagon";
41  case hsail64: return "hsail64";
42  case hsail: return "hsail";
43  case kalimba: return "kalimba";
44  case lanai: return "lanai";
45  case le32: return "le32";
46  case le64: return "le64";
47  case m68k: return "m68k";
48  case mips64: return "mips64";
49  case mips64el: return "mips64el";
50  case mips: return "mips";
51  case mipsel: return "mipsel";
52  case msp430: return "msp430";
53  case nvptx64: return "nvptx64";
54  case nvptx: return "nvptx";
55  case ppc64: return "powerpc64";
56  case ppc64le: return "powerpc64le";
57  case ppc: return "powerpc";
58  case ppcle: return "powerpcle";
59  case r600: return "r600";
60  case renderscript32: return "renderscript32";
61  case renderscript64: return "renderscript64";
62  case riscv32: return "riscv32";
63  case riscv64: return "riscv64";
64  case shave: return "shave";
65  case sparc: return "sparc";
66  case sparcel: return "sparcel";
67  case sparcv9: return "sparcv9";
68  case spir64: return "spir64";
69  case spir: return "spir";
70  case systemz: return "s390x";
71  case tce: return "tce";
72  case tcele: return "tcele";
73  case thumb: return "thumb";
74  case thumbeb: return "thumbeb";
75  case ve: return "ve";
76  case wasm32: return "wasm32";
77  case wasm64: return "wasm64";
78  case x86: return "i386";
79  case x86_64: return "x86_64";
80  case xcore: return "xcore";
81  }
82 
83  llvm_unreachable("Invalid ArchType!");
84 }
85 
87  switch (Kind) {
88  default:
89  return StringRef();
90 
91  case aarch64:
92  case aarch64_be:
93  case aarch64_32: return "aarch64";
94 
95  case arc: return "arc";
96 
97  case arm:
98  case armeb:
99  case thumb:
100  case thumbeb: return "arm";
101 
102  case avr: return "avr";
103 
104  case ppc64:
105  case ppc64le:
106  case ppc:
107  case ppcle: return "ppc";
108 
109  case m68k: return "m68k";
110 
111  case mips:
112  case mipsel:
113  case mips64:
114  case mips64el: return "mips";
115 
116  case hexagon: return "hexagon";
117 
118  case amdgcn: return "amdgcn";
119  case r600: return "r600";
120 
121  case bpfel:
122  case bpfeb: return "bpf";
123 
124  case sparcv9:
125  case sparcel:
126  case sparc: return "sparc";
127 
128  case systemz: return "s390";
129 
130  case x86:
131  case x86_64: return "x86";
132 
133  case xcore: return "xcore";
134 
135  // NVPTX intrinsics are namespaced under nvvm.
136  case nvptx: return "nvvm";
137  case nvptx64: return "nvvm";
138 
139  case le32: return "le32";
140  case le64: return "le64";
141 
142  case amdil:
143  case amdil64: return "amdil";
144 
145  case hsail:
146  case hsail64: return "hsail";
147 
148  case spir:
149  case spir64: return "spir";
150  case kalimba: return "kalimba";
151  case lanai: return "lanai";
152  case shave: return "shave";
153  case wasm32:
154  case wasm64: return "wasm";
155 
156  case riscv32:
157  case riscv64: return "riscv";
158 
159  case ve: return "ve";
160  case csky: return "csky";
161  }
162 }
163 
165  switch (Kind) {
166  case UnknownVendor: return "unknown";
167 
168  case AMD: return "amd";
169  case Apple: return "apple";
170  case CSR: return "csr";
171  case Freescale: return "fsl";
172  case IBM: return "ibm";
173  case ImaginationTechnologies: return "img";
174  case Mesa: return "mesa";
175  case MipsTechnologies: return "mti";
176  case Myriad: return "myriad";
177  case NVIDIA: return "nvidia";
178  case OpenEmbedded: return "oe";
179  case PC: return "pc";
180  case SCEI: return "scei";
181  case SUSE: return "suse";
182  }
183 
184  llvm_unreachable("Invalid VendorType!");
185 }
186 
188  switch (Kind) {
189  case UnknownOS: return "unknown";
190 
191  case AIX: return "aix";
192  case AMDHSA: return "amdhsa";
193  case AMDPAL: return "amdpal";
194  case Ananas: return "ananas";
195  case CUDA: return "cuda";
196  case CloudABI: return "cloudabi";
197  case Contiki: return "contiki";
198  case Darwin: return "darwin";
199  case DragonFly: return "dragonfly";
200  case ELFIAMCU: return "elfiamcu";
201  case Emscripten: return "emscripten";
202  case FreeBSD: return "freebsd";
203  case Fuchsia: return "fuchsia";
204  case Haiku: return "haiku";
205  case HermitCore: return "hermit";
206  case Hurd: return "hurd";
207  case IOS: return "ios";
208  case KFreeBSD: return "kfreebsd";
209  case Linux: return "linux";
210  case Lv2: return "lv2";
211  case MacOSX: return "macosx";
212  case Mesa3D: return "mesa3d";
213  case Minix: return "minix";
214  case NVCL: return "nvcl";
215  case NaCl: return "nacl";
216  case NetBSD: return "netbsd";
217  case OpenBSD: return "openbsd";
218  case PS4: return "ps4";
219  case RTEMS: return "rtems";
220  case Solaris: return "solaris";
221  case TvOS: return "tvos";
222  case WASI: return "wasi";
223  case WatchOS: return "watchos";
224  case Win32: return "windows";
225  case ZOS: return "zos";
226  }
227 
228  llvm_unreachable("Invalid OSType");
229 }
230 
232  switch (Kind) {
233  case UnknownEnvironment: return "unknown";
234  case Android: return "android";
235  case CODE16: return "code16";
236  case CoreCLR: return "coreclr";
237  case Cygnus: return "cygnus";
238  case EABI: return "eabi";
239  case EABIHF: return "eabihf";
240  case GNU: return "gnu";
241  case GNUABI64: return "gnuabi64";
242  case GNUABIN32: return "gnuabin32";
243  case GNUEABI: return "gnueabi";
244  case GNUEABIHF: return "gnueabihf";
245  case GNUX32: return "gnux32";
246  case GNUILP32: return "gnu_ilp32";
247  case Itanium: return "itanium";
248  case MSVC: return "msvc";
249  case MacABI: return "macabi";
250  case Musl: return "musl";
251  case MuslEABI: return "musleabi";
252  case MuslEABIHF: return "musleabihf";
253  case MuslX32: return "muslx32";
254  case Simulator: return "simulator";
255  }
256 
257  llvm_unreachable("Invalid EnvironmentType!");
258 }
259 
261  if (ArchName.equals("bpf")) {
263  return Triple::bpfel;
264  else
265  return Triple::bpfeb;
266  } else if (ArchName.equals("bpf_be") || ArchName.equals("bpfeb")) {
267  return Triple::bpfeb;
268  } else if (ArchName.equals("bpf_le") || ArchName.equals("bpfel")) {
269  return Triple::bpfel;
270  } else {
271  return Triple::UnknownArch;
272  }
273 }
274 
278  .Case("aarch64", aarch64)
279  .Case("aarch64_be", aarch64_be)
280  .Case("aarch64_32", aarch64_32)
281  .Case("arc", arc)
282  .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
283  .Case("arm64_32", aarch64_32)
284  .Case("arm", arm)
285  .Case("armeb", armeb)
286  .Case("avr", avr)
287  .StartsWith("bpf", BPFArch)
288  .Case("m68k", m68k)
289  .Case("mips", mips)
290  .Case("mipsel", mipsel)
291  .Case("mips64", mips64)
292  .Case("mips64el", mips64el)
293  .Case("msp430", msp430)
294  .Case("ppc64", ppc64)
295  .Case("ppc32", ppc)
296  .Case("ppc", ppc)
297  .Case("ppc32le", ppcle)
298  .Case("ppcle", ppcle)
299  .Case("ppc64le", ppc64le)
300  .Case("r600", r600)
301  .Case("amdgcn", amdgcn)
302  .Case("riscv32", riscv32)
303  .Case("riscv64", riscv64)
304  .Case("hexagon", hexagon)
305  .Case("sparc", sparc)
306  .Case("sparcel", sparcel)
307  .Case("sparcv9", sparcv9)
308  .Case("systemz", systemz)
309  .Case("tce", tce)
310  .Case("tcele", tcele)
311  .Case("thumb", thumb)
312  .Case("thumbeb", thumbeb)
313  .Case("x86", x86)
314  .Case("x86-64", x86_64)
315  .Case("xcore", xcore)
316  .Case("nvptx", nvptx)
317  .Case("nvptx64", nvptx64)
318  .Case("le32", le32)
319  .Case("le64", le64)
320  .Case("amdil", amdil)
321  .Case("amdil64", amdil64)
322  .Case("hsail", hsail)
323  .Case("hsail64", hsail64)
324  .Case("spir", spir)
325  .Case("spir64", spir64)
326  .Case("kalimba", kalimba)
327  .Case("lanai", lanai)
328  .Case("shave", shave)
329  .Case("wasm32", wasm32)
330  .Case("wasm64", wasm64)
331  .Case("renderscript32", renderscript32)
332  .Case("renderscript64", renderscript64)
333  .Case("ve", ve)
334  .Case("csky", csky)
336 }
337 
339  ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
340  ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
341 
343  switch (ENDIAN) {
345  switch (ISA) {
346  case ARM::ISAKind::ARM:
347  arch = Triple::arm;
348  break;
349  case ARM::ISAKind::THUMB:
350  arch = Triple::thumb;
351  break;
353  arch = Triple::aarch64;
354  break;
356  break;
357  }
358  break;
359  }
360  case ARM::EndianKind::BIG: {
361  switch (ISA) {
362  case ARM::ISAKind::ARM:
363  arch = Triple::armeb;
364  break;
365  case ARM::ISAKind::THUMB:
366  arch = Triple::thumbeb;
367  break;
369  arch = Triple::aarch64_be;
370  break;
372  break;
373  }
374  break;
375  }
377  break;
378  }
379  }
380 
381  ArchName = ARM::getCanonicalArchName(ArchName);
382  if (ArchName.empty())
383  return Triple::UnknownArch;
384 
385  // Thumb only exists in v4+
386  if (ISA == ARM::ISAKind::THUMB &&
387  (ArchName.startswith("v2") || ArchName.startswith("v3")))
388  return Triple::UnknownArch;
389 
390  // Thumb only for v6m
391  ARM::ProfileKind Profile = ARM::parseArchProfile(ArchName);
392  unsigned Version = ARM::parseArchVersion(ArchName);
393  if (Profile == ARM::ProfileKind::M && Version == 6) {
394  if (ENDIAN == ARM::EndianKind::BIG)
395  return Triple::thumbeb;
396  else
397  return Triple::thumb;
398  }
399 
400  return arch;
401 }
402 
404  auto AT = StringSwitch<Triple::ArchType>(ArchName)
405  .Cases("i386", "i486", "i586", "i686", Triple::x86)
406  // FIXME: Do we need to support these?
407  .Cases("i786", "i886", "i986", Triple::x86)
408  .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
409  .Cases("powerpc", "powerpcspe", "ppc", "ppc32", Triple::ppc)
410  .Cases("powerpcle", "ppcle", "ppc32le", Triple::ppcle)
411  .Cases("powerpc64", "ppu", "ppc64", Triple::ppc64)
412  .Cases("powerpc64le", "ppc64le", Triple::ppc64le)
413  .Case("xscale", Triple::arm)
414  .Case("xscaleeb", Triple::armeb)
415  .Case("aarch64", Triple::aarch64)
416  .Case("aarch64_be", Triple::aarch64_be)
417  .Case("aarch64_32", Triple::aarch64_32)
418  .Case("arc", Triple::arc)
419  .Case("arm64", Triple::aarch64)
420  .Case("arm64_32", Triple::aarch64_32)
421  .Case("arm64e", Triple::aarch64)
422  .Case("arm", Triple::arm)
423  .Case("armeb", Triple::armeb)
424  .Case("thumb", Triple::thumb)
425  .Case("thumbeb", Triple::thumbeb)
426  .Case("avr", Triple::avr)
427  .Case("m68k", Triple::m68k)
428  .Case("msp430", Triple::msp430)
429  .Cases("mips", "mipseb", "mipsallegrex", "mipsisa32r6",
430  "mipsr6", Triple::mips)
431  .Cases("mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el",
433  .Cases("mips64", "mips64eb", "mipsn32", "mipsisa64r6",
434  "mips64r6", "mipsn32r6", Triple::mips64)
435  .Cases("mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
436  "mipsn32r6el", Triple::mips64el)
437  .Case("r600", Triple::r600)
438  .Case("amdgcn", Triple::amdgcn)
439  .Case("riscv32", Triple::riscv32)
440  .Case("riscv64", Triple::riscv64)
441  .Case("hexagon", Triple::hexagon)
442  .Cases("s390x", "systemz", Triple::systemz)
443  .Case("sparc", Triple::sparc)
444  .Case("sparcel", Triple::sparcel)
445  .Cases("sparcv9", "sparc64", Triple::sparcv9)
446  .Case("tce", Triple::tce)
447  .Case("tcele", Triple::tcele)
448  .Case("xcore", Triple::xcore)
449  .Case("nvptx", Triple::nvptx)
450  .Case("nvptx64", Triple::nvptx64)
451  .Case("le32", Triple::le32)
452  .Case("le64", Triple::le64)
453  .Case("amdil", Triple::amdil)
454  .Case("amdil64", Triple::amdil64)
455  .Case("hsail", Triple::hsail)
456  .Case("hsail64", Triple::hsail64)
457  .Case("spir", Triple::spir)
458  .Case("spir64", Triple::spir64)
459  .StartsWith("kalimba", Triple::kalimba)
460  .Case("lanai", Triple::lanai)
461  .Case("renderscript32", Triple::renderscript32)
462  .Case("renderscript64", Triple::renderscript64)
463  .Case("shave", Triple::shave)
464  .Case("ve", Triple::ve)
465  .Case("wasm32", Triple::wasm32)
466  .Case("wasm64", Triple::wasm64)
467  .Case("csky", Triple::csky)
469 
470  // Some architectures require special parsing logic just to compute the
471  // ArchType result.
472  if (AT == Triple::UnknownArch) {
473  if (ArchName.startswith("arm") || ArchName.startswith("thumb") ||
474  ArchName.startswith("aarch64"))
475  return parseARMArch(ArchName);
476  if (ArchName.startswith("bpf"))
477  return parseBPFArch(ArchName);
478  }
479 
480  return AT;
481 }
482 
484  return StringSwitch<Triple::VendorType>(VendorName)
485  .Case("apple", Triple::Apple)
486  .Case("pc", Triple::PC)
487  .Case("scei", Triple::SCEI)
488  .Case("sie", Triple::SCEI)
489  .Case("fsl", Triple::Freescale)
490  .Case("ibm", Triple::IBM)
493  .Case("nvidia", Triple::NVIDIA)
494  .Case("csr", Triple::CSR)
495  .Case("myriad", Triple::Myriad)
496  .Case("amd", Triple::AMD)
497  .Case("mesa", Triple::Mesa)
498  .Case("suse", Triple::SUSE)
499  .Case("oe", Triple::OpenEmbedded)
501 }
502 
504  return StringSwitch<Triple::OSType>(OSName)
505  .StartsWith("ananas", Triple::Ananas)
506  .StartsWith("cloudabi", Triple::CloudABI)
507  .StartsWith("darwin", Triple::Darwin)
508  .StartsWith("dragonfly", Triple::DragonFly)
509  .StartsWith("freebsd", Triple::FreeBSD)
510  .StartsWith("fuchsia", Triple::Fuchsia)
511  .StartsWith("ios", Triple::IOS)
512  .StartsWith("kfreebsd", Triple::KFreeBSD)
513  .StartsWith("linux", Triple::Linux)
514  .StartsWith("lv2", Triple::Lv2)
515  .StartsWith("macos", Triple::MacOSX)
516  .StartsWith("netbsd", Triple::NetBSD)
517  .StartsWith("openbsd", Triple::OpenBSD)
518  .StartsWith("solaris", Triple::Solaris)
519  .StartsWith("win32", Triple::Win32)
520  .StartsWith("windows", Triple::Win32)
521  .StartsWith("zos", Triple::ZOS)
522  .StartsWith("haiku", Triple::Haiku)
523  .StartsWith("minix", Triple::Minix)
524  .StartsWith("rtems", Triple::RTEMS)
525  .StartsWith("nacl", Triple::NaCl)
526  .StartsWith("aix", Triple::AIX)
527  .StartsWith("cuda", Triple::CUDA)
528  .StartsWith("nvcl", Triple::NVCL)
529  .StartsWith("amdhsa", Triple::AMDHSA)
530  .StartsWith("ps4", Triple::PS4)
531  .StartsWith("elfiamcu", Triple::ELFIAMCU)
532  .StartsWith("tvos", Triple::TvOS)
533  .StartsWith("watchos", Triple::WatchOS)
534  .StartsWith("mesa3d", Triple::Mesa3D)
535  .StartsWith("contiki", Triple::Contiki)
536  .StartsWith("amdpal", Triple::AMDPAL)
537  .StartsWith("hermit", Triple::HermitCore)
538  .StartsWith("hurd", Triple::Hurd)
539  .StartsWith("wasi", Triple::WASI)
540  .StartsWith("emscripten", Triple::Emscripten)
542 }
543 
545  return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
546  .StartsWith("eabihf", Triple::EABIHF)
547  .StartsWith("eabi", Triple::EABI)
548  .StartsWith("gnuabin32", Triple::GNUABIN32)
549  .StartsWith("gnuabi64", Triple::GNUABI64)
550  .StartsWith("gnueabihf", Triple::GNUEABIHF)
551  .StartsWith("gnueabi", Triple::GNUEABI)
552  .StartsWith("gnux32", Triple::GNUX32)
553  .StartsWith("gnu_ilp32", Triple::GNUILP32)
554  .StartsWith("code16", Triple::CODE16)
555  .StartsWith("gnu", Triple::GNU)
556  .StartsWith("android", Triple::Android)
557  .StartsWith("musleabihf", Triple::MuslEABIHF)
558  .StartsWith("musleabi", Triple::MuslEABI)
559  .StartsWith("muslx32", Triple::MuslX32)
560  .StartsWith("musl", Triple::Musl)
561  .StartsWith("msvc", Triple::MSVC)
562  .StartsWith("itanium", Triple::Itanium)
563  .StartsWith("cygnus", Triple::Cygnus)
564  .StartsWith("coreclr", Triple::CoreCLR)
565  .StartsWith("simulator", Triple::Simulator)
566  .StartsWith("macabi", Triple::MacABI)
568 }
569 
571  return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
572  // "xcoff" must come before "coff" because of the order-dependendent
573  // pattern matching.
574  .EndsWith("xcoff", Triple::XCOFF)
575  .EndsWith("coff", Triple::COFF)
576  .EndsWith("elf", Triple::ELF)
577  .EndsWith("goff", Triple::GOFF)
578  .EndsWith("macho", Triple::MachO)
579  .EndsWith("wasm", Triple::Wasm)
581 }
582 
584  if (SubArchName.startswith("mips") &&
585  (SubArchName.endswith("r6el") || SubArchName.endswith("r6")))
586  return Triple::MipsSubArch_r6;
587 
588  if (SubArchName == "powerpcspe")
589  return Triple::PPCSubArch_spe;
590 
591  if (SubArchName == "arm64e")
593 
594  StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
595 
596  // For now, this is the small part. Early return.
597  if (ARMSubArch.empty())
598  return StringSwitch<Triple::SubArchType>(SubArchName)
599  .EndsWith("kalimba3", Triple::KalimbaSubArch_v3)
600  .EndsWith("kalimba4", Triple::KalimbaSubArch_v4)
601  .EndsWith("kalimba5", Triple::KalimbaSubArch_v5)
603 
604  // ARM sub arch.
605  switch(ARM::parseArch(ARMSubArch)) {
606  case ARM::ArchKind::ARMV4:
607  return Triple::NoSubArch;
608  case ARM::ArchKind::ARMV4T:
609  return Triple::ARMSubArch_v4t;
610  case ARM::ArchKind::ARMV5T:
611  return Triple::ARMSubArch_v5;
612  case ARM::ArchKind::ARMV5TE:
613  case ARM::ArchKind::IWMMXT:
614  case ARM::ArchKind::IWMMXT2:
615  case ARM::ArchKind::XSCALE:
616  case ARM::ArchKind::ARMV5TEJ:
618  case ARM::ArchKind::ARMV6:
619  return Triple::ARMSubArch_v6;
620  case ARM::ArchKind::ARMV6K:
621  case ARM::ArchKind::ARMV6KZ:
622  return Triple::ARMSubArch_v6k;
623  case ARM::ArchKind::ARMV6T2:
625  case ARM::ArchKind::ARMV6M:
626  return Triple::ARMSubArch_v6m;
627  case ARM::ArchKind::ARMV7A:
628  case ARM::ArchKind::ARMV7R:
629  return Triple::ARMSubArch_v7;
630  case ARM::ArchKind::ARMV7VE:
632  case ARM::ArchKind::ARMV7K:
633  return Triple::ARMSubArch_v7k;
634  case ARM::ArchKind::ARMV7M:
635  return Triple::ARMSubArch_v7m;
636  case ARM::ArchKind::ARMV7S:
637  return Triple::ARMSubArch_v7s;
638  case ARM::ArchKind::ARMV7EM:
640  case ARM::ArchKind::ARMV8A:
641  return Triple::ARMSubArch_v8;
642  case ARM::ArchKind::ARMV8_1A:
644  case ARM::ArchKind::ARMV8_2A:
646  case ARM::ArchKind::ARMV8_3A:
648  case ARM::ArchKind::ARMV8_4A:
650  case ARM::ArchKind::ARMV8_5A:
652  case ARM::ArchKind::ARMV8_6A:
654  case ARM::ArchKind::ARMV8_7A:
656  case ARM::ArchKind::ARMV8R:
657  return Triple::ARMSubArch_v8r;
658  case ARM::ArchKind::ARMV8MBaseline:
660  case ARM::ArchKind::ARMV8MMainline:
662  case ARM::ArchKind::ARMV8_1MMainline:
664  default:
665  return Triple::NoSubArch;
666  }
667 }
668 
670  switch (Kind) {
671  case Triple::UnknownObjectFormat: return "";
672  case Triple::COFF: return "coff";
673  case Triple::ELF: return "elf";
674  case Triple::GOFF: return "goff";
675  case Triple::MachO: return "macho";
676  case Triple::Wasm: return "wasm";
677  case Triple::XCOFF: return "xcoff";
678  }
679  llvm_unreachable("unknown object format type");
680 }
681 
683  switch (T.getArch()) {
684  case Triple::UnknownArch:
685  case Triple::aarch64:
686  case Triple::aarch64_32:
687  case Triple::arm:
688  case Triple::thumb:
689  case Triple::x86:
690  case Triple::x86_64:
691  if (T.isOSDarwin())
692  return Triple::MachO;
693  else if (T.isOSWindows())
694  return Triple::COFF;
695  return Triple::ELF;
696 
697  case Triple::aarch64_be:
698  case Triple::amdgcn:
699  case Triple::amdil64:
700  case Triple::amdil:
701  case Triple::arc:
702  case Triple::armeb:
703  case Triple::avr:
704  case Triple::bpfeb:
705  case Triple::bpfel:
706  case Triple::csky:
707  case Triple::hexagon:
708  case Triple::hsail64:
709  case Triple::hsail:
710  case Triple::kalimba:
711  case Triple::lanai:
712  case Triple::le32:
713  case Triple::le64:
714  case Triple::m68k:
715  case Triple::mips64:
716  case Triple::mips64el:
717  case Triple::mips:
718  case Triple::mipsel:
719  case Triple::msp430:
720  case Triple::nvptx64:
721  case Triple::nvptx:
722  case Triple::ppc64le:
723  case Triple::ppcle:
724  case Triple::r600:
727  case Triple::riscv32:
728  case Triple::riscv64:
729  case Triple::shave:
730  case Triple::sparc:
731  case Triple::sparcel:
732  case Triple::sparcv9:
733  case Triple::spir64:
734  case Triple::spir:
735  case Triple::tce:
736  case Triple::tcele:
737  case Triple::thumbeb:
738  case Triple::ve:
739  case Triple::xcore:
740  return Triple::ELF;
741 
742  case Triple::ppc64:
743  case Triple::ppc:
744  if (T.isOSAIX())
745  return Triple::XCOFF;
746  return Triple::ELF;
747 
748  case Triple::systemz:
749  if (T.isOSzOS())
750  return Triple::GOFF;
751  return Triple::ELF;
752 
753  case Triple::wasm32:
754  case Triple::wasm64:
755  return Triple::Wasm;
756  }
757  llvm_unreachable("unknown architecture");
758 }
759 
760 /// Construct a triple from the string representation provided.
761 ///
762 /// This stores the string representation and parses the various pieces into
763 /// enum members.
765  : Data(Str.str()), Arch(UnknownArch), SubArch(NoSubArch),
766  Vendor(UnknownVendor), OS(UnknownOS), Environment(UnknownEnvironment),
767  ObjectFormat(UnknownObjectFormat) {
768  // Do minimal parsing by hand here.
769  SmallVector<StringRef, 4> Components;
770  StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
771  if (Components.size() > 0) {
772  Arch = parseArch(Components[0]);
773  SubArch = parseSubArch(Components[0]);
774  if (Components.size() > 1) {
775  Vendor = parseVendor(Components[1]);
776  if (Components.size() > 2) {
777  OS = parseOS(Components[2]);
778  if (Components.size() > 3) {
779  Environment = parseEnvironment(Components[3]);
780  ObjectFormat = parseFormat(Components[3]);
781  }
782  }
783  } else {
784  Environment =
786  .StartsWith("mipsn32", Triple::GNUABIN32)
787  .StartsWith("mips64", Triple::GNUABI64)
788  .StartsWith("mipsisa64", Triple::GNUABI64)
789  .StartsWith("mipsisa32", Triple::GNU)
790  .Cases("mips", "mipsel", "mipsr6", "mipsr6el", Triple::GNU)
792  }
793  }
794  if (ObjectFormat == UnknownObjectFormat)
795  ObjectFormat = getDefaultFormat(*this);
796 }
797 
798 /// Construct a triple from string representations of the architecture,
799 /// vendor, and OS.
800 ///
801 /// This joins each argument into a canonical string representation and parses
802 /// them into enum members. It leaves the environment unknown and omits it from
803 /// the string representation.
804 Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
805  : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
806  Arch(parseArch(ArchStr.str())),
807  SubArch(parseSubArch(ArchStr.str())),
808  Vendor(parseVendor(VendorStr.str())),
809  OS(parseOS(OSStr.str())),
810  Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
811  ObjectFormat = getDefaultFormat(*this);
812 }
813 
814 /// Construct a triple from string representations of the architecture,
815 /// vendor, OS, and environment.
816 ///
817 /// This joins each argument into a canonical string representation and parses
818 /// them into enum members.
819 Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
820  const Twine &EnvironmentStr)
821  : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
822  EnvironmentStr).str()),
823  Arch(parseArch(ArchStr.str())),
824  SubArch(parseSubArch(ArchStr.str())),
825  Vendor(parseVendor(VendorStr.str())),
826  OS(parseOS(OSStr.str())),
827  Environment(parseEnvironment(EnvironmentStr.str())),
828  ObjectFormat(parseFormat(EnvironmentStr.str())) {
829  if (ObjectFormat == Triple::UnknownObjectFormat)
830  ObjectFormat = getDefaultFormat(*this);
831 }
832 
833 std::string Triple::normalize(StringRef Str) {
834  bool IsMinGW32 = false;
835  bool IsCygwin = false;
836 
837  // Parse into components.
838  SmallVector<StringRef, 4> Components;
839  Str.split(Components, '-');
840 
841  // If the first component corresponds to a known architecture, preferentially
842  // use it for the architecture. If the second component corresponds to a
843  // known vendor, preferentially use it for the vendor, etc. This avoids silly
844  // component movement when a component parses as (eg) both a valid arch and a
845  // valid os.
846  ArchType Arch = UnknownArch;
847  if (Components.size() > 0)
848  Arch = parseArch(Components[0]);
849  VendorType Vendor = UnknownVendor;
850  if (Components.size() > 1)
851  Vendor = parseVendor(Components[1]);
852  OSType OS = UnknownOS;
853  if (Components.size() > 2) {
854  OS = parseOS(Components[2]);
855  IsCygwin = Components[2].startswith("cygwin");
856  IsMinGW32 = Components[2].startswith("mingw");
857  }
858  EnvironmentType Environment = UnknownEnvironment;
859  if (Components.size() > 3)
860  Environment = parseEnvironment(Components[3]);
861  ObjectFormatType ObjectFormat = UnknownObjectFormat;
862  if (Components.size() > 4)
863  ObjectFormat = parseFormat(Components[4]);
864 
865  // Note which components are already in their final position. These will not
866  // be moved.
867  bool Found[4];
868  Found[0] = Arch != UnknownArch;
869  Found[1] = Vendor != UnknownVendor;
870  Found[2] = OS != UnknownOS;
871  Found[3] = Environment != UnknownEnvironment;
872 
873  // If they are not there already, permute the components into their canonical
874  // positions by seeing if they parse as a valid architecture, and if so moving
875  // the component to the architecture position etc.
876  for (unsigned Pos = 0; Pos != array_lengthof(Found); ++Pos) {
877  if (Found[Pos])
878  continue; // Already in the canonical position.
879 
880  for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
881  // Do not reparse any components that already matched.
882  if (Idx < array_lengthof(Found) && Found[Idx])
883  continue;
884 
885  // Does this component parse as valid for the target position?
886  bool Valid = false;
887  StringRef Comp = Components[Idx];
888  switch (Pos) {
889  default: llvm_unreachable("unexpected component type!");
890  case 0:
891  Arch = parseArch(Comp);
892  Valid = Arch != UnknownArch;
893  break;
894  case 1:
895  Vendor = parseVendor(Comp);
896  Valid = Vendor != UnknownVendor;
897  break;
898  case 2:
899  OS = parseOS(Comp);
900  IsCygwin = Comp.startswith("cygwin");
901  IsMinGW32 = Comp.startswith("mingw");
902  Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
903  break;
904  case 3:
905  Environment = parseEnvironment(Comp);
906  Valid = Environment != UnknownEnvironment;
907  if (!Valid) {
908  ObjectFormat = parseFormat(Comp);
909  Valid = ObjectFormat != UnknownObjectFormat;
910  }
911  break;
912  }
913  if (!Valid)
914  continue; // Nope, try the next component.
915 
916  // Move the component to the target position, pushing any non-fixed
917  // components that are in the way to the right. This tends to give
918  // good results in the common cases of a forgotten vendor component
919  // or a wrongly positioned environment.
920  if (Pos < Idx) {
921  // Insert left, pushing the existing components to the right. For
922  // example, a-b-i386 -> i386-a-b when moving i386 to the front.
923  StringRef CurrentComponent(""); // The empty component.
924  // Replace the component we are moving with an empty component.
925  std::swap(CurrentComponent, Components[Idx]);
926  // Insert the component being moved at Pos, displacing any existing
927  // components to the right.
928  for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
929  // Skip over any fixed components.
930  while (i < array_lengthof(Found) && Found[i])
931  ++i;
932  // Place the component at the new position, getting the component
933  // that was at this position - it will be moved right.
934  std::swap(CurrentComponent, Components[i]);
935  }
936  } else if (Pos > Idx) {
937  // Push right by inserting empty components until the component at Idx
938  // reaches the target position Pos. For example, pc-a -> -pc-a when
939  // moving pc to the second position.
940  do {
941  // Insert one empty component at Idx.
942  StringRef CurrentComponent(""); // The empty component.
943  for (unsigned i = Idx; i < Components.size();) {
944  // Place the component at the new position, getting the component
945  // that was at this position - it will be moved right.
946  std::swap(CurrentComponent, Components[i]);
947  // If it was placed on top of an empty component then we are done.
948  if (CurrentComponent.empty())
949  break;
950  // Advance to the next component, skipping any fixed components.
951  while (++i < array_lengthof(Found) && Found[i])
952  ;
953  }
954  // The last component was pushed off the end - append it.
955  if (!CurrentComponent.empty())
956  Components.push_back(CurrentComponent);
957 
958  // Advance Idx to the component's new position.
959  while (++Idx < array_lengthof(Found) && Found[Idx])
960  ;
961  } while (Idx < Pos); // Add more until the final position is reached.
962  }
963  assert(Pos < Components.size() && Components[Pos] == Comp &&
964  "Component moved wrong!");
965  Found[Pos] = true;
966  break;
967  }
968  }
969 
970  // Replace empty components with "unknown" value.
971  for (unsigned i = 0, e = Components.size(); i < e; ++i) {
972  if (Components[i].empty())
973  Components[i] = "unknown";
974  }
975 
976  // Special case logic goes here. At this point Arch, Vendor and OS have the
977  // correct values for the computed components.
978  std::string NormalizedEnvironment;
979  if (Environment == Triple::Android && Components[3].startswith("androideabi")) {
980  StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
981  if (AndroidVersion.empty()) {
982  Components[3] = "android";
983  } else {
984  NormalizedEnvironment = Twine("android", AndroidVersion).str();
985  Components[3] = NormalizedEnvironment;
986  }
987  }
988 
989  // SUSE uses "gnueabi" to mean "gnueabihf"
990  if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
991  Components[3] = "gnueabihf";
992 
993  if (OS == Triple::Win32) {
994  Components.resize(4);
995  Components[2] = "windows";
996  if (Environment == UnknownEnvironment) {
997  if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
998  Components[3] = "msvc";
999  else
1000  Components[3] = getObjectFormatTypeName(ObjectFormat);
1001  }
1002  } else if (IsMinGW32) {
1003  Components.resize(4);
1004  Components[2] = "windows";
1005  Components[3] = "gnu";
1006  } else if (IsCygwin) {
1007  Components.resize(4);
1008  Components[2] = "windows";
1009  Components[3] = "cygnus";
1010  }
1011  if (IsMinGW32 || IsCygwin ||
1012  (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1013  if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1014  Components.resize(5);
1015  Components[4] = getObjectFormatTypeName(ObjectFormat);
1016  }
1017  }
1018 
1019  // Stick the corrected components back together to form the normalized string.
1020  return join(Components, "-");
1021 }
1022 
1024  return StringRef(Data).split('-').first; // Isolate first component
1025 }
1026 
1028  StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1029  return Tmp.split('-').first; // Isolate second component
1030 }
1031 
1033  StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1034  Tmp = Tmp.split('-').second; // Strip second component
1035  return Tmp.split('-').first; // Isolate third component
1036 }
1037 
1039  StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1040  Tmp = Tmp.split('-').second; // Strip second component
1041  return Tmp.split('-').second; // Strip third component
1042 }
1043 
1045  StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1046  return Tmp.split('-').second; // Strip second component
1047 }
1048 
1049 static unsigned EatNumber(StringRef &Str) {
1050  assert(!Str.empty() && isDigit(Str[0]) && "Not a number");
1051  unsigned Result = 0;
1052 
1053  do {
1054  // Consume the leading digit.
1055  Result = Result*10 + (Str[0] - '0');
1056 
1057  // Eat the digit.
1058  Str = Str.substr(1);
1059  } while (!Str.empty() && isDigit(Str[0]));
1060 
1061  return Result;
1062 }
1063 
1064 static void parseVersionFromName(StringRef Name, unsigned &Major,
1065  unsigned &Minor, unsigned &Micro) {
1066  // Any unset version defaults to 0.
1067  Major = Minor = Micro = 0;
1068 
1069  // Parse up to three components.
1070  unsigned *Components[3] = {&Major, &Minor, &Micro};
1071  for (unsigned i = 0; i != 3; ++i) {
1072  if (Name.empty() || Name[0] < '0' || Name[0] > '9')
1073  break;
1074 
1075  // Consume the leading number.
1076  *Components[i] = EatNumber(Name);
1077 
1078  // Consume the separator, if present.
1079  if (Name.startswith("."))
1080  Name = Name.substr(1);
1081  }
1082 }
1083 
1084 void Triple::getEnvironmentVersion(unsigned &Major, unsigned &Minor,
1085  unsigned &Micro) const {
1086  StringRef EnvironmentName = getEnvironmentName();
1087  StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1088  if (EnvironmentName.startswith(EnvironmentTypeName))
1089  EnvironmentName = EnvironmentName.substr(EnvironmentTypeName.size());
1090 
1091  parseVersionFromName(EnvironmentName, Major, Minor, Micro);
1092 }
1093 
1094 void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
1095  unsigned &Micro) const {
1096  StringRef OSName = getOSName();
1097  // Assume that the OS portion of the triple starts with the canonical name.
1098  StringRef OSTypeName = getOSTypeName(getOS());
1099  if (OSName.startswith(OSTypeName))
1100  OSName = OSName.substr(OSTypeName.size());
1101  else if (getOS() == MacOSX)
1102  OSName.consume_front("macos");
1103 
1104  parseVersionFromName(OSName, Major, Minor, Micro);
1105 }
1106 
1107 bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
1108  unsigned &Micro) const {
1109  getOSVersion(Major, Minor, Micro);
1110 
1111  switch (getOS()) {
1112  default: llvm_unreachable("unexpected OS for Darwin triple");
1113  case Darwin:
1114  // Default to darwin8, i.e., MacOSX 10.4.
1115  if (Major == 0)
1116  Major = 8;
1117  // Darwin version numbers are skewed from OS X versions.
1118  if (Major < 4)
1119  return false;
1120  if (Major <= 19) {
1121  Micro = 0;
1122  Minor = Major - 4;
1123  Major = 10;
1124  } else {
1125  Micro = 0;
1126  Minor = 0;
1127  // darwin20+ corresponds to macOS 11+.
1128  Major = 11 + Major - 20;
1129  }
1130  break;
1131  case MacOSX:
1132  // Default to 10.4.
1133  if (Major == 0) {
1134  Major = 10;
1135  Minor = 4;
1136  } else if (Major < 10)
1137  return false;
1138  break;
1139  case IOS:
1140  case TvOS:
1141  case WatchOS:
1142  // Ignore the version from the triple. This is only handled because the
1143  // the clang driver combines OS X and IOS support into a common Darwin
1144  // toolchain that wants to know the OS X version number even when targeting
1145  // IOS.
1146  Major = 10;
1147  Minor = 4;
1148  Micro = 0;
1149  break;
1150  }
1151  return true;
1152 }
1153 
1154 void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
1155  unsigned &Micro) const {
1156  switch (getOS()) {
1157  default: llvm_unreachable("unexpected OS for Darwin triple");
1158  case Darwin:
1159  case MacOSX:
1160  // Ignore the version from the triple. This is only handled because the
1161  // the clang driver combines OS X and IOS support into a common Darwin
1162  // toolchain that wants to know the iOS version number even when targeting
1163  // OS X.
1164  Major = 5;
1165  Minor = 0;
1166  Micro = 0;
1167  break;
1168  case IOS:
1169  case TvOS:
1170  getOSVersion(Major, Minor, Micro);
1171  // Default to 5.0 (or 7.0 for arm64).
1172  if (Major == 0)
1173  Major = (getArch() == aarch64) ? 7 : 5;
1174  break;
1175  case WatchOS:
1176  llvm_unreachable("conflicting triple info");
1177  }
1178 }
1179 
1180 void Triple::getWatchOSVersion(unsigned &Major, unsigned &Minor,
1181  unsigned &Micro) const {
1182  switch (getOS()) {
1183  default: llvm_unreachable("unexpected OS for Darwin triple");
1184  case Darwin:
1185  case MacOSX:
1186  // Ignore the version from the triple. This is only handled because the
1187  // the clang driver combines OS X and IOS support into a common Darwin
1188  // toolchain that wants to know the iOS version number even when targeting
1189  // OS X.
1190  Major = 2;
1191  Minor = 0;
1192  Micro = 0;
1193  break;
1194  case WatchOS:
1195  getOSVersion(Major, Minor, Micro);
1196  if (Major == 0)
1197  Major = 2;
1198  break;
1199  case IOS:
1200  llvm_unreachable("conflicting triple info");
1201  }
1202 }
1203 
1204 void Triple::setTriple(const Twine &Str) {
1205  *this = Triple(Str);
1206 }
1207 
1210 }
1211 
1214 }
1215 
1218 }
1219 
1221  if (ObjectFormat == getDefaultFormat(*this))
1223 
1225  getObjectFormatTypeName(ObjectFormat)).str());
1226 }
1227 
1229  if (Environment == UnknownEnvironment)
1231 
1232  setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1234 }
1235 
1237  // Work around a miscompilation bug for Twines in gcc 4.0.3.
1239  Triple += Str;
1240  Triple += "-";
1241  Triple += getVendorName();
1242  Triple += "-";
1244  setTriple(Triple);
1245 }
1246 
1248  setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1249 }
1250 
1252  if (hasEnvironment())
1253  setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1254  "-" + getEnvironmentName());
1255  else
1256  setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1257 }
1258 
1260  setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1261  "-" + Str);
1262 }
1263 
1265  setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1266 }
1267 
1269  switch (Arch) {
1271  return 0;
1272 
1273  case llvm::Triple::avr:
1274  case llvm::Triple::msp430:
1275  return 16;
1276 
1278  case llvm::Triple::amdil:
1279  case llvm::Triple::arc:
1280  case llvm::Triple::arm:
1281  case llvm::Triple::armeb:
1282  case llvm::Triple::csky:
1283  case llvm::Triple::hexagon:
1284  case llvm::Triple::hsail:
1285  case llvm::Triple::kalimba:
1286  case llvm::Triple::lanai:
1287  case llvm::Triple::le32:
1288  case llvm::Triple::m68k:
1289  case llvm::Triple::mips:
1290  case llvm::Triple::mipsel:
1291  case llvm::Triple::nvptx:
1292  case llvm::Triple::ppc:
1293  case llvm::Triple::ppcle:
1294  case llvm::Triple::r600:
1296  case llvm::Triple::riscv32:
1297  case llvm::Triple::shave:
1298  case llvm::Triple::sparc:
1299  case llvm::Triple::sparcel:
1300  case llvm::Triple::spir:
1301  case llvm::Triple::tce:
1302  case llvm::Triple::tcele:
1303  case llvm::Triple::thumb:
1304  case llvm::Triple::thumbeb:
1305  case llvm::Triple::wasm32:
1306  case llvm::Triple::x86:
1307  case llvm::Triple::xcore:
1308  return 32;
1309 
1310  case llvm::Triple::aarch64:
1312  case llvm::Triple::amdgcn:
1313  case llvm::Triple::amdil64:
1314  case llvm::Triple::bpfeb:
1315  case llvm::Triple::bpfel:
1316  case llvm::Triple::hsail64:
1317  case llvm::Triple::le64:
1318  case llvm::Triple::mips64:
1320  case llvm::Triple::nvptx64:
1321  case llvm::Triple::ppc64:
1322  case llvm::Triple::ppc64le:
1324  case llvm::Triple::riscv64:
1325  case llvm::Triple::sparcv9:
1326  case llvm::Triple::spir64:
1327  case llvm::Triple::systemz:
1328  case llvm::Triple::ve:
1329  case llvm::Triple::wasm64:
1330  case llvm::Triple::x86_64:
1331  return 64;
1332  }
1333  llvm_unreachable("Invalid architecture value");
1334 }
1335 
1336 bool Triple::isArch64Bit() const {
1337  return getArchPointerBitWidth(getArch()) == 64;
1338 }
1339 
1340 bool Triple::isArch32Bit() const {
1341  return getArchPointerBitWidth(getArch()) == 32;
1342 }
1343 
1344 bool Triple::isArch16Bit() const {
1345  return getArchPointerBitWidth(getArch()) == 16;
1346 }
1347 
1349  Triple T(*this);
1350  switch (getArch()) {
1351  case Triple::UnknownArch:
1352  case Triple::amdgcn:
1353  case Triple::avr:
1354  case Triple::bpfeb:
1355  case Triple::bpfel:
1356  case Triple::msp430:
1357  case Triple::systemz:
1358  case Triple::ve:
1359  T.setArch(UnknownArch);
1360  break;
1361 
1362  case Triple::aarch64_32:
1363  case Triple::amdil:
1364  case Triple::arc:
1365  case Triple::arm:
1366  case Triple::armeb:
1367  case Triple::csky:
1368  case Triple::hexagon:
1369  case Triple::hsail:
1370  case Triple::kalimba:
1371  case Triple::lanai:
1372  case Triple::le32:
1373  case Triple::m68k:
1374  case Triple::mips:
1375  case Triple::mipsel:
1376  case Triple::nvptx:
1377  case Triple::ppc:
1378  case Triple::ppcle:
1379  case Triple::r600:
1381  case Triple::riscv32:
1382  case Triple::shave:
1383  case Triple::sparc:
1384  case Triple::sparcel:
1385  case Triple::spir:
1386  case Triple::tce:
1387  case Triple::tcele:
1388  case Triple::thumb:
1389  case Triple::thumbeb:
1390  case Triple::wasm32:
1391  case Triple::x86:
1392  case Triple::xcore:
1393  // Already 32-bit.
1394  break;
1395 
1396  case Triple::aarch64: T.setArch(Triple::arm); break;
1397  case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1398  case Triple::amdil64: T.setArch(Triple::amdil); break;
1399  case Triple::hsail64: T.setArch(Triple::hsail); break;
1400  case Triple::le64: T.setArch(Triple::le32); break;
1401  case Triple::mips64: T.setArch(Triple::mips); break;
1402  case Triple::mips64el: T.setArch(Triple::mipsel); break;
1403  case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1404  case Triple::ppc64: T.setArch(Triple::ppc); break;
1405  case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1406  case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1407  case Triple::riscv64: T.setArch(Triple::riscv32); break;
1408  case Triple::sparcv9: T.setArch(Triple::sparc); break;
1409  case Triple::spir64: T.setArch(Triple::spir); break;
1410  case Triple::wasm64: T.setArch(Triple::wasm32); break;
1411  case Triple::x86_64: T.setArch(Triple::x86); break;
1412  }
1413  return T;
1414 }
1415 
1417  Triple T(*this);
1418  switch (getArch()) {
1419  case Triple::UnknownArch:
1420  case Triple::arc:
1421  case Triple::avr:
1422  case Triple::csky:
1423  case Triple::hexagon:
1424  case Triple::kalimba:
1425  case Triple::lanai:
1426  case Triple::m68k:
1427  case Triple::msp430:
1428  case Triple::r600:
1429  case Triple::shave:
1430  case Triple::sparcel:
1431  case Triple::tce:
1432  case Triple::tcele:
1433  case Triple::xcore:
1434  T.setArch(UnknownArch);
1435  break;
1436 
1437  case Triple::aarch64:
1438  case Triple::aarch64_be:
1439  case Triple::amdgcn:
1440  case Triple::amdil64:
1441  case Triple::bpfeb:
1442  case Triple::bpfel:
1443  case Triple::hsail64:
1444  case Triple::le64:
1445  case Triple::mips64:
1446  case Triple::mips64el:
1447  case Triple::nvptx64:
1448  case Triple::ppc64:
1449  case Triple::ppc64le:
1451  case Triple::riscv64:
1452  case Triple::sparcv9:
1453  case Triple::spir64:
1454  case Triple::systemz:
1455  case Triple::ve:
1456  case Triple::wasm64:
1457  case Triple::x86_64:
1458  // Already 64-bit.
1459  break;
1460 
1461  case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1462  case Triple::amdil: T.setArch(Triple::amdil64); break;
1463  case Triple::arm: T.setArch(Triple::aarch64); break;
1464  case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1465  case Triple::hsail: T.setArch(Triple::hsail64); break;
1466  case Triple::le32: T.setArch(Triple::le64); break;
1467  case Triple::mips: T.setArch(Triple::mips64); break;
1468  case Triple::mipsel: T.setArch(Triple::mips64el); break;
1469  case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1470  case Triple::ppc: T.setArch(Triple::ppc64); break;
1471  case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1472  case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1473  case Triple::riscv32: T.setArch(Triple::riscv64); break;
1474  case Triple::sparc: T.setArch(Triple::sparcv9); break;
1475  case Triple::spir: T.setArch(Triple::spir64); break;
1476  case Triple::thumb: T.setArch(Triple::aarch64); break;
1477  case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1478  case Triple::wasm32: T.setArch(Triple::wasm64); break;
1479  case Triple::x86: T.setArch(Triple::x86_64); break;
1480  }
1481  return T;
1482 }
1483 
1485  Triple T(*this);
1486  // Already big endian.
1487  if (!isLittleEndian())
1488  return T;
1489  switch (getArch()) {
1490  case Triple::UnknownArch:
1491  case Triple::amdgcn:
1492  case Triple::amdil64:
1493  case Triple::amdil:
1494  case Triple::avr:
1495  case Triple::hexagon:
1496  case Triple::hsail64:
1497  case Triple::hsail:
1498  case Triple::kalimba:
1499  case Triple::le32:
1500  case Triple::le64:
1501  case Triple::msp430:
1502  case Triple::nvptx64:
1503  case Triple::nvptx:
1504  case Triple::r600:
1507  case Triple::riscv32:
1508  case Triple::riscv64:
1509  case Triple::shave:
1510  case Triple::spir64:
1511  case Triple::spir:
1512  case Triple::wasm32:
1513  case Triple::wasm64:
1514  case Triple::x86:
1515  case Triple::x86_64:
1516  case Triple::xcore:
1517  case Triple::ve:
1518  case Triple::csky:
1519 
1520  // ARM is intentionally unsupported here, changing the architecture would
1521  // drop any arch suffixes.
1522  case Triple::arm:
1523  case Triple::thumb:
1524  T.setArch(UnknownArch);
1525  break;
1526 
1527  case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1528  case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1529  case Triple::mips64el:T.setArch(Triple::mips64); break;
1530  case Triple::mipsel: T.setArch(Triple::mips); break;
1531  case Triple::ppcle: T.setArch(Triple::ppc); break;
1532  case Triple::ppc64le: T.setArch(Triple::ppc64); break;
1533  case Triple::sparcel: T.setArch(Triple::sparc); break;
1534  case Triple::tcele: T.setArch(Triple::tce); break;
1535  default:
1536  llvm_unreachable("getBigEndianArchVariant: unknown triple.");
1537  }
1538  return T;
1539 }
1540 
1542  Triple T(*this);
1543  if (isLittleEndian())
1544  return T;
1545 
1546  switch (getArch()) {
1547  case Triple::UnknownArch:
1548  case Triple::lanai:
1549  case Triple::sparcv9:
1550  case Triple::systemz:
1551  case Triple::m68k:
1552 
1553  // ARM is intentionally unsupported here, changing the architecture would
1554  // drop any arch suffixes.
1555  case Triple::armeb:
1556  case Triple::thumbeb:
1557  T.setArch(UnknownArch);
1558  break;
1559 
1560  case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
1561  case Triple::bpfeb: T.setArch(Triple::bpfel); break;
1562  case Triple::mips64: T.setArch(Triple::mips64el); break;
1563  case Triple::mips: T.setArch(Triple::mipsel); break;
1564  case Triple::ppc: T.setArch(Triple::ppcle); break;
1565  case Triple::ppc64: T.setArch(Triple::ppc64le); break;
1566  case Triple::sparc: T.setArch(Triple::sparcel); break;
1567  case Triple::tce: T.setArch(Triple::tcele); break;
1568  default:
1569  llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
1570  }
1571  return T;
1572 }
1573 
1575  switch (getArch()) {
1576  case Triple::aarch64:
1577  case Triple::aarch64_32:
1578  case Triple::amdgcn:
1579  case Triple::amdil64:
1580  case Triple::amdil:
1581  case Triple::arm:
1582  case Triple::avr:
1583  case Triple::bpfel:
1584  case Triple::csky:
1585  case Triple::hexagon:
1586  case Triple::hsail64:
1587  case Triple::hsail:
1588  case Triple::kalimba:
1589  case Triple::le32:
1590  case Triple::le64:
1591  case Triple::mips64el:
1592  case Triple::mipsel:
1593  case Triple::msp430:
1594  case Triple::nvptx64:
1595  case Triple::nvptx:
1596  case Triple::ppcle:
1597  case Triple::ppc64le:
1598  case Triple::r600:
1601  case Triple::riscv32:
1602  case Triple::riscv64:
1603  case Triple::shave:
1604  case Triple::sparcel:
1605  case Triple::spir64:
1606  case Triple::spir:
1607  case Triple::tcele:
1608  case Triple::thumb:
1609  case Triple::ve:
1610  case Triple::wasm32:
1611  case Triple::wasm64:
1612  case Triple::x86:
1613  case Triple::x86_64:
1614  case Triple::xcore:
1615  return true;
1616  default:
1617  return false;
1618  }
1619 }
1620 
1621 bool Triple::isCompatibleWith(const Triple &Other) const {
1622  // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1623  if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
1624  (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
1625  (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
1626  (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
1627  if (getVendor() == Triple::Apple)
1628  return getSubArch() == Other.getSubArch() &&
1629  getVendor() == Other.getVendor() && getOS() == Other.getOS();
1630  else
1631  return getSubArch() == Other.getSubArch() &&
1632  getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
1633  getEnvironment() == Other.getEnvironment() &&
1634  getObjectFormat() == Other.getObjectFormat();
1635  }
1636 
1637  // If vendor is apple, ignore the version number.
1638  if (getVendor() == Triple::Apple)
1639  return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
1640  getVendor() == Other.getVendor() && getOS() == Other.getOS();
1641 
1642  return *this == Other;
1643 }
1644 
1645 std::string Triple::merge(const Triple &Other) const {
1646  // If vendor is apple, pick the triple with the larger version number.
1647  if (getVendor() == Triple::Apple)
1648  if (Other.isOSVersionLT(*this))
1649  return str();
1650 
1651  return Other.str();
1652 }
1653 
1654 bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
1655  unsigned Micro) const {
1656  assert(isMacOSX() && "Not an OS X triple!");
1657 
1658  // If this is OS X, expect a sane version number.
1659  if (getOS() == Triple::MacOSX)
1660  return isOSVersionLT(Major, Minor, Micro);
1661 
1662  // Otherwise, compare to the "Darwin" number.
1663  if (Major == 10) {
1664  return isOSVersionLT(Minor + 4, Micro, 0);
1665  } else {
1666  assert(Major >= 11 && "Unexpected major version");
1667  return isOSVersionLT(Major - 11 + 20, Minor, Micro);
1668  }
1669 }
1670 
1673  return VersionTuple();
1674  switch (getOS()) {
1675  case Triple::MacOSX:
1676  // ARM64 slice is supported starting from macOS 11.0+.
1677  return VersionTuple(11, 0, 0);
1678  case Triple::IOS:
1679  // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
1680  // ARM64 simulators are supported for iOS 14+.
1682  return VersionTuple(14, 0, 0);
1683  // ARM64e slice is supported starting from iOS 14.
1684  if (isArm64e())
1685  return VersionTuple(14, 0, 0);
1686  break;
1687  case Triple::TvOS:
1688  // ARM64 simulators are supported for tvOS 14+.
1689  if (isSimulatorEnvironment())
1690  return VersionTuple(14, 0, 0);
1691  break;
1692  case Triple::WatchOS:
1693  // ARM64 simulators are supported for watchOS 7+.
1694  if (isSimulatorEnvironment())
1695  return VersionTuple(7, 0, 0);
1696  break;
1697  default:
1698  break;
1699  }
1700  return VersionTuple();
1701 }
1702 
1704  if (MArch.empty())
1705  MArch = getArchName();
1706  MArch = ARM::getCanonicalArchName(MArch);
1707 
1708  // Some defaults are forced.
1709  switch (getOS()) {
1710  case llvm::Triple::FreeBSD:
1711  case llvm::Triple::NetBSD:
1712  if (!MArch.empty() && MArch == "v6")
1713  return "arm1176jzf-s";
1714  if (!MArch.empty() && MArch == "v7")
1715  return "cortex-a8";
1716  break;
1717  case llvm::Triple::Win32:
1718  // FIXME: this is invalid for WindowsCE
1719  if (ARM::parseArchVersion(MArch) <= 7)
1720  return "cortex-a9";
1721  break;
1722  case llvm::Triple::IOS:
1723  case llvm::Triple::MacOSX:
1724  case llvm::Triple::TvOS:
1725  case llvm::Triple::WatchOS:
1726  if (MArch == "v7k")
1727  return "cortex-a7";
1728  break;
1729  default:
1730  break;
1731  }
1732 
1733  if (MArch.empty())
1734  return StringRef();
1735 
1736  StringRef CPU = ARM::getDefaultCPU(MArch);
1737  if (!CPU.empty() && !CPU.equals("invalid"))
1738  return CPU;
1739 
1740  // If no specific architecture version is requested, return the minimum CPU
1741  // required by the OS and environment.
1742  switch (getOS()) {
1743  case llvm::Triple::NetBSD:
1744  switch (getEnvironment()) {
1745  case llvm::Triple::EABI:
1746  case llvm::Triple::EABIHF:
1747  case llvm::Triple::GNUEABI:
1749  return "arm926ej-s";
1750  default:
1751  return "strongarm";
1752  }
1753  case llvm::Triple::NaCl:
1754  case llvm::Triple::OpenBSD:
1755  return "cortex-a8";
1756  default:
1757  switch (getEnvironment()) {
1758  case llvm::Triple::EABIHF:
1761  return "arm1176jzf-s";
1762  default:
1763  return "arm7tdmi";
1764  }
1765  }
1766 
1767  llvm_unreachable("invalid arch name");
1768 }
1769 
1771  const VersionTuple &Version) {
1772  switch (OSKind) {
1773  case MacOSX:
1774  // macOS 10.16 is canonicalized to macOS 11.
1775  if (Version == VersionTuple(10, 16))
1776  return VersionTuple(11, 0);
1778  default:
1779  return Version;
1780  }
1781 }
llvm::Triple::setEnvironment
void setEnvironment(EnvironmentType Kind)
setEnvironment - Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1220
llvm::StringSwitch::Case
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:67
i
i
Definition: README.txt:29
llvm::Triple::isMacOSXVersionLT
bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isMacOSXVersionLT - Comparison function for checking OS X version compatibility, which handles suppor...
Definition: Triple.cpp:1654
llvm::Triple::setVendorName
void setVendorName(StringRef Str)
setVendorName - Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1247
llvm::Triple::riscv64
@ riscv64
Definition: Triple.h:74
llvm::Triple::Wasm
@ Wasm
Definition: Triple.h:238
llvm::Triple::getARMCPUForArch
StringRef getARMCPUForArch(StringRef Arch=StringRef()) const
Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
Definition: Triple.cpp:1703
llvm::Triple::spir64
@ spir64
Definition: Triple.h:95
getObjectFormatTypeName
static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind)
Definition: Triple.cpp:669
llvm::Triple::setTriple
void setTriple(const Twine &Str)
setTriple - Set all components to the new triple Str.
Definition: Triple.cpp:1204
llvm::StringRef::startswith
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:286
llvm::Triple::Mesa
@ Mesa
Definition: Triple.h:159
llvm::StringSwitch::StartsWith
StringSwitch & StartsWith(StringLiteral S, T Value)
Definition: StringSwitch.h:81
llvm::ARM::EndianKind::BIG
@ BIG
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::Triple::getOSVersion
void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getOSVersion - Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1094
llvm::ARM::EndianKind
EndianKind
Definition: ARMTargetParser.h:167
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::Triple::GNUILP32
@ GNUILP32
Definition: Triple.h:213
llvm::Triple::bpfeb
@ bpfeb
Definition: Triple.h:58
llvm::Triple::Lv2
@ Lv2
Definition: Triple.h:176
llvm::Triple::UnknownArch
@ UnknownArch
Definition: Triple.h:48
llvm::ARM::getCanonicalArchName
StringRef getCanonicalArchName(StringRef Arch)
Definition: ARMTargetParser.cpp:279
llvm::Triple::hsail
@ hsail
Definition: Triple.h:92
llvm::ARM::ISAKind::THUMB
@ THUMB
llvm::Triple::HermitCore
@ HermitCore
Definition: Triple.h:198
llvm::Triple::wasm32
@ wasm32
Definition: Triple.h:99
llvm::StringRef::endswith
LLVM_NODISCARD bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:297
llvm::Triple::CUDA
@ CUDA
Definition: Triple.h:188
llvm::Triple::Darwin
@ Darwin
Definition: Triple.h:169
llvm::StringSwitch::Default
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
llvm::Triple::KalimbaSubArch_v3
@ KalimbaSubArch_v3
Definition: Triple.h:137
llvm::Triple::getiOSVersion
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getiOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1154
llvm::Triple::EnvironmentType
EnvironmentType
Definition: Triple.h:204
llvm::Triple::ARMSubArch_v8m_mainline
@ ARMSubArch_v8m_mainline
Definition: Triple.h:119
llvm::Triple::x86
@ x86
Definition: Triple.h:83
llvm::Triple::SubArchType
SubArchType
Definition: Triple.h:106
Host.h
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::StringSwitch::EndsWith
StringSwitch & EndsWith(StringLiteral S, T Value)
Definition: StringSwitch.h:74
llvm::Triple::amdgcn
@ amdgcn
Definition: Triple.h:72
llvm::Triple::Simulator
@ Simulator
Definition: Triple.h:227
llvm::Triple::amdil
@ amdil
Definition: Triple.h:90
ErrorHandling.h
VersionTuple.h
llvm::Triple::MuslEABIHF
@ MuslEABIHF
Definition: Triple.h:220
llvm::Triple::kalimba
@ kalimba
Definition: Triple.h:96
llvm::Triple::getArchTypeForLLVMName
static ArchType getArchTypeForLLVMName(StringRef Str)
getArchTypeForLLVMName - The canonical type for the given LLVM architecture name (e....
Definition: Triple.cpp:275
llvm::Triple::get32BitArchVariant
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1348
llvm::StringRef::consume_front
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:682
llvm::Triple::IOS
@ IOS
Definition: Triple.h:173
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
SwapByteOrder.h
llvm::ARM::parseArchProfile
ProfileKind parseArchProfile(StringRef Arch)
Definition: ARMTargetParser.cpp:92
llvm::Triple::renderscript32
@ renderscript32
Definition: Triple.h:101
llvm::ARM::ProfileKind
ProfileKind
Definition: ARMTargetParser.h:170
llvm::Triple::getOSAndEnvironmentName
StringRef getOSAndEnvironmentName() const
getOSAndEnvironmentName - Get the operating system and optional environment components as a single st...
Definition: Triple.cpp:1044
llvm::Triple::Minix
@ Minix
Definition: Triple.h:184
llvm::Triple::KalimbaSubArch_v5
@ KalimbaSubArch_v5
Definition: Triple.h:139
startswith
static bool startswith(StringRef Magic, const char(&S)[N])
Definition: Magic.cpp:30
llvm::Triple::x86_64
@ x86_64
Definition: Triple.h:84
llvm::Triple::getMacOSXVersion
bool getMacOSXVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getMacOSXVersion - Parse the version number as with getOSVersion and then translate generic "darwin" ...
Definition: Triple.cpp:1107
llvm::Triple::CSR
@ CSR
Definition: Triple.h:156
llvm::Triple::OpenBSD
@ OpenBSD
Definition: Triple.h:179
getDefaultFormat
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition: Triple.cpp:682
llvm::Triple::Ananas
@ Ananas
Definition: Triple.h:167
llvm::Triple::getMinimumSupportedOSVersion
VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition: Triple.cpp:1671
llvm::Triple::ppc
@ ppc
Definition: Triple.h:67
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::Triple::nvptx
@ nvptx
Definition: Triple.h:86
llvm::Triple::hexagon
@ hexagon
Definition: Triple.h:60
llvm::Triple::XCOFF
@ XCOFF
Definition: Triple.h:239
parseSubArch
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition: Triple.cpp:583
llvm::Triple::KalimbaSubArch_v4
@ KalimbaSubArch_v4
Definition: Triple.h:138
llvm::Triple::merge
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:1645
STLExtras.h
llvm::Triple::NVIDIA
@ NVIDIA
Definition: Triple.h:155
TargetParser.h
parseFormat
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition: Triple.cpp:570
llvm::Triple::avr
@ avr
Definition: Triple.h:56
llvm::Triple::aarch64_32
@ aarch64_32
Definition: Triple.h:54
llvm::Triple::le32
@ le32
Definition: Triple.h:88
llvm::Triple::mips64
@ mips64
Definition: Triple.h:64
llvm::Triple::DragonFly
@ DragonFly
Definition: Triple.h:170
llvm::Data
@ Data
Definition: SIMachineScheduler.h:56
llvm::Triple::WatchOS
@ WatchOS
Definition: Triple.h:194
llvm::Triple::GNUEABI
@ GNUEABI
Definition: Triple.h:210
llvm::Triple::ARMSubArch_v8m_baseline
@ ARMSubArch_v8m_baseline
Definition: Triple.h:118
llvm::Triple::getCanonicalVersionForOS
static VersionTuple getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version)
Returns a canonicalized OS version number for the specified OS.
Definition: Triple.cpp:1770
llvm::Triple::setOSAndEnvironmentName
void setOSAndEnvironmentName(StringRef Str)
setOSAndEnvironmentName - Set the operating system and optional environment components with a single ...
Definition: Triple.cpp:1264
llvm::Triple::isArch64Bit
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1336
llvm::Triple::GNU
@ GNU
Definition: Triple.h:207
llvm::Triple::ARMSubArch_v8_1m_mainline
@ ARMSubArch_v8_1m_mainline
Definition: Triple.h:120
llvm::StringRef::substr
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:611
llvm::Triple::isMacOSX
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:454
llvm::Triple::hsail64
@ hsail64
Definition: Triple.h:93
llvm::Triple::isCompatibleWith
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1621
llvm::Triple::isLittleEndian
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1574
llvm::Triple::sparc
@ sparc
Definition: Triple.h:75
llvm::Triple::Musl
@ Musl
Definition: Triple.h:218
llvm::Triple::FreeBSD
@ FreeBSD
Definition: Triple.h:171
llvm::Triple::sparcv9
@ sparcv9
Definition: Triple.h:76
llvm::Triple::sparcel
@ sparcel
Definition: Triple.h:77
llvm::Triple::get64BitArchVariant
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1416
llvm::Triple::ARMSubArch_v8_2a
@ ARMSubArch_v8_2a
Definition: Triple.h:114
llvm::Triple::ArchType
ArchType
Definition: Triple.h:47
llvm::Triple::ARMSubArch_v5
@ ARMSubArch_v5
Definition: Triple.h:131
llvm::Triple::GNUABI64
@ GNUABI64
Definition: Triple.h:209
parseEnvironment
static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName)
Definition: Triple.cpp:544
SmallString.h
llvm::Triple::TvOS
@ TvOS
Definition: Triple.h:193
llvm::Triple::str
const std::string & str() const
Definition: Triple.h:376
llvm::Triple::ARMSubArch_v8_4a
@ ARMSubArch_v8_4a
Definition: Triple.h:112
llvm::StringRef::split
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:749
llvm::Triple::Cygnus
@ Cygnus
Definition: Triple.h:225
llvm::Triple::ARMSubArch_v8r
@ ARMSubArch_v8r
Definition: Triple.h:117
llvm::Triple::Mesa3D
@ Mesa3D
Definition: Triple.h:195
llvm::Triple::mips64el
@ mips64el
Definition: Triple.h:65
llvm::Triple::PC
@ PC
Definition: Triple.h:149
llvm::Triple::CODE16
@ CODE16
Definition: Triple.h:214
llvm::Triple::nvptx64
@ nvptx64
Definition: Triple.h:87
getArchPointerBitWidth
static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch)
Definition: Triple.cpp:1268
parseOS
static Triple::OSType parseOS(StringRef OSName)
Definition: Triple.cpp:503
llvm::Triple::PS4
@ PS4
Definition: Triple.h:191
llvm::Triple::OpenEmbedded
@ OpenEmbedded
Definition: Triple.h:161
llvm::Triple::le64
@ le64
Definition: Triple.h:89
llvm::Triple::Emscripten
@ Emscripten
Definition: Triple.h:201
llvm::Triple::Haiku
@ Haiku
Definition: Triple.h:183
llvm::Triple::MipsSubArch_r6
@ MipsSubArch_r6
Definition: Triple.h:141
llvm::Triple::Freescale
@ Freescale
Definition: Triple.h:151
parseBPFArch
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition: Triple.cpp:260
llvm::Triple::ppc64
@ ppc64
Definition: Triple.h:69
llvm::Triple::NaCl
@ NaCl
Definition: Triple.h:186
llvm::Triple::NetBSD
@ NetBSD
Definition: Triple.h:178
llvm::Triple::xcore
@ xcore
Definition: Triple.h:85
llvm::Triple::setVendor
void setVendor(VendorType Kind)
setVendor - Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1212
llvm::Triple::setEnvironmentName
void setEnvironmentName(StringRef Str)
setEnvironmentName - Set the optional environment (fourth) component of the triple by name.
Definition: Triple.cpp:1259
parseARMArch
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition: Triple.cpp:338
llvm::Triple::r600
@ r600
Definition: Triple.h:71
llvm::Triple::Win32
@ Win32
Definition: Triple.h:181
llvm::Triple::getObjectFormat
ObjectFormatType getObjectFormat() const
getFormat - Get the object format for this triple.
Definition: Triple.h:337
llvm::Triple::KFreeBSD
@ KFreeBSD
Definition: Triple.h:174
llvm::Triple::RTEMS
@ RTEMS
Definition: Triple.h:185
llvm::Triple::m68k
@ m68k
Definition: Triple.h:61
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition: SmallVector.h:606
llvm::Triple::UnknownEnvironment
@ UnknownEnvironment
Definition: Triple.h:205
llvm::VersionTuple
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:28
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:991
llvm::Triple::getArchName
StringRef getArchName() const
getArchName - Get the architecture (first) component of the triple.
Definition: Triple.cpp:1023
llvm::Triple::lanai
@ lanai
Definition: Triple.h:98
llvm::Triple::MuslEABI
@ MuslEABI
Definition: Triple.h:219
llvm::ARM::parseArch
ArchKind parseArch(StringRef Arch)
Definition: ARMTargetParser.cpp:28
llvm::Triple::getEnvironmentTypeName
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
getEnvironmentTypeName - Get the canonical name for the Kind environment.
Definition: Triple.cpp:231
llvm::Triple::getArch
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:307
llvm::array_lengthof
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:1377
llvm::Triple::GOFF
@ GOFF
Definition: Triple.h:236
llvm::Triple::ARMSubArch_v8_5a
@ ARMSubArch_v8_5a
Definition: Triple.h:111
llvm::Triple::ARMSubArch_v7s
@ ARMSubArch_v7s
Definition: Triple.h:124
parseVersionFromName
static void parseVersionFromName(StringRef Name, unsigned &Major, unsigned &Minor, unsigned &Micro)
Definition: Triple.cpp:1064
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::Triple::csky
@ csky
Definition: Triple.h:59
llvm::Triple::CoreCLR
@ CoreCLR
Definition: Triple.h:226
llvm::StringRef::equals
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:187
llvm::Triple::renderscript64
@ renderscript64
Definition: Triple.h:102
llvm::Triple::ARMSubArch_v6k
@ ARMSubArch_v6k
Definition: Triple.h:129
llvm::SmallString< 64 >
llvm::ARM::parseArchEndian
EndianKind parseArchEndian(StringRef Arch)
Definition: ARMTargetParser.cpp:232
llvm::Triple::isOSVersionLT
bool isOSVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isOSVersionLT - Helper function for doing comparisons against version numbers included in the target ...
Definition: Triple.h:425
llvm::Twine::str
std::string str() const
Return the twine contents as a std::string.
Definition: Twine.cpp:17
llvm::Triple::MuslX32
@ MuslX32
Definition: Triple.h:221
llvm::Triple::AMDHSA
@ AMDHSA
Definition: Triple.h:190
llvm::Triple::AArch64SubArch_arm64e
@ AArch64SubArch_arm64e
Definition: Triple.h:135
llvm::Triple::ppc64le
@ ppc64le
Definition: Triple.h:70
llvm::Triple::MacOSX
@ MacOSX
Definition: Triple.h:177
llvm::Triple::getEnvironmentVersion
void getEnvironmentVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1084
llvm::Triple::ELF
@ ELF
Definition: Triple.h:235
parseArch
static Triple::ArchType parseArch(StringRef ArchName)
Definition: Triple.cpp:403
llvm::Triple::GNUX32
@ GNUX32
Definition: Triple.h:212
llvm::Triple::ARMSubArch_v7ve
@ ARMSubArch_v7ve
Definition: Triple.h:126
llvm::Triple::isArch16Bit
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1344
llvm::Triple::Android
@ Android
Definition: Triple.h:217
llvm::Triple::Hurd
@ Hurd
Definition: Triple.h:199
llvm::Triple::getOS
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Definition: Triple.h:316
llvm::Triple::arc
@ arc
Definition: Triple.h:55
llvm::Triple::normalize
std::string normalize() const
Return the normalized form of this triple's string.
Definition: Triple.h:300
EatNumber
static unsigned EatNumber(StringRef &Str)
Definition: Triple.cpp:1049
llvm::Triple::isArch32Bit
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1340
llvm::Triple::MSVC
@ MSVC
Definition: Triple.h:223
llvm::Triple::IBM
@ IBM
Definition: Triple.h:152
llvm::Triple::ARMSubArch_v7k
@ ARMSubArch_v7k
Definition: Triple.h:125
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::Triple::NVCL
@ NVCL
Definition: Triple.h:189
llvm::Triple::Linux
@ Linux
Definition: Triple.h:175
llvm::Triple::Solaris
@ Solaris
Definition: Triple.h:180
llvm::Triple::getVendorName
StringRef getVendorName() const
getVendorName - Get the vendor (second) component of the triple.
Definition: Triple.cpp:1027
llvm::Triple::ARMSubArch_v7m
@ ARMSubArch_v7m
Definition: Triple.h:123
StringExtras.h
llvm::Triple::ARMSubArch_v4t
@ ARMSubArch_v4t
Definition: Triple.h:133
llvm::Triple::isSimulatorEnvironment
bool isSimulatorEnvironment() const
Definition: Triple.h:488
llvm::Triple::ImaginationTechnologies
@ ImaginationTechnologies
Definition: Triple.h:153
llvm::Triple::ARMSubArch_v8
@ ARMSubArch_v8
Definition: Triple.h:116
llvm::Triple::ARMSubArch_v6m
@ ARMSubArch_v6m
Definition: Triple.h:128
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::Triple::ZOS
@ ZOS
Definition: Triple.h:182
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:840
llvm::Triple::bpfel
@ bpfel
Definition: Triple.h:57
llvm::Triple::AMD
@ AMD
Definition: Triple.h:158
llvm::ARM::parseArchVersion
unsigned parseArchVersion(StringRef Arch)
Definition: ARMTargetParser.cpp:39
llvm::Triple::ARMSubArch_v5te
@ ARMSubArch_v5te
Definition: Triple.h:132
llvm::Triple::SCEI
@ SCEI
Definition: Triple.h:150
llvm::Triple::armeb
@ armeb
Definition: Triple.h:51
llvm::Triple::GNUABIN32
@ GNUABIN32
Definition: Triple.h:208
Triple.h
llvm::ARM::EndianKind::LITTLE
@ LITTLE
isDigit
static bool isDigit(const char C)
Definition: RustDemangle.cpp:205
llvm::Triple::arm
@ arm
Definition: Triple.h:50
llvm::ARM::ISAKind
ISAKind
Definition: ARMTargetParser.h:163
llvm::ARM::ISAKind::INVALID
@ INVALID
llvm::Triple::aarch64_be
@ aarch64_be
Definition: Triple.h:53
llvm::Triple::msp430
@ msp430
Definition: Triple.h:66
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::ARM::parseArchISA
ISAKind parseArchISA(StringRef Arch)
Definition: ARMTargetParser.cpp:251
llvm::Triple::setArch
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1208
llvm::Triple::ppcle
@ ppcle
Definition: Triple.h:68
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Triple::ARMSubArch_v8_7a
@ ARMSubArch_v8_7a
Definition: Triple.h:109
llvm::Triple::ARMSubArch_v8_3a
@ ARMSubArch_v8_3a
Definition: Triple.h:113
llvm::Triple::thumb
@ thumb
Definition: Triple.h:81
llvm::Triple::UnknownVendor
@ UnknownVendor
Definition: Triple.h:146
llvm::Triple::ve
@ ve
Definition: Triple.h:103
LLVM_FALLTHROUGH
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:281
llvm::Triple::ObjectFormatType
ObjectFormatType
Definition: Triple.h:231
llvm::StringSwitch::Cases
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
Definition: StringSwitch.h:88
llvm::Triple::ARMSubArch_v7
@ ARMSubArch_v7
Definition: Triple.h:121
llvm::Triple::amdil64
@ amdil64
Definition: Triple.h:91
llvm::Triple::setOS
void setOS(OSType Kind)
setOS - Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1216
llvm::ARM::getDefaultCPU
StringRef getDefaultCPU(StringRef Arch)
Definition: ARMTargetParser.cpp:543
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::Triple::WASI
@ WASI
Definition: Triple.h:200
llvm::Triple::OSType
OSType
Definition: Triple.h:164
llvm::Triple::Itanium
@ Itanium
Definition: Triple.h:224
llvm::Triple::VendorType
VendorType
Definition: Triple.h:145
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:254
llvm::Triple::ARMSubArch_v8_6a
@ ARMSubArch_v8_6a
Definition: Triple.h:110
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::Triple::getOSName
StringRef getOSName() const
getOSName - Get the operating system (third) component of the triple.
Definition: Triple.cpp:1032
llvm::Triple::ARMSubArch_v6t2
@ ARMSubArch_v6t2
Definition: Triple.h:130
llvm::Triple::MipsTechnologies
@ MipsTechnologies
Definition: Triple.h:154
llvm::Triple::getSubArch
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Definition: Triple.h:310
llvm::ARM::EndianKind::INVALID
@ INVALID
llvm::Triple::Fuchsia
@ Fuchsia
Definition: Triple.h:172
llvm::Triple::riscv32
@ riscv32
Definition: Triple.h:73
llvm::Triple::AMDPAL
@ AMDPAL
Definition: Triple.h:197
llvm::Triple::setOSName
void setOSName(StringRef Str)
setOSName - Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1251
llvm::Triple::MachO
@ MachO
Definition: Triple.h:237
llvm::Triple::Contiki
@ Contiki
Definition: Triple.h:196
llvm::Triple::Triple
Triple()
Default constructor is the same as an empty string and leaves all triple fields unknown.
Definition: Triple.h:269
llvm::Triple::getOSTypeName
static StringRef getOSTypeName(OSType Kind)
getOSTypeName - Get the canonical name for the Kind operating system.
Definition: Triple.cpp:187
llvm::Triple::isArm64e
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition: Triple.h:803
llvm::Triple::mipsel
@ mipsel
Definition: Triple.h:63
llvm::Triple::ELFIAMCU
@ ELFIAMCU
Definition: Triple.h:192
llvm::Triple::getArchTypePrefix
static StringRef getArchTypePrefix(ArchType Kind)
getArchTypePrefix - Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:86
llvm::Triple::ARMSubArch_v7em
@ ARMSubArch_v7em
Definition: Triple.h:122
llvm::Triple::shave
@ shave
Definition: Triple.h:97
llvm::Triple::AIX
@ AIX
Definition: Triple.h:187
llvm::Triple::tcele
@ tcele
Definition: Triple.h:80
StringSwitch.h
llvm::Triple::systemz
@ systemz
Definition: Triple.h:78
llvm::Triple::Myriad
@ Myriad
Definition: Triple.h:157
llvm::ARM::ISAKind::ARM
@ ARM
llvm::Triple::ARMSubArch_v8_1a
@ ARMSubArch_v8_1a
Definition: Triple.h:115
llvm::Triple::getVendorTypeName
static StringRef getVendorTypeName(VendorType Kind)
getVendorTypeName - Get the canonical name for the Kind vendor.
Definition: Triple.cpp:164
llvm::Triple::isMacCatalystEnvironment
bool isMacCatalystEnvironment() const
Definition: Triple.h:492
llvm::Triple::COFF
@ COFF
Definition: Triple.h:234
llvm::Triple::spir
@ spir
Definition: Triple.h:94
llvm::Triple::setArchName
void setArchName(StringRef Str)
setArchName - Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1236
llvm::Triple::hasEnvironment
bool hasEnvironment() const
hasEnvironment - Does this triple have the optional environment (fourth) component?
Definition: Triple.h:320
llvm::Triple::MacABI
@ MacABI
Definition: Triple.h:228
llvm::Triple::thumbeb
@ thumbeb
Definition: Triple.h:82
llvm::sys::IsLittleEndianHost
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:101
llvm::ARM::ProfileKind::M
@ M
llvm::Triple::CloudABI
@ CloudABI
Definition: Triple.h:168
llvm::Triple::getArchTypeName
static StringRef getArchTypeName(ArchType Kind)
getArchTypeName - Get the canonical name for the Kind architecture.
Definition: Triple.cpp:23
llvm::Triple::ARMSubArch_v6
@ ARMSubArch_v6
Definition: Triple.h:127
llvm::Triple::getEnvironment
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:325
llvm::Triple::EABIHF
@ EABIHF
Definition: Triple.h:216
llvm::Triple::getVendor
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
Definition: Triple.h:313
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
llvm::Triple::SUSE
@ SUSE
Definition: Triple.h:160
llvm::Triple::GNUEABIHF
@ GNUEABIHF
Definition: Triple.h:211
llvm::Triple::getBigEndianArchVariant
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1484
llvm::Triple::UnknownOS
@ UnknownOS
Definition: Triple.h:165
llvm::Triple::NoSubArch
@ NoSubArch
Definition: Triple.h:107
llvm::StringRef::size
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:157
parseVendor
static Triple::VendorType parseVendor(StringRef VendorName)
Definition: Triple.cpp:483
llvm::Triple::EABI
@ EABI
Definition: Triple.h:215
llvm::Triple::wasm64
@ wasm64
Definition: Triple.h:100
llvm::Triple::getLittleEndianArchVariant
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1541
llvm::ARM::ISAKind::AARCH64
@ AARCH64
llvm::Triple::tce
@ tce
Definition: Triple.h:79
llvm::Triple::getWatchOSVersion
void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getWatchOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1180
llvm::Triple::mips
@ mips
Definition: Triple.h:62
llvm::Triple::aarch64
@ aarch64
Definition: Triple.h:52
llvm::Triple::setObjectFormat
void setObjectFormat(ObjectFormatType Kind)
setObjectFormat - Set the object file format
Definition: Triple.cpp:1228
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1172
llvm::Triple::Apple
@ Apple
Definition: Triple.h:148
llvm::Triple::PPCSubArch_spe
@ PPCSubArch_spe
Definition: Triple.h:143
llvm::Triple::UnknownObjectFormat
@ UnknownObjectFormat
Definition: Triple.h:232
llvm::Triple::getEnvironmentName
StringRef getEnvironmentName() const
getEnvironmentName - Get the optional environment (fourth) component of the triple,...
Definition: Triple.cpp:1038