LLVM  14.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
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::ARMV9A:
657  return Triple::ARMSubArch_v9;
658  case ARM::ArchKind::ARMV9_1A:
660  case ARM::ArchKind::ARMV9_2A:
662  case ARM::ArchKind::ARMV8R:
663  return Triple::ARMSubArch_v8r;
664  case ARM::ArchKind::ARMV8MBaseline:
666  case ARM::ArchKind::ARMV8MMainline:
668  case ARM::ArchKind::ARMV8_1MMainline:
670  default:
671  return Triple::NoSubArch;
672  }
673 }
674 
676  switch (Kind) {
677  case Triple::UnknownObjectFormat: return "";
678  case Triple::COFF: return "coff";
679  case Triple::ELF: return "elf";
680  case Triple::GOFF: return "goff";
681  case Triple::MachO: return "macho";
682  case Triple::Wasm: return "wasm";
683  case Triple::XCOFF: return "xcoff";
684  }
685  llvm_unreachable("unknown object format type");
686 }
687 
689  switch (T.getArch()) {
690  case Triple::UnknownArch:
691  case Triple::aarch64:
692  case Triple::aarch64_32:
693  case Triple::arm:
694  case Triple::thumb:
695  case Triple::x86:
696  case Triple::x86_64:
697  if (T.isOSDarwin())
698  return Triple::MachO;
699  else if (T.isOSWindows())
700  return Triple::COFF;
701  return Triple::ELF;
702 
703  case Triple::aarch64_be:
704  case Triple::amdgcn:
705  case Triple::amdil64:
706  case Triple::amdil:
707  case Triple::arc:
708  case Triple::armeb:
709  case Triple::avr:
710  case Triple::bpfeb:
711  case Triple::bpfel:
712  case Triple::csky:
713  case Triple::hexagon:
714  case Triple::hsail64:
715  case Triple::hsail:
716  case Triple::kalimba:
717  case Triple::lanai:
718  case Triple::le32:
719  case Triple::le64:
720  case Triple::m68k:
721  case Triple::mips64:
722  case Triple::mips64el:
723  case Triple::mips:
724  case Triple::mipsel:
725  case Triple::msp430:
726  case Triple::nvptx64:
727  case Triple::nvptx:
728  case Triple::ppc64le:
729  case Triple::ppcle:
730  case Triple::r600:
733  case Triple::riscv32:
734  case Triple::riscv64:
735  case Triple::shave:
736  case Triple::sparc:
737  case Triple::sparcel:
738  case Triple::sparcv9:
739  case Triple::spir64:
740  case Triple::spir:
741  case Triple::tce:
742  case Triple::tcele:
743  case Triple::thumbeb:
744  case Triple::ve:
745  case Triple::xcore:
746  return Triple::ELF;
747 
748  case Triple::ppc64:
749  case Triple::ppc:
750  if (T.isOSAIX())
751  return Triple::XCOFF;
752  return Triple::ELF;
753 
754  case Triple::systemz:
755  if (T.isOSzOS())
756  return Triple::GOFF;
757  return Triple::ELF;
758 
759  case Triple::wasm32:
760  case Triple::wasm64:
761  return Triple::Wasm;
762  }
763  llvm_unreachable("unknown architecture");
764 }
765 
766 /// Construct a triple from the string representation provided.
767 ///
768 /// This stores the string representation and parses the various pieces into
769 /// enum members.
771  : Data(Str.str()), Arch(UnknownArch), SubArch(NoSubArch),
772  Vendor(UnknownVendor), OS(UnknownOS), Environment(UnknownEnvironment),
773  ObjectFormat(UnknownObjectFormat) {
774  // Do minimal parsing by hand here.
775  SmallVector<StringRef, 4> Components;
776  StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
777  if (Components.size() > 0) {
778  Arch = parseArch(Components[0]);
779  SubArch = parseSubArch(Components[0]);
780  if (Components.size() > 1) {
781  Vendor = parseVendor(Components[1]);
782  if (Components.size() > 2) {
783  OS = parseOS(Components[2]);
784  if (Components.size() > 3) {
785  Environment = parseEnvironment(Components[3]);
786  ObjectFormat = parseFormat(Components[3]);
787  }
788  }
789  } else {
790  Environment =
792  .StartsWith("mipsn32", Triple::GNUABIN32)
793  .StartsWith("mips64", Triple::GNUABI64)
794  .StartsWith("mipsisa64", Triple::GNUABI64)
795  .StartsWith("mipsisa32", Triple::GNU)
796  .Cases("mips", "mipsel", "mipsr6", "mipsr6el", Triple::GNU)
798  }
799  }
800  if (ObjectFormat == UnknownObjectFormat)
801  ObjectFormat = getDefaultFormat(*this);
802 }
803 
804 /// Construct a triple from string representations of the architecture,
805 /// vendor, and OS.
806 ///
807 /// This joins each argument into a canonical string representation and parses
808 /// them into enum members. It leaves the environment unknown and omits it from
809 /// the string representation.
810 Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
811  : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
812  Arch(parseArch(ArchStr.str())),
813  SubArch(parseSubArch(ArchStr.str())),
814  Vendor(parseVendor(VendorStr.str())),
815  OS(parseOS(OSStr.str())),
816  Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
817  ObjectFormat = getDefaultFormat(*this);
818 }
819 
820 /// Construct a triple from string representations of the architecture,
821 /// vendor, OS, and environment.
822 ///
823 /// This joins each argument into a canonical string representation and parses
824 /// them into enum members.
825 Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
826  const Twine &EnvironmentStr)
827  : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
828  EnvironmentStr).str()),
829  Arch(parseArch(ArchStr.str())),
830  SubArch(parseSubArch(ArchStr.str())),
831  Vendor(parseVendor(VendorStr.str())),
832  OS(parseOS(OSStr.str())),
833  Environment(parseEnvironment(EnvironmentStr.str())),
834  ObjectFormat(parseFormat(EnvironmentStr.str())) {
835  if (ObjectFormat == Triple::UnknownObjectFormat)
836  ObjectFormat = getDefaultFormat(*this);
837 }
838 
839 std::string Triple::normalize(StringRef Str) {
840  bool IsMinGW32 = false;
841  bool IsCygwin = false;
842 
843  // Parse into components.
844  SmallVector<StringRef, 4> Components;
845  Str.split(Components, '-');
846 
847  // If the first component corresponds to a known architecture, preferentially
848  // use it for the architecture. If the second component corresponds to a
849  // known vendor, preferentially use it for the vendor, etc. This avoids silly
850  // component movement when a component parses as (eg) both a valid arch and a
851  // valid os.
852  ArchType Arch = UnknownArch;
853  if (Components.size() > 0)
854  Arch = parseArch(Components[0]);
855  VendorType Vendor = UnknownVendor;
856  if (Components.size() > 1)
857  Vendor = parseVendor(Components[1]);
858  OSType OS = UnknownOS;
859  if (Components.size() > 2) {
860  OS = parseOS(Components[2]);
861  IsCygwin = Components[2].startswith("cygwin");
862  IsMinGW32 = Components[2].startswith("mingw");
863  }
864  EnvironmentType Environment = UnknownEnvironment;
865  if (Components.size() > 3)
866  Environment = parseEnvironment(Components[3]);
867  ObjectFormatType ObjectFormat = UnknownObjectFormat;
868  if (Components.size() > 4)
869  ObjectFormat = parseFormat(Components[4]);
870 
871  // Note which components are already in their final position. These will not
872  // be moved.
873  bool Found[4];
874  Found[0] = Arch != UnknownArch;
875  Found[1] = Vendor != UnknownVendor;
876  Found[2] = OS != UnknownOS;
877  Found[3] = Environment != UnknownEnvironment;
878 
879  // If they are not there already, permute the components into their canonical
880  // positions by seeing if they parse as a valid architecture, and if so moving
881  // the component to the architecture position etc.
882  for (unsigned Pos = 0; Pos != array_lengthof(Found); ++Pos) {
883  if (Found[Pos])
884  continue; // Already in the canonical position.
885 
886  for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
887  // Do not reparse any components that already matched.
888  if (Idx < array_lengthof(Found) && Found[Idx])
889  continue;
890 
891  // Does this component parse as valid for the target position?
892  bool Valid = false;
893  StringRef Comp = Components[Idx];
894  switch (Pos) {
895  default: llvm_unreachable("unexpected component type!");
896  case 0:
897  Arch = parseArch(Comp);
898  Valid = Arch != UnknownArch;
899  break;
900  case 1:
901  Vendor = parseVendor(Comp);
902  Valid = Vendor != UnknownVendor;
903  break;
904  case 2:
905  OS = parseOS(Comp);
906  IsCygwin = Comp.startswith("cygwin");
907  IsMinGW32 = Comp.startswith("mingw");
908  Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
909  break;
910  case 3:
911  Environment = parseEnvironment(Comp);
912  Valid = Environment != UnknownEnvironment;
913  if (!Valid) {
914  ObjectFormat = parseFormat(Comp);
915  Valid = ObjectFormat != UnknownObjectFormat;
916  }
917  break;
918  }
919  if (!Valid)
920  continue; // Nope, try the next component.
921 
922  // Move the component to the target position, pushing any non-fixed
923  // components that are in the way to the right. This tends to give
924  // good results in the common cases of a forgotten vendor component
925  // or a wrongly positioned environment.
926  if (Pos < Idx) {
927  // Insert left, pushing the existing components to the right. For
928  // example, a-b-i386 -> i386-a-b when moving i386 to the front.
929  StringRef CurrentComponent(""); // The empty component.
930  // Replace the component we are moving with an empty component.
931  std::swap(CurrentComponent, Components[Idx]);
932  // Insert the component being moved at Pos, displacing any existing
933  // components to the right.
934  for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
935  // Skip over any fixed components.
936  while (i < array_lengthof(Found) && Found[i])
937  ++i;
938  // Place the component at the new position, getting the component
939  // that was at this position - it will be moved right.
940  std::swap(CurrentComponent, Components[i]);
941  }
942  } else if (Pos > Idx) {
943  // Push right by inserting empty components until the component at Idx
944  // reaches the target position Pos. For example, pc-a -> -pc-a when
945  // moving pc to the second position.
946  do {
947  // Insert one empty component at Idx.
948  StringRef CurrentComponent(""); // The empty component.
949  for (unsigned i = Idx; i < Components.size();) {
950  // Place the component at the new position, getting the component
951  // that was at this position - it will be moved right.
952  std::swap(CurrentComponent, Components[i]);
953  // If it was placed on top of an empty component then we are done.
954  if (CurrentComponent.empty())
955  break;
956  // Advance to the next component, skipping any fixed components.
957  while (++i < array_lengthof(Found) && Found[i])
958  ;
959  }
960  // The last component was pushed off the end - append it.
961  if (!CurrentComponent.empty())
962  Components.push_back(CurrentComponent);
963 
964  // Advance Idx to the component's new position.
965  while (++Idx < array_lengthof(Found) && Found[Idx])
966  ;
967  } while (Idx < Pos); // Add more until the final position is reached.
968  }
969  assert(Pos < Components.size() && Components[Pos] == Comp &&
970  "Component moved wrong!");
971  Found[Pos] = true;
972  break;
973  }
974  }
975 
976  // Replace empty components with "unknown" value.
977  for (unsigned i = 0, e = Components.size(); i < e; ++i) {
978  if (Components[i].empty())
979  Components[i] = "unknown";
980  }
981 
982  // Special case logic goes here. At this point Arch, Vendor and OS have the
983  // correct values for the computed components.
984  std::string NormalizedEnvironment;
985  if (Environment == Triple::Android && Components[3].startswith("androideabi")) {
986  StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
987  if (AndroidVersion.empty()) {
988  Components[3] = "android";
989  } else {
990  NormalizedEnvironment = Twine("android", AndroidVersion).str();
991  Components[3] = NormalizedEnvironment;
992  }
993  }
994 
995  // SUSE uses "gnueabi" to mean "gnueabihf"
996  if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
997  Components[3] = "gnueabihf";
998 
999  if (OS == Triple::Win32) {
1000  Components.resize(4);
1001  Components[2] = "windows";
1002  if (Environment == UnknownEnvironment) {
1003  if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1004  Components[3] = "msvc";
1005  else
1006  Components[3] = getObjectFormatTypeName(ObjectFormat);
1007  }
1008  } else if (IsMinGW32) {
1009  Components.resize(4);
1010  Components[2] = "windows";
1011  Components[3] = "gnu";
1012  } else if (IsCygwin) {
1013  Components.resize(4);
1014  Components[2] = "windows";
1015  Components[3] = "cygnus";
1016  }
1017  if (IsMinGW32 || IsCygwin ||
1018  (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1019  if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1020  Components.resize(5);
1021  Components[4] = getObjectFormatTypeName(ObjectFormat);
1022  }
1023  }
1024 
1025  // Stick the corrected components back together to form the normalized string.
1026  return join(Components, "-");
1027 }
1028 
1030  return StringRef(Data).split('-').first; // Isolate first component
1031 }
1032 
1034  switch (Kind) {
1035  case Triple::mips:
1036  if (SubArch == MipsSubArch_r6)
1037  return "mipsisa32r6";
1038  break;
1039  case Triple::mipsel:
1040  if (SubArch == MipsSubArch_r6)
1041  return "mipsisa32r6el";
1042  break;
1043  case Triple::mips64:
1044  if (SubArch == MipsSubArch_r6)
1045  return "mipsisa64r6";
1046  break;
1047  case Triple::mips64el:
1048  if (SubArch == MipsSubArch_r6)
1049  return "mipsisa64r6el";
1050  break;
1051  default:
1052  break;
1053  }
1054  return getArchTypeName(Kind);
1055 }
1056 
1058  StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1059  return Tmp.split('-').first; // Isolate second component
1060 }
1061 
1063  StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1064  Tmp = Tmp.split('-').second; // Strip second component
1065  return Tmp.split('-').first; // Isolate third component
1066 }
1067 
1069  StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1070  Tmp = Tmp.split('-').second; // Strip second component
1071  return Tmp.split('-').second; // Strip third component
1072 }
1073 
1075  StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1076  return Tmp.split('-').second; // Strip second component
1077 }
1078 
1079 static unsigned EatNumber(StringRef &Str) {
1080  assert(!Str.empty() && isDigit(Str[0]) && "Not a number");
1081  unsigned Result = 0;
1082 
1083  do {
1084  // Consume the leading digit.
1085  Result = Result*10 + (Str[0] - '0');
1086 
1087  // Eat the digit.
1088  Str = Str.substr(1);
1089  } while (!Str.empty() && isDigit(Str[0]));
1090 
1091  return Result;
1092 }
1093 
1094 static void parseVersionFromName(StringRef Name, unsigned &Major,
1095  unsigned &Minor, unsigned &Micro) {
1096  // Any unset version defaults to 0.
1097  Major = Minor = Micro = 0;
1098 
1099  // Parse up to three components.
1100  unsigned *Components[3] = {&Major, &Minor, &Micro};
1101  for (unsigned i = 0; i != 3; ++i) {
1102  if (Name.empty() || Name[0] < '0' || Name[0] > '9')
1103  break;
1104 
1105  // Consume the leading number.
1106  *Components[i] = EatNumber(Name);
1107 
1108  // Consume the separator, if present.
1109  if (Name.startswith("."))
1110  Name = Name.substr(1);
1111  }
1112 }
1113 
1114 void Triple::getEnvironmentVersion(unsigned &Major, unsigned &Minor,
1115  unsigned &Micro) const {
1116  StringRef EnvironmentName = getEnvironmentName();
1117  StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1118  if (EnvironmentName.startswith(EnvironmentTypeName))
1119  EnvironmentName = EnvironmentName.substr(EnvironmentTypeName.size());
1120 
1121  parseVersionFromName(EnvironmentName, Major, Minor, Micro);
1122 }
1123 
1124 void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
1125  unsigned &Micro) const {
1126  StringRef OSName = getOSName();
1127  // Assume that the OS portion of the triple starts with the canonical name.
1128  StringRef OSTypeName = getOSTypeName(getOS());
1129  if (OSName.startswith(OSTypeName))
1130  OSName = OSName.substr(OSTypeName.size());
1131  else if (getOS() == MacOSX)
1132  OSName.consume_front("macos");
1133 
1134  parseVersionFromName(OSName, Major, Minor, Micro);
1135 }
1136 
1137 bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
1138  unsigned &Micro) const {
1139  getOSVersion(Major, Minor, Micro);
1140 
1141  switch (getOS()) {
1142  default: llvm_unreachable("unexpected OS for Darwin triple");
1143  case Darwin:
1144  // Default to darwin8, i.e., MacOSX 10.4.
1145  if (Major == 0)
1146  Major = 8;
1147  // Darwin version numbers are skewed from OS X versions.
1148  if (Major < 4)
1149  return false;
1150  if (Major <= 19) {
1151  Micro = 0;
1152  Minor = Major - 4;
1153  Major = 10;
1154  } else {
1155  Micro = 0;
1156  Minor = 0;
1157  // darwin20+ corresponds to macOS 11+.
1158  Major = 11 + Major - 20;
1159  }
1160  break;
1161  case MacOSX:
1162  // Default to 10.4.
1163  if (Major == 0) {
1164  Major = 10;
1165  Minor = 4;
1166  } else if (Major < 10)
1167  return false;
1168  break;
1169  case IOS:
1170  case TvOS:
1171  case WatchOS:
1172  // Ignore the version from the triple. This is only handled because the
1173  // the clang driver combines OS X and IOS support into a common Darwin
1174  // toolchain that wants to know the OS X version number even when targeting
1175  // IOS.
1176  Major = 10;
1177  Minor = 4;
1178  Micro = 0;
1179  break;
1180  }
1181  return true;
1182 }
1183 
1184 void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
1185  unsigned &Micro) const {
1186  switch (getOS()) {
1187  default: llvm_unreachable("unexpected OS for Darwin triple");
1188  case Darwin:
1189  case MacOSX:
1190  // Ignore the version from the triple. This is only handled because the
1191  // the clang driver combines OS X and IOS support into a common Darwin
1192  // toolchain that wants to know the iOS version number even when targeting
1193  // OS X.
1194  Major = 5;
1195  Minor = 0;
1196  Micro = 0;
1197  break;
1198  case IOS:
1199  case TvOS:
1200  getOSVersion(Major, Minor, Micro);
1201  // Default to 5.0 (or 7.0 for arm64).
1202  if (Major == 0)
1203  Major = (getArch() == aarch64) ? 7 : 5;
1204  break;
1205  case WatchOS:
1206  llvm_unreachable("conflicting triple info");
1207  }
1208 }
1209 
1210 void Triple::getWatchOSVersion(unsigned &Major, unsigned &Minor,
1211  unsigned &Micro) const {
1212  switch (getOS()) {
1213  default: llvm_unreachable("unexpected OS for Darwin triple");
1214  case Darwin:
1215  case MacOSX:
1216  // Ignore the version from the triple. This is only handled because the
1217  // the clang driver combines OS X and IOS support into a common Darwin
1218  // toolchain that wants to know the iOS version number even when targeting
1219  // OS X.
1220  Major = 2;
1221  Minor = 0;
1222  Micro = 0;
1223  break;
1224  case WatchOS:
1225  getOSVersion(Major, Minor, Micro);
1226  if (Major == 0)
1227  Major = 2;
1228  break;
1229  case IOS:
1230  llvm_unreachable("conflicting triple info");
1231  }
1232 }
1233 
1234 void Triple::setTriple(const Twine &Str) {
1235  *this = Triple(Str);
1236 }
1237 
1239  setArchName(getArchName(Kind, SubArch));
1240 }
1241 
1244 }
1245 
1248 }
1249 
1251  if (ObjectFormat == getDefaultFormat(*this))
1253 
1255  getObjectFormatTypeName(ObjectFormat)).str());
1256 }
1257 
1259  if (Environment == UnknownEnvironment)
1261 
1262  setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1264 }
1265 
1267  // Work around a miscompilation bug for Twines in gcc 4.0.3.
1269  Triple += Str;
1270  Triple += "-";
1271  Triple += getVendorName();
1272  Triple += "-";
1274  setTriple(Triple);
1275 }
1276 
1278  setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1279 }
1280 
1282  if (hasEnvironment())
1283  setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1284  "-" + getEnvironmentName());
1285  else
1286  setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1287 }
1288 
1290  setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1291  "-" + Str);
1292 }
1293 
1295  setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1296 }
1297 
1299  switch (Arch) {
1301  return 0;
1302 
1303  case llvm::Triple::avr:
1304  case llvm::Triple::msp430:
1305  return 16;
1306 
1308  case llvm::Triple::amdil:
1309  case llvm::Triple::arc:
1310  case llvm::Triple::arm:
1311  case llvm::Triple::armeb:
1312  case llvm::Triple::csky:
1313  case llvm::Triple::hexagon:
1314  case llvm::Triple::hsail:
1315  case llvm::Triple::kalimba:
1316  case llvm::Triple::lanai:
1317  case llvm::Triple::le32:
1318  case llvm::Triple::m68k:
1319  case llvm::Triple::mips:
1320  case llvm::Triple::mipsel:
1321  case llvm::Triple::nvptx:
1322  case llvm::Triple::ppc:
1323  case llvm::Triple::ppcle:
1324  case llvm::Triple::r600:
1326  case llvm::Triple::riscv32:
1327  case llvm::Triple::shave:
1328  case llvm::Triple::sparc:
1329  case llvm::Triple::sparcel:
1330  case llvm::Triple::spir:
1331  case llvm::Triple::tce:
1332  case llvm::Triple::tcele:
1333  case llvm::Triple::thumb:
1334  case llvm::Triple::thumbeb:
1335  case llvm::Triple::wasm32:
1336  case llvm::Triple::x86:
1337  case llvm::Triple::xcore:
1338  return 32;
1339 
1340  case llvm::Triple::aarch64:
1342  case llvm::Triple::amdgcn:
1343  case llvm::Triple::amdil64:
1344  case llvm::Triple::bpfeb:
1345  case llvm::Triple::bpfel:
1346  case llvm::Triple::hsail64:
1347  case llvm::Triple::le64:
1348  case llvm::Triple::mips64:
1350  case llvm::Triple::nvptx64:
1351  case llvm::Triple::ppc64:
1352  case llvm::Triple::ppc64le:
1354  case llvm::Triple::riscv64:
1355  case llvm::Triple::sparcv9:
1356  case llvm::Triple::spir64:
1357  case llvm::Triple::systemz:
1358  case llvm::Triple::ve:
1359  case llvm::Triple::wasm64:
1360  case llvm::Triple::x86_64:
1361  return 64;
1362  }
1363  llvm_unreachable("Invalid architecture value");
1364 }
1365 
1366 bool Triple::isArch64Bit() const {
1367  return getArchPointerBitWidth(getArch()) == 64;
1368 }
1369 
1370 bool Triple::isArch32Bit() const {
1371  return getArchPointerBitWidth(getArch()) == 32;
1372 }
1373 
1374 bool Triple::isArch16Bit() const {
1375  return getArchPointerBitWidth(getArch()) == 16;
1376 }
1377 
1379  Triple T(*this);
1380  switch (getArch()) {
1381  case Triple::UnknownArch:
1382  case Triple::amdgcn:
1383  case Triple::avr:
1384  case Triple::bpfeb:
1385  case Triple::bpfel:
1386  case Triple::msp430:
1387  case Triple::systemz:
1388  case Triple::ve:
1389  T.setArch(UnknownArch);
1390  break;
1391 
1392  case Triple::aarch64_32:
1393  case Triple::amdil:
1394  case Triple::arc:
1395  case Triple::arm:
1396  case Triple::armeb:
1397  case Triple::csky:
1398  case Triple::hexagon:
1399  case Triple::hsail:
1400  case Triple::kalimba:
1401  case Triple::lanai:
1402  case Triple::le32:
1403  case Triple::m68k:
1404  case Triple::mips:
1405  case Triple::mipsel:
1406  case Triple::nvptx:
1407  case Triple::ppc:
1408  case Triple::ppcle:
1409  case Triple::r600:
1411  case Triple::riscv32:
1412  case Triple::shave:
1413  case Triple::sparc:
1414  case Triple::sparcel:
1415  case Triple::spir:
1416  case Triple::tce:
1417  case Triple::tcele:
1418  case Triple::thumb:
1419  case Triple::thumbeb:
1420  case Triple::wasm32:
1421  case Triple::x86:
1422  case Triple::xcore:
1423  // Already 32-bit.
1424  break;
1425 
1426  case Triple::aarch64: T.setArch(Triple::arm); break;
1427  case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1428  case Triple::amdil64: T.setArch(Triple::amdil); break;
1429  case Triple::hsail64: T.setArch(Triple::hsail); break;
1430  case Triple::le64: T.setArch(Triple::le32); break;
1431  case Triple::mips64:
1432  T.setArch(Triple::mips, getSubArch());
1433  break;
1434  case Triple::mips64el:
1435  T.setArch(Triple::mipsel, getSubArch());
1436  break;
1437  case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1438  case Triple::ppc64: T.setArch(Triple::ppc); break;
1439  case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1440  case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1441  case Triple::riscv64: T.setArch(Triple::riscv32); break;
1442  case Triple::sparcv9: T.setArch(Triple::sparc); break;
1443  case Triple::spir64: T.setArch(Triple::spir); break;
1444  case Triple::wasm64: T.setArch(Triple::wasm32); break;
1445  case Triple::x86_64: T.setArch(Triple::x86); break;
1446  }
1447  return T;
1448 }
1449 
1451  Triple T(*this);
1452  switch (getArch()) {
1453  case Triple::UnknownArch:
1454  case Triple::arc:
1455  case Triple::avr:
1456  case Triple::csky:
1457  case Triple::hexagon:
1458  case Triple::kalimba:
1459  case Triple::lanai:
1460  case Triple::m68k:
1461  case Triple::msp430:
1462  case Triple::r600:
1463  case Triple::shave:
1464  case Triple::sparcel:
1465  case Triple::tce:
1466  case Triple::tcele:
1467  case Triple::xcore:
1468  T.setArch(UnknownArch);
1469  break;
1470 
1471  case Triple::aarch64:
1472  case Triple::aarch64_be:
1473  case Triple::amdgcn:
1474  case Triple::amdil64:
1475  case Triple::bpfeb:
1476  case Triple::bpfel:
1477  case Triple::hsail64:
1478  case Triple::le64:
1479  case Triple::mips64:
1480  case Triple::mips64el:
1481  case Triple::nvptx64:
1482  case Triple::ppc64:
1483  case Triple::ppc64le:
1485  case Triple::riscv64:
1486  case Triple::sparcv9:
1487  case Triple::spir64:
1488  case Triple::systemz:
1489  case Triple::ve:
1490  case Triple::wasm64:
1491  case Triple::x86_64:
1492  // Already 64-bit.
1493  break;
1494 
1495  case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1496  case Triple::amdil: T.setArch(Triple::amdil64); break;
1497  case Triple::arm: T.setArch(Triple::aarch64); break;
1498  case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1499  case Triple::hsail: T.setArch(Triple::hsail64); break;
1500  case Triple::le32: T.setArch(Triple::le64); break;
1501  case Triple::mips:
1502  T.setArch(Triple::mips64, getSubArch());
1503  break;
1504  case Triple::mipsel:
1505  T.setArch(Triple::mips64el, getSubArch());
1506  break;
1507  case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1508  case Triple::ppc: T.setArch(Triple::ppc64); break;
1509  case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1510  case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1511  case Triple::riscv32: T.setArch(Triple::riscv64); break;
1512  case Triple::sparc: T.setArch(Triple::sparcv9); break;
1513  case Triple::spir: T.setArch(Triple::spir64); break;
1514  case Triple::thumb: T.setArch(Triple::aarch64); break;
1515  case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1516  case Triple::wasm32: T.setArch(Triple::wasm64); break;
1517  case Triple::x86: T.setArch(Triple::x86_64); break;
1518  }
1519  return T;
1520 }
1521 
1523  Triple T(*this);
1524  // Already big endian.
1525  if (!isLittleEndian())
1526  return T;
1527  switch (getArch()) {
1528  case Triple::UnknownArch:
1529  case Triple::amdgcn:
1530  case Triple::amdil64:
1531  case Triple::amdil:
1532  case Triple::avr:
1533  case Triple::hexagon:
1534  case Triple::hsail64:
1535  case Triple::hsail:
1536  case Triple::kalimba:
1537  case Triple::le32:
1538  case Triple::le64:
1539  case Triple::msp430:
1540  case Triple::nvptx64:
1541  case Triple::nvptx:
1542  case Triple::r600:
1545  case Triple::riscv32:
1546  case Triple::riscv64:
1547  case Triple::shave:
1548  case Triple::spir64:
1549  case Triple::spir:
1550  case Triple::wasm32:
1551  case Triple::wasm64:
1552  case Triple::x86:
1553  case Triple::x86_64:
1554  case Triple::xcore:
1555  case Triple::ve:
1556  case Triple::csky:
1557 
1558  // ARM is intentionally unsupported here, changing the architecture would
1559  // drop any arch suffixes.
1560  case Triple::arm:
1561  case Triple::thumb:
1562  T.setArch(UnknownArch);
1563  break;
1564 
1565  case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1566  case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1567  case Triple::mips64el:
1568  T.setArch(Triple::mips64, getSubArch());
1569  break;
1570  case Triple::mipsel:
1571  T.setArch(Triple::mips, getSubArch());
1572  break;
1573  case Triple::ppcle: T.setArch(Triple::ppc); break;
1574  case Triple::ppc64le: T.setArch(Triple::ppc64); break;
1575  case Triple::sparcel: T.setArch(Triple::sparc); break;
1576  case Triple::tcele: T.setArch(Triple::tce); break;
1577  default:
1578  llvm_unreachable("getBigEndianArchVariant: unknown triple.");
1579  }
1580  return T;
1581 }
1582 
1584  Triple T(*this);
1585  if (isLittleEndian())
1586  return T;
1587 
1588  switch (getArch()) {
1589  case Triple::UnknownArch:
1590  case Triple::lanai:
1591  case Triple::sparcv9:
1592  case Triple::systemz:
1593  case Triple::m68k:
1594 
1595  // ARM is intentionally unsupported here, changing the architecture would
1596  // drop any arch suffixes.
1597  case Triple::armeb:
1598  case Triple::thumbeb:
1599  T.setArch(UnknownArch);
1600  break;
1601 
1602  case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
1603  case Triple::bpfeb: T.setArch(Triple::bpfel); break;
1604  case Triple::mips64:
1605  T.setArch(Triple::mips64el, getSubArch());
1606  break;
1607  case Triple::mips:
1608  T.setArch(Triple::mipsel, getSubArch());
1609  break;
1610  case Triple::ppc: T.setArch(Triple::ppcle); break;
1611  case Triple::ppc64: T.setArch(Triple::ppc64le); break;
1612  case Triple::sparc: T.setArch(Triple::sparcel); break;
1613  case Triple::tce: T.setArch(Triple::tcele); break;
1614  default:
1615  llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
1616  }
1617  return T;
1618 }
1619 
1621  switch (getArch()) {
1622  case Triple::aarch64:
1623  case Triple::aarch64_32:
1624  case Triple::amdgcn:
1625  case Triple::amdil64:
1626  case Triple::amdil:
1627  case Triple::arm:
1628  case Triple::avr:
1629  case Triple::bpfel:
1630  case Triple::csky:
1631  case Triple::hexagon:
1632  case Triple::hsail64:
1633  case Triple::hsail:
1634  case Triple::kalimba:
1635  case Triple::le32:
1636  case Triple::le64:
1637  case Triple::mips64el:
1638  case Triple::mipsel:
1639  case Triple::msp430:
1640  case Triple::nvptx64:
1641  case Triple::nvptx:
1642  case Triple::ppcle:
1643  case Triple::ppc64le:
1644  case Triple::r600:
1647  case Triple::riscv32:
1648  case Triple::riscv64:
1649  case Triple::shave:
1650  case Triple::sparcel:
1651  case Triple::spir64:
1652  case Triple::spir:
1653  case Triple::tcele:
1654  case Triple::thumb:
1655  case Triple::ve:
1656  case Triple::wasm32:
1657  case Triple::wasm64:
1658  case Triple::x86:
1659  case Triple::x86_64:
1660  case Triple::xcore:
1661  return true;
1662  default:
1663  return false;
1664  }
1665 }
1666 
1667 bool Triple::isCompatibleWith(const Triple &Other) const {
1668  // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1669  if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
1670  (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
1671  (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
1672  (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
1673  if (getVendor() == Triple::Apple)
1674  return getSubArch() == Other.getSubArch() &&
1675  getVendor() == Other.getVendor() && getOS() == Other.getOS();
1676  else
1677  return getSubArch() == Other.getSubArch() &&
1678  getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
1679  getEnvironment() == Other.getEnvironment() &&
1680  getObjectFormat() == Other.getObjectFormat();
1681  }
1682 
1683  // If vendor is apple, ignore the version number.
1684  if (getVendor() == Triple::Apple)
1685  return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
1686  getVendor() == Other.getVendor() && getOS() == Other.getOS();
1687 
1688  return *this == Other;
1689 }
1690 
1691 std::string Triple::merge(const Triple &Other) const {
1692  // If vendor is apple, pick the triple with the larger version number.
1693  if (getVendor() == Triple::Apple)
1694  if (Other.isOSVersionLT(*this))
1695  return str();
1696 
1697  return Other.str();
1698 }
1699 
1700 bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
1701  unsigned Micro) const {
1702  assert(isMacOSX() && "Not an OS X triple!");
1703 
1704  // If this is OS X, expect a sane version number.
1705  if (getOS() == Triple::MacOSX)
1706  return isOSVersionLT(Major, Minor, Micro);
1707 
1708  // Otherwise, compare to the "Darwin" number.
1709  if (Major == 10) {
1710  return isOSVersionLT(Minor + 4, Micro, 0);
1711  } else {
1712  assert(Major >= 11 && "Unexpected major version");
1713  return isOSVersionLT(Major - 11 + 20, Minor, Micro);
1714  }
1715 }
1716 
1719  return VersionTuple();
1720  switch (getOS()) {
1721  case Triple::MacOSX:
1722  // ARM64 slice is supported starting from macOS 11.0+.
1723  return VersionTuple(11, 0, 0);
1724  case Triple::IOS:
1725  // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
1726  // ARM64 simulators are supported for iOS 14+.
1728  return VersionTuple(14, 0, 0);
1729  // ARM64e slice is supported starting from iOS 14.
1730  if (isArm64e())
1731  return VersionTuple(14, 0, 0);
1732  break;
1733  case Triple::TvOS:
1734  // ARM64 simulators are supported for tvOS 14+.
1735  if (isSimulatorEnvironment())
1736  return VersionTuple(14, 0, 0);
1737  break;
1738  case Triple::WatchOS:
1739  // ARM64 simulators are supported for watchOS 7+.
1740  if (isSimulatorEnvironment())
1741  return VersionTuple(7, 0, 0);
1742  break;
1743  default:
1744  break;
1745  }
1746  return VersionTuple();
1747 }
1748 
1750  if (MArch.empty())
1751  MArch = getArchName();
1752  MArch = ARM::getCanonicalArchName(MArch);
1753 
1754  // Some defaults are forced.
1755  switch (getOS()) {
1756  case llvm::Triple::FreeBSD:
1757  case llvm::Triple::NetBSD:
1758  case llvm::Triple::OpenBSD:
1759  if (!MArch.empty() && MArch == "v6")
1760  return "arm1176jzf-s";
1761  if (!MArch.empty() && MArch == "v7")
1762  return "cortex-a8";
1763  break;
1764  case llvm::Triple::Win32:
1765  // FIXME: this is invalid for WindowsCE
1766  if (ARM::parseArchVersion(MArch) <= 7)
1767  return "cortex-a9";
1768  break;
1769  case llvm::Triple::IOS:
1770  case llvm::Triple::MacOSX:
1771  case llvm::Triple::TvOS:
1772  case llvm::Triple::WatchOS:
1773  if (MArch == "v7k")
1774  return "cortex-a7";
1775  break;
1776  default:
1777  break;
1778  }
1779 
1780  if (MArch.empty())
1781  return StringRef();
1782 
1783  StringRef CPU = ARM::getDefaultCPU(MArch);
1784  if (!CPU.empty() && !CPU.equals("invalid"))
1785  return CPU;
1786 
1787  // If no specific architecture version is requested, return the minimum CPU
1788  // required by the OS and environment.
1789  switch (getOS()) {
1790  case llvm::Triple::NetBSD:
1791  switch (getEnvironment()) {
1792  case llvm::Triple::EABI:
1793  case llvm::Triple::EABIHF:
1794  case llvm::Triple::GNUEABI:
1796  return "arm926ej-s";
1797  default:
1798  return "strongarm";
1799  }
1800  case llvm::Triple::NaCl:
1801  case llvm::Triple::OpenBSD:
1802  return "cortex-a8";
1803  default:
1804  switch (getEnvironment()) {
1805  case llvm::Triple::EABIHF:
1808  return "arm1176jzf-s";
1809  default:
1810  return "arm7tdmi";
1811  }
1812  }
1813 
1814  llvm_unreachable("invalid arch name");
1815 }
1816 
1818  const VersionTuple &Version) {
1819  switch (OSKind) {
1820  case MacOSX:
1821  // macOS 10.16 is canonicalized to macOS 11.
1822  if (Version == VersionTuple(10, 16))
1823  return VersionTuple(11, 0);
1825  default:
1826  return Version;
1827  }
1828 }
llvm::Triple::setEnvironment
void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1250
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
Comparison function for checking OS X version compatibility, which handles supporting skewed version ...
Definition: Triple.cpp:1700
llvm::Triple::setVendorName
void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1277
llvm::Triple::riscv64
@ riscv64
Definition: Triple.h:74
llvm::Triple::Wasm
@ Wasm
Definition: Triple.h:241
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:1749
llvm::Triple::spir64
@ spir64
Definition: Triple.h:95
getObjectFormatTypeName
static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind)
Definition: Triple.cpp:675
llvm::Triple::setTriple
void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition: Triple.cpp:1234
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:162
llvm::StringSwitch::StartsWith
StringSwitch & StartsWith(StringLiteral S, T Value)
Definition: StringSwitch.h:81
llvm::ARM::EndianKind::BIG
@ BIG
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::Triple::getOSVersion
void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1124
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:216
llvm::Triple::bpfeb
@ bpfeb
Definition: Triple.h:58
llvm::Triple::Lv2
@ Lv2
Definition: Triple.h:179
llvm::Triple::UnknownArch
@ UnknownArch
Definition: Triple.h:48
llvm::ARM::getCanonicalArchName
StringRef getCanonicalArchName(StringRef Arch)
Definition: ARMTargetParser.cpp:289
llvm::Triple::hsail
@ hsail
Definition: Triple.h:92
llvm::ARM::ISAKind::THUMB
@ THUMB
llvm::Triple::HermitCore
@ HermitCore
Definition: Triple.h:201
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
T
llvm::Triple::CUDA
@ CUDA
Definition: Triple.h:191
llvm::Triple::Darwin
@ Darwin
Definition: Triple.h:172
llvm::StringSwitch::Default
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
llvm::Triple::KalimbaSubArch_v3
@ KalimbaSubArch_v3
Definition: Triple.h:140
llvm::Triple::getiOSVersion
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1184
llvm::Triple::EnvironmentType
EnvironmentType
Definition: Triple.h:207
llvm::Triple::ARMSubArch_v8m_mainline
@ ARMSubArch_v8m_mainline
Definition: Triple.h:122
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:230
llvm::Triple::amdil
@ amdil
Definition: Triple.h:90
ErrorHandling.h
VersionTuple.h
llvm::Triple::MuslEABIHF
@ MuslEABIHF
Definition: Triple.h:223
llvm::Triple::kalimba
@ kalimba
Definition: Triple.h:96
llvm::Triple::getArchTypeForLLVMName
static ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
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:1378
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:176
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:96
llvm::Triple::renderscript32
@ renderscript32
Definition: Triple.h:101
llvm::ARM::ProfileKind
ProfileKind
Definition: ARMTargetParser.h:170
llvm::Triple::getOSAndEnvironmentName
StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition: Triple.cpp:1074
llvm::Triple::Minix
@ Minix
Definition: Triple.h:187
llvm::Triple::KalimbaSubArch_v5
@ KalimbaSubArch_v5
Definition: Triple.h:142
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
Parse the version number as with getOSVersion and then translate generic "darwin" versions to the cor...
Definition: Triple.cpp:1137
llvm::Triple::CSR
@ CSR
Definition: Triple.h:159
llvm::Triple::OpenBSD
@ OpenBSD
Definition: Triple.h:182
getDefaultFormat
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition: Triple.cpp:688
llvm::Triple::Ananas
@ Ananas
Definition: Triple.h:170
llvm::Triple::getMinimumSupportedOSVersion
VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition: Triple.cpp:1717
llvm::Triple::ppc
@ ppc
Definition: Triple.h:67
llvm::Triple::nvptx
@ nvptx
Definition: Triple.h:86
llvm::Triple::hexagon
@ hexagon
Definition: Triple.h:60
llvm::Triple::XCOFF
@ XCOFF
Definition: Triple.h:242
parseSubArch
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition: Triple.cpp:583
llvm::Triple::KalimbaSubArch_v4
@ KalimbaSubArch_v4
Definition: Triple.h:141
llvm::Triple::merge
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:1691
STLExtras.h
llvm::Triple::NVIDIA
@ NVIDIA
Definition: Triple.h:158
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:173
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::Triple::WatchOS
@ WatchOS
Definition: Triple.h:197
llvm::Triple::GNUEABI
@ GNUEABI
Definition: Triple.h:213
llvm::Triple::ARMSubArch_v8m_baseline
@ ARMSubArch_v8m_baseline
Definition: Triple.h:121
llvm::Triple::getCanonicalVersionForOS
static VersionTuple getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version)
Returns a canonicalized OS version number for the specified OS.
Definition: Triple.cpp:1817
llvm::Triple::setOSAndEnvironmentName
void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition: Triple.cpp:1294
llvm::Triple::isArch64Bit
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1366
llvm::Triple::GNU
@ GNU
Definition: Triple.h:210
llvm::Triple::ARMSubArch_v8_1m_mainline
@ ARMSubArch_v8_1m_mainline
Definition: Triple.h:123
llvm::Triple::ARMSubArch_v9
@ ARMSubArch_v9
Definition: Triple.h:111
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
Is this a Mac OS X triple.
Definition: Triple.h:455
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:1667
llvm::Triple::isLittleEndian
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1620
llvm::Triple::sparc
@ sparc
Definition: Triple.h:75
llvm::Triple::Musl
@ Musl
Definition: Triple.h:221
llvm::Triple::FreeBSD
@ FreeBSD
Definition: Triple.h:174
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:1450
llvm::Triple::ARMSubArch_v8_2a
@ ARMSubArch_v8_2a
Definition: Triple.h:117
llvm::Triple::ArchType
ArchType
Definition: Triple.h:47
llvm::Triple::ARMSubArch_v5
@ ARMSubArch_v5
Definition: Triple.h:134
llvm::Triple::GNUABI64
@ GNUABI64
Definition: Triple.h:212
parseEnvironment
static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName)
Definition: Triple.cpp:544
SmallString.h
llvm::Triple::TvOS
@ TvOS
Definition: Triple.h:196
llvm::Triple::str
const std::string & str() const
Definition: Triple.h:378
llvm::Triple::ARMSubArch_v8_4a
@ ARMSubArch_v8_4a
Definition: Triple.h:115
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:228
llvm::Triple::ARMSubArch_v8r
@ ARMSubArch_v8r
Definition: Triple.h:120
llvm::Triple::Mesa3D
@ Mesa3D
Definition: Triple.h:198
llvm::Triple::mips64el
@ mips64el
Definition: Triple.h:65
llvm::Triple::PC
@ PC
Definition: Triple.h:152
llvm::Triple::CODE16
@ CODE16
Definition: Triple.h:217
llvm::Triple::nvptx64
@ nvptx64
Definition: Triple.h:87
getArchPointerBitWidth
static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch)
Definition: Triple.cpp:1298
parseOS
static Triple::OSType parseOS(StringRef OSName)
Definition: Triple.cpp:503
llvm::Triple::PS4
@ PS4
Definition: Triple.h:194
llvm::Triple::OpenEmbedded
@ OpenEmbedded
Definition: Triple.h:164
llvm::Triple::le64
@ le64
Definition: Triple.h:89
llvm::Triple::Emscripten
@ Emscripten
Definition: Triple.h:204
llvm::Triple::Haiku
@ Haiku
Definition: Triple.h:186
llvm::Triple::MipsSubArch_r6
@ MipsSubArch_r6
Definition: Triple.h:144
llvm::Triple::Freescale
@ Freescale
Definition: Triple.h:154
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:189
llvm::Triple::NetBSD
@ NetBSD
Definition: Triple.h:181
llvm::Triple::xcore
@ xcore
Definition: Triple.h:85
llvm::Triple::ARMSubArch_v9_1a
@ ARMSubArch_v9_1a
Definition: Triple.h:110
llvm::Triple::setVendor
void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1242
llvm::Triple::setEnvironmentName
void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition: Triple.cpp:1289
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:184
llvm::Triple::getObjectFormat
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition: Triple.h:339
llvm::Triple::KFreeBSD
@ KFreeBSD
Definition: Triple.h:177
llvm::Triple::RTEMS
@ RTEMS
Definition: Triple.h:188
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:208
llvm::VersionTuple
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:991
llvm::Triple::getArchName
StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1029
llvm::Triple::lanai
@ lanai
Definition: Triple.h:98
llvm::Triple::MuslEABI
@ MuslEABI
Definition: Triple.h:222
llvm::ARM::parseArch
ArchKind parseArch(StringRef Arch)
Definition: ARMTargetParser.cpp:28
llvm::Triple::getEnvironmentTypeName
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition: Triple.cpp:231
llvm::Triple::getArch
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition: Triple.h:310
llvm::array_lengthof
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:1394
llvm::Triple::GOFF
@ GOFF
Definition: Triple.h:239
llvm::Triple::ARMSubArch_v8_5a
@ ARMSubArch_v8_5a
Definition: Triple.h:114
llvm::Triple::ARMSubArch_v7s
@ ARMSubArch_v7s
Definition: Triple.h:127
parseVersionFromName
static void parseVersionFromName(StringRef Name, unsigned &Major, unsigned &Minor, unsigned &Micro)
Definition: Triple.cpp:1094
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::Triple::csky
@ csky
Definition: Triple.h:59
llvm::Triple::CoreCLR
@ CoreCLR
Definition: Triple.h:229
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:132
llvm::SmallString< 64 >
llvm::ARM::parseArchEndian
EndianKind parseArchEndian(StringRef Arch)
Definition: ARMTargetParser.cpp:242
llvm::Triple::isOSVersionLT
bool isOSVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Helper function for doing comparisons against version numbers included in the target triple.
Definition: Triple.h:427
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:224
llvm::Triple::AMDHSA
@ AMDHSA
Definition: Triple.h:193
llvm::Triple::AArch64SubArch_arm64e
@ AArch64SubArch_arm64e
Definition: Triple.h:138
llvm::Triple::ppc64le
@ ppc64le
Definition: Triple.h:70
llvm::Triple::MacOSX
@ MacOSX
Definition: Triple.h:180
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:1114
llvm::Triple::ELF
@ ELF
Definition: Triple.h:238
parseArch
static Triple::ArchType parseArch(StringRef ArchName)
Definition: Triple.cpp:403
llvm::Triple::GNUX32
@ GNUX32
Definition: Triple.h:215
llvm::Triple::ARMSubArch_v7ve
@ ARMSubArch_v7ve
Definition: Triple.h:129
llvm::Triple::isArch16Bit
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1374
llvm::Triple::Android
@ Android
Definition: Triple.h:220
llvm::Triple::Hurd
@ Hurd
Definition: Triple.h:202
llvm::Triple::getOS
OSType getOS() const
Get the parsed operating system type of this triple.
Definition: Triple.h:319
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:303
EatNumber
static unsigned EatNumber(StringRef &Str)
Definition: Triple.cpp:1079
llvm::Triple::isArch32Bit
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1370
llvm::Triple::MSVC
@ MSVC
Definition: Triple.h:226
llvm::Triple::IBM
@ IBM
Definition: Triple.h:155
llvm::Triple::ARMSubArch_v7k
@ ARMSubArch_v7k
Definition: Triple.h:128
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::Triple::NVCL
@ NVCL
Definition: Triple.h:192
llvm::Triple::Linux
@ Linux
Definition: Triple.h:178
llvm::Triple::Solaris
@ Solaris
Definition: Triple.h:183
llvm::Triple::getVendorName
StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition: Triple.cpp:1057
llvm::Triple::ARMSubArch_v7m
@ ARMSubArch_v7m
Definition: Triple.h:126
StringExtras.h
llvm::Triple::ARMSubArch_v4t
@ ARMSubArch_v4t
Definition: Triple.h:136
llvm::Triple::isSimulatorEnvironment
bool isSimulatorEnvironment() const
Definition: Triple.h:489
llvm::Triple::ImaginationTechnologies
@ ImaginationTechnologies
Definition: Triple.h:156
llvm::Triple::ARMSubArch_v8
@ ARMSubArch_v8
Definition: Triple.h:119
llvm::Triple::ARMSubArch_v6m
@ ARMSubArch_v6m
Definition: Triple.h:131
llvm::Triple::setArch
void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1238
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::Triple::ZOS
@ ZOS
Definition: Triple.h:185
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:161
llvm::ARM::parseArchVersion
unsigned parseArchVersion(StringRef Arch)
Definition: ARMTargetParser.cpp:39
llvm::Triple::ARMSubArch_v5te
@ ARMSubArch_v5te
Definition: Triple.h:135
llvm::Triple::SCEI
@ SCEI
Definition: Triple.h:153
llvm::Triple::armeb
@ armeb
Definition: Triple.h:51
llvm::Triple::GNUABIN32
@ GNUABIN32
Definition: Triple.h:211
Triple.h
llvm::MSP430Attrs::ISA
ISA
Definition: MSP430Attributes.h:36
llvm::ARM::EndianKind::LITTLE
@ LITTLE
isDigit
static bool isDigit(const char C)
Definition: RustDemangle.cpp:206
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:261
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:134
llvm::Triple::ARMSubArch_v8_7a
@ ARMSubArch_v8_7a
Definition: Triple.h:112
llvm::Triple::ARMSubArch_v8_3a
@ ARMSubArch_v8_3a
Definition: Triple.h:116
llvm::Triple::thumb
@ thumb
Definition: Triple.h:81
Profile
Load MIR Sample Profile
Definition: MIRSampleProfile.cpp:62
llvm::Triple::UnknownVendor
@ UnknownVendor
Definition: Triple.h:149
llvm::Triple::ve
@ ve
Definition: Triple.h:103
LLVM_FALLTHROUGH
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:286
llvm::Triple::ObjectFormatType
ObjectFormatType
Definition: Triple.h:234
llvm::StringSwitch::Cases
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
Definition: StringSwitch.h:88
llvm::Triple::ARMSubArch_v7
@ ARMSubArch_v7
Definition: Triple.h:124
llvm::Triple::amdil64
@ amdil64
Definition: Triple.h:91
llvm::Triple::setOS
void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1246
llvm::ARM::getDefaultCPU
StringRef getDefaultCPU(StringRef Arch)
Definition: ARMTargetParser.cpp:553
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:203
llvm::Triple::OSType
OSType
Definition: Triple.h:167
llvm::Triple::Itanium
@ Itanium
Definition: Triple.h:227
llvm::Triple::VendorType
VendorType
Definition: Triple.h:148
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:113
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::Triple::getOSName
StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition: Triple.cpp:1062
llvm::Triple::ARMSubArch_v6t2
@ ARMSubArch_v6t2
Definition: Triple.h:133
llvm::Triple::MipsTechnologies
@ MipsTechnologies
Definition: Triple.h:157
llvm::Triple::getSubArch
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition: Triple.h:313
llvm::ARM::EndianKind::INVALID
@ INVALID
llvm::Triple::Fuchsia
@ Fuchsia
Definition: Triple.h:175
llvm::Triple::riscv32
@ riscv32
Definition: Triple.h:73
llvm::Triple::AMDPAL
@ AMDPAL
Definition: Triple.h:200
llvm::Triple::setOSName
void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1281
llvm::Triple::MachO
@ MachO
Definition: Triple.h:240
llvm::Triple::Contiki
@ Contiki
Definition: Triple.h:199
llvm::Triple::Triple
Triple()
Default constructor is the same as an empty string and leaves all triple fields unknown.
Definition: Triple.h:272
llvm::Triple::getOSTypeName
static StringRef getOSTypeName(OSType Kind)
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:804
llvm::Triple::mipsel
@ mipsel
Definition: Triple.h:63
llvm::Triple::ELFIAMCU
@ ELFIAMCU
Definition: Triple.h:195
llvm::Triple::getArchTypePrefix
static StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:86
llvm::Triple::ARMSubArch_v7em
@ ARMSubArch_v7em
Definition: Triple.h:125
llvm::Triple::shave
@ shave
Definition: Triple.h:97
llvm::Triple::AIX
@ AIX
Definition: Triple.h:190
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:160
llvm::ARM::ISAKind::ARM
@ ARM
llvm::Triple::ARMSubArch_v8_1a
@ ARMSubArch_v8_1a
Definition: Triple.h:118
llvm::Triple::getVendorTypeName
static StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition: Triple.cpp:164
llvm::Triple::isMacCatalystEnvironment
bool isMacCatalystEnvironment() const
Definition: Triple.h:493
llvm::Triple::COFF
@ COFF
Definition: Triple.h:237
llvm::Triple::spir
@ spir
Definition: Triple.h:94
llvm::Triple::setArchName
void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1266
llvm::Triple::hasEnvironment
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition: Triple.h:322
llvm::Triple::MacABI
@ MacABI
Definition: Triple.h:231
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:171
llvm::Triple::getArchTypeName
static StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition: Triple.cpp:23
llvm::Triple::ARMSubArch_v6
@ ARMSubArch_v6
Definition: Triple.h:130
llvm::Triple::getEnvironment
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition: Triple.h:327
llvm::Triple::EABIHF
@ EABIHF
Definition: Triple.h:219
llvm::Triple::getVendor
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition: Triple.h:316
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
llvm::Triple::SUSE
@ SUSE
Definition: Triple.h:163
llvm::Triple::GNUEABIHF
@ GNUEABIHF
Definition: Triple.h:214
llvm::Triple::getBigEndianArchVariant
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1522
llvm::Triple::UnknownOS
@ UnknownOS
Definition: Triple.h:168
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:218
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:1583
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
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1210
llvm::Triple::ARMSubArch_v9_2a
@ ARMSubArch_v9_2a
Definition: Triple.h:109
llvm::Triple::mips
@ mips
Definition: Triple.h:62
llvm::Triple::aarch64
@ aarch64
Definition: Triple.h:52
llvm::Triple::setObjectFormat
void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition: Triple.cpp:1258
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1184
llvm::Triple::Apple
@ Apple
Definition: Triple.h:151
llvm::Triple::PPCSubArch_spe
@ PPCSubArch_spe
Definition: Triple.h:146
llvm::Triple::UnknownObjectFormat
@ UnknownObjectFormat
Definition: Triple.h:235
llvm::Triple::getEnvironmentName
StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:1068