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