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