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