LLVM 22.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
10#include "llvm/ADT/DenseMap.h"
20#include <cassert>
21#include <cstring>
22using namespace llvm;
23
25 switch (Kind) {
26 case UnknownArch: return "unknown";
27
28 case aarch64: return "aarch64";
29 case aarch64_32: return "aarch64_32";
30 case aarch64_be: return "aarch64_be";
31 case amdgcn: return "amdgcn";
32 case amdil64: return "amdil64";
33 case amdil: return "amdil";
34 case arc: return "arc";
35 case arm: return "arm";
36 case armeb: return "armeb";
37 case avr: return "avr";
38 case bpfeb: return "bpfeb";
39 case bpfel: return "bpfel";
40 case csky: return "csky";
41 case dxil: return "dxil";
42 case hexagon: return "hexagon";
43 case hsail64: return "hsail64";
44 case hsail: return "hsail";
45 case kalimba: return "kalimba";
46 case lanai: return "lanai";
47 case loongarch32: return "loongarch32";
48 case loongarch64: return "loongarch64";
49 case m68k: return "m68k";
50 case mips64: return "mips64";
51 case mips64el: return "mips64el";
52 case mips: return "mips";
53 case mipsel: return "mipsel";
54 case msp430: return "msp430";
55 case nvptx64: return "nvptx64";
56 case nvptx: return "nvptx";
57 case ppc64: return "powerpc64";
58 case ppc64le: return "powerpc64le";
59 case ppc: return "powerpc";
60 case ppcle: return "powerpcle";
61 case r600: return "r600";
62 case renderscript32: return "renderscript32";
63 case renderscript64: return "renderscript64";
64 case riscv32: return "riscv32";
65 case riscv64: return "riscv64";
66 case riscv32be:
67 return "riscv32be";
68 case riscv64be:
69 return "riscv64be";
70 case shave: return "shave";
71 case sparc: return "sparc";
72 case sparcel: return "sparcel";
73 case sparcv9: return "sparcv9";
74 case spir64: return "spir64";
75 case spir: return "spir";
76 case spirv: return "spirv";
77 case spirv32: return "spirv32";
78 case spirv64: return "spirv64";
79 case systemz: return "s390x";
80 case tce: return "tce";
81 case tcele: return "tcele";
82 case thumb: return "thumb";
83 case thumbeb: return "thumbeb";
84 case ve: return "ve";
85 case wasm32: return "wasm32";
86 case wasm64: return "wasm64";
87 case x86: return "i386";
88 case x86_64: return "x86_64";
89 case xcore: return "xcore";
90 case xtensa: return "xtensa";
91 }
92
93 llvm_unreachable("Invalid ArchType!");
94}
95
97 switch (Kind) {
98 case Triple::mips:
99 if (SubArch == MipsSubArch_r6)
100 return "mipsisa32r6";
101 break;
102 case Triple::mipsel:
103 if (SubArch == MipsSubArch_r6)
104 return "mipsisa32r6el";
105 break;
106 case Triple::mips64:
107 if (SubArch == MipsSubArch_r6)
108 return "mipsisa64r6";
109 break;
110 case Triple::mips64el:
111 if (SubArch == MipsSubArch_r6)
112 return "mipsisa64r6el";
113 break;
114 case Triple::aarch64:
115 if (SubArch == AArch64SubArch_arm64ec)
116 return "arm64ec";
117 if (SubArch == AArch64SubArch_arm64e)
118 return "arm64e";
119 if (SubArch == AArch64SubArch_lfi)
120 return "aarch64_lfi";
121 break;
122 case Triple::spirv:
123 switch (SubArch) {
125 return "spirv1.0";
127 return "spirv1.1";
129 return "spirv1.2";
131 return "spirv1.3";
133 return "spirv1.4";
135 return "spirv1.5";
137 return "spirv1.6";
138 default:
139 break;
140 }
141 break;
142 case Triple::dxil:
143 switch (SubArch) {
146 return "dxilv1.0";
148 return "dxilv1.1";
150 return "dxilv1.2";
152 return "dxilv1.3";
154 return "dxilv1.4";
156 return "dxilv1.5";
158 return "dxilv1.6";
160 return "dxilv1.7";
162 return "dxilv1.8";
164 return "dxilv1.9";
165 default:
166 break;
167 }
168 break;
169 default:
170 break;
171 }
172 return getArchTypeName(Kind);
173}
174
176 switch (Kind) {
177 default:
178 return StringRef();
179
180 case aarch64:
181 case aarch64_be:
182 case aarch64_32: return "aarch64";
183
184 case arc: return "arc";
185
186 case arm:
187 case armeb:
188 case thumb:
189 case thumbeb: return "arm";
190
191 case avr: return "avr";
192
193 case ppc64:
194 case ppc64le:
195 case ppc:
196 case ppcle: return "ppc";
197
198 case m68k: return "m68k";
199
200 case mips:
201 case mipsel:
202 case mips64:
203 case mips64el: return "mips";
204
205 case hexagon: return "hexagon";
206
207 case amdgcn: return "amdgcn";
208 case r600: return "r600";
209
210 case bpfel:
211 case bpfeb: return "bpf";
212
213 case sparcv9:
214 case sparcel:
215 case sparc: return "sparc";
216
217 case systemz: return "s390";
218
219 case x86:
220 case x86_64: return "x86";
221
222 case xcore: return "xcore";
223
224 // NVPTX intrinsics are namespaced under nvvm.
225 case nvptx: return "nvvm";
226 case nvptx64: return "nvvm";
227
228 case amdil:
229 case amdil64: return "amdil";
230
231 case hsail:
232 case hsail64: return "hsail";
233
234 case spir:
235 case spir64: return "spir";
236
237 case spirv:
238 case spirv32:
239 case spirv64: return "spv";
240
241 case kalimba: return "kalimba";
242 case lanai: return "lanai";
243 case shave: return "shave";
244 case wasm32:
245 case wasm64: return "wasm";
246
247 case riscv32:
248 case riscv64:
249 case riscv32be:
250 case riscv64be:
251 return "riscv";
252
253 case ve: return "ve";
254 case csky: return "csky";
255
256 case loongarch32:
257 case loongarch64: return "loongarch";
258
259 case dxil: return "dx";
260
261 case xtensa: return "xtensa";
262 }
263}
264
266 switch (Kind) {
267 case UnknownVendor: return "unknown";
268
269 case AMD: return "amd";
270 case Apple: return "apple";
271 case CSR: return "csr";
272 case Freescale: return "fsl";
273 case IBM: return "ibm";
274 case ImaginationTechnologies: return "img";
275 case Intel:
276 return "intel";
277 case Mesa: return "mesa";
278 case MipsTechnologies: return "mti";
279 case NVIDIA: return "nvidia";
280 case OpenEmbedded: return "oe";
281 case PC: return "pc";
282 case SCEI: return "scei";
283 case SUSE: return "suse";
284 case Meta:
285 return "meta";
286 }
287
288 llvm_unreachable("Invalid VendorType!");
289}
290
292 switch (Kind) {
293 case UnknownOS: return "unknown";
294
295 case AIX: return "aix";
296 case AMDHSA: return "amdhsa";
297 case AMDPAL: return "amdpal";
298 case BridgeOS: return "bridgeos";
299 case CUDA: return "cuda";
300 case Darwin: return "darwin";
301 case DragonFly: return "dragonfly";
302 case DriverKit: return "driverkit";
303 case ELFIAMCU: return "elfiamcu";
304 case Emscripten: return "emscripten";
305 case FreeBSD: return "freebsd";
306 case Fuchsia: return "fuchsia";
307 case Haiku: return "haiku";
308 case HermitCore: return "hermit";
309 case Hurd: return "hurd";
310 case IOS: return "ios";
311 case KFreeBSD: return "kfreebsd";
312 case Linux: return "linux";
313 case Lv2: return "lv2";
314 case MacOSX: return "macosx";
315 case Managarm:
316 return "managarm";
317 case Mesa3D: return "mesa3d";
318 case NVCL: return "nvcl";
319 case NetBSD: return "netbsd";
320 case OpenBSD: return "openbsd";
321 case PS4: return "ps4";
322 case PS5: return "ps5";
323 case RTEMS: return "rtems";
324 case Solaris: return "solaris";
325 case Serenity: return "serenity";
326 case TvOS: return "tvos";
327 case UEFI: return "uefi";
328 case WASI: return "wasi";
329 case WatchOS: return "watchos";
330 case Win32: return "windows";
331 case ZOS: return "zos";
332 case ShaderModel: return "shadermodel";
333 case LiteOS: return "liteos";
334 case XROS: return "xros";
335 case Vulkan: return "vulkan";
336 case CheriotRTOS:
337 return "cheriotrtos";
338 }
339
340 llvm_unreachable("Invalid OSType");
341}
342
344 switch (Kind) {
345 case UnknownEnvironment: return "unknown";
346 case Android: return "android";
347 case CODE16: return "code16";
348 case CoreCLR: return "coreclr";
349 case Cygnus: return "cygnus";
350 case EABI: return "eabi";
351 case EABIHF: return "eabihf";
352 case GNU: return "gnu";
353 case GNUT64: return "gnut64";
354 case GNUABI64: return "gnuabi64";
355 case GNUABIN32: return "gnuabin32";
356 case GNUEABI: return "gnueabi";
357 case GNUEABIT64: return "gnueabit64";
358 case GNUEABIHF: return "gnueabihf";
359 case GNUEABIHFT64: return "gnueabihft64";
360 case GNUF32: return "gnuf32";
361 case GNUF64: return "gnuf64";
362 case GNUSF: return "gnusf";
363 case GNUX32: return "gnux32";
364 case GNUILP32: return "gnu_ilp32";
365 case Itanium: return "itanium";
366 case MSVC: return "msvc";
367 case MacABI: return "macabi";
368 case Musl: return "musl";
369 case MuslABIN32:
370 return "muslabin32";
371 case MuslABI64:
372 return "muslabi64";
373 case MuslEABI: return "musleabi";
374 case MuslEABIHF: return "musleabihf";
375 case MuslF32:
376 return "muslf32";
377 case MuslSF:
378 return "muslsf";
379 case MuslX32: return "muslx32";
380 case MuslWALI:
381 return "muslwali";
382 case Simulator: return "simulator";
383 case Pixel: return "pixel";
384 case Vertex: return "vertex";
385 case Geometry: return "geometry";
386 case Hull: return "hull";
387 case Domain: return "domain";
388 case Compute: return "compute";
389 case Library: return "library";
390 case RayGeneration: return "raygeneration";
391 case Intersection: return "intersection";
392 case AnyHit: return "anyhit";
393 case ClosestHit: return "closesthit";
394 case Miss: return "miss";
395 case Callable: return "callable";
396 case Mesh: return "mesh";
397 case Amplification: return "amplification";
398 case RootSignature:
399 return "rootsignature";
400 case OpenCL:
401 return "opencl";
402 case OpenHOS: return "ohos";
403 case PAuthTest:
404 return "pauthtest";
405 case MTIA:
406 return "mtia";
407 case LLVM:
408 return "llvm";
409 case Mlibc:
410 return "mlibc";
411 }
412
413 llvm_unreachable("Invalid EnvironmentType!");
414}
415
417 switch (Kind) {
418 case UnknownObjectFormat: return "";
419 case COFF: return "coff";
420 case ELF: return "elf";
421 case GOFF: return "goff";
422 case MachO: return "macho";
423 case Wasm: return "wasm";
424 case XCOFF: return "xcoff";
425 case DXContainer: return "dxcontainer";
426 case SPIRV: return "spirv";
427 }
428 llvm_unreachable("unknown object format type");
429}
430
432 if (ArchName == "bpf") {
434 return Triple::bpfel;
435 else
436 return Triple::bpfeb;
437 } else if (ArchName == "bpf_be" || ArchName == "bpfeb") {
438 return Triple::bpfeb;
439 } else if (ArchName == "bpf_le" || ArchName == "bpfel") {
440 return Triple::bpfel;
441 } else {
442 return Triple::UnknownArch;
443 }
444}
445
447 Triple::ArchType BPFArch(parseBPFArch(Name));
449 .Case("aarch64", aarch64)
450 .Case("aarch64_be", aarch64_be)
451 .Case("aarch64_32", aarch64_32)
452 .Case("arc", arc)
453 .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
454 .Case("arm64_32", aarch64_32)
455 .Case("arm", arm)
456 .Case("armeb", armeb)
457 .Case("avr", avr)
458 .StartsWith("bpf", BPFArch)
459 .Case("m68k", m68k)
460 .Case("mips", mips)
461 .Case("mipsel", mipsel)
462 .Case("mips64", mips64)
463 .Case("mips64el", mips64el)
464 .Case("msp430", msp430)
465 .Case("ppc64", ppc64)
466 .Case("ppc32", ppc)
467 .Case("ppc", ppc)
468 .Case("ppc32le", ppcle)
469 .Case("ppcle", ppcle)
470 .Case("ppc64le", ppc64le)
471 .Case("r600", r600)
472 .Case("amdgcn", amdgcn)
473 .Case("riscv32", riscv32)
474 .Case("riscv64", riscv64)
475 .Case("riscv32be", riscv32be)
476 .Case("riscv64be", riscv64be)
477 .Case("hexagon", hexagon)
478 .Case("sparc", sparc)
479 .Case("sparcel", sparcel)
480 .Case("sparcv9", sparcv9)
481 .Case("s390x", systemz)
482 .Case("systemz", systemz)
483 .Case("tce", tce)
484 .Case("tcele", tcele)
485 .Case("thumb", thumb)
486 .Case("thumbeb", thumbeb)
487 .Case("x86", x86)
488 .Case("i386", x86)
489 .Case("x86-64", x86_64)
490 .Case("xcore", xcore)
491 .Case("nvptx", nvptx)
492 .Case("nvptx64", nvptx64)
493 .Case("amdil", amdil)
494 .Case("amdil64", amdil64)
495 .Case("hsail", hsail)
496 .Case("hsail64", hsail64)
497 .Case("spir", spir)
498 .Case("spir64", spir64)
499 .Case("spirv", spirv)
500 .Case("spirv32", spirv32)
501 .Case("spirv64", spirv64)
502 .Case("kalimba", kalimba)
503 .Case("lanai", lanai)
504 .Case("shave", shave)
505 .Case("wasm32", wasm32)
506 .Case("wasm64", wasm64)
507 .Case("renderscript32", renderscript32)
508 .Case("renderscript64", renderscript64)
509 .Case("ve", ve)
510 .Case("csky", csky)
511 .Case("loongarch32", loongarch32)
512 .Case("loongarch64", loongarch64)
513 .Case("dxil", dxil)
514 .Case("xtensa", xtensa)
516}
517
519 ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
520 ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
521
523 switch (ENDIAN) {
525 switch (ISA) {
527 arch = Triple::arm;
528 break;
530 arch = Triple::thumb;
531 break;
533 arch = Triple::aarch64;
534 break;
536 break;
537 }
538 break;
539 }
541 switch (ISA) {
543 arch = Triple::armeb;
544 break;
546 arch = Triple::thumbeb;
547 break;
549 arch = Triple::aarch64_be;
550 break;
552 break;
553 }
554 break;
555 }
557 break;
558 }
559 }
560
561 ArchName = ARM::getCanonicalArchName(ArchName);
562 if (ArchName.empty())
563 return Triple::UnknownArch;
564
565 // Thumb only exists in v4+
566 if (ISA == ARM::ISAKind::THUMB &&
567 (ArchName.starts_with("v2") || ArchName.starts_with("v3")))
568 return Triple::UnknownArch;
569
570 // Thumb only for v6m
572 unsigned Version = ARM::parseArchVersion(ArchName);
573 if (Profile == ARM::ProfileKind::M && Version == 6) {
574 if (ENDIAN == ARM::EndianKind::BIG)
575 return Triple::thumbeb;
576 else
577 return Triple::thumb;
578 }
579
580 return arch;
581}
582
584 auto AT =
586 .Cases({"i386", "i486", "i586", "i686"}, Triple::x86)
587 // FIXME: Do we need to support these?
588 .Cases({"i786", "i886", "i986"}, Triple::x86)
589 .Cases({"amd64", "x86_64", "x86_64h"}, Triple::x86_64)
590 .Cases({"powerpc", "powerpcspe", "ppc", "ppc32"}, Triple::ppc)
591 .Cases({"powerpcle", "ppcle", "ppc32le"}, Triple::ppcle)
592 .Cases({"powerpc64", "ppu", "ppc64"}, Triple::ppc64)
593 .Cases({"powerpc64le", "ppc64le"}, Triple::ppc64le)
594 .Case("xscale", Triple::arm)
595 .Case("xscaleeb", Triple::armeb)
596 .Case("aarch64", Triple::aarch64)
597 .Case("aarch64_be", Triple::aarch64_be)
598 .Case("aarch64_32", Triple::aarch64_32)
599 .Case("aarch64_lfi", Triple::aarch64)
600 .Case("arc", Triple::arc)
601 .Case("arm64", Triple::aarch64)
602 .Case("arm64_32", Triple::aarch64_32)
603 .Case("arm64e", Triple::aarch64)
604 .Case("arm64ec", Triple::aarch64)
605 .Case("arm", Triple::arm)
606 .Case("armeb", Triple::armeb)
607 .Case("thumb", Triple::thumb)
608 .Case("thumbeb", Triple::thumbeb)
609 .Case("avr", Triple::avr)
610 .Case("m68k", Triple::m68k)
611 .Case("msp430", Triple::msp430)
612 .Cases({"mips", "mipseb", "mipsallegrex", "mipsisa32r6", "mipsr6"},
614 .Cases({"mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el"},
616 .Cases({"mips64", "mips64eb", "mipsn32", "mipsisa64r6", "mips64r6",
617 "mipsn32r6"},
619 .Cases({"mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
620 "mipsn32r6el"},
622 .Case("r600", Triple::r600)
623 .Case("amdgcn", Triple::amdgcn)
624 .Case("riscv32", Triple::riscv32)
625 .Case("riscv64", Triple::riscv64)
626 .Case("riscv32be", Triple::riscv32be)
627 .Case("riscv64be", Triple::riscv64be)
628 .Case("hexagon", Triple::hexagon)
629 .Cases({"s390x", "systemz"}, Triple::systemz)
630 .Case("sparc", Triple::sparc)
631 .Case("sparcel", Triple::sparcel)
632 .Cases({"sparcv9", "sparc64"}, Triple::sparcv9)
633 .Case("tce", Triple::tce)
634 .Case("tcele", Triple::tcele)
635 .Case("xcore", Triple::xcore)
636 .Case("nvptx", Triple::nvptx)
637 .Case("nvptx64", Triple::nvptx64)
638 .Case("amdil", Triple::amdil)
639 .Case("amdil64", Triple::amdil64)
640 .Case("hsail", Triple::hsail)
641 .Case("hsail64", Triple::hsail64)
642 .Case("spir", Triple::spir)
643 .Case("spir64", Triple::spir64)
644 .Cases({"spirv", "spirv1.5", "spirv1.6"}, Triple::spirv)
645 .Cases({"spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
646 "spirv32v1.3", "spirv32v1.4", "spirv32v1.5", "spirv32v1.6"},
648 .Cases({"spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
649 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5", "spirv64v1.6"},
651 .StartsWith("kalimba", Triple::kalimba)
652 .Case("lanai", Triple::lanai)
653 .Case("renderscript32", Triple::renderscript32)
654 .Case("renderscript64", Triple::renderscript64)
655 .Case("shave", Triple::shave)
656 .Case("ve", Triple::ve)
657 .Case("wasm32", Triple::wasm32)
658 .Case("wasm64", Triple::wasm64)
659 .Case("csky", Triple::csky)
660 .Case("loongarch32", Triple::loongarch32)
661 .Case("loongarch64", Triple::loongarch64)
662 .Cases({"dxil", "dxilv1.0", "dxilv1.1", "dxilv1.2", "dxilv1.3",
663 "dxilv1.4", "dxilv1.5", "dxilv1.6", "dxilv1.7", "dxilv1.8",
664 "dxilv1.9"},
666 .Case("xtensa", Triple::xtensa)
668
669 // Some architectures require special parsing logic just to compute the
670 // ArchType result.
671 if (AT == Triple::UnknownArch) {
672 if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
673 ArchName.starts_with("aarch64"))
674 return parseARMArch(ArchName);
675 if (ArchName.starts_with("bpf"))
676 return parseBPFArch(ArchName);
677 }
678
679 return AT;
680}
681
683 return StringSwitch<Triple::VendorType>(VendorName)
684 .Case("apple", Triple::Apple)
685 .Case("pc", Triple::PC)
686 .Case("scei", Triple::SCEI)
687 .Case("sie", Triple::SCEI)
688 .Case("fsl", Triple::Freescale)
689 .Case("ibm", Triple::IBM)
692 .Case("nvidia", Triple::NVIDIA)
693 .Case("csr", Triple::CSR)
694 .Case("amd", Triple::AMD)
695 .Case("mesa", Triple::Mesa)
696 .Case("suse", Triple::SUSE)
698 .Case("intel", Triple::Intel)
699 .Case("meta", Triple::Meta)
701}
702
704 return StringSwitch<Triple::OSType>(OSName)
705 .StartsWith("darwin", Triple::Darwin)
706 .StartsWith("dragonfly", Triple::DragonFly)
707 .StartsWith("freebsd", Triple::FreeBSD)
708 .StartsWith("fuchsia", Triple::Fuchsia)
709 .StartsWith("ios", Triple::IOS)
710 .StartsWith("kfreebsd", Triple::KFreeBSD)
711 .StartsWith("linux", Triple::Linux)
712 .StartsWith("lv2", Triple::Lv2)
713 .StartsWith("macos", Triple::MacOSX)
714 .StartsWith("managarm", Triple::Managarm)
715 .StartsWith("netbsd", Triple::NetBSD)
716 .StartsWith("openbsd", Triple::OpenBSD)
717 .StartsWith("solaris", Triple::Solaris)
718 .StartsWith("uefi", Triple::UEFI)
719 .StartsWith("win32", Triple::Win32)
720 .StartsWith("windows", Triple::Win32)
721 .StartsWith("zos", Triple::ZOS)
722 .StartsWith("haiku", Triple::Haiku)
723 .StartsWith("rtems", Triple::RTEMS)
724 .StartsWith("aix", Triple::AIX)
725 .StartsWith("cuda", Triple::CUDA)
726 .StartsWith("nvcl", Triple::NVCL)
727 .StartsWith("amdhsa", Triple::AMDHSA)
728 .StartsWith("ps4", Triple::PS4)
729 .StartsWith("ps5", Triple::PS5)
730 .StartsWith("elfiamcu", Triple::ELFIAMCU)
731 .StartsWith("tvos", Triple::TvOS)
732 .StartsWith("watchos", Triple::WatchOS)
733 .StartsWith("bridgeos", Triple::BridgeOS)
734 .StartsWith("driverkit", Triple::DriverKit)
735 .StartsWith("xros", Triple::XROS)
736 .StartsWith("visionos", Triple::XROS)
737 .StartsWith("mesa3d", Triple::Mesa3D)
738 .StartsWith("amdpal", Triple::AMDPAL)
740 .StartsWith("hurd", Triple::Hurd)
741 .StartsWith("wasi", Triple::WASI)
742 .StartsWith("emscripten", Triple::Emscripten)
743 .StartsWith("shadermodel", Triple::ShaderModel)
744 .StartsWith("liteos", Triple::LiteOS)
745 .StartsWith("serenity", Triple::Serenity)
746 .StartsWith("vulkan", Triple::Vulkan)
747 .StartsWith("cheriotrtos", Triple::CheriotRTOS)
749}
750
752 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
753 .StartsWith("eabihf", Triple::EABIHF)
754 .StartsWith("eabi", Triple::EABI)
755 .StartsWith("gnuabin32", Triple::GNUABIN32)
756 .StartsWith("gnuabi64", Triple::GNUABI64)
757 .StartsWith("gnueabihft64", Triple::GNUEABIHFT64)
758 .StartsWith("gnueabihf", Triple::GNUEABIHF)
759 .StartsWith("gnueabit64", Triple::GNUEABIT64)
760 .StartsWith("gnueabi", Triple::GNUEABI)
761 .StartsWith("gnuf32", Triple::GNUF32)
762 .StartsWith("gnuf64", Triple::GNUF64)
763 .StartsWith("gnusf", Triple::GNUSF)
764 .StartsWith("gnux32", Triple::GNUX32)
765 .StartsWith("gnu_ilp32", Triple::GNUILP32)
766 .StartsWith("code16", Triple::CODE16)
767 .StartsWith("gnut64", Triple::GNUT64)
768 .StartsWith("gnu", Triple::GNU)
769 .StartsWith("android", Triple::Android)
770 .StartsWith("muslabin32", Triple::MuslABIN32)
771 .StartsWith("muslabi64", Triple::MuslABI64)
772 .StartsWith("musleabihf", Triple::MuslEABIHF)
773 .StartsWith("musleabi", Triple::MuslEABI)
774 .StartsWith("muslf32", Triple::MuslF32)
775 .StartsWith("muslsf", Triple::MuslSF)
776 .StartsWith("muslx32", Triple::MuslX32)
777 .StartsWith("muslwali", Triple::MuslWALI)
778 .StartsWith("musl", Triple::Musl)
779 .StartsWith("msvc", Triple::MSVC)
780 .StartsWith("itanium", Triple::Itanium)
781 .StartsWith("cygnus", Triple::Cygnus)
782 .StartsWith("coreclr", Triple::CoreCLR)
783 .StartsWith("simulator", Triple::Simulator)
784 .StartsWith("macabi", Triple::MacABI)
785 .StartsWith("pixel", Triple::Pixel)
786 .StartsWith("vertex", Triple::Vertex)
787 .StartsWith("geometry", Triple::Geometry)
788 .StartsWith("hull", Triple::Hull)
789 .StartsWith("domain", Triple::Domain)
790 .StartsWith("compute", Triple::Compute)
791 .StartsWith("library", Triple::Library)
792 .StartsWith("raygeneration", Triple::RayGeneration)
793 .StartsWith("intersection", Triple::Intersection)
794 .StartsWith("anyhit", Triple::AnyHit)
795 .StartsWith("closesthit", Triple::ClosestHit)
796 .StartsWith("miss", Triple::Miss)
797 .StartsWith("callable", Triple::Callable)
798 .StartsWith("mesh", Triple::Mesh)
799 .StartsWith("amplification", Triple::Amplification)
800 .StartsWith("rootsignature", Triple::RootSignature)
801 .StartsWith("opencl", Triple::OpenCL)
803 .StartsWith("pauthtest", Triple::PAuthTest)
804 .StartsWith("llvm", Triple::LLVM)
805 .StartsWith("mlibc", Triple::Mlibc)
806 .StartsWith("mtia", Triple::MTIA)
808}
809
811 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
812 // "xcoff" must come before "coff" because of the order-dependendent
813 // pattern matching.
814 .EndsWith("xcoff", Triple::XCOFF)
815 .EndsWith("coff", Triple::COFF)
816 .EndsWith("elf", Triple::ELF)
817 .EndsWith("goff", Triple::GOFF)
818 .EndsWith("macho", Triple::MachO)
819 .EndsWith("wasm", Triple::Wasm)
820 .EndsWith("spirv", Triple::SPIRV)
822}
823
825 if (SubArchName.starts_with("mips") &&
826 (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
828
829 if (SubArchName == "powerpcspe")
831
832 if (SubArchName == "arm64e")
834
835 if (SubArchName == "arm64ec")
837
838 if (SubArchName == "aarch64_lfi")
840
841 if (SubArchName.starts_with("spirv"))
842 return StringSwitch<Triple::SubArchType>(SubArchName)
851
852 if (SubArchName.starts_with("dxil"))
853 return StringSwitch<Triple::SubArchType>(SubArchName)
865
866 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
867
868 // For now, this is the small part. Early return.
869 if (ARMSubArch.empty())
870 return StringSwitch<Triple::SubArchType>(SubArchName)
875
876 // ARM sub arch.
877 switch(ARM::parseArch(ARMSubArch)) {
878 case ARM::ArchKind::ARMV4:
879 return Triple::NoSubArch;
880 case ARM::ArchKind::ARMV4T:
882 case ARM::ArchKind::ARMV5T:
884 case ARM::ArchKind::ARMV5TE:
885 case ARM::ArchKind::IWMMXT:
886 case ARM::ArchKind::IWMMXT2:
887 case ARM::ArchKind::XSCALE:
888 case ARM::ArchKind::ARMV5TEJ:
890 case ARM::ArchKind::ARMV6:
892 case ARM::ArchKind::ARMV6K:
893 case ARM::ArchKind::ARMV6KZ:
895 case ARM::ArchKind::ARMV6T2:
897 case ARM::ArchKind::ARMV6M:
899 case ARM::ArchKind::ARMV7A:
900 case ARM::ArchKind::ARMV7R:
902 case ARM::ArchKind::ARMV7VE:
904 case ARM::ArchKind::ARMV7K:
906 case ARM::ArchKind::ARMV7M:
908 case ARM::ArchKind::ARMV7S:
910 case ARM::ArchKind::ARMV7EM:
912 case ARM::ArchKind::ARMV8A:
914 case ARM::ArchKind::ARMV8_1A:
916 case ARM::ArchKind::ARMV8_2A:
918 case ARM::ArchKind::ARMV8_3A:
920 case ARM::ArchKind::ARMV8_4A:
922 case ARM::ArchKind::ARMV8_5A:
924 case ARM::ArchKind::ARMV8_6A:
926 case ARM::ArchKind::ARMV8_7A:
928 case ARM::ArchKind::ARMV8_8A:
930 case ARM::ArchKind::ARMV8_9A:
932 case ARM::ArchKind::ARMV9A:
934 case ARM::ArchKind::ARMV9_1A:
936 case ARM::ArchKind::ARMV9_2A:
938 case ARM::ArchKind::ARMV9_3A:
940 case ARM::ArchKind::ARMV9_4A:
942 case ARM::ArchKind::ARMV9_5A:
944 case ARM::ArchKind::ARMV9_6A:
946 case ARM::ArchKind::ARMV9_7A:
948 case ARM::ArchKind::ARMV8R:
950 case ARM::ArchKind::ARMV8MBaseline:
952 case ARM::ArchKind::ARMV8MMainline:
954 case ARM::ArchKind::ARMV8_1MMainline:
956 default:
957 return Triple::NoSubArch;
958 }
959}
960
962 switch (T.getArch()) {
964 case Triple::aarch64:
966 case Triple::arm:
967 case Triple::thumb:
968 case Triple::x86:
969 case Triple::x86_64:
970 switch (T.getOS()) {
971 case Triple::Win32:
972 case Triple::UEFI:
973 return Triple::COFF;
974 default:
975 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
976 }
978 case Triple::amdgcn:
979 case Triple::amdil64:
980 case Triple::amdil:
981 case Triple::arc:
982 case Triple::armeb:
983 case Triple::avr:
984 case Triple::bpfeb:
985 case Triple::bpfel:
986 case Triple::csky:
987 case Triple::hexagon:
988 case Triple::hsail64:
989 case Triple::hsail:
990 case Triple::kalimba:
991 case Triple::lanai:
994 case Triple::m68k:
995 case Triple::mips64:
996 case Triple::mips64el:
997 case Triple::mips:
998 case Triple::msp430:
999 case Triple::nvptx64:
1000 case Triple::nvptx:
1001 case Triple::ppc64le:
1002 case Triple::ppcle:
1003 case Triple::r600:
1006 case Triple::riscv32:
1007 case Triple::riscv64:
1008 case Triple::riscv32be:
1009 case Triple::riscv64be:
1010 case Triple::shave:
1011 case Triple::sparc:
1012 case Triple::sparcel:
1013 case Triple::sparcv9:
1014 case Triple::spir64:
1015 case Triple::spir:
1016 case Triple::tce:
1017 case Triple::tcele:
1018 case Triple::thumbeb:
1019 case Triple::ve:
1020 case Triple::xcore:
1021 case Triple::xtensa:
1022 return Triple::ELF;
1023
1024 case Triple::mipsel:
1025 if (T.isOSWindows())
1026 return Triple::COFF;
1027 return Triple::ELF;
1028
1029 case Triple::ppc64:
1030 case Triple::ppc:
1031 if (T.isOSAIX())
1032 return Triple::XCOFF;
1033 if (T.isOSDarwin())
1034 return Triple::MachO;
1035 return Triple::ELF;
1036
1037 case Triple::systemz:
1038 if (T.isOSzOS())
1039 return Triple::GOFF;
1040 return Triple::ELF;
1041
1042 case Triple::wasm32:
1043 case Triple::wasm64:
1044 return Triple::Wasm;
1045
1046 case Triple::spirv:
1047 case Triple::spirv32:
1048 case Triple::spirv64:
1049 return Triple::SPIRV;
1050
1051 case Triple::dxil:
1052 return Triple::DXContainer;
1053 }
1054 llvm_unreachable("unknown architecture");
1055}
1056
1057/// Construct a triple from the string representation provided.
1058///
1059/// This stores the string representation and parses the various pieces into
1060/// enum members.
1061Triple::Triple(std::string &&Str) : Data(std::move(Str)) {
1062 // Do minimal parsing by hand here.
1063 SmallVector<StringRef, 4> Components;
1064 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
1065 if (Components.size() > 0) {
1066 Arch = parseArch(Components[0]);
1067 SubArch = parseSubArch(Components[0]);
1068 if (Components.size() > 1) {
1069 Vendor = parseVendor(Components[1]);
1070 if (Components.size() > 2) {
1071 OS = parseOS(Components[2]);
1072 if (Components.size() > 3) {
1073 Environment = parseEnvironment(Components[3]);
1074 ObjectFormat = parseFormat(Components[3]);
1075 }
1076 }
1077 } else {
1078 Environment =
1080 .StartsWith("mipsn32", Triple::GNUABIN32)
1081 .StartsWith("mips64", Triple::GNUABI64)
1082 .StartsWith("mipsisa64", Triple::GNUABI64)
1083 .StartsWith("mipsisa32", Triple::GNU)
1084 .Cases({"mips", "mipsel", "mipsr6", "mipsr6el"}, Triple::GNU)
1086 }
1087 }
1088 if (ObjectFormat == UnknownObjectFormat)
1089 ObjectFormat = getDefaultFormat(*this);
1090}
1091
1092Triple::Triple(const Twine &Str) : Triple(Str.str()) {}
1093
1094/// Construct a triple from string representations of the architecture,
1095/// vendor, and OS.
1096///
1097/// This joins each argument into a canonical string representation and parses
1098/// them into enum members. It leaves the environment unknown and omits it from
1099/// the string representation.
1100Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1101 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1102 Arch(parseArch(ArchStr.str())),
1103 SubArch(parseSubArch(ArchStr.str())),
1104 Vendor(parseVendor(VendorStr.str())),
1105 OS(parseOS(OSStr.str())),
1106 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1107 ObjectFormat = getDefaultFormat(*this);
1108}
1109
1110/// Construct a triple from string representations of the architecture,
1111/// vendor, OS, and environment.
1112///
1113/// This joins each argument into a canonical string representation and parses
1114/// them into enum members.
1115Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1116 const Twine &EnvironmentStr)
1117 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1118 EnvironmentStr).str()),
1119 Arch(parseArch(ArchStr.str())),
1120 SubArch(parseSubArch(ArchStr.str())),
1121 Vendor(parseVendor(VendorStr.str())),
1122 OS(parseOS(OSStr.str())),
1123 Environment(parseEnvironment(EnvironmentStr.str())),
1124 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1125 if (ObjectFormat == Triple::UnknownObjectFormat)
1126 ObjectFormat = getDefaultFormat(*this);
1127}
1128
1130
1132 VersionTuple Ver =
1133 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1134 // Default DXIL minor version when Shader Model version is anything other
1135 // than 6.[0...9] or 6.x (which translates to latest current SM version)
1136 const unsigned SMMajor = 6;
1137 if (!Ver.empty()) {
1138 if (Ver.getMajor() == SMMajor) {
1139 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1140 switch (*SMMinor) {
1141 case 0:
1143 case 1:
1145 case 2:
1147 case 3:
1149 case 4:
1151 case 5:
1153 case 6:
1155 case 7:
1157 case 8:
1159 case 9:
1161 default:
1162 report_fatal_error("Unsupported Shader Model version", false);
1163 }
1164 }
1165 }
1166 } else {
1167 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1168 // shadermodel6.x is
1169 if (ShaderModelStr == "shadermodel6.x") {
1171 }
1172 }
1173 // DXIL version corresponding to Shader Model version other than 6.Minor
1174 // is 1.0
1176}
1177
1179 bool IsMinGW32 = false;
1180 bool IsCygwin = false;
1181
1182 // Parse into components.
1183 SmallVector<StringRef, 4> Components;
1184 Str.split(Components, '-');
1185
1186 // If the first component corresponds to a known architecture, preferentially
1187 // use it for the architecture. If the second component corresponds to a
1188 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1189 // component movement when a component parses as (eg) both a valid arch and a
1190 // valid os.
1191 ArchType Arch = UnknownArch;
1192 if (Components.size() > 0)
1193 Arch = parseArch(Components[0]);
1194 VendorType Vendor = UnknownVendor;
1195 if (Components.size() > 1)
1196 Vendor = parseVendor(Components[1]);
1197 OSType OS = UnknownOS;
1198 if (Components.size() > 2) {
1199 OS = parseOS(Components[2]);
1200 IsCygwin = Components[2].starts_with("cygwin") ||
1201 Components[2].starts_with("msys");
1202 IsMinGW32 = Components[2].starts_with("mingw");
1203 }
1204 EnvironmentType Environment = UnknownEnvironment;
1205 if (Components.size() > 3)
1206 Environment = parseEnvironment(Components[3]);
1208 if (Components.size() > 4)
1209 ObjectFormat = parseFormat(Components[4]);
1210
1211 // Note which components are already in their final position. These will not
1212 // be moved.
1213 bool Found[4];
1214 Found[0] = Arch != UnknownArch;
1215 Found[1] = Vendor != UnknownVendor;
1216 Found[2] = OS != UnknownOS;
1217 Found[3] = Environment != UnknownEnvironment;
1218
1219 // If they are not there already, permute the components into their canonical
1220 // positions by seeing if they parse as a valid architecture, and if so moving
1221 // the component to the architecture position etc.
1222 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1223 if (Found[Pos])
1224 continue; // Already in the canonical position.
1225
1226 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1227 // Do not reparse any components that already matched.
1228 if (Idx < std::size(Found) && Found[Idx])
1229 continue;
1230
1231 // Does this component parse as valid for the target position?
1232 bool Valid = false;
1233 StringRef Comp = Components[Idx];
1234 switch (Pos) {
1235 default: llvm_unreachable("unexpected component type!");
1236 case 0:
1237 Arch = parseArch(Comp);
1238 Valid = Arch != UnknownArch;
1239 break;
1240 case 1:
1241 Vendor = parseVendor(Comp);
1242 Valid = Vendor != UnknownVendor;
1243 break;
1244 case 2:
1245 OS = parseOS(Comp);
1246 IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
1247 IsMinGW32 = Comp.starts_with("mingw");
1248 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1249 break;
1250 case 3:
1251 Environment = parseEnvironment(Comp);
1252 Valid = Environment != UnknownEnvironment;
1253 if (!Valid) {
1254 ObjectFormat = parseFormat(Comp);
1255 Valid = ObjectFormat != UnknownObjectFormat;
1256 }
1257 break;
1258 }
1259 if (!Valid)
1260 continue; // Nope, try the next component.
1261
1262 // Move the component to the target position, pushing any non-fixed
1263 // components that are in the way to the right. This tends to give
1264 // good results in the common cases of a forgotten vendor component
1265 // or a wrongly positioned environment.
1266 if (Pos < Idx) {
1267 // Insert left, pushing the existing components to the right. For
1268 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1269 StringRef CurrentComponent(""); // The empty component.
1270 // Replace the component we are moving with an empty component.
1271 std::swap(CurrentComponent, Components[Idx]);
1272 // Insert the component being moved at Pos, displacing any existing
1273 // components to the right.
1274 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1275 // Skip over any fixed components.
1276 while (i < std::size(Found) && Found[i])
1277 ++i;
1278 // Place the component at the new position, getting the component
1279 // that was at this position - it will be moved right.
1280 std::swap(CurrentComponent, Components[i]);
1281 }
1282 } else if (Pos > Idx) {
1283 // Push right by inserting empty components until the component at Idx
1284 // reaches the target position Pos. For example, pc-a -> -pc-a when
1285 // moving pc to the second position.
1286 do {
1287 // Insert one empty component at Idx.
1288 StringRef CurrentComponent(""); // The empty component.
1289 for (unsigned i = Idx; i < Components.size();) {
1290 // Place the component at the new position, getting the component
1291 // that was at this position - it will be moved right.
1292 std::swap(CurrentComponent, Components[i]);
1293 // If it was placed on top of an empty component then we are done.
1294 if (CurrentComponent.empty())
1295 break;
1296 // Advance to the next component, skipping any fixed components.
1297 while (++i < std::size(Found) && Found[i])
1298 ;
1299 }
1300 // The last component was pushed off the end - append it.
1301 if (!CurrentComponent.empty())
1302 Components.push_back(CurrentComponent);
1303
1304 // Advance Idx to the component's new position.
1305 while (++Idx < std::size(Found) && Found[Idx])
1306 ;
1307 } while (Idx < Pos); // Add more until the final position is reached.
1308 }
1309 assert(Pos < Components.size() && Components[Pos] == Comp &&
1310 "Component moved wrong!");
1311 Found[Pos] = true;
1312 break;
1313 }
1314 }
1315
1316 // If "none" is in the middle component in a three-component triple, treat it
1317 // as the OS (Components[2]) instead of the vendor (Components[1]).
1318 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1319 Components[1] == "none" && Components[2].empty())
1320 std::swap(Components[1], Components[2]);
1321
1322 // Replace empty components with "unknown" value.
1323 for (StringRef &C : Components)
1324 if (C.empty())
1325 C = "unknown";
1326
1327 // Special case logic goes here. At this point Arch, Vendor and OS have the
1328 // correct values for the computed components.
1329 std::string NormalizedEnvironment;
1330 if (Environment == Triple::Android &&
1331 Components[3].starts_with("androideabi")) {
1332 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1333 if (AndroidVersion.empty()) {
1334 Components[3] = "android";
1335 } else {
1336 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1337 Components[3] = NormalizedEnvironment;
1338 }
1339 }
1340
1341 // SUSE uses "gnueabi" to mean "gnueabihf"
1342 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1343 Components[3] = "gnueabihf";
1344
1345 if (OS == Triple::Win32) {
1346 Components.resize(4);
1347 Components[2] = "windows";
1348 if (Environment == UnknownEnvironment) {
1349 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1350 Components[3] = "msvc";
1351 else
1352 Components[3] = getObjectFormatTypeName(ObjectFormat);
1353 }
1354 } else if (IsMinGW32) {
1355 Components.resize(4);
1356 Components[2] = "windows";
1357 Components[3] = "gnu";
1358 } else if (IsCygwin) {
1359 Components.resize(4);
1360 Components[2] = "windows";
1361 Components[3] = "cygnus";
1362 }
1363 if (IsMinGW32 || IsCygwin ||
1364 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1365 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1366 Components.resize(5);
1367 Components[4] = getObjectFormatTypeName(ObjectFormat);
1368 }
1369 }
1370
1371 // Normalize DXIL triple if it does not include DXIL version number.
1372 // Determine DXIL version number using the minor version number of Shader
1373 // Model version specified in target triple, if any. Prior to decoupling DXIL
1374 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1375 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1376 if (Components[0] == "dxil") {
1377 if (Components.size() > 4) {
1378 Components.resize(4);
1379 }
1380 // Add DXIL version only if shadermodel is specified in the triple
1381 if (OS == Triple::ShaderModel) {
1382 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1383 }
1384 }
1385
1386 // Canonicalize the components if necessary.
1387 switch (Form) {
1388 case CanonicalForm::ANY:
1389 break;
1393 Components.resize(static_cast<unsigned>(Form), "unknown");
1394 break;
1395 }
1396 }
1397
1398 // Stick the corrected components back together to form the normalized string.
1399 return join(Components, "-");
1400}
1401
1403 return StringRef(Data).split('-').first; // Isolate first component
1404}
1405
1407 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1408 return Tmp.split('-').first; // Isolate second component
1409}
1410
1412 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1413 Tmp = Tmp.split('-').second; // Strip second component
1414 return Tmp.split('-').first; // Isolate third component
1415}
1416
1418 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1419 Tmp = Tmp.split('-').second; // Strip second component
1420 return Tmp.split('-').second; // Strip third component
1421}
1422
1424 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1425 return Tmp.split('-').second; // Strip second component
1426}
1427
1429 VersionTuple Version;
1430 Version.tryParse(Name);
1431 return Version.withoutBuild();
1432}
1433
1437
1439 StringRef EnvironmentName = getEnvironmentName();
1440
1441 // none is a valid environment type - it basically amounts to a freestanding
1442 // environment.
1443 if (EnvironmentName == "none")
1444 return "";
1445
1446 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1447 EnvironmentName.consume_front(EnvironmentTypeName);
1448
1449 if (EnvironmentName.contains("-")) {
1450 // -obj is the suffix
1452 StringRef ObjectFormatTypeName =
1454 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1455 EnvironmentName.consume_back(tmp);
1456 }
1457 }
1458 return EnvironmentName;
1459}
1460
1462 StringRef OSName = getOSName();
1463 // Assume that the OS portion of the triple starts with the canonical name.
1464 StringRef OSTypeName = getOSTypeName(getOS());
1465 if (OSName.starts_with(OSTypeName))
1466 OSName = OSName.substr(OSTypeName.size());
1467 else if (getOS() == MacOSX)
1468 OSName.consume_front("macos");
1469 else if (OSName.starts_with("visionos"))
1470 OSName.consume_front("visionos");
1471
1472 return parseVersionFromName(OSName);
1473}
1474
1477
1478 switch (getOS()) {
1479 default: llvm_unreachable("unexpected OS for Darwin triple");
1480 case Darwin:
1481 // Default to darwin8, i.e., MacOSX 10.4.
1482 if (Version.getMajor() == 0)
1483 Version = VersionTuple(8);
1484 // Darwin version numbers are skewed from OS X versions.
1485 if (Version.getMajor() < 4) {
1486 return false;
1487 }
1488 if (Version.getMajor() <= 19) {
1489 Version = VersionTuple(10, Version.getMajor() - 4);
1490 } else if (Version.getMajor() < 25) {
1491 // darwin20-24 corresponds to macOS 11-15.
1492 Version = VersionTuple(11 + Version.getMajor() - 20);
1493 } else {
1494 // darwin25 corresponds with macOS26+.
1495 Version = VersionTuple(Version.getMajor() + 1);
1496 }
1497 break;
1498 case MacOSX:
1499 // Default to 10.4.
1500 if (Version.getMajor() == 0) {
1501 Version = VersionTuple(10, 4);
1502 } else if (Version.getMajor() < 10) {
1503 return false;
1504 }
1505 break;
1506 case IOS:
1507 case TvOS:
1508 case WatchOS:
1509 // Ignore the version from the triple. This is only handled because the
1510 // the clang driver combines OS X and IOS support into a common Darwin
1511 // toolchain that wants to know the OS X version number even when targeting
1512 // IOS.
1513 Version = VersionTuple(10, 4);
1514 break;
1515 case XROS:
1516 llvm_unreachable("OSX version isn't relevant for xrOS");
1517 case DriverKit:
1518 llvm_unreachable("OSX version isn't relevant for DriverKit");
1519 }
1520 return true;
1521}
1522
1524 switch (getOS()) {
1525 default: llvm_unreachable("unexpected OS for Darwin triple");
1526 case Darwin:
1527 case MacOSX:
1528 // Ignore the version from the triple. This is only handled because the
1529 // the clang driver combines OS X and IOS support into a common Darwin
1530 // toolchain that wants to know the iOS version number even when targeting
1531 // OS X.
1532 return VersionTuple(5);
1533 case IOS:
1534 case TvOS: {
1536 // Default to 5.0 (or 7.0 for arm64).
1537 if (Version.getMajor() == 0)
1538 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1539 if (Version.getMajor() == 19)
1540 // tvOS 19 corresponds to ios26.
1541 return VersionTuple(26);
1544 }
1545 case XROS: {
1547 // xrOS 1 is aligned with iOS 17.
1548 if (Version.getMajor() < 3)
1549 return Version.withMajorReplaced(Version.getMajor() + 16);
1550 // visionOS 3 corresponds to ios 26+.
1551 if (Version.getMajor() == 3)
1552 return VersionTuple(26);
1555 }
1556 case WatchOS: {
1558 // watchOS 12 corresponds to ios 26.
1559 if (Version.getMajor() == 12)
1560 return VersionTuple(26);
1564 }
1565 case BridgeOS:
1566 llvm_unreachable("conflicting triple info");
1567 case DriverKit:
1568 llvm_unreachable("DriverKit doesn't have an iOS version");
1569 }
1570}
1571
1573 switch (getOS()) {
1574 default: llvm_unreachable("unexpected OS for Darwin triple");
1575 case Darwin:
1576 case MacOSX:
1577 // Ignore the version from the triple. This is only handled because the
1578 // the clang driver combines OS X and IOS support into a common Darwin
1579 // toolchain that wants to know the iOS version number even when targeting
1580 // OS X.
1581 return VersionTuple(2);
1582 case WatchOS: {
1584 if (Version.getMajor() == 0)
1585 return VersionTuple(2);
1586 return Version;
1587 }
1588 case IOS:
1589 llvm_unreachable("conflicting triple info");
1590 case XROS:
1591 llvm_unreachable("watchOS version isn't relevant for xrOS");
1592 case DriverKit:
1593 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1594 }
1595}
1596
1598 switch (getOS()) {
1599 default:
1600 llvm_unreachable("unexpected OS for Darwin triple");
1601 case DriverKit:
1603 if (Version.getMajor() == 0)
1604 return Version.withMajorReplaced(19);
1605 return Version;
1606 }
1607}
1608
1610 if (getArch() != spirv || getOS() != Vulkan)
1611 llvm_unreachable("invalid Vulkan SPIR-V triple");
1612
1613 VersionTuple VulkanVersion = getOSVersion();
1614 SubArchType SpirvVersion = getSubArch();
1615
1617 // Vulkan 1.2 -> SPIR-V 1.5.
1619 // Vulkan 1.3 -> SPIR-V 1.6.
1621
1622 // If Vulkan version is unset, default to 1.2.
1623 if (VulkanVersion == VersionTuple(0))
1624 VulkanVersion = VersionTuple(1, 2);
1625
1626 if (ValidVersionMap.contains(VulkanVersion) &&
1627 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1628 SpirvVersion == NoSubArch))
1629 return VulkanVersion;
1630
1631 return VersionTuple(0);
1632}
1633
1635 if (getArch() != dxil || getOS() != ShaderModel)
1636 llvm_unreachable("invalid DXIL triple");
1637 StringRef Arch = getArchName();
1638 if (getSubArch() == NoSubArch)
1640 Arch.consume_front("dxilv");
1641 VersionTuple DXILVersion = parseVersionFromName(Arch);
1642 // FIXME: validate DXIL version against Shader Model version.
1643 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1644 return DXILVersion;
1645}
1646
1647void Triple::setTriple(const Twine &Str) {
1648 *this = Triple(Str);
1649}
1650
1652 setArchName(getArchName(Kind, SubArch));
1653}
1654
1658
1660 setOSName(getOSTypeName(Kind));
1661}
1662
1664 if (ObjectFormat == getDefaultFormat(*this))
1666
1668 getObjectFormatTypeName(ObjectFormat)).str());
1669}
1670
1672 if (Environment == UnknownEnvironment)
1674
1675 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1676 getObjectFormatTypeName(Kind)).str());
1677}
1678
1680 setTriple(Str + "-" + getVendorName() + "-" + getOSAndEnvironmentName());
1681}
1682
1684 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1685}
1686
1688 if (hasEnvironment())
1689 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1690 "-" + getEnvironmentName());
1691 else
1692 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1693}
1694
1696 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1697 "-" + Str);
1698}
1699
1701 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1702}
1703
1705 switch (Arch) {
1707 return 0;
1708
1709 case llvm::Triple::avr:
1711 return 16;
1712
1715 case llvm::Triple::arc:
1716 case llvm::Triple::arm:
1718 case llvm::Triple::csky:
1719 case llvm::Triple::dxil:
1725 case llvm::Triple::m68k:
1726 case llvm::Triple::mips:
1729 case llvm::Triple::ppc:
1731 case llvm::Triple::r600:
1738 case llvm::Triple::spir:
1740 case llvm::Triple::tce:
1745 case llvm::Triple::x86:
1748 return 32;
1749
1771 case llvm::Triple::ve:
1774 return 64;
1775 }
1776 llvm_unreachable("Invalid architecture value");
1777}
1778
1780 switch (getArch()) {
1781 default:
1782 break;
1783 case Triple::ppc:
1784 case Triple::ppcle:
1785 if (isOSLinux())
1786 return 40;
1787 break;
1788 case Triple::ppc64:
1789 case Triple::ppc64le:
1790 if (isOSLinux())
1791 return 48;
1792 break;
1793 }
1794 return 32;
1795}
1796
1798 return getArchPointerBitWidth(getArch()) == 64;
1799}
1800
1802 return getArchPointerBitWidth(getArch()) == 32;
1803}
1804
1806 return getArchPointerBitWidth(getArch()) == 16;
1807}
1808
1810 Triple T(*this);
1811 switch (getArch()) {
1813 case Triple::amdgcn:
1814 case Triple::avr:
1815 case Triple::bpfeb:
1816 case Triple::bpfel:
1817 case Triple::msp430:
1818 case Triple::systemz:
1819 case Triple::ve:
1820 T.setArch(UnknownArch);
1821 break;
1822
1823 case Triple::aarch64_32:
1824 case Triple::amdil:
1825 case Triple::arc:
1826 case Triple::arm:
1827 case Triple::armeb:
1828 case Triple::csky:
1829 case Triple::dxil:
1830 case Triple::hexagon:
1831 case Triple::hsail:
1832 case Triple::kalimba:
1833 case Triple::lanai:
1835 case Triple::m68k:
1836 case Triple::mips:
1837 case Triple::mipsel:
1838 case Triple::nvptx:
1839 case Triple::ppc:
1840 case Triple::ppcle:
1841 case Triple::r600:
1843 case Triple::riscv32:
1844 case Triple::riscv32be:
1845 case Triple::shave:
1846 case Triple::sparc:
1847 case Triple::sparcel:
1848 case Triple::spir:
1849 case Triple::spirv32:
1850 case Triple::tce:
1851 case Triple::tcele:
1852 case Triple::thumb:
1853 case Triple::thumbeb:
1854 case Triple::wasm32:
1855 case Triple::x86:
1856 case Triple::xcore:
1857 case Triple::xtensa:
1858 // Already 32-bit.
1859 break;
1860
1861 case Triple::aarch64: T.setArch(Triple::arm); break;
1862 case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1863 case Triple::amdil64: T.setArch(Triple::amdil); break;
1864 case Triple::hsail64: T.setArch(Triple::hsail); break;
1865 case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
1866 case Triple::mips64:
1867 T.setArch(Triple::mips, getSubArch());
1868 break;
1869 case Triple::mips64el:
1870 T.setArch(Triple::mipsel, getSubArch());
1871 break;
1872 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1873 case Triple::ppc64: T.setArch(Triple::ppc); break;
1874 case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1875 case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1876 case Triple::riscv64: T.setArch(Triple::riscv32); break;
1877 case Triple::riscv64be:
1878 T.setArch(Triple::riscv32be);
1879 break;
1880 case Triple::sparcv9: T.setArch(Triple::sparc); break;
1881 case Triple::spir64: T.setArch(Triple::spir); break;
1882 case Triple::spirv:
1883 case Triple::spirv64:
1884 T.setArch(Triple::spirv32, getSubArch());
1885 break;
1886 case Triple::wasm64: T.setArch(Triple::wasm32); break;
1887 case Triple::x86_64: T.setArch(Triple::x86); break;
1888 }
1889 return T;
1890}
1891
1893 Triple T(*this);
1894 switch (getArch()) {
1896 case Triple::arc:
1897 case Triple::avr:
1898 case Triple::csky:
1899 case Triple::dxil:
1900 case Triple::hexagon:
1901 case Triple::kalimba:
1902 case Triple::lanai:
1903 case Triple::m68k:
1904 case Triple::msp430:
1905 case Triple::r600:
1906 case Triple::shave:
1907 case Triple::sparcel:
1908 case Triple::tce:
1909 case Triple::tcele:
1910 case Triple::xcore:
1911 case Triple::xtensa:
1912 T.setArch(UnknownArch);
1913 break;
1914
1915 case Triple::aarch64:
1916 case Triple::aarch64_be:
1917 case Triple::amdgcn:
1918 case Triple::amdil64:
1919 case Triple::bpfeb:
1920 case Triple::bpfel:
1921 case Triple::hsail64:
1923 case Triple::mips64:
1924 case Triple::mips64el:
1925 case Triple::nvptx64:
1926 case Triple::ppc64:
1927 case Triple::ppc64le:
1929 case Triple::riscv64:
1930 case Triple::riscv64be:
1931 case Triple::sparcv9:
1932 case Triple::spir64:
1933 case Triple::spirv64:
1934 case Triple::systemz:
1935 case Triple::ve:
1936 case Triple::wasm64:
1937 case Triple::x86_64:
1938 // Already 64-bit.
1939 break;
1940
1941 case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1942 case Triple::amdil: T.setArch(Triple::amdil64); break;
1943 case Triple::arm: T.setArch(Triple::aarch64); break;
1944 case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1945 case Triple::hsail: T.setArch(Triple::hsail64); break;
1946 case Triple::loongarch32: T.setArch(Triple::loongarch64); break;
1947 case Triple::mips:
1948 T.setArch(Triple::mips64, getSubArch());
1949 break;
1950 case Triple::mipsel:
1951 T.setArch(Triple::mips64el, getSubArch());
1952 break;
1953 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1954 case Triple::ppc: T.setArch(Triple::ppc64); break;
1955 case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1956 case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1957 case Triple::riscv32: T.setArch(Triple::riscv64); break;
1958 case Triple::riscv32be:
1959 T.setArch(Triple::riscv64be);
1960 break;
1961 case Triple::sparc: T.setArch(Triple::sparcv9); break;
1962 case Triple::spir: T.setArch(Triple::spir64); break;
1963 case Triple::spirv:
1964 case Triple::spirv32:
1965 T.setArch(Triple::spirv64, getSubArch());
1966 break;
1967 case Triple::thumb: T.setArch(Triple::aarch64); break;
1968 case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1969 case Triple::wasm32: T.setArch(Triple::wasm64); break;
1970 case Triple::x86: T.setArch(Triple::x86_64); break;
1971 }
1972 return T;
1973}
1974
1976 Triple T(*this);
1977 // Already big endian.
1978 if (!isLittleEndian())
1979 return T;
1980 switch (getArch()) {
1982 case Triple::amdgcn:
1983 case Triple::amdil64:
1984 case Triple::amdil:
1985 case Triple::avr:
1986 case Triple::dxil:
1987 case Triple::hexagon:
1988 case Triple::hsail64:
1989 case Triple::hsail:
1990 case Triple::kalimba:
1993 case Triple::msp430:
1994 case Triple::nvptx64:
1995 case Triple::nvptx:
1996 case Triple::r600:
1999 case Triple::shave:
2000 case Triple::spir64:
2001 case Triple::spir:
2002 case Triple::spirv:
2003 case Triple::spirv32:
2004 case Triple::spirv64:
2005 case Triple::wasm32:
2006 case Triple::wasm64:
2007 case Triple::x86:
2008 case Triple::x86_64:
2009 case Triple::xcore:
2010 case Triple::ve:
2011 case Triple::csky:
2012 case Triple::xtensa:
2013
2014 // ARM is intentionally unsupported here, changing the architecture would
2015 // drop any arch suffixes.
2016 case Triple::arm:
2017 case Triple::thumb:
2018 T.setArch(UnknownArch);
2019 break;
2020
2021 case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
2022 case Triple::bpfel: T.setArch(Triple::bpfeb); break;
2023 case Triple::mips64el:
2024 T.setArch(Triple::mips64, getSubArch());
2025 break;
2026 case Triple::mipsel:
2027 T.setArch(Triple::mips, getSubArch());
2028 break;
2029 case Triple::ppcle: T.setArch(Triple::ppc); break;
2030 case Triple::ppc64le: T.setArch(Triple::ppc64); break;
2031 case Triple::riscv32:
2032 T.setArch(Triple::riscv32be);
2033 break;
2034 case Triple::riscv64:
2035 T.setArch(Triple::riscv64be);
2036 break;
2037 case Triple::sparcel: T.setArch(Triple::sparc); break;
2038 case Triple::tcele: T.setArch(Triple::tce); break;
2039 default:
2040 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
2041 }
2042 return T;
2043}
2044
2046 Triple T(*this);
2047 if (isLittleEndian())
2048 return T;
2049
2050 switch (getArch()) {
2052 case Triple::lanai:
2053 case Triple::sparcv9:
2054 case Triple::systemz:
2055 case Triple::m68k:
2056
2057 // ARM is intentionally unsupported here, changing the architecture would
2058 // drop any arch suffixes.
2059 case Triple::armeb:
2060 case Triple::thumbeb:
2061 T.setArch(UnknownArch);
2062 break;
2063
2064 case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
2065 case Triple::bpfeb: T.setArch(Triple::bpfel); break;
2066 case Triple::mips64:
2067 T.setArch(Triple::mips64el, getSubArch());
2068 break;
2069 case Triple::mips:
2070 T.setArch(Triple::mipsel, getSubArch());
2071 break;
2072 case Triple::ppc: T.setArch(Triple::ppcle); break;
2073 case Triple::ppc64: T.setArch(Triple::ppc64le); break;
2074 case Triple::riscv32be:
2075 T.setArch(Triple::riscv32);
2076 break;
2077 case Triple::riscv64be:
2078 T.setArch(Triple::riscv64);
2079 break;
2080 case Triple::sparc: T.setArch(Triple::sparcel); break;
2081 case Triple::tce: T.setArch(Triple::tcele); break;
2082 default:
2083 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
2084 }
2085 return T;
2086}
2087
2089 switch (getArch()) {
2090 case Triple::aarch64:
2091 case Triple::aarch64_32:
2092 case Triple::amdgcn:
2093 case Triple::amdil64:
2094 case Triple::amdil:
2095 case Triple::arm:
2096 case Triple::avr:
2097 case Triple::bpfel:
2098 case Triple::csky:
2099 case Triple::dxil:
2100 case Triple::hexagon:
2101 case Triple::hsail64:
2102 case Triple::hsail:
2103 case Triple::kalimba:
2106 case Triple::mips64el:
2107 case Triple::mipsel:
2108 case Triple::msp430:
2109 case Triple::nvptx64:
2110 case Triple::nvptx:
2111 case Triple::ppcle:
2112 case Triple::ppc64le:
2113 case Triple::r600:
2116 case Triple::riscv32:
2117 case Triple::riscv64:
2118 case Triple::shave:
2119 case Triple::sparcel:
2120 case Triple::spir64:
2121 case Triple::spir:
2122 case Triple::spirv:
2123 case Triple::spirv32:
2124 case Triple::spirv64:
2125 case Triple::tcele:
2126 case Triple::thumb:
2127 case Triple::ve:
2128 case Triple::wasm32:
2129 case Triple::wasm64:
2130 case Triple::x86:
2131 case Triple::x86_64:
2132 case Triple::xcore:
2133 case Triple::xtensa:
2134 return true;
2135 default:
2136 return false;
2137 }
2138}
2139
2141 // On MinGW, C code is usually built with a "w64" vendor, while Rust
2142 // often uses a "pc" vendor.
2143 bool IgnoreVendor = isWindowsGNUEnvironment();
2144
2145 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
2146 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2147 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2148 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2149 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2150 if (getVendor() == Triple::Apple)
2151 return getSubArch() == Other.getSubArch() &&
2152 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2153 else
2154 return getSubArch() == Other.getSubArch() &&
2155 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2156 getOS() == Other.getOS() &&
2157 getEnvironment() == Other.getEnvironment() &&
2158 getObjectFormat() == Other.getObjectFormat();
2159 }
2160
2161 // If vendor is apple, ignore the version number (the environment field)
2162 // and the object format.
2163 if (getVendor() == Triple::Apple)
2164 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2165 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2166 getOS() == Other.getOS();
2167
2168 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2169 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2170 getOS() == Other.getOS() &&
2171 getEnvironment() == Other.getEnvironment() &&
2172 getObjectFormat() == Other.getObjectFormat();
2173}
2174
2175std::string Triple::merge(const Triple &Other) const {
2176 // If vendor is apple, pick the triple with the larger version number.
2177 if (getVendor() == Triple::Apple)
2178 if (Other.isOSVersionLT(*this))
2179 return str();
2180
2181 return Other.str();
2182}
2183
2184bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2185 unsigned Micro) const {
2186 assert(isMacOSX() && "Not an OS X triple!");
2187
2188 // If this is OS X, expect a sane version number.
2189 if (getOS() == Triple::MacOSX)
2190 return isOSVersionLT(Major, Minor, Micro);
2191
2192 // Otherwise, compare to the "Darwin" number.
2193 if (Major == 10)
2194 return isOSVersionLT(Minor + 4, Micro, 0);
2195 assert(Major >= 11 && "Unexpected major version");
2196 if (Major < 25)
2197 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2198 return isOSVersionLT(Major + 1, Minor, Micro);
2199}
2200
2203 return VersionTuple();
2204 switch (getOS()) {
2205 case Triple::MacOSX:
2206 // ARM64 slice is supported starting from macOS 11.0+.
2207 return VersionTuple(11, 0, 0);
2208 case Triple::IOS:
2209 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2210 // ARM64 simulators are supported for iOS 14+.
2212 return VersionTuple(14, 0, 0);
2213 // ARM64e slice is supported starting from iOS 14.
2214 if (isArm64e())
2215 return VersionTuple(14, 0, 0);
2216 break;
2217 case Triple::TvOS:
2218 // ARM64 simulators are supported for tvOS 14+.
2220 return VersionTuple(14, 0, 0);
2221 break;
2222 case Triple::WatchOS:
2223 // ARM64 simulators are supported for watchOS 7+.
2225 return VersionTuple(7, 0, 0);
2226 // ARM64/ARM64e slices are supported starting from watchOS 26.
2227 // ARM64_32 is older though.
2229 return VersionTuple(26, 0, 0);
2230 case Triple::DriverKit:
2231 return VersionTuple(20, 0, 0);
2232 default:
2233 break;
2234 }
2235 return VersionTuple();
2236}
2237
2239 const VersionTuple &Version,
2240 bool IsInValidRange) {
2241 const unsigned MacOSRangeBump = 10;
2242 const unsigned IOSRangeBump = 7;
2243 const unsigned XROSRangeBump = 23;
2244 const unsigned WatchOSRangeBump = 14;
2245 switch (OSKind) {
2246 case MacOSX: {
2247 // macOS 10.16 is canonicalized to macOS 11.
2248 if (Version == VersionTuple(10, 16))
2249 return VersionTuple(11, 0);
2250 // macOS 16 is canonicalized to macOS 26.
2251 if (Version == VersionTuple(16, 0))
2252 return VersionTuple(26, 0);
2253 if (!IsInValidRange)
2254 return Version.withMajorReplaced(Version.getMajor() + MacOSRangeBump);
2255 break;
2256 }
2257 case IOS:
2258 case TvOS: {
2259 // Both iOS & tvOS 19.0 canonicalize to 26.
2260 if (Version == VersionTuple(19, 0))
2261 return VersionTuple(26, 0);
2262 if (!IsInValidRange)
2263 return Version.withMajorReplaced(Version.getMajor() + IOSRangeBump);
2264 break;
2265 }
2266 case XROS: {
2267 // visionOS3 is canonicalized to 26.
2268 if (Version == VersionTuple(3, 0))
2269 return VersionTuple(26, 0);
2270 if (!IsInValidRange)
2271 return Version.withMajorReplaced(Version.getMajor() + XROSRangeBump);
2272 break;
2273 }
2274 case WatchOS: {
2275 // watchOS 12 is canonicalized to 26.
2276 if (Version == VersionTuple(12, 0))
2277 return VersionTuple(26, 0);
2278 if (!IsInValidRange)
2279 return Version.withMajorReplaced(Version.getMajor() + WatchOSRangeBump);
2280 break;
2281 }
2282 default:
2283 return Version;
2284 }
2285
2286 return Version;
2287}
2288
2290 /// This constant is used to capture gaps in versioning.
2291 const VersionTuple CommonVersion(26);
2292 auto IsValid = [&](const VersionTuple &StartingVersion) {
2293 return !((Version > StartingVersion) && (Version < CommonVersion));
2294 };
2295 switch (OSKind) {
2296 case WatchOS: {
2297 const VersionTuple StartingWatchOS(12);
2298 return IsValid(StartingWatchOS);
2299 }
2300 case IOS:
2301 case TvOS: {
2302 const VersionTuple StartingIOS(19);
2303 return IsValid(StartingIOS);
2304 }
2305 case MacOSX: {
2306 const VersionTuple StartingMacOS(16);
2307 return IsValid(StartingMacOS);
2308 }
2309 case XROS: {
2310 const VersionTuple StartingXROS(3);
2311 return IsValid(StartingXROS);
2312 }
2313 default:
2314 return true;
2315 }
2316
2317 llvm_unreachable("unexpected or invalid os version");
2318}
2319
2321 if (isOSBinFormatCOFF()) {
2322 if (getArch() == Triple::x86 &&
2326 }
2327
2328 if (isOSBinFormatXCOFF())
2330 if (isOSBinFormatGOFF())
2332
2333 if (isARM() || isThumb()) {
2334 if (isOSBinFormatELF()) {
2337 }
2338
2341 }
2342
2343 if (isAArch64() || isX86() || isPPC() || isMIPS() || isSPARC() || isBPF() ||
2344 isRISCV() || isLoongArch())
2346
2347 switch (getArch()) {
2348 case Triple::arc:
2349 case Triple::csky:
2350 case Triple::hexagon:
2351 case Triple::lanai:
2352 case Triple::m68k:
2353 case Triple::msp430:
2354 case Triple::systemz:
2355 case Triple::xcore:
2356 case Triple::xtensa:
2358 default:
2359 break;
2360 }
2361
2362 // Explicitly none targets.
2363 if (isWasm() || isAMDGPU() || isNVPTX() || isSPIROrSPIRV())
2365
2366 // Default to none.
2368}
2369
2370// HLSL triple environment orders are relied on in the front end
2371static_assert(Triple::Vertex - Triple::Pixel == 1,
2372 "incorrect HLSL stage order");
2373static_assert(Triple::Geometry - Triple::Pixel == 2,
2374 "incorrect HLSL stage order");
2375static_assert(Triple::Hull - Triple::Pixel == 3,
2376 "incorrect HLSL stage order");
2377static_assert(Triple::Domain - Triple::Pixel == 4,
2378 "incorrect HLSL stage order");
2379static_assert(Triple::Compute - Triple::Pixel == 5,
2380 "incorrect HLSL stage order");
2381static_assert(Triple::Library - Triple::Pixel == 6,
2382 "incorrect HLSL stage order");
2383static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2384 "incorrect HLSL stage order");
2385static_assert(Triple::Intersection - Triple::Pixel == 8,
2386 "incorrect HLSL stage order");
2387static_assert(Triple::AnyHit - Triple::Pixel == 9,
2388 "incorrect HLSL stage order");
2389static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2390 "incorrect HLSL stage order");
2391static_assert(Triple::Miss - Triple::Pixel == 11,
2392 "incorrect HLSL stage order");
2393static_assert(Triple::Callable - Triple::Pixel == 12,
2394 "incorrect HLSL stage order");
2395static_assert(Triple::Mesh - Triple::Pixel == 13,
2396 "incorrect HLSL stage order");
2397static_assert(Triple::Amplification - Triple::Pixel == 14,
2398 "incorrect HLSL stage order");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseMap class.
Load MIR Sample Profile
#define T
This file contains some functions that are useful when dealing with strings.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
DEMANGLE_NAMESPACE_BEGIN bool starts_with(std::string_view self, char C) noexcept
static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName)
Definition Triple.cpp:751
static VersionTuple parseVersionFromName(StringRef Name)
Definition Triple.cpp:1428
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition Triple.cpp:961
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition Triple.cpp:518
static Triple::OSType parseOS(StringRef OSName)
Definition Triple.cpp:703
static StringRef getDXILArchNameFromShaderModel(StringRef ShaderModelStr)
Definition Triple.cpp:1131
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition Triple.cpp:431
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition Triple.cpp:824
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition Triple.cpp:810
static Triple::ArchType parseArch(StringRef ArchName)
Definition Triple.cpp:583
static Triple::VendorType parseVendor(StringRef VendorName)
Definition Triple.cpp:682
Defines the llvm::VersionTuple class, which represents a version in the form major[....
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition DenseMap.h:205
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition DenseMap.h:169
void resize(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition StringRef.h:702
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition StringRef.h:657
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:573
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:261
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:143
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition StringRef.h:611
constexpr size_t size() const
size - Get the string size.
Definition StringRef.h:146
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition StringRef.h:426
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition StringRef.h:637
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition StringRef.h:273
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & StartsWith(StringLiteral S, T Value)
StringSwitch & EndsWith(StringLiteral S, T Value)
StringSwitch & Cases(std::initializer_list< StringLiteral > CaseStrings, T Value)
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM_ABI 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:2184
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1461
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1071
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1406
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1572
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1679
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1671
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:1809
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:734
bool isWatchABI() const
Definition Triple.h:606
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:303
@ UnknownEnvironment
Definition Triple.h:255
@ RootSignature
Definition Triple.h:311
@ Amplification
Definition Triple.h:310
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:933
static LLVM_ABI VersionTuple getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version, bool IsInValidRange)
Returns a canonicalized OS version number for the specified OS.
Definition Triple.cpp:2238
CanonicalForm
Canonical form.
Definition Triple.h:389
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:519
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2045
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1177
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition Triple.cpp:265
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:440
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:417
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1133
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1159
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:796
bool isWindowsGNUEnvironment() const
Definition Triple.h:729
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1683
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1700
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:1892
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2088
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1663
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1411
bool isSPIROrSPIRV() const
Definition Triple.h:915
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2320
@ loongarch32
Definition Triple.h:64
@ renderscript64
Definition Triple.h:111
@ UnknownArch
Definition Triple.h:50
@ loongarch64
Definition Triple.h:65
@ renderscript32
Definition Triple.h:110
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1647
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:423
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1434
static LLVM_ABI std::string normalize(StringRef Str, CanonicalForm Form=CanonicalForm::ANY)
Turn an arbitrary machine specification into the canonical triple form (or something sensible that th...
Definition Triple.cpp:1178
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:446
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:414
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:1779
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:791
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1417
bool isSimulatorEnvironment() const
Definition Triple.h:633
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1634
const std::string & str() const
Definition Triple.h:481
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:431
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1609
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1597
static LLVM_ABI StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition Triple.cpp:24
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition Triple.h:809
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:291
@ UnknownObjectFormat
Definition Triple.h:321
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:938
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2175
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:745
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1114
bool isAMDGPU() const
Definition Triple.h:930
@ UnknownVendor
Definition Triple.h:189
@ ImaginationTechnologies
Definition Triple.h:196
@ MipsTechnologies
Definition Triple.h:197
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:923
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2201
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1797
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1423
@ ARMSubArch_v6t2
Definition Triple.h:149
@ MipsSubArch_r6
Definition Triple.h:162
@ DXILSubArch_v1_2
Definition Triple.h:178
@ ARMSubArch_v7
Definition Triple.h:140
@ ARMSubArch_v8m_mainline
Definition Triple.h:138
@ ARMSubArch_v9_6a
Definition Triple.h:119
@ ARMSubArch_v8r
Definition Triple.h:136
@ ARMSubArch_v9_1a
Definition Triple.h:124
@ DXILSubArch_v1_1
Definition Triple.h:177
@ LatestDXILSubArch
Definition Triple.h:186
@ SPIRVSubArch_v10
Definition Triple.h:167
@ SPIRVSubArch_v13
Definition Triple.h:170
@ ARMSubArch_v7k
Definition Triple.h:144
@ ARMSubArch_v8_7a
Definition Triple.h:128
@ ARMSubArch_v8
Definition Triple.h:135
@ SPIRVSubArch_v16
Definition Triple.h:173
@ ARMSubArch_v8_1a
Definition Triple.h:134
@ ARMSubArch_v9_2a
Definition Triple.h:123
@ DXILSubArch_v1_3
Definition Triple.h:179
@ SPIRVSubArch_v15
Definition Triple.h:172
@ ARMSubArch_v7m
Definition Triple.h:142
@ ARMSubArch_v9_7a
Definition Triple.h:118
@ ARMSubArch_v6k
Definition Triple.h:148
@ ARMSubArch_v5
Definition Triple.h:150
@ AArch64SubArch_arm64e
Definition Triple.h:154
@ ARMSubArch_v6
Definition Triple.h:146
@ ARMSubArch_v9_5a
Definition Triple.h:120
@ ARMSubArch_v7ve
Definition Triple.h:145
@ ARMSubArch_v8m_baseline
Definition Triple.h:137
@ ARMSubArch_v8_8a
Definition Triple.h:127
@ ARMSubArch_v8_2a
Definition Triple.h:133
@ ARMSubArch_v7s
Definition Triple.h:143
@ DXILSubArch_v1_0
Definition Triple.h:176
@ DXILSubArch_v1_7
Definition Triple.h:183
@ KalimbaSubArch_v3
Definition Triple.h:158
@ DXILSubArch_v1_5
Definition Triple.h:181
@ ARMSubArch_v8_4a
Definition Triple.h:131
@ ARMSubArch_v8_9a
Definition Triple.h:126
@ ARMSubArch_v7em
Definition Triple.h:141
@ SPIRVSubArch_v12
Definition Triple.h:169
@ SPIRVSubArch_v14
Definition Triple.h:171
@ KalimbaSubArch_v4
Definition Triple.h:159
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:139
@ ARMSubArch_v8_3a
Definition Triple.h:132
@ AArch64SubArch_arm64ec
Definition Triple.h:155
@ ARMSubArch_v8_6a
Definition Triple.h:129
@ ARMSubArch_v5te
Definition Triple.h:151
@ KalimbaSubArch_v5
Definition Triple.h:160
@ ARMSubArch_v4t
Definition Triple.h:152
@ DXILSubArch_v1_6
Definition Triple.h:182
@ DXILSubArch_v1_8
Definition Triple.h:184
@ ARMSubArch_v9_4a
Definition Triple.h:121
@ ARMSubArch_v8_5a
Definition Triple.h:130
@ AArch64SubArch_lfi
Definition Triple.h:156
@ ARMSubArch_v6m
Definition Triple.h:147
@ ARMSubArch_v9_3a
Definition Triple.h:122
@ DXILSubArch_v1_9
Definition Triple.h:185
@ ARMSubArch_v9
Definition Triple.h:125
@ DXILSubArch_v1_4
Definition Triple.h:180
@ SPIRVSubArch_v11
Definition Triple.h:168
@ PPCSubArch_spe
Definition Triple.h:164
LLVM_ABI bool getMacOSXVersion(VersionTuple &Version) const
Parse the version number as with getOSVersion and then translate generic "darwin" versions to the cor...
Definition Triple.cpp:1475
static LLVM_ABI bool isValidVersionForOS(OSType OSKind, const VersionTuple &Version)
Returns whether an OS version is invalid and would not map to an Apple OS.
Definition Triple.cpp:2289
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:583
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1695
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1659
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1687
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:420
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1125
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:628
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:343
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:547
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:486
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1066
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1149
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1402
bool isMacCatalystEnvironment() const
Definition Triple.h:637
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1029
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:416
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:1805
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:1975
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1523
LLVM_ABI StringRef getEnvironmentVersionString() const
Get the version component of the environment component as a single string (the version after the envi...
Definition Triple.cpp:1438
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:1801
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2140
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:786
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:426
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition Triple.cpp:175
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition Triple.cpp:1651
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1655
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1053
bool isWindowsItaniumEnvironment() const
Definition Triple.h:721
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Definition Twine.cpp:17
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getMajor() const
Retrieve the major version number.
LLVM_ABI bool tryParse(StringRef string)
Try to parse the given string as a version number.
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI StringRef getCanonicalArchName(StringRef Arch)
MArch is expected to be of the form (arm|thumb)?(eb)?(v.
LLVM_ABI ISAKind parseArchISA(StringRef Arch)
LLVM_ABI ArchKind parseArch(StringRef Arch)
LLVM_ABI ProfileKind parseArchProfile(StringRef Arch)
LLVM_ABI unsigned parseArchVersion(StringRef Arch)
LLVM_ABI EndianKind parseArchEndian(StringRef Arch)
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
constexpr bool IsLittleEndianHost
This is an optimization pass for GlobalISel generic memory operations.
ExceptionHandling
Definition CodeGen.h:53
@ SjLj
setjmp/longjmp based exceptions
Definition CodeGen.h:56
@ ZOS
z/OS MVS Exception Handling.
Definition CodeGen.h:61
@ None
No exception support.
Definition CodeGen.h:54
@ AIX
AIX Exception Handling.
Definition CodeGen.h:60
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:55
@ WinEH
Windows Exception Handling.
Definition CodeGen.h:58
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:167
@ Other
Any other memory.
Definition ModRef.h:68
std::string join(IteratorT Begin, IteratorT End, StringRef Separator)
Joins the strings in the range [Begin, End), adding Separator between the elements.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1888
@ Default
The result values are uniform if and only if all operands are uniform.
Definition Uniformity.h:20
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:872