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