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