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