LLVM 23.0.0git
Triple.cpp
Go to the documentation of this file.
1//===--- Triple.cpp - Target triple helper class --------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/ADT/DenseMap.h"
20#include <cassert>
21#include <cstring>
22using namespace llvm;
23
25 switch (Kind) {
26 case UnknownArch:
27 return "unknown";
28
29 case aarch64:
30 return "aarch64";
31 case aarch64_32:
32 return "aarch64_32";
33 case aarch64_be:
34 return "aarch64_be";
35 case amdgcn:
36 return "amdgcn";
37 case amdil64:
38 return "amdil64";
39 case amdil:
40 return "amdil";
41 case arc:
42 return "arc";
43 case arm:
44 return "arm";
45 case armeb:
46 return "armeb";
47 case avr:
48 return "avr";
49 case bpfeb:
50 return "bpfeb";
51 case bpfel:
52 return "bpfel";
53 case csky:
54 return "csky";
55 case dxil:
56 return "dxil";
57 case hexagon:
58 return "hexagon";
59 case hsail64:
60 return "hsail64";
61 case hsail:
62 return "hsail";
63 case kalimba:
64 return "kalimba";
65 case lanai:
66 return "lanai";
67 case loongarch32:
68 return "loongarch32";
69 case loongarch64:
70 return "loongarch64";
71 case m68k:
72 return "m68k";
73 case mips64:
74 return "mips64";
75 case mips64el:
76 return "mips64el";
77 case mips:
78 return "mips";
79 case mipsel:
80 return "mipsel";
81 case msp430:
82 return "msp430";
83 case nvptx64:
84 return "nvptx64";
85 case nvptx:
86 return "nvptx";
87 case ppc64:
88 return "powerpc64";
89 case ppc64le:
90 return "powerpc64le";
91 case ppc:
92 return "powerpc";
93 case ppcle:
94 return "powerpcle";
95 case r600:
96 return "r600";
97 case renderscript32:
98 return "renderscript32";
99 case renderscript64:
100 return "renderscript64";
101 case riscv32:
102 return "riscv32";
103 case riscv64:
104 return "riscv64";
105 case riscv32be:
106 return "riscv32be";
107 case riscv64be:
108 return "riscv64be";
109 case shave:
110 return "shave";
111 case sparc:
112 return "sparc";
113 case sparcel:
114 return "sparcel";
115 case sparcv9:
116 return "sparcv9";
117 case spir64:
118 return "spir64";
119 case spir:
120 return "spir";
121 case spirv:
122 return "spirv";
123 case spirv32:
124 return "spirv32";
125 case spirv64:
126 return "spirv64";
127 case systemz:
128 return "s390x";
129 case tce:
130 return "tce";
131 case tcele:
132 return "tcele";
133 case tcele64:
134 return "tcele64";
135 case thumb:
136 return "thumb";
137 case thumbeb:
138 return "thumbeb";
139 case ve:
140 return "ve";
141 case wasm32:
142 return "wasm32";
143 case wasm64:
144 return "wasm64";
145 case x86:
146 return "i386";
147 case x86_64:
148 return "x86_64";
149 case xcore:
150 return "xcore";
151 case xtensa:
152 return "xtensa";
153 }
154
155 llvm_unreachable("Invalid ArchType!");
156}
157
159 switch (Kind) {
160 case Triple::mips:
161 if (SubArch == MipsSubArch_r6)
162 return "mipsisa32r6";
163 break;
164 case Triple::mipsel:
165 if (SubArch == MipsSubArch_r6)
166 return "mipsisa32r6el";
167 break;
168 case Triple::mips64:
169 if (SubArch == MipsSubArch_r6)
170 return "mipsisa64r6";
171 break;
172 case Triple::mips64el:
173 if (SubArch == MipsSubArch_r6)
174 return "mipsisa64r6el";
175 break;
176 case Triple::aarch64:
177 if (SubArch == AArch64SubArch_arm64ec)
178 return "arm64ec";
179 if (SubArch == AArch64SubArch_arm64e)
180 return "arm64e";
181 if (SubArch == AArch64SubArch_lfi)
182 return "aarch64_lfi";
183 break;
184 case Triple::spirv:
185 switch (SubArch) {
187 return "spirv1.0";
189 return "spirv1.1";
191 return "spirv1.2";
193 return "spirv1.3";
195 return "spirv1.4";
197 return "spirv1.5";
199 return "spirv1.6";
200 default:
201 break;
202 }
203 break;
204 case Triple::dxil:
205 switch (SubArch) {
208 return "dxilv1.0";
210 return "dxilv1.1";
212 return "dxilv1.2";
214 return "dxilv1.3";
216 return "dxilv1.4";
218 return "dxilv1.5";
220 return "dxilv1.6";
222 return "dxilv1.7";
224 return "dxilv1.8";
226 return "dxilv1.9";
227 default:
228 break;
229 }
230 break;
231 default:
232 break;
233 }
234 return getArchTypeName(Kind);
235}
236
238 switch (Kind) {
239 default:
240 return StringRef();
241
242 case aarch64:
243 case aarch64_be:
244 case aarch64_32:
245 return "aarch64";
246
247 case arc:
248 return "arc";
249
250 case arm:
251 case armeb:
252 case thumb:
253 case thumbeb:
254 return "arm";
255
256 case avr:
257 return "avr";
258
259 case ppc64:
260 case ppc64le:
261 case ppc:
262 case ppcle:
263 return "ppc";
264
265 case m68k:
266 return "m68k";
267
268 case mips:
269 case mipsel:
270 case mips64:
271 case mips64el:
272 return "mips";
273
274 case hexagon:
275 return "hexagon";
276
277 case amdgcn:
278 return "amdgcn";
279 case r600:
280 return "r600";
281
282 case bpfel:
283 case bpfeb:
284 return "bpf";
285
286 case sparcv9:
287 case sparcel:
288 case sparc:
289 return "sparc";
290
291 case systemz:
292 return "s390";
293
294 case x86:
295 case x86_64:
296 return "x86";
297
298 case xcore:
299 return "xcore";
300
301 // NVPTX intrinsics are namespaced under nvvm.
302 case nvptx:
303 return "nvvm";
304 case nvptx64:
305 return "nvvm";
306
307 case amdil:
308 case amdil64:
309 return "amdil";
310
311 case hsail:
312 case hsail64:
313 return "hsail";
314
315 case spir:
316 case spir64:
317 return "spir";
318
319 case spirv:
320 case spirv32:
321 case spirv64:
322 return "spv";
323
324 case kalimba:
325 return "kalimba";
326 case lanai:
327 return "lanai";
328 case shave:
329 return "shave";
330 case wasm32:
331 case wasm64:
332 return "wasm";
333
334 case riscv32:
335 case riscv64:
336 case riscv32be:
337 case riscv64be:
338 return "riscv";
339
340 case ve:
341 return "ve";
342 case csky:
343 return "csky";
344
345 case loongarch32:
346 case loongarch64:
347 return "loongarch";
348
349 case dxil:
350 return "dx";
351
352 case xtensa:
353 return "xtensa";
354 }
355}
356
358 switch (Kind) {
359 case UnknownVendor:
360 return "unknown";
361
362 case AMD:
363 return "amd";
364 case Apple:
365 return "apple";
366 case CSR:
367 return "csr";
368 case Freescale:
369 return "fsl";
370 case IBM:
371 return "ibm";
373 return "img";
374 case Intel:
375 return "intel";
376 case Mesa:
377 return "mesa";
378 case MipsTechnologies:
379 return "mti";
380 case NVIDIA:
381 return "nvidia";
382 case OpenEmbedded:
383 return "oe";
384 case PC:
385 return "pc";
386 case SCEI:
387 return "scei";
388 case SUSE:
389 return "suse";
390 case Meta:
391 return "meta";
392 }
393
394 llvm_unreachable("Invalid VendorType!");
395}
396
398 switch (Kind) {
399 case UnknownOS:
400 return "unknown";
401
402 case AIX:
403 return "aix";
404 case AMDHSA:
405 return "amdhsa";
406 case AMDPAL:
407 return "amdpal";
408 case BridgeOS:
409 return "bridgeos";
410 case CUDA:
411 return "cuda";
412 case Darwin:
413 return "darwin";
414 case DragonFly:
415 return "dragonfly";
416 case DriverKit:
417 return "driverkit";
418 case ELFIAMCU:
419 return "elfiamcu";
420 case Emscripten:
421 return "emscripten";
422 case FreeBSD:
423 return "freebsd";
424 case Fuchsia:
425 return "fuchsia";
426 case Haiku:
427 return "haiku";
428 case HermitCore:
429 return "hermit";
430 case Hurd:
431 return "hurd";
432 case IOS:
433 return "ios";
434 case KFreeBSD:
435 return "kfreebsd";
436 case Linux:
437 return "linux";
438 case Lv2:
439 return "lv2";
440 case MacOSX:
441 return "macosx";
442 case Managarm:
443 return "managarm";
444 case Mesa3D:
445 return "mesa3d";
446 case NVCL:
447 return "nvcl";
448 case NetBSD:
449 return "netbsd";
450 case OpenBSD:
451 return "openbsd";
452 case PS4:
453 return "ps4";
454 case PS5:
455 return "ps5";
456 case RTEMS:
457 return "rtems";
458 case Solaris:
459 return "solaris";
460 case Serenity:
461 return "serenity";
462 case TvOS:
463 return "tvos";
464 case UEFI:
465 return "uefi";
466 case WASI:
467 return "wasi";
468 case WASIp1:
469 return "wasip1";
470 case WASIp2:
471 return "wasip2";
472 case WASIp3:
473 return "wasip3";
474 case WatchOS:
475 return "watchos";
476 case Win32:
477 return "windows";
478 case ZOS:
479 return "zos";
480 case ShaderModel:
481 return "shadermodel";
482 case LiteOS:
483 return "liteos";
484 case XROS:
485 return "xros";
486 case Vulkan:
487 return "vulkan";
488 case CheriotRTOS:
489 return "cheriotrtos";
490 case OpenCL:
491 return "opencl";
492 case ChipStar:
493 return "chipstar";
494 case Firmware:
495 return "firmware";
496 case QURT:
497 return "qurt";
498 case H2:
499 return "h2";
500 }
501
502 llvm_unreachable("Invalid OSType");
503}
504
506 switch (Kind) {
508 return "unknown";
509 case Android:
510 return "android";
511 case CODE16:
512 return "code16";
513 case CoreCLR:
514 return "coreclr";
515 case Cygnus:
516 return "cygnus";
517 case EABI:
518 return "eabi";
519 case EABIHF:
520 return "eabihf";
521 case GNU:
522 return "gnu";
523 case GNUT64:
524 return "gnut64";
525 case GNUABI64:
526 return "gnuabi64";
527 case GNUABIN32:
528 return "gnuabin32";
529 case GNUEABI:
530 return "gnueabi";
531 case GNUEABIT64:
532 return "gnueabit64";
533 case GNUEABIHF:
534 return "gnueabihf";
535 case GNUEABIHFT64:
536 return "gnueabihft64";
537 case GNUF32:
538 return "gnuf32";
539 case GNUF64:
540 return "gnuf64";
541 case GNUSF:
542 return "gnusf";
543 case GNUX32:
544 return "gnux32";
545 case GNUILP32:
546 return "gnu_ilp32";
547 case Itanium:
548 return "itanium";
549 case MSVC:
550 return "msvc";
551 case MacABI:
552 return "macabi";
553 case Musl:
554 return "musl";
555 case MuslABIN32:
556 return "muslabin32";
557 case MuslABI64:
558 return "muslabi64";
559 case MuslEABI:
560 return "musleabi";
561 case MuslEABIHF:
562 return "musleabihf";
563 case MuslF32:
564 return "muslf32";
565 case MuslSF:
566 return "muslsf";
567 case MuslX32:
568 return "muslx32";
569 case MuslWALI:
570 return "muslwali";
571 case Simulator:
572 return "simulator";
573 case Pixel:
574 return "pixel";
575 case Vertex:
576 return "vertex";
577 case Geometry:
578 return "geometry";
579 case Hull:
580 return "hull";
581 case Domain:
582 return "domain";
583 case Compute:
584 return "compute";
585 case Library:
586 return "library";
587 case RayGeneration:
588 return "raygeneration";
589 case Intersection:
590 return "intersection";
591 case AnyHit:
592 return "anyhit";
593 case ClosestHit:
594 return "closesthit";
595 case Miss:
596 return "miss";
597 case Callable:
598 return "callable";
599 case Mesh:
600 return "mesh";
601 case Amplification:
602 return "amplification";
603 case RootSignature:
604 return "rootsignature";
605 case OpenHOS:
606 return "ohos";
607 case PAuthTest:
608 return "pauthtest";
609 case MTIA:
610 return "mtia";
611 case LLVM:
612 return "llvm";
613 case Mlibc:
614 return "mlibc";
615 }
616
617 llvm_unreachable("Invalid EnvironmentType!");
618}
619
621 switch (Kind) {
623 return "";
624 case COFF:
625 return "coff";
626 case ELF:
627 return "elf";
628 case GOFF:
629 return "goff";
630 case MachO:
631 return "macho";
632 case Wasm:
633 return "wasm";
634 case XCOFF:
635 return "xcoff";
636 case DXContainer:
637 return "dxcontainer";
638 case SPIRV:
639 return "spirv";
640 }
641 llvm_unreachable("unknown object format type");
642}
643
645 if (ArchName == "bpf") {
647 return Triple::bpfel;
648 else
649 return Triple::bpfeb;
650 } else if (ArchName == "bpf_be" || ArchName == "bpfeb") {
651 return Triple::bpfeb;
652 } else if (ArchName == "bpf_le" || ArchName == "bpfel") {
653 return Triple::bpfel;
654 } else {
655 return Triple::UnknownArch;
656 }
657}
658
660 Triple::ArchType BPFArch(parseBPFArch(Name));
662 .Case("aarch64", aarch64)
663 .Case("aarch64_be", aarch64_be)
664 .Case("aarch64_32", aarch64_32)
665 .Case("arc", arc)
666 .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
667 .Case("arm64_32", aarch64_32)
668 .Case("arm", arm)
669 .Case("armeb", armeb)
670 .Case("avr", avr)
671 .StartsWith("bpf", BPFArch)
672 .Case("m68k", m68k)
673 .Case("mips", mips)
674 .Case("mipsel", mipsel)
675 .Case("mips64", mips64)
676 .Case("mips64el", mips64el)
677 .Case("msp430", msp430)
678 .Case("ppc64", ppc64)
679 .Case("ppc32", ppc)
680 .Case("ppc", ppc)
681 .Case("ppc32le", ppcle)
682 .Case("ppcle", ppcle)
683 .Case("ppc64le", ppc64le)
684 .Case("r600", r600)
685 .Case("amdgcn", amdgcn)
686 .Case("riscv32", riscv32)
687 .Case("riscv64", riscv64)
688 .Case("riscv32be", riscv32be)
689 .Case("riscv64be", riscv64be)
690 .Case("hexagon", hexagon)
691 .Case("sparc", sparc)
692 .Case("sparcel", sparcel)
693 .Case("sparcv9", sparcv9)
694 .Case("s390x", systemz)
695 .Case("systemz", systemz)
696 .Case("tce", tce)
697 .Case("tcele", tcele)
698 .Case("tcele64", tcele64)
699 .Case("thumb", thumb)
700 .Case("thumbeb", thumbeb)
701 .Case("x86", x86)
702 .Case("i386", x86)
703 .Case("x86-64", x86_64)
704 .Case("xcore", xcore)
705 .Case("nvptx", nvptx)
706 .Case("nvptx64", nvptx64)
707 .Case("amdil", amdil)
708 .Case("amdil64", amdil64)
709 .Case("hsail", hsail)
710 .Case("hsail64", hsail64)
711 .Case("spir", spir)
712 .Case("spir64", spir64)
713 .Case("spirv", spirv)
714 .Case("spirv32", spirv32)
715 .Case("spirv64", spirv64)
716 .Case("kalimba", kalimba)
717 .Case("lanai", lanai)
718 .Case("shave", shave)
719 .Case("wasm32", wasm32)
720 .Case("wasm64", wasm64)
721 .Case("renderscript32", renderscript32)
722 .Case("renderscript64", renderscript64)
723 .Case("ve", ve)
724 .Case("csky", csky)
725 .Case("loongarch32", loongarch32)
726 .Case("loongarch64", loongarch64)
727 .Case("dxil", dxil)
728 .Case("xtensa", xtensa)
730}
731
733 ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
734 ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
735
737 switch (ENDIAN) {
739 switch (ISA) {
741 arch = Triple::arm;
742 break;
744 arch = Triple::thumb;
745 break;
747 arch = Triple::aarch64;
748 break;
750 break;
751 }
752 break;
753 }
755 switch (ISA) {
757 arch = Triple::armeb;
758 break;
760 arch = Triple::thumbeb;
761 break;
763 arch = Triple::aarch64_be;
764 break;
766 break;
767 }
768 break;
769 }
771 break;
772 }
773 }
774
775 ArchName = ARM::getCanonicalArchName(ArchName);
776 if (ArchName.empty())
777 return Triple::UnknownArch;
778
779 // Thumb only exists in v4+
780 if (ISA == ARM::ISAKind::THUMB &&
781 (ArchName.starts_with("v2") || ArchName.starts_with("v3")))
782 return Triple::UnknownArch;
783
784 // Thumb only for v6m
786 unsigned Version = ARM::parseArchVersion(ArchName);
787 if (Profile == ARM::ProfileKind::M && Version == 6) {
788 if (ENDIAN == ARM::EndianKind::BIG)
789 return Triple::thumbeb;
790 else
791 return Triple::thumb;
792 }
793
794 return arch;
795}
796
798 auto AT =
800 .Cases({"i386", "i486", "i586", "i686"}, Triple::x86)
801 // FIXME: Do we need to support these?
802 .Cases({"i786", "i886", "i986"}, Triple::x86)
803 .Cases({"amd64", "x86_64", "x86_64h"}, Triple::x86_64)
804 .Cases({"powerpc", "powerpcspe", "ppc", "ppc32"}, Triple::ppc)
805 .Cases({"powerpcle", "ppcle", "ppc32le"}, Triple::ppcle)
806 .Cases({"powerpc64", "ppu", "ppc64"}, Triple::ppc64)
807 .Cases({"powerpc64le", "ppc64le"}, Triple::ppc64le)
808 .Case("xscale", Triple::arm)
809 .Case("xscaleeb", Triple::armeb)
810 .Case("aarch64", Triple::aarch64)
811 .Case("aarch64_be", Triple::aarch64_be)
812 .Case("aarch64_32", Triple::aarch64_32)
813 .Case("aarch64_lfi", Triple::aarch64)
814 .Case("arc", Triple::arc)
815 .Case("arm64", Triple::aarch64)
816 .Case("arm64_32", Triple::aarch64_32)
817 .Case("arm64e", Triple::aarch64)
818 .Case("arm64ec", Triple::aarch64)
819 .Case("arm", Triple::arm)
820 .Case("armeb", Triple::armeb)
821 .Case("thumb", Triple::thumb)
822 .Case("thumbeb", Triple::thumbeb)
823 .Case("avr", Triple::avr)
824 .Case("m68k", Triple::m68k)
825 .Case("msp430", Triple::msp430)
826 .Cases({"mips", "mipseb", "mipsallegrex", "mipsisa32r6", "mipsr6"},
828 .Cases({"mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el"},
830 .Cases({"mips64", "mips64eb", "mipsn32", "mipsisa64r6", "mips64r6",
831 "mipsn32r6"},
833 .Cases({"mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
834 "mipsn32r6el"},
836 .Case("r600", Triple::r600)
837 .Case("amdgcn", Triple::amdgcn)
838 .Case("riscv32", Triple::riscv32)
839 .Case("riscv64", Triple::riscv64)
840 .Case("riscv32be", Triple::riscv32be)
841 .Case("riscv64be", Triple::riscv64be)
842 .Case("hexagon", Triple::hexagon)
843 .Cases({"s390x", "systemz"}, Triple::systemz)
844 .Case("sparc", Triple::sparc)
845 .Case("sparcel", Triple::sparcel)
846 .Cases({"sparcv9", "sparc64"}, Triple::sparcv9)
847 .Case("tce", Triple::tce)
848 .Case("tcele", Triple::tcele)
849 .Case("tcele64", Triple::tcele64)
850 .Case("xcore", Triple::xcore)
851 .Case("nvptx", Triple::nvptx)
852 .Case("nvptx64", Triple::nvptx64)
853 .Case("amdil", Triple::amdil)
854 .Case("amdil64", Triple::amdil64)
855 .Case("hsail", Triple::hsail)
856 .Case("hsail64", Triple::hsail64)
857 .Case("spir", Triple::spir)
858 .Case("spir64", Triple::spir64)
859 .Cases({"spirv", "spirv1.5", "spirv1.6"}, Triple::spirv)
860 .Cases({"spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
861 "spirv32v1.3", "spirv32v1.4", "spirv32v1.5", "spirv32v1.6"},
863 .Cases({"spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
864 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5", "spirv64v1.6"},
866 .StartsWith("kalimba", Triple::kalimba)
867 .Case("lanai", Triple::lanai)
868 .Case("renderscript32", Triple::renderscript32)
869 .Case("renderscript64", Triple::renderscript64)
870 .Case("shave", Triple::shave)
871 .Case("ve", Triple::ve)
872 .Case("wasm32", Triple::wasm32)
873 .Case("wasm64", Triple::wasm64)
874 .Case("csky", Triple::csky)
875 .Case("loongarch32", Triple::loongarch32)
876 .Case("loongarch64", Triple::loongarch64)
877 .Cases({"dxil", "dxilv1.0", "dxilv1.1", "dxilv1.2", "dxilv1.3",
878 "dxilv1.4", "dxilv1.5", "dxilv1.6", "dxilv1.7", "dxilv1.8",
879 "dxilv1.9"},
881 .Case("xtensa", Triple::xtensa)
883
884 // Some architectures require special parsing logic just to compute the
885 // ArchType result.
886 if (AT == Triple::UnknownArch) {
887 if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
888 ArchName.starts_with("aarch64"))
889 return parseARMArch(ArchName);
890 if (ArchName.starts_with("bpf"))
891 return parseBPFArch(ArchName);
892 }
893
894 return AT;
895}
896
898 return StringSwitch<Triple::VendorType>(VendorName)
899 .Case("apple", Triple::Apple)
900 .Case("pc", Triple::PC)
901 .Case("scei", Triple::SCEI)
902 .Case("sie", Triple::SCEI)
903 .Case("fsl", Triple::Freescale)
904 .Case("ibm", Triple::IBM)
907 .Case("nvidia", Triple::NVIDIA)
908 .Case("csr", Triple::CSR)
909 .Case("amd", Triple::AMD)
910 .Case("mesa", Triple::Mesa)
911 .Case("suse", Triple::SUSE)
913 .Case("intel", Triple::Intel)
914 .Case("meta", Triple::Meta)
916}
917
919 return StringSwitch<Triple::OSType>(OSName)
920 .StartsWith("darwin", Triple::Darwin)
921 .StartsWith("dragonfly", Triple::DragonFly)
922 .StartsWith("freebsd", Triple::FreeBSD)
923 .StartsWith("fuchsia", Triple::Fuchsia)
924 .StartsWith("ios", Triple::IOS)
925 .StartsWith("kfreebsd", Triple::KFreeBSD)
926 .StartsWith("linux", Triple::Linux)
927 .StartsWith("lv2", Triple::Lv2)
928 .StartsWith("macos", Triple::MacOSX)
929 .StartsWith("managarm", Triple::Managarm)
930 .StartsWith("netbsd", Triple::NetBSD)
931 .StartsWith("openbsd", Triple::OpenBSD)
932 .StartsWith("solaris", Triple::Solaris)
933 .StartsWith("uefi", Triple::UEFI)
934 .StartsWith("win32", Triple::Win32)
935 .StartsWith("windows", Triple::Win32)
936 .StartsWith("zos", Triple::ZOS)
937 .StartsWith("haiku", Triple::Haiku)
938 .StartsWith("rtems", Triple::RTEMS)
939 .StartsWith("aix", Triple::AIX)
940 .StartsWith("cuda", Triple::CUDA)
941 .StartsWith("nvcl", Triple::NVCL)
942 .StartsWith("amdhsa", Triple::AMDHSA)
943 .StartsWith("ps4", Triple::PS4)
944 .StartsWith("ps5", Triple::PS5)
945 .StartsWith("elfiamcu", Triple::ELFIAMCU)
946 .StartsWith("tvos", Triple::TvOS)
947 .StartsWith("watchos", Triple::WatchOS)
948 .StartsWith("bridgeos", Triple::BridgeOS)
949 .StartsWith("driverkit", Triple::DriverKit)
950 .StartsWith("xros", Triple::XROS)
951 .StartsWith("visionos", Triple::XROS)
952 .StartsWith("mesa3d", Triple::Mesa3D)
953 .StartsWith("amdpal", Triple::AMDPAL)
955 .StartsWith("hurd", Triple::Hurd)
956 .StartsWith("wasip1", Triple::WASIp1)
957 .StartsWith("wasip2", Triple::WASIp2)
958 .StartsWith("wasip3", Triple::WASIp3)
959 .StartsWith("wasi", Triple::WASI)
960 .StartsWith("emscripten", Triple::Emscripten)
961 .StartsWith("shadermodel", Triple::ShaderModel)
962 .StartsWith("liteos", Triple::LiteOS)
963 .StartsWith("serenity", Triple::Serenity)
964 .StartsWith("vulkan", Triple::Vulkan)
965 .StartsWith("cheriotrtos", Triple::CheriotRTOS)
966 .StartsWith("opencl", Triple::OpenCL)
967 .StartsWith("chipstar", Triple::ChipStar)
968 .StartsWith("firmware", Triple::Firmware)
969 .StartsWith("qurt", Triple::QURT)
970 .StartsWith("h2", Triple::H2)
972}
973
975 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
976 .StartsWith("eabihf", Triple::EABIHF)
977 .StartsWith("eabi", Triple::EABI)
978 .StartsWith("gnuabin32", Triple::GNUABIN32)
979 .StartsWith("gnuabi64", Triple::GNUABI64)
980 .StartsWith("gnueabihft64", Triple::GNUEABIHFT64)
981 .StartsWith("gnueabihf", Triple::GNUEABIHF)
982 .StartsWith("gnueabit64", Triple::GNUEABIT64)
983 .StartsWith("gnueabi", Triple::GNUEABI)
984 .StartsWith("gnuf32", Triple::GNUF32)
985 .StartsWith("gnuf64", Triple::GNUF64)
986 .StartsWith("gnusf", Triple::GNUSF)
987 .StartsWith("gnux32", Triple::GNUX32)
988 .StartsWith("gnu_ilp32", Triple::GNUILP32)
989 .StartsWith("code16", Triple::CODE16)
990 .StartsWith("gnut64", Triple::GNUT64)
991 .StartsWith("gnu", Triple::GNU)
992 .StartsWith("android", Triple::Android)
993 .StartsWith("muslabin32", Triple::MuslABIN32)
994 .StartsWith("muslabi64", Triple::MuslABI64)
995 .StartsWith("musleabihf", Triple::MuslEABIHF)
996 .StartsWith("musleabi", Triple::MuslEABI)
997 .StartsWith("muslf32", Triple::MuslF32)
998 .StartsWith("muslsf", Triple::MuslSF)
999 .StartsWith("muslx32", Triple::MuslX32)
1000 .StartsWith("muslwali", Triple::MuslWALI)
1001 .StartsWith("musl", Triple::Musl)
1002 .StartsWith("msvc", Triple::MSVC)
1003 .StartsWith("itanium", Triple::Itanium)
1004 .StartsWith("cygnus", Triple::Cygnus)
1005 .StartsWith("coreclr", Triple::CoreCLR)
1006 .StartsWith("simulator", Triple::Simulator)
1007 .StartsWith("macabi", Triple::MacABI)
1008 .StartsWith("pixel", Triple::Pixel)
1009 .StartsWith("vertex", Triple::Vertex)
1010 .StartsWith("geometry", Triple::Geometry)
1011 .StartsWith("hull", Triple::Hull)
1012 .StartsWith("domain", Triple::Domain)
1013 .StartsWith("compute", Triple::Compute)
1014 .StartsWith("library", Triple::Library)
1015 .StartsWith("raygeneration", Triple::RayGeneration)
1016 .StartsWith("intersection", Triple::Intersection)
1017 .StartsWith("anyhit", Triple::AnyHit)
1018 .StartsWith("closesthit", Triple::ClosestHit)
1019 .StartsWith("miss", Triple::Miss)
1020 .StartsWith("callable", Triple::Callable)
1021 .StartsWith("mesh", Triple::Mesh)
1022 .StartsWith("amplification", Triple::Amplification)
1023 .StartsWith("rootsignature", Triple::RootSignature)
1024 .StartsWith("ohos", Triple::OpenHOS)
1025 .StartsWith("pauthtest", Triple::PAuthTest)
1026 .StartsWith("llvm", Triple::LLVM)
1027 .StartsWith("mlibc", Triple::Mlibc)
1028 .StartsWith("mtia", Triple::MTIA)
1030}
1031
1033 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
1034 // "xcoff" must come before "coff" because of the order-dependendent
1035 // pattern matching.
1036 .EndsWith("xcoff", Triple::XCOFF)
1037 .EndsWith("coff", Triple::COFF)
1038 .EndsWith("elf", Triple::ELF)
1039 .EndsWith("goff", Triple::GOFF)
1040 .EndsWith("macho", Triple::MachO)
1041 .EndsWith("wasm", Triple::Wasm)
1042 .EndsWith("spirv", Triple::SPIRV)
1044}
1045
1047 if (SubArchName.starts_with("mips") &&
1048 (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
1050
1051 if (SubArchName == "powerpcspe")
1053
1054 if (SubArchName == "arm64e")
1056
1057 if (SubArchName == "arm64ec")
1059
1060 if (SubArchName == "aarch64_lfi")
1062
1063 if (SubArchName.starts_with("spirv"))
1064 return StringSwitch<Triple::SubArchType>(SubArchName)
1073
1074 if (SubArchName.starts_with("dxil"))
1075 return StringSwitch<Triple::SubArchType>(SubArchName)
1087
1088 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
1089
1090 // For now, this is the small part. Early return.
1091 if (ARMSubArch.empty())
1092 return StringSwitch<Triple::SubArchType>(SubArchName)
1097
1098 // ARM sub arch.
1099 switch (ARM::parseArch(ARMSubArch)) {
1100 case ARM::ArchKind::ARMV4:
1101 return Triple::NoSubArch;
1102 case ARM::ArchKind::ARMV4T:
1104 case ARM::ArchKind::ARMV5T:
1105 return Triple::ARMSubArch_v5;
1106 case ARM::ArchKind::ARMV5TE:
1107 case ARM::ArchKind::IWMMXT:
1108 case ARM::ArchKind::IWMMXT2:
1109 case ARM::ArchKind::XSCALE:
1110 case ARM::ArchKind::ARMV5TEJ:
1112 case ARM::ArchKind::ARMV6:
1113 return Triple::ARMSubArch_v6;
1114 case ARM::ArchKind::ARMV6K:
1115 case ARM::ArchKind::ARMV6KZ:
1117 case ARM::ArchKind::ARMV6T2:
1119 case ARM::ArchKind::ARMV6M:
1121 case ARM::ArchKind::ARMV7A:
1122 case ARM::ArchKind::ARMV7R:
1123 return Triple::ARMSubArch_v7;
1124 case ARM::ArchKind::ARMV7VE:
1126 case ARM::ArchKind::ARMV7K:
1128 case ARM::ArchKind::ARMV7M:
1130 case ARM::ArchKind::ARMV7S:
1132 case ARM::ArchKind::ARMV7EM:
1134 case ARM::ArchKind::ARMV8A:
1135 return Triple::ARMSubArch_v8;
1136 case ARM::ArchKind::ARMV8_1A:
1138 case ARM::ArchKind::ARMV8_2A:
1140 case ARM::ArchKind::ARMV8_3A:
1142 case ARM::ArchKind::ARMV8_4A:
1144 case ARM::ArchKind::ARMV8_5A:
1146 case ARM::ArchKind::ARMV8_6A:
1148 case ARM::ArchKind::ARMV8_7A:
1150 case ARM::ArchKind::ARMV8_8A:
1152 case ARM::ArchKind::ARMV8_9A:
1154 case ARM::ArchKind::ARMV9A:
1155 return Triple::ARMSubArch_v9;
1156 case ARM::ArchKind::ARMV9_1A:
1158 case ARM::ArchKind::ARMV9_2A:
1160 case ARM::ArchKind::ARMV9_3A:
1162 case ARM::ArchKind::ARMV9_4A:
1164 case ARM::ArchKind::ARMV9_5A:
1166 case ARM::ArchKind::ARMV9_6A:
1168 case ARM::ArchKind::ARMV9_7A:
1170 case ARM::ArchKind::ARMV8R:
1172 case ARM::ArchKind::ARMV8MBaseline:
1174 case ARM::ArchKind::ARMV8MMainline:
1176 case ARM::ArchKind::ARMV8_1MMainline:
1178 default:
1179 return Triple::NoSubArch;
1180 }
1181}
1182
1184 switch (T.getArch()) {
1186 case Triple::aarch64:
1187 case Triple::aarch64_32:
1188 case Triple::arm:
1189 case Triple::thumb:
1190 case Triple::x86:
1191 case Triple::x86_64:
1192 switch (T.getOS()) {
1193 case Triple::Win32:
1194 case Triple::UEFI:
1195 return Triple::COFF;
1196 default:
1197 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
1198 }
1199 case Triple::aarch64_be:
1200 case Triple::amdgcn:
1201 case Triple::amdil64:
1202 case Triple::amdil:
1203 case Triple::arc:
1204 case Triple::armeb:
1205 case Triple::avr:
1206 case Triple::bpfeb:
1207 case Triple::bpfel:
1208 case Triple::csky:
1209 case Triple::hexagon:
1210 case Triple::hsail64:
1211 case Triple::hsail:
1212 case Triple::kalimba:
1213 case Triple::lanai:
1216 case Triple::m68k:
1217 case Triple::mips64:
1218 case Triple::mips64el:
1219 case Triple::mips:
1220 case Triple::msp430:
1221 case Triple::nvptx64:
1222 case Triple::nvptx:
1223 case Triple::ppc64le:
1224 case Triple::ppcle:
1225 case Triple::r600:
1228 case Triple::riscv32:
1229 case Triple::riscv64:
1230 case Triple::riscv32be:
1231 case Triple::riscv64be:
1232 case Triple::shave:
1233 case Triple::sparc:
1234 case Triple::sparcel:
1235 case Triple::sparcv9:
1236 case Triple::spir64:
1237 case Triple::spir:
1238 case Triple::tce:
1239 case Triple::tcele:
1240 case Triple::tcele64:
1241 case Triple::thumbeb:
1242 case Triple::ve:
1243 case Triple::xcore:
1244 case Triple::xtensa:
1245 return Triple::ELF;
1246
1247 case Triple::mipsel:
1248 if (T.isOSWindows())
1249 return Triple::COFF;
1250 return Triple::ELF;
1251
1252 case Triple::ppc64:
1253 case Triple::ppc:
1254 if (T.isOSAIX())
1255 return Triple::XCOFF;
1256 if (T.isOSDarwin())
1257 return Triple::MachO;
1258 return Triple::ELF;
1259
1260 case Triple::systemz:
1261 if (T.isOSzOS())
1262 return Triple::GOFF;
1263 return Triple::ELF;
1264
1265 case Triple::wasm32:
1266 case Triple::wasm64:
1267 return Triple::Wasm;
1268
1269 case Triple::spirv:
1270 case Triple::spirv32:
1271 case Triple::spirv64:
1272 return Triple::SPIRV;
1273
1274 case Triple::dxil:
1275 return Triple::DXContainer;
1276 }
1277 llvm_unreachable("unknown architecture");
1278}
1279
1280/// Construct a triple from the string representation provided.
1281///
1282/// This stores the string representation and parses the various pieces into
1283/// enum members.
1284Triple::Triple(std::string &&Str) : Data(std::move(Str)) {
1285 // Do minimal parsing by hand here.
1286 SmallVector<StringRef, 4> Components;
1287 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
1288 if (Components.size() > 0) {
1289 Arch = parseArch(Components[0]);
1290 SubArch = parseSubArch(Components[0]);
1291 if (Components.size() > 1) {
1292 Vendor = parseVendor(Components[1]);
1293 if (Components.size() > 2) {
1294 OS = parseOS(Components[2]);
1295 if (Components.size() > 3) {
1296 Environment = parseEnvironment(Components[3]);
1297 ObjectFormat = parseFormat(Components[3]);
1298 }
1299 }
1300 } else {
1301 Environment =
1303 .StartsWith("mipsn32", Triple::GNUABIN32)
1304 .StartsWith("mips64", Triple::GNUABI64)
1305 .StartsWith("mipsisa64", Triple::GNUABI64)
1306 .StartsWith("mipsisa32", Triple::GNU)
1307 .Cases({"mips", "mipsel", "mipsr6", "mipsr6el"}, Triple::GNU)
1309 }
1310 }
1311 if (ObjectFormat == UnknownObjectFormat)
1312 ObjectFormat = getDefaultFormat(*this);
1313}
1314
1315Triple::Triple(const Twine &Str) : Triple(Str.str()) {}
1316
1317/// Construct a triple from string representations of the architecture,
1318/// vendor, and OS.
1319///
1320/// This joins each argument into a canonical string representation and parses
1321/// them into enum members. It leaves the environment unknown and omits it from
1322/// the string representation.
1323Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1324 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1325 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1326 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1327 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1328 ObjectFormat = getDefaultFormat(*this);
1329}
1330
1331/// Construct a triple from string representations of the architecture,
1332/// vendor, OS, and environment.
1333///
1334/// This joins each argument into a canonical string representation and parses
1335/// them into enum members.
1336Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1337 const Twine &EnvironmentStr)
1338 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1339 EnvironmentStr)
1340 .str()),
1341 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1342 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1343 Environment(parseEnvironment(EnvironmentStr.str())),
1344 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1345 if (ObjectFormat == Triple::UnknownObjectFormat)
1346 ObjectFormat = getDefaultFormat(*this);
1347}
1348
1350 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1351 Twine('-') + getOSTypeName(OS))
1352 .str()),
1353 Arch(A), SubArch(SA), Vendor(V), OS(OS),
1354 ObjectFormat(getDefaultFormat(*this)) {}
1355
1358 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1359 Twine('-') + getOSTypeName(OS) + Twine('-') +
1361 .str()),
1362 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1363 ObjectFormat(getDefaultFormat(*this)) {}
1364
1367 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1368 Twine('-') + getOSTypeName(OS) + Twine('-') +
1369 getEnvironmentTypeName(E) + Twine('-') +
1371 .str()),
1372 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1373 ObjectFormat(OF) {}
1374
1376
1378 VersionTuple Ver =
1379 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1380 // Default DXIL minor version when Shader Model version is anything other
1381 // than 6.[0...9] or 6.x (which translates to latest current SM version)
1382 const unsigned SMMajor = 6;
1383 if (!Ver.empty()) {
1384 if (Ver.getMajor() == SMMajor) {
1385 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1386 switch (*SMMinor) {
1387 case 0:
1389 case 1:
1391 case 2:
1393 case 3:
1395 case 4:
1397 case 5:
1399 case 6:
1401 case 7:
1403 case 8:
1405 case 9:
1407 default:
1408 report_fatal_error("Unsupported Shader Model version", false);
1409 }
1410 }
1411 }
1412 } else {
1413 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1414 // shadermodel6.x is
1415 if (ShaderModelStr == "shadermodel6.x") {
1417 }
1418 }
1419 // DXIL version corresponding to Shader Model version other than 6.Minor
1420 // is 1.0
1422}
1423
1425 bool IsMinGW32 = false;
1426 bool IsCygwin = false;
1427
1428 // Parse into components.
1429 SmallVector<StringRef, 4> Components;
1430 Str.split(Components, '-');
1431
1432 // If the first component corresponds to a known architecture, preferentially
1433 // use it for the architecture. If the second component corresponds to a
1434 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1435 // component movement when a component parses as (eg) both a valid arch and a
1436 // valid os.
1437 ArchType Arch = UnknownArch;
1438 if (Components.size() > 0)
1439 Arch = parseArch(Components[0]);
1440 VendorType Vendor = UnknownVendor;
1441 if (Components.size() > 1)
1442 Vendor = parseVendor(Components[1]);
1443 OSType OS = UnknownOS;
1444 if (Components.size() > 2) {
1445 OS = parseOS(Components[2]);
1446 IsCygwin = Components[2].starts_with("cygwin") ||
1447 Components[2].starts_with("msys");
1448 IsMinGW32 = Components[2].starts_with("mingw");
1449 }
1450 EnvironmentType Environment = UnknownEnvironment;
1451 if (Components.size() > 3)
1452 Environment = parseEnvironment(Components[3]);
1454 if (Components.size() > 4)
1455 ObjectFormat = parseFormat(Components[4]);
1456
1457 // Note which components are already in their final position. These will not
1458 // be moved.
1459 bool Found[4];
1460 Found[0] = Arch != UnknownArch;
1461 Found[1] = Vendor != UnknownVendor;
1462 Found[2] = OS != UnknownOS;
1463 Found[3] = Environment != UnknownEnvironment;
1464
1465 // If they are not there already, permute the components into their canonical
1466 // positions by seeing if they parse as a valid architecture, and if so moving
1467 // the component to the architecture position etc.
1468 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1469 if (Found[Pos])
1470 continue; // Already in the canonical position.
1471
1472 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1473 // Do not reparse any components that already matched.
1474 if (Idx < std::size(Found) && Found[Idx])
1475 continue;
1476
1477 // Does this component parse as valid for the target position?
1478 bool Valid = false;
1479 StringRef Comp = Components[Idx];
1480 switch (Pos) {
1481 default:
1482 llvm_unreachable("unexpected component type!");
1483 case 0:
1484 Arch = parseArch(Comp);
1485 Valid = Arch != UnknownArch;
1486 break;
1487 case 1:
1488 Vendor = parseVendor(Comp);
1489 Valid = Vendor != UnknownVendor;
1490 break;
1491 case 2:
1492 OS = parseOS(Comp);
1493 IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
1494 IsMinGW32 = Comp.starts_with("mingw");
1495 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1496 break;
1497 case 3:
1498 Environment = parseEnvironment(Comp);
1499 Valid = Environment != UnknownEnvironment;
1500 if (!Valid) {
1501 ObjectFormat = parseFormat(Comp);
1502 Valid = ObjectFormat != UnknownObjectFormat;
1503 }
1504 break;
1505 }
1506 if (!Valid)
1507 continue; // Nope, try the next component.
1508
1509 // Move the component to the target position, pushing any non-fixed
1510 // components that are in the way to the right. This tends to give
1511 // good results in the common cases of a forgotten vendor component
1512 // or a wrongly positioned environment.
1513 if (Pos < Idx) {
1514 // Insert left, pushing the existing components to the right. For
1515 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1516 StringRef CurrentComponent(""); // The empty component.
1517 // Replace the component we are moving with an empty component.
1518 std::swap(CurrentComponent, Components[Idx]);
1519 // Insert the component being moved at Pos, displacing any existing
1520 // components to the right.
1521 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1522 // Skip over any fixed components.
1523 while (i < std::size(Found) && Found[i])
1524 ++i;
1525 // Place the component at the new position, getting the component
1526 // that was at this position - it will be moved right.
1527 std::swap(CurrentComponent, Components[i]);
1528 }
1529 } else if (Pos > Idx) {
1530 // Push right by inserting empty components until the component at Idx
1531 // reaches the target position Pos. For example, pc-a -> -pc-a when
1532 // moving pc to the second position.
1533 do {
1534 // Insert one empty component at Idx.
1535 StringRef CurrentComponent(""); // The empty component.
1536 for (unsigned i = Idx; i < Components.size();) {
1537 // Place the component at the new position, getting the component
1538 // that was at this position - it will be moved right.
1539 std::swap(CurrentComponent, Components[i]);
1540 // If it was placed on top of an empty component then we are done.
1541 if (CurrentComponent.empty())
1542 break;
1543 // Advance to the next component, skipping any fixed components.
1544 while (++i < std::size(Found) && Found[i])
1545 ;
1546 }
1547 // The last component was pushed off the end - append it.
1548 if (!CurrentComponent.empty())
1549 Components.push_back(CurrentComponent);
1550
1551 // Advance Idx to the component's new position.
1552 while (++Idx < std::size(Found) && Found[Idx])
1553 ;
1554 } while (Idx < Pos); // Add more until the final position is reached.
1555 }
1556 assert(Pos < Components.size() && Components[Pos] == Comp &&
1557 "Component moved wrong!");
1558 Found[Pos] = true;
1559 break;
1560 }
1561 }
1562
1563 // If "none" is in the middle component in a three-component triple, treat it
1564 // as the OS (Components[2]) instead of the vendor (Components[1]).
1565 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1566 Components[1] == "none" && Components[2].empty())
1567 std::swap(Components[1], Components[2]);
1568
1569 // Replace empty components with "unknown" value.
1570 for (StringRef &C : Components)
1571 if (C.empty())
1572 C = "unknown";
1573
1574 // Special case logic goes here. At this point Arch, Vendor and OS have the
1575 // correct values for the computed components.
1576 std::string NormalizedEnvironment;
1577 if (Environment == Triple::Android &&
1578 Components[3].starts_with("androideabi")) {
1579 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1580 if (AndroidVersion.empty()) {
1581 Components[3] = "android";
1582 } else {
1583 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1584 Components[3] = NormalizedEnvironment;
1585 }
1586 }
1587
1588 // SUSE uses "gnueabi" to mean "gnueabihf"
1589 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1590 Components[3] = "gnueabihf";
1591
1592 if (OS == Triple::Win32) {
1593 Components.resize(4);
1594 Components[2] = "windows";
1595 if (Environment == UnknownEnvironment) {
1596 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1597 Components[3] = "msvc";
1598 else
1599 Components[3] = getObjectFormatTypeName(ObjectFormat);
1600 }
1601 } else if (IsMinGW32) {
1602 Components.resize(4);
1603 Components[2] = "windows";
1604 Components[3] = "gnu";
1605 } else if (IsCygwin) {
1606 Components.resize(4);
1607 Components[2] = "windows";
1608 Components[3] = "cygnus";
1609 }
1610 if (IsMinGW32 || IsCygwin ||
1611 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1612 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1613 Components.resize(5);
1614 Components[4] = getObjectFormatTypeName(ObjectFormat);
1615 }
1616 }
1617
1618 // Normalize DXIL triple if it does not include DXIL version number.
1619 // Determine DXIL version number using the minor version number of Shader
1620 // Model version specified in target triple, if any. Prior to decoupling DXIL
1621 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1622 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1623 if (Components[0] == "dxil") {
1624 if (Components.size() > 4) {
1625 Components.resize(4);
1626 }
1627 // Add DXIL version only if shadermodel is specified in the triple
1628 if (OS == Triple::ShaderModel) {
1629 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1630 }
1631 }
1632
1633 // Currently the firmware OS is an Apple specific concept.
1634 if ((Components.size() > 2) && (Components[2] == "firmware") &&
1635 (Components[1] != "apple"))
1637 "the firmware target os is only supported for the apple vendor");
1638
1639 // Canonicalize the components if necessary.
1640 switch (Form) {
1641 case CanonicalForm::ANY:
1642 break;
1646 Components.resize(static_cast<unsigned>(Form), "unknown");
1647 break;
1648 }
1649 }
1650
1651 // Stick the corrected components back together to form the normalized string.
1652 return join(Components, "-");
1653}
1654
1656 return StringRef(Data).split('-').first; // Isolate first component
1657}
1658
1660 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1661 return Tmp.split('-').first; // Isolate second component
1662}
1663
1665 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1666 Tmp = Tmp.split('-').second; // Strip second component
1667 return Tmp.split('-').first; // Isolate third component
1668}
1669
1671 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1672 Tmp = Tmp.split('-').second; // Strip second component
1673 return Tmp.split('-').second; // Strip third component
1674}
1675
1677 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1678 return Tmp.split('-').second; // Strip second component
1679}
1680
1682 VersionTuple Version;
1683 Version.tryParse(Name);
1684 return Version.withoutBuild();
1685}
1686
1690
1692 StringRef EnvironmentName = getEnvironmentName();
1693
1694 // none is a valid environment type - it basically amounts to a freestanding
1695 // environment.
1696 if (EnvironmentName == "none")
1697 return "";
1698
1699 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1700 EnvironmentName.consume_front(EnvironmentTypeName);
1701
1702 if (EnvironmentName.contains("-")) {
1703 // -obj is the suffix
1705 StringRef ObjectFormatTypeName =
1707 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1708 EnvironmentName.consume_back(tmp);
1709 }
1710 }
1711 return EnvironmentName;
1712}
1713
1715 StringRef OSName = getOSName();
1716 // Assume that the OS portion of the triple starts with the canonical name.
1717 StringRef OSTypeName = getOSTypeName(getOS());
1718 if (OSName.starts_with(OSTypeName))
1719 OSName = OSName.substr(OSTypeName.size());
1720 else if (getOS() == MacOSX)
1721 OSName.consume_front("macos");
1722 else if (OSName.starts_with("visionos"))
1723 OSName.consume_front("visionos");
1724
1725 return parseVersionFromName(OSName);
1726}
1727
1730
1731 switch (getOS()) {
1732 default:
1733 llvm_unreachable("unexpected OS for Darwin triple");
1734 case Darwin:
1735 // Default to darwin8, i.e., MacOSX 10.4.
1736 if (Version.getMajor() == 0)
1737 Version = VersionTuple(8);
1738 // Darwin version numbers are skewed from OS X versions.
1739 if (Version.getMajor() < 4) {
1740 return false;
1741 }
1742 if (Version.getMajor() <= 19) {
1743 Version = VersionTuple(10, Version.getMajor() - 4);
1744 } else if (Version.getMajor() < 25) {
1745 // darwin20-24 corresponds to macOS 11-15.
1746 Version = VersionTuple(11 + Version.getMajor() - 20);
1747 } else {
1748 // darwin25 corresponds with macOS26+.
1749 Version = VersionTuple(Version.getMajor() + 1);
1750 }
1751 break;
1752 case MacOSX:
1753 // Default to 10.4.
1754 if (Version.getMajor() == 0) {
1755 Version = VersionTuple(10, 4);
1756 } else if (Version.getMajor() < 10) {
1757 return false;
1758 }
1759 break;
1760 case IOS:
1761 case TvOS:
1762 case WatchOS:
1763 // Ignore the version from the triple. This is only handled because the
1764 // the clang driver combines OS X and IOS support into a common Darwin
1765 // toolchain that wants to know the OS X version number even when targeting
1766 // IOS.
1767 Version = VersionTuple(10, 4);
1768 break;
1769 case XROS:
1770 llvm_unreachable("OSX version isn't relevant for xrOS");
1771 case DriverKit:
1772 llvm_unreachable("OSX version isn't relevant for DriverKit");
1773 case Firmware:
1774 llvm_unreachable("OSX version isn't relevant for Firmware");
1775 }
1776 return true;
1777}
1778
1780 switch (getOS()) {
1781 default:
1782 llvm_unreachable("unexpected OS for Darwin triple");
1783 case Darwin:
1784 case MacOSX:
1785 // Ignore the version from the triple. This is only handled because the
1786 // the clang driver combines OS X and IOS support into a common Darwin
1787 // toolchain that wants to know the iOS version number even when targeting
1788 // OS X.
1789 return VersionTuple(5);
1790 case IOS:
1791 case TvOS: {
1793 // Default to 5.0 (or 7.0 for arm64).
1794 if (Version.getMajor() == 0)
1795 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1796 if (Version.getMajor() == 19)
1797 // tvOS 19 corresponds to ios26.
1798 return VersionTuple(26);
1801 }
1802 case XROS: {
1804 // xrOS 1 is aligned with iOS 17.
1805 if (Version.getMajor() < 3)
1806 return Version.withMajorReplaced(Version.getMajor() + 16);
1807 // visionOS 3 corresponds to ios 26+.
1808 if (Version.getMajor() == 3)
1809 return VersionTuple(26);
1812 }
1813 case WatchOS: {
1815 // watchOS 12 corresponds to ios 26.
1816 if (Version.getMajor() == 12)
1817 return VersionTuple(26);
1821 }
1822 case BridgeOS:
1823 llvm_unreachable("conflicting triple info");
1824 case DriverKit:
1825 llvm_unreachable("DriverKit doesn't have an iOS version");
1826 case Firmware:
1827 llvm_unreachable("iOS version isn't relevant for Firmware");
1828 }
1829}
1830
1832 switch (getOS()) {
1833 default:
1834 llvm_unreachable("unexpected OS for Darwin triple");
1835 case Darwin:
1836 case MacOSX:
1837 // Ignore the version from the triple. This is only handled because the
1838 // the clang driver combines OS X and IOS support into a common Darwin
1839 // toolchain that wants to know the iOS version number even when targeting
1840 // OS X.
1841 return VersionTuple(2);
1842 case WatchOS: {
1844 if (Version.getMajor() == 0)
1845 return VersionTuple(2);
1846 return Version;
1847 }
1848 case IOS:
1849 llvm_unreachable("conflicting triple info");
1850 case XROS:
1851 llvm_unreachable("watchOS version isn't relevant for xrOS");
1852 case DriverKit:
1853 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1854 case Firmware:
1855 llvm_unreachable("watchOS version isn't relevant for Firmware");
1856 }
1857}
1858
1860 switch (getOS()) {
1861 default:
1862 llvm_unreachable("unexpected OS for Darwin triple");
1863 case DriverKit:
1865 if (Version.getMajor() == 0)
1866 return Version.withMajorReplaced(19);
1867 return Version;
1868 }
1869}
1870
1872 if (getArch() != spirv || getOS() != Vulkan)
1873 llvm_unreachable("invalid Vulkan SPIR-V triple");
1874
1875 VersionTuple VulkanVersion = getOSVersion();
1876 SubArchType SpirvVersion = getSubArch();
1877
1879 // Vulkan 1.2 -> SPIR-V 1.5.
1881 // Vulkan 1.3 -> SPIR-V 1.6.
1883
1884 // If Vulkan version is unset, default to 1.2.
1885 if (VulkanVersion == VersionTuple(0))
1886 VulkanVersion = VersionTuple(1, 2);
1887
1888 if (ValidVersionMap.contains(VulkanVersion) &&
1889 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1890 SpirvVersion == NoSubArch))
1891 return VulkanVersion;
1892
1893 return VersionTuple(0);
1894}
1895
1897 if (getArch() != dxil || getOS() != ShaderModel)
1898 llvm_unreachable("invalid DXIL triple");
1899 StringRef Arch = getArchName();
1900 if (getSubArch() == NoSubArch)
1902 Arch.consume_front("dxilv");
1903 VersionTuple DXILVersion = parseVersionFromName(Arch);
1904 // FIXME: validate DXIL version against Shader Model version.
1905 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1906 return DXILVersion;
1907}
1908
1909void Triple::setTriple(const Twine &Str) { *this = Triple(Str); }
1910
1912 setArchName(getArchName(Kind, SubArch));
1913}
1914
1918
1920
1922 if (ObjectFormat == getDefaultFormat(*this))
1924
1926 getObjectFormatTypeName(ObjectFormat))
1927 .str());
1928}
1929
1931 if (Environment == UnknownEnvironment)
1933
1934 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1936 .str());
1937}
1938
1940 setTriple(Str + "-" + getVendorName() + "-" + getOSAndEnvironmentName());
1941}
1942
1944 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1945}
1946
1948 if (hasEnvironment())
1949 setTriple(getArchName() + "-" + getVendorName() + "-" + Str + "-" +
1951 else
1952 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1953}
1954
1956 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() + "-" +
1957 Str);
1958}
1959
1961 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1962}
1963
1965 switch (Arch) {
1967 return 0;
1968
1969 case llvm::Triple::avr:
1971 return 16;
1972
1975 case llvm::Triple::arc:
1976 case llvm::Triple::arm:
1978 case llvm::Triple::csky:
1979 case llvm::Triple::dxil:
1985 case llvm::Triple::m68k:
1986 case llvm::Triple::mips:
1989 case llvm::Triple::ppc:
1991 case llvm::Triple::r600:
1998 case llvm::Triple::spir:
2000 case llvm::Triple::tce:
2005 case llvm::Triple::x86:
2008 return 32;
2009
2032 case llvm::Triple::ve:
2035 return 64;
2036 }
2037 llvm_unreachable("Invalid architecture value");
2038}
2039
2041 switch (getArch()) {
2042 default:
2043 break;
2044 case Triple::ppc:
2045 case Triple::ppcle:
2046 if (isOSLinux())
2047 return 40;
2048 break;
2049 case Triple::ppc64:
2050 case Triple::ppc64le:
2051 if (isOSLinux())
2052 return 48;
2053 break;
2054 }
2055 return 32;
2056}
2057
2059 return getArchPointerBitWidth(getArch()) == 64;
2060}
2061
2063 return getArchPointerBitWidth(getArch()) == 32;
2064}
2065
2067 return getArchPointerBitWidth(getArch()) == 16;
2068}
2069
2071 Triple T(*this);
2072 switch (getArch()) {
2074 case Triple::amdgcn:
2075 case Triple::avr:
2076 case Triple::bpfeb:
2077 case Triple::bpfel:
2078 case Triple::msp430:
2079 case Triple::systemz:
2080 case Triple::ve:
2081 T.setArch(UnknownArch);
2082 break;
2083
2084 case Triple::aarch64_32:
2085 case Triple::amdil:
2086 case Triple::arc:
2087 case Triple::arm:
2088 case Triple::armeb:
2089 case Triple::csky:
2090 case Triple::dxil:
2091 case Triple::hexagon:
2092 case Triple::hsail:
2093 case Triple::kalimba:
2094 case Triple::lanai:
2096 case Triple::m68k:
2097 case Triple::mips:
2098 case Triple::mipsel:
2099 case Triple::nvptx:
2100 case Triple::ppc:
2101 case Triple::ppcle:
2102 case Triple::r600:
2104 case Triple::riscv32:
2105 case Triple::riscv32be:
2106 case Triple::shave:
2107 case Triple::sparc:
2108 case Triple::sparcel:
2109 case Triple::spir:
2110 case Triple::spirv32:
2111 case Triple::tce:
2112 case Triple::tcele:
2113 case Triple::thumb:
2114 case Triple::thumbeb:
2115 case Triple::wasm32:
2116 case Triple::x86:
2117 case Triple::xcore:
2118 case Triple::xtensa:
2119 // Already 32-bit.
2120 break;
2121
2122 case Triple::aarch64:
2123 T.setArch(Triple::arm);
2124 break;
2125 case Triple::aarch64_be:
2126 T.setArch(Triple::armeb);
2127 break;
2128 case Triple::amdil64:
2129 T.setArch(Triple::amdil);
2130 break;
2131 case Triple::hsail64:
2132 T.setArch(Triple::hsail);
2133 break;
2135 T.setArch(Triple::loongarch32);
2136 break;
2137 case Triple::mips64:
2138 T.setArch(Triple::mips, getSubArch());
2139 break;
2140 case Triple::mips64el:
2141 T.setArch(Triple::mipsel, getSubArch());
2142 break;
2143 case Triple::nvptx64:
2144 T.setArch(Triple::nvptx);
2145 break;
2146 case Triple::ppc64:
2147 T.setArch(Triple::ppc);
2148 break;
2149 case Triple::ppc64le:
2150 T.setArch(Triple::ppcle);
2151 break;
2153 T.setArch(Triple::renderscript32);
2154 break;
2155 case Triple::riscv64:
2156 T.setArch(Triple::riscv32);
2157 break;
2158 case Triple::riscv64be:
2159 T.setArch(Triple::riscv32be);
2160 break;
2161 case Triple::sparcv9:
2162 T.setArch(Triple::sparc);
2163 break;
2164 case Triple::spir64:
2165 T.setArch(Triple::spir);
2166 break;
2167 case Triple::spirv:
2168 case Triple::spirv64:
2169 T.setArch(Triple::spirv32, getSubArch());
2170 break;
2171 case Triple::tcele64:
2172 T.setArch(Triple::tcele);
2173 break;
2174 case Triple::wasm64:
2175 T.setArch(Triple::wasm32);
2176 break;
2177 case Triple::x86_64:
2178 T.setArch(Triple::x86);
2179 break;
2180 }
2181 return T;
2182}
2183
2185 Triple T(*this);
2186 switch (getArch()) {
2188 case Triple::arc:
2189 case Triple::avr:
2190 case Triple::csky:
2191 case Triple::dxil:
2192 case Triple::hexagon:
2193 case Triple::kalimba:
2194 case Triple::lanai:
2195 case Triple::m68k:
2196 case Triple::msp430:
2197 case Triple::r600:
2198 case Triple::shave:
2199 case Triple::sparcel:
2200 case Triple::tce:
2201 case Triple::xcore:
2202 case Triple::xtensa:
2203 T.setArch(UnknownArch);
2204 break;
2205
2206 case Triple::aarch64:
2207 case Triple::aarch64_be:
2208 case Triple::amdgcn:
2209 case Triple::amdil64:
2210 case Triple::bpfeb:
2211 case Triple::bpfel:
2212 case Triple::hsail64:
2214 case Triple::mips64:
2215 case Triple::mips64el:
2216 case Triple::nvptx64:
2217 case Triple::ppc64:
2218 case Triple::ppc64le:
2220 case Triple::riscv64:
2221 case Triple::riscv64be:
2222 case Triple::sparcv9:
2223 case Triple::spir64:
2224 case Triple::spirv64:
2225 case Triple::systemz:
2226 case Triple::tcele64:
2227 case Triple::ve:
2228 case Triple::wasm64:
2229 case Triple::x86_64:
2230 // Already 64-bit.
2231 break;
2232
2233 case Triple::aarch64_32:
2234 T.setArch(Triple::aarch64);
2235 break;
2236 case Triple::amdil:
2237 T.setArch(Triple::amdil64);
2238 break;
2239 case Triple::arm:
2240 T.setArch(Triple::aarch64);
2241 break;
2242 case Triple::armeb:
2243 T.setArch(Triple::aarch64_be);
2244 break;
2245 case Triple::hsail:
2246 T.setArch(Triple::hsail64);
2247 break;
2249 T.setArch(Triple::loongarch64);
2250 break;
2251 case Triple::mips:
2252 T.setArch(Triple::mips64, getSubArch());
2253 break;
2254 case Triple::mipsel:
2255 T.setArch(Triple::mips64el, getSubArch());
2256 break;
2257 case Triple::nvptx:
2258 T.setArch(Triple::nvptx64);
2259 break;
2260 case Triple::ppc:
2261 T.setArch(Triple::ppc64);
2262 break;
2263 case Triple::ppcle:
2264 T.setArch(Triple::ppc64le);
2265 break;
2267 T.setArch(Triple::renderscript64);
2268 break;
2269 case Triple::riscv32:
2270 T.setArch(Triple::riscv64);
2271 break;
2272 case Triple::riscv32be:
2273 T.setArch(Triple::riscv64be);
2274 break;
2275 case Triple::sparc:
2276 T.setArch(Triple::sparcv9);
2277 break;
2278 case Triple::spir:
2279 T.setArch(Triple::spir64);
2280 break;
2281 case Triple::spirv:
2282 case Triple::spirv32:
2283 T.setArch(Triple::spirv64, getSubArch());
2284 break;
2285 case Triple::tcele:
2286 T.setArch(Triple::tcele64);
2287 break;
2288 case Triple::thumb:
2289 T.setArch(Triple::aarch64);
2290 break;
2291 case Triple::thumbeb:
2292 T.setArch(Triple::aarch64_be);
2293 break;
2294 case Triple::wasm32:
2295 T.setArch(Triple::wasm64);
2296 break;
2297 case Triple::x86:
2298 T.setArch(Triple::x86_64);
2299 break;
2300 }
2301 return T;
2302}
2303
2305 Triple T(*this);
2306 // Already big endian.
2307 if (!isLittleEndian())
2308 return T;
2309 switch (getArch()) {
2311 case Triple::amdgcn:
2312 case Triple::amdil64:
2313 case Triple::amdil:
2314 case Triple::avr:
2315 case Triple::dxil:
2316 case Triple::hexagon:
2317 case Triple::hsail64:
2318 case Triple::hsail:
2319 case Triple::kalimba:
2322 case Triple::msp430:
2323 case Triple::nvptx64:
2324 case Triple::nvptx:
2325 case Triple::r600:
2328 case Triple::shave:
2329 case Triple::spir64:
2330 case Triple::spir:
2331 case Triple::spirv:
2332 case Triple::spirv32:
2333 case Triple::spirv64:
2334 case Triple::tcele64:
2335 case Triple::wasm32:
2336 case Triple::wasm64:
2337 case Triple::x86:
2338 case Triple::x86_64:
2339 case Triple::xcore:
2340 case Triple::ve:
2341 case Triple::csky:
2342 case Triple::xtensa:
2343
2344 // ARM is intentionally unsupported here, changing the architecture would
2345 // drop any arch suffixes.
2346 case Triple::arm:
2347 case Triple::thumb:
2348 T.setArch(UnknownArch);
2349 break;
2350
2351 case Triple::aarch64:
2352 T.setArch(Triple::aarch64_be);
2353 break;
2354 case Triple::bpfel:
2355 T.setArch(Triple::bpfeb);
2356 break;
2357 case Triple::mips64el:
2358 T.setArch(Triple::mips64, getSubArch());
2359 break;
2360 case Triple::mipsel:
2361 T.setArch(Triple::mips, getSubArch());
2362 break;
2363 case Triple::ppcle:
2364 T.setArch(Triple::ppc);
2365 break;
2366 case Triple::ppc64le:
2367 T.setArch(Triple::ppc64);
2368 break;
2369 case Triple::riscv32:
2370 T.setArch(Triple::riscv32be);
2371 break;
2372 case Triple::riscv64:
2373 T.setArch(Triple::riscv64be);
2374 break;
2375 case Triple::sparcel:
2376 T.setArch(Triple::sparc);
2377 break;
2378 case Triple::tcele:
2379 T.setArch(Triple::tce);
2380 break;
2381 default:
2382 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
2383 }
2384 return T;
2385}
2386
2388 Triple T(*this);
2389 if (isLittleEndian())
2390 return T;
2391
2392 switch (getArch()) {
2394 case Triple::lanai:
2395 case Triple::sparcv9:
2396 case Triple::systemz:
2397 case Triple::m68k:
2398
2399 // ARM is intentionally unsupported here, changing the architecture would
2400 // drop any arch suffixes.
2401 case Triple::armeb:
2402 case Triple::thumbeb:
2403 T.setArch(UnknownArch);
2404 break;
2405
2406 case Triple::aarch64_be:
2407 T.setArch(Triple::aarch64);
2408 break;
2409 case Triple::bpfeb:
2410 T.setArch(Triple::bpfel);
2411 break;
2412 case Triple::mips64:
2413 T.setArch(Triple::mips64el, getSubArch());
2414 break;
2415 case Triple::mips:
2416 T.setArch(Triple::mipsel, getSubArch());
2417 break;
2418 case Triple::ppc:
2419 T.setArch(Triple::ppcle);
2420 break;
2421 case Triple::ppc64:
2422 T.setArch(Triple::ppc64le);
2423 break;
2424 case Triple::riscv32be:
2425 T.setArch(Triple::riscv32);
2426 break;
2427 case Triple::riscv64be:
2428 T.setArch(Triple::riscv64);
2429 break;
2430 case Triple::sparc:
2431 T.setArch(Triple::sparcel);
2432 break;
2433 case Triple::tce:
2434 T.setArch(Triple::tcele);
2435 break;
2436 default:
2437 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
2438 }
2439 return T;
2440}
2441
2443 switch (getArch()) {
2444 case Triple::aarch64:
2445 case Triple::aarch64_32:
2446 case Triple::amdgcn:
2447 case Triple::amdil64:
2448 case Triple::amdil:
2449 case Triple::arm:
2450 case Triple::avr:
2451 case Triple::bpfel:
2452 case Triple::csky:
2453 case Triple::dxil:
2454 case Triple::hexagon:
2455 case Triple::hsail64:
2456 case Triple::hsail:
2457 case Triple::kalimba:
2460 case Triple::mips64el:
2461 case Triple::mipsel:
2462 case Triple::msp430:
2463 case Triple::nvptx64:
2464 case Triple::nvptx:
2465 case Triple::ppcle:
2466 case Triple::ppc64le:
2467 case Triple::r600:
2470 case Triple::riscv32:
2471 case Triple::riscv64:
2472 case Triple::shave:
2473 case Triple::sparcel:
2474 case Triple::spir64:
2475 case Triple::spir:
2476 case Triple::spirv:
2477 case Triple::spirv32:
2478 case Triple::spirv64:
2479 case Triple::tcele:
2480 case Triple::tcele64:
2481 case Triple::thumb:
2482 case Triple::ve:
2483 case Triple::wasm32:
2484 case Triple::wasm64:
2485 case Triple::x86:
2486 case Triple::x86_64:
2487 case Triple::xcore:
2488 case Triple::xtensa:
2489 return true;
2490 default:
2491 return false;
2492 }
2493}
2494
2496 if (getArch() == Triple::xcore)
2497 return 1;
2499 return 2;
2500 if (isOSAIX() && isArch32Bit())
2501 return 2;
2502 return 4;
2503}
2504
2506 // On MinGW, C code is usually built with a "w64" vendor, while Rust
2507 // often uses a "pc" vendor.
2508 bool IgnoreVendor = isWindowsGNUEnvironment();
2509
2510 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
2511 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2512 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2513 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2514 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2515 if (getVendor() == Triple::Apple)
2516 return getSubArch() == Other.getSubArch() &&
2517 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2518 else
2519 return getSubArch() == Other.getSubArch() &&
2520 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2521 getOS() == Other.getOS() &&
2522 getEnvironment() == Other.getEnvironment() &&
2523 getObjectFormat() == Other.getObjectFormat();
2524 }
2525
2526 // If vendor is apple, ignore the version number (the environment field)
2527 // and the object format.
2528 if (getVendor() == Triple::Apple)
2529 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2530 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2531 getOS() == Other.getOS();
2532
2533 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2534 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2535 getOS() == Other.getOS() &&
2536 getEnvironment() == Other.getEnvironment() &&
2537 getObjectFormat() == Other.getObjectFormat();
2538}
2539
2540std::string Triple::merge(const Triple &Other) const {
2541 // If vendor is apple, pick the triple with the larger version number.
2542 if (getVendor() == Triple::Apple)
2543 if (Other.isOSVersionLT(*this))
2544 return str();
2545
2546 return Other.str();
2547}
2548
2549bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2550 unsigned Micro) const {
2551 assert(isMacOSX() && "Not an OS X triple!");
2552
2553 // If this is OS X, expect a sane version number.
2554 if (getOS() == Triple::MacOSX)
2555 return isOSVersionLT(Major, Minor, Micro);
2556
2557 // Otherwise, compare to the "Darwin" number.
2558 if (Major == 10)
2559 return isOSVersionLT(Minor + 4, Micro, 0);
2560 assert(Major >= 11 && "Unexpected major version");
2561 if (Major < 25)
2562 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2563 return isOSVersionLT(Major + 1, Minor, Micro);
2564}
2565
2568 return VersionTuple();
2569 switch (getOS()) {
2570 case Triple::MacOSX:
2571 // ARM64 slice is supported starting from macOS 11.0+.
2572 return VersionTuple(11, 0, 0);
2573 case Triple::IOS:
2574 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2575 // ARM64 simulators are supported for iOS 14+.
2577 return VersionTuple(14, 0, 0);
2578 // ARM64e slice is supported starting from iOS 14.
2579 if (isArm64e())
2580 return VersionTuple(14, 0, 0);
2581 break;
2582 case Triple::TvOS:
2583 // ARM64 simulators are supported for tvOS 14+.
2585 return VersionTuple(14, 0, 0);
2586 break;
2587 case Triple::WatchOS:
2588 // ARM64 simulators are supported for watchOS 7+.
2590 return VersionTuple(7, 0, 0);
2591 // ARM64/ARM64e slices are supported starting from watchOS 26.
2592 // ARM64_32 is older though.
2594 return VersionTuple(26, 0, 0);
2595 case Triple::DriverKit:
2596 return VersionTuple(20, 0, 0);
2597 default:
2598 break;
2599 }
2600 return VersionTuple();
2601}
2602
2604 const VersionTuple &Version,
2605 bool IsInValidRange) {
2606 const unsigned MacOSRangeBump = 10;
2607 const unsigned IOSRangeBump = 7;
2608 const unsigned XROSRangeBump = 23;
2609 const unsigned WatchOSRangeBump = 14;
2610 switch (OSKind) {
2611 case MacOSX: {
2612 // macOS 10.16 is canonicalized to macOS 11.
2613 if (Version == VersionTuple(10, 16))
2614 return VersionTuple(11, 0);
2615 // macOS 16 is canonicalized to macOS 26.
2616 if (Version == VersionTuple(16, 0))
2617 return VersionTuple(26, 0);
2618 if (!IsInValidRange)
2619 return Version.withMajorReplaced(Version.getMajor() + MacOSRangeBump);
2620 break;
2621 }
2622 case IOS:
2623 case TvOS: {
2624 // Both iOS & tvOS 19.0 canonicalize to 26.
2625 if (Version == VersionTuple(19, 0))
2626 return VersionTuple(26, 0);
2627 if (!IsInValidRange)
2628 return Version.withMajorReplaced(Version.getMajor() + IOSRangeBump);
2629 break;
2630 }
2631 case XROS: {
2632 // visionOS3 is canonicalized to 26.
2633 if (Version == VersionTuple(3, 0))
2634 return VersionTuple(26, 0);
2635 if (!IsInValidRange)
2636 return Version.withMajorReplaced(Version.getMajor() + XROSRangeBump);
2637 break;
2638 }
2639 case WatchOS: {
2640 // watchOS 12 is canonicalized to 26.
2641 if (Version == VersionTuple(12, 0))
2642 return VersionTuple(26, 0);
2643 if (!IsInValidRange)
2644 return Version.withMajorReplaced(Version.getMajor() + WatchOSRangeBump);
2645 break;
2646 }
2647 default:
2648 return Version;
2649 }
2650
2651 return Version;
2652}
2653
2655 /// This constant is used to capture gaps in versioning.
2656 const VersionTuple CommonVersion(26);
2657 auto IsValid = [&](const VersionTuple &StartingVersion) {
2658 return !((Version > StartingVersion) && (Version < CommonVersion));
2659 };
2660 switch (OSKind) {
2661 case WatchOS: {
2662 const VersionTuple StartingWatchOS(12);
2663 return IsValid(StartingWatchOS);
2664 }
2665 case IOS:
2666 case TvOS: {
2667 const VersionTuple StartingIOS(19);
2668 return IsValid(StartingIOS);
2669 }
2670 case MacOSX: {
2671 const VersionTuple StartingMacOS(16);
2672 return IsValid(StartingMacOS);
2673 }
2674 case XROS: {
2675 const VersionTuple StartingXROS(3);
2676 return IsValid(StartingXROS);
2677 }
2678 default:
2679 return true;
2680 }
2681
2682 llvm_unreachable("unexpected or invalid os version");
2683}
2684
2686 if (isOSBinFormatCOFF()) {
2687 if (getArch() == Triple::x86 &&
2691 }
2692
2693 if (isOSBinFormatXCOFF())
2695 if (isOSBinFormatGOFF())
2697
2698 if (isARM() || isThumb()) {
2699 if (isOSBinFormatELF()) {
2702 }
2703
2706 }
2707
2708 if (isAArch64() || isX86() || isPPC() || isMIPS() || isSPARC() || isBPF() ||
2709 isRISCV() || isLoongArch())
2711
2712 switch (getArch()) {
2713 case Triple::arc:
2714 case Triple::csky:
2715 case Triple::hexagon:
2716 case Triple::lanai:
2717 case Triple::m68k:
2718 case Triple::msp430:
2719 case Triple::systemz:
2720 case Triple::xcore:
2721 case Triple::xtensa:
2723 default:
2724 break;
2725 }
2726
2727 // Explicitly none targets.
2728 if (isWasm() || isAMDGPU() || isNVPTX() || isSPIROrSPIRV())
2730
2731 // Default to none.
2733}
2734
2735// HLSL triple environment orders are relied on in the front end
2736static_assert(Triple::Vertex - Triple::Pixel == 1,
2737 "incorrect HLSL stage order");
2738static_assert(Triple::Geometry - Triple::Pixel == 2,
2739 "incorrect HLSL stage order");
2740static_assert(Triple::Hull - Triple::Pixel == 3, "incorrect HLSL stage order");
2741static_assert(Triple::Domain - Triple::Pixel == 4,
2742 "incorrect HLSL stage order");
2743static_assert(Triple::Compute - Triple::Pixel == 5,
2744 "incorrect HLSL stage order");
2745static_assert(Triple::Library - Triple::Pixel == 6,
2746 "incorrect HLSL stage order");
2747static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2748 "incorrect HLSL stage order");
2749static_assert(Triple::Intersection - Triple::Pixel == 8,
2750 "incorrect HLSL stage order");
2751static_assert(Triple::AnyHit - Triple::Pixel == 9,
2752 "incorrect HLSL stage order");
2753static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2754 "incorrect HLSL stage order");
2755static_assert(Triple::Miss - Triple::Pixel == 11, "incorrect HLSL stage order");
2756static_assert(Triple::Callable - Triple::Pixel == 12,
2757 "incorrect HLSL stage order");
2758static_assert(Triple::Mesh - Triple::Pixel == 13, "incorrect HLSL stage order");
2759static_assert(Triple::Amplification - Triple::Pixel == 14,
2760 "incorrect HLSL stage order");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
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:974
static VersionTuple parseVersionFromName(StringRef Name)
Definition Triple.cpp:1681
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition Triple.cpp:1183
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition Triple.cpp:732
static Triple::OSType parseOS(StringRef OSName)
Definition Triple.cpp:918
static StringRef getDXILArchNameFromShaderModel(StringRef ShaderModelStr)
Definition Triple.cpp:1377
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition Triple.cpp:644
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition Triple.cpp:1046
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition Triple.cpp:1032
static Triple::VendorType parseVendor(StringRef VendorName)
Definition Triple.cpp:897
Defines the llvm::VersionTuple class, which represents a version in the form major[....
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
Definition DenseMap.h:205
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition DenseMap.h:169
void resize(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition StringRef.h:730
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition StringRef.h:685
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:591
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:258
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition StringRef.h:629
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition StringRef.h:446
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition StringRef.h:270
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition StringRef.h:655
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & StartsWith(StringLiteral S, T Value)
StringSwitch & EndsWith(StringLiteral S, T Value)
StringSwitch & Cases(std::initializer_list< StringLiteral > CaseStrings, T Value)
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Comparison function for checking OS X version compatibility, which handles supporting skewed version ...
Definition Triple.cpp:2549
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1714
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1051
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1659
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1831
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1939
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1930
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:2070
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:735
bool isWatchABI() const
Definition Triple.h:620
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:315
@ UnknownEnvironment
Definition Triple.h:267
@ RootSignature
Definition Triple.h:323
@ Amplification
Definition Triple.h:322
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:913
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:2603
CanonicalForm
Canonical form.
Definition Triple.h:411
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:539
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2387
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1151
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition Triple.cpp:357
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:460
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:439
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1111
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1133
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:788
bool isWindowsGNUEnvironment() const
Definition Triple.h:730
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1943
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1960
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:2184
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2442
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1921
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1664
bool isSPIROrSPIRV() const
Definition Triple.h:897
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2685
@ loongarch32
Definition Triple.h:64
@ renderscript64
Definition Triple.h:115
@ UnknownArch
Definition Triple.h:50
@ loongarch64
Definition Triple.h:65
@ renderscript32
Definition Triple.h:114
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1909
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:445
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1687
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:1424
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:659
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:436
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:2040
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:785
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1670
bool isSimulatorEnvironment() const
Definition Triple.h:652
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1896
const std::string & str() const
Definition Triple.h:501
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:451
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1871
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1859
static LLVM_ABI ArchType parseArch(StringRef Str)
Parse anything recognized as an architecture for the first field of the triple.
Definition Triple.cpp:797
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:696
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:699
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:797
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:397
@ UnknownObjectFormat
Definition Triple.h:332
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:918
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2540
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:746
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1094
bool isAMDGPU() const
Definition Triple.h:910
@ UnknownVendor
Definition Triple.h:193
@ ImaginationTechnologies
Definition Triple.h:200
@ MipsTechnologies
Definition Triple.h:201
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:903
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:771
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2566
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:2058
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1676
@ ARMSubArch_v6t2
Definition Triple.h:153
@ MipsSubArch_r6
Definition Triple.h:166
@ DXILSubArch_v1_2
Definition Triple.h:182
@ ARMSubArch_v7
Definition Triple.h:144
@ ARMSubArch_v8m_mainline
Definition Triple.h:142
@ ARMSubArch_v9_6a
Definition Triple.h:123
@ ARMSubArch_v8r
Definition Triple.h:140
@ ARMSubArch_v9_1a
Definition Triple.h:128
@ DXILSubArch_v1_1
Definition Triple.h:181
@ LatestDXILSubArch
Definition Triple.h:190
@ SPIRVSubArch_v10
Definition Triple.h:171
@ SPIRVSubArch_v13
Definition Triple.h:174
@ ARMSubArch_v7k
Definition Triple.h:148
@ ARMSubArch_v8_7a
Definition Triple.h:132
@ ARMSubArch_v8
Definition Triple.h:139
@ SPIRVSubArch_v16
Definition Triple.h:177
@ ARMSubArch_v8_1a
Definition Triple.h:138
@ ARMSubArch_v9_2a
Definition Triple.h:127
@ DXILSubArch_v1_3
Definition Triple.h:183
@ SPIRVSubArch_v15
Definition Triple.h:176
@ ARMSubArch_v7m
Definition Triple.h:146
@ ARMSubArch_v9_7a
Definition Triple.h:122
@ ARMSubArch_v6k
Definition Triple.h:152
@ ARMSubArch_v5
Definition Triple.h:154
@ AArch64SubArch_arm64e
Definition Triple.h:158
@ ARMSubArch_v6
Definition Triple.h:150
@ ARMSubArch_v9_5a
Definition Triple.h:124
@ ARMSubArch_v7ve
Definition Triple.h:149
@ ARMSubArch_v8m_baseline
Definition Triple.h:141
@ ARMSubArch_v8_8a
Definition Triple.h:131
@ ARMSubArch_v8_2a
Definition Triple.h:137
@ ARMSubArch_v7s
Definition Triple.h:147
@ DXILSubArch_v1_0
Definition Triple.h:180
@ DXILSubArch_v1_7
Definition Triple.h:187
@ KalimbaSubArch_v3
Definition Triple.h:162
@ DXILSubArch_v1_5
Definition Triple.h:185
@ ARMSubArch_v8_4a
Definition Triple.h:135
@ ARMSubArch_v8_9a
Definition Triple.h:130
@ ARMSubArch_v7em
Definition Triple.h:145
@ SPIRVSubArch_v12
Definition Triple.h:173
@ SPIRVSubArch_v14
Definition Triple.h:175
@ KalimbaSubArch_v4
Definition Triple.h:163
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:143
@ ARMSubArch_v8_3a
Definition Triple.h:136
@ AArch64SubArch_arm64ec
Definition Triple.h:159
@ ARMSubArch_v8_6a
Definition Triple.h:133
@ ARMSubArch_v5te
Definition Triple.h:155
@ KalimbaSubArch_v5
Definition Triple.h:164
@ ARMSubArch_v4t
Definition Triple.h:156
@ DXILSubArch_v1_6
Definition Triple.h:186
@ DXILSubArch_v1_8
Definition Triple.h:188
@ ARMSubArch_v9_4a
Definition Triple.h:125
@ ARMSubArch_v8_5a
Definition Triple.h:134
@ AArch64SubArch_lfi
Definition Triple.h:160
@ ARMSubArch_v6m
Definition Triple.h:151
@ ARMSubArch_v9_3a
Definition Triple.h:126
@ DXILSubArch_v1_9
Definition Triple.h:189
@ ARMSubArch_v9
Definition Triple.h:129
@ DXILSubArch_v1_4
Definition Triple.h:184
@ SPIRVSubArch_v11
Definition Triple.h:172
@ PPCSubArch_spe
Definition Triple.h:168
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:1728
bool isWindowsCygwinEnvironment() const
Definition Triple.h:726
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:2654
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:603
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1955
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1919
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1947
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:442
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1105
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:645
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:505
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:567
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:506
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1048
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:823
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1125
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1655
bool isMacCatalystEnvironment() const
Definition Triple.h:656
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1009
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:620
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:2066
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2304
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1779
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:1691
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:2062
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2505
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:782
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:448
unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2495
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition Triple.cpp:237
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition Triple.cpp:1911
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1915
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1035
bool isWindowsItaniumEnvironment() const
Definition Triple.h:722
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:334
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
@ Other
Any other memory.
Definition ModRef.h:68
std::string join(IteratorT Begin, IteratorT End, StringRef Separator)
Joins the strings in the range [Begin, End), adding Separator between the elements.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1916
@ Default
The result value is uniform if and only if all operands are uniform.
Definition Uniformity.h:20
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:874
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:876