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 }
499
500 llvm_unreachable("Invalid OSType");
501}
502
504 switch (Kind) {
506 return "unknown";
507 case Android:
508 return "android";
509 case CODE16:
510 return "code16";
511 case CoreCLR:
512 return "coreclr";
513 case Cygnus:
514 return "cygnus";
515 case EABI:
516 return "eabi";
517 case EABIHF:
518 return "eabihf";
519 case GNU:
520 return "gnu";
521 case GNUT64:
522 return "gnut64";
523 case GNUABI64:
524 return "gnuabi64";
525 case GNUABIN32:
526 return "gnuabin32";
527 case GNUEABI:
528 return "gnueabi";
529 case GNUEABIT64:
530 return "gnueabit64";
531 case GNUEABIHF:
532 return "gnueabihf";
533 case GNUEABIHFT64:
534 return "gnueabihft64";
535 case GNUF32:
536 return "gnuf32";
537 case GNUF64:
538 return "gnuf64";
539 case GNUSF:
540 return "gnusf";
541 case GNUX32:
542 return "gnux32";
543 case GNUILP32:
544 return "gnu_ilp32";
545 case Itanium:
546 return "itanium";
547 case MSVC:
548 return "msvc";
549 case MacABI:
550 return "macabi";
551 case Musl:
552 return "musl";
553 case MuslABIN32:
554 return "muslabin32";
555 case MuslABI64:
556 return "muslabi64";
557 case MuslEABI:
558 return "musleabi";
559 case MuslEABIHF:
560 return "musleabihf";
561 case MuslF32:
562 return "muslf32";
563 case MuslSF:
564 return "muslsf";
565 case MuslX32:
566 return "muslx32";
567 case MuslWALI:
568 return "muslwali";
569 case Simulator:
570 return "simulator";
571 case Pixel:
572 return "pixel";
573 case Vertex:
574 return "vertex";
575 case Geometry:
576 return "geometry";
577 case Hull:
578 return "hull";
579 case Domain:
580 return "domain";
581 case Compute:
582 return "compute";
583 case Library:
584 return "library";
585 case RayGeneration:
586 return "raygeneration";
587 case Intersection:
588 return "intersection";
589 case AnyHit:
590 return "anyhit";
591 case ClosestHit:
592 return "closesthit";
593 case Miss:
594 return "miss";
595 case Callable:
596 return "callable";
597 case Mesh:
598 return "mesh";
599 case Amplification:
600 return "amplification";
601 case RootSignature:
602 return "rootsignature";
603 case OpenHOS:
604 return "ohos";
605 case PAuthTest:
606 return "pauthtest";
607 case MTIA:
608 return "mtia";
609 case LLVM:
610 return "llvm";
611 case Mlibc:
612 return "mlibc";
613 }
614
615 llvm_unreachable("Invalid EnvironmentType!");
616}
617
619 switch (Kind) {
621 return "";
622 case COFF:
623 return "coff";
624 case ELF:
625 return "elf";
626 case GOFF:
627 return "goff";
628 case MachO:
629 return "macho";
630 case Wasm:
631 return "wasm";
632 case XCOFF:
633 return "xcoff";
634 case DXContainer:
635 return "dxcontainer";
636 case SPIRV:
637 return "spirv";
638 }
639 llvm_unreachable("unknown object format type");
640}
641
643 if (ArchName == "bpf") {
645 return Triple::bpfel;
646 else
647 return Triple::bpfeb;
648 } else if (ArchName == "bpf_be" || ArchName == "bpfeb") {
649 return Triple::bpfeb;
650 } else if (ArchName == "bpf_le" || ArchName == "bpfel") {
651 return Triple::bpfel;
652 } else {
653 return Triple::UnknownArch;
654 }
655}
656
658 Triple::ArchType BPFArch(parseBPFArch(Name));
660 .Case("aarch64", aarch64)
661 .Case("aarch64_be", aarch64_be)
662 .Case("aarch64_32", aarch64_32)
663 .Case("arc", arc)
664 .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
665 .Case("arm64_32", aarch64_32)
666 .Case("arm", arm)
667 .Case("armeb", armeb)
668 .Case("avr", avr)
669 .StartsWith("bpf", BPFArch)
670 .Case("m68k", m68k)
671 .Case("mips", mips)
672 .Case("mipsel", mipsel)
673 .Case("mips64", mips64)
674 .Case("mips64el", mips64el)
675 .Case("msp430", msp430)
676 .Case("ppc64", ppc64)
677 .Case("ppc32", ppc)
678 .Case("ppc", ppc)
679 .Case("ppc32le", ppcle)
680 .Case("ppcle", ppcle)
681 .Case("ppc64le", ppc64le)
682 .Case("r600", r600)
683 .Case("amdgcn", amdgcn)
684 .Case("riscv32", riscv32)
685 .Case("riscv64", riscv64)
686 .Case("riscv32be", riscv32be)
687 .Case("riscv64be", riscv64be)
688 .Case("hexagon", hexagon)
689 .Case("sparc", sparc)
690 .Case("sparcel", sparcel)
691 .Case("sparcv9", sparcv9)
692 .Case("s390x", systemz)
693 .Case("systemz", systemz)
694 .Case("tce", tce)
695 .Case("tcele", tcele)
696 .Case("tcele64", tcele64)
697 .Case("thumb", thumb)
698 .Case("thumbeb", thumbeb)
699 .Case("x86", x86)
700 .Case("i386", x86)
701 .Case("x86-64", x86_64)
702 .Case("xcore", xcore)
703 .Case("nvptx", nvptx)
704 .Case("nvptx64", nvptx64)
705 .Case("amdil", amdil)
706 .Case("amdil64", amdil64)
707 .Case("hsail", hsail)
708 .Case("hsail64", hsail64)
709 .Case("spir", spir)
710 .Case("spir64", spir64)
711 .Case("spirv", spirv)
712 .Case("spirv32", spirv32)
713 .Case("spirv64", spirv64)
714 .Case("kalimba", kalimba)
715 .Case("lanai", lanai)
716 .Case("shave", shave)
717 .Case("wasm32", wasm32)
718 .Case("wasm64", wasm64)
719 .Case("renderscript32", renderscript32)
720 .Case("renderscript64", renderscript64)
721 .Case("ve", ve)
722 .Case("csky", csky)
723 .Case("loongarch32", loongarch32)
724 .Case("loongarch64", loongarch64)
725 .Case("dxil", dxil)
726 .Case("xtensa", xtensa)
728}
729
731 ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
732 ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
733
735 switch (ENDIAN) {
737 switch (ISA) {
739 arch = Triple::arm;
740 break;
742 arch = Triple::thumb;
743 break;
745 arch = Triple::aarch64;
746 break;
748 break;
749 }
750 break;
751 }
753 switch (ISA) {
755 arch = Triple::armeb;
756 break;
758 arch = Triple::thumbeb;
759 break;
761 arch = Triple::aarch64_be;
762 break;
764 break;
765 }
766 break;
767 }
769 break;
770 }
771 }
772
773 ArchName = ARM::getCanonicalArchName(ArchName);
774 if (ArchName.empty())
775 return Triple::UnknownArch;
776
777 // Thumb only exists in v4+
778 if (ISA == ARM::ISAKind::THUMB &&
779 (ArchName.starts_with("v2") || ArchName.starts_with("v3")))
780 return Triple::UnknownArch;
781
782 // Thumb only for v6m
784 unsigned Version = ARM::parseArchVersion(ArchName);
785 if (Profile == ARM::ProfileKind::M && Version == 6) {
786 if (ENDIAN == ARM::EndianKind::BIG)
787 return Triple::thumbeb;
788 else
789 return Triple::thumb;
790 }
791
792 return arch;
793}
794
796 auto AT =
798 .Cases({"i386", "i486", "i586", "i686"}, Triple::x86)
799 // FIXME: Do we need to support these?
800 .Cases({"i786", "i886", "i986"}, Triple::x86)
801 .Cases({"amd64", "x86_64", "x86_64h"}, Triple::x86_64)
802 .Cases({"powerpc", "powerpcspe", "ppc", "ppc32"}, Triple::ppc)
803 .Cases({"powerpcle", "ppcle", "ppc32le"}, Triple::ppcle)
804 .Cases({"powerpc64", "ppu", "ppc64"}, Triple::ppc64)
805 .Cases({"powerpc64le", "ppc64le"}, Triple::ppc64le)
806 .Case("xscale", Triple::arm)
807 .Case("xscaleeb", Triple::armeb)
808 .Case("aarch64", Triple::aarch64)
809 .Case("aarch64_be", Triple::aarch64_be)
810 .Case("aarch64_32", Triple::aarch64_32)
811 .Case("aarch64_lfi", Triple::aarch64)
812 .Case("arc", Triple::arc)
813 .Case("arm64", Triple::aarch64)
814 .Case("arm64_32", Triple::aarch64_32)
815 .Case("arm64e", Triple::aarch64)
816 .Case("arm64ec", Triple::aarch64)
817 .Case("arm", Triple::arm)
818 .Case("armeb", Triple::armeb)
819 .Case("thumb", Triple::thumb)
820 .Case("thumbeb", Triple::thumbeb)
821 .Case("avr", Triple::avr)
822 .Case("m68k", Triple::m68k)
823 .Case("msp430", Triple::msp430)
824 .Cases({"mips", "mipseb", "mipsallegrex", "mipsisa32r6", "mipsr6"},
826 .Cases({"mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el"},
828 .Cases({"mips64", "mips64eb", "mipsn32", "mipsisa64r6", "mips64r6",
829 "mipsn32r6"},
831 .Cases({"mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
832 "mipsn32r6el"},
834 .Case("r600", Triple::r600)
835 .Case("amdgcn", Triple::amdgcn)
836 .Case("riscv32", Triple::riscv32)
837 .Case("riscv64", Triple::riscv64)
838 .Case("riscv32be", Triple::riscv32be)
839 .Case("riscv64be", Triple::riscv64be)
840 .Case("hexagon", Triple::hexagon)
841 .Cases({"s390x", "systemz"}, Triple::systemz)
842 .Case("sparc", Triple::sparc)
843 .Case("sparcel", Triple::sparcel)
844 .Cases({"sparcv9", "sparc64"}, Triple::sparcv9)
845 .Case("tce", Triple::tce)
846 .Case("tcele", Triple::tcele)
847 .Case("tcele64", Triple::tcele64)
848 .Case("xcore", Triple::xcore)
849 .Case("nvptx", Triple::nvptx)
850 .Case("nvptx64", Triple::nvptx64)
851 .Case("amdil", Triple::amdil)
852 .Case("amdil64", Triple::amdil64)
853 .Case("hsail", Triple::hsail)
854 .Case("hsail64", Triple::hsail64)
855 .Case("spir", Triple::spir)
856 .Case("spir64", Triple::spir64)
857 .Cases({"spirv", "spirv1.5", "spirv1.6"}, Triple::spirv)
858 .Cases({"spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
859 "spirv32v1.3", "spirv32v1.4", "spirv32v1.5", "spirv32v1.6"},
861 .Cases({"spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
862 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5", "spirv64v1.6"},
864 .StartsWith("kalimba", Triple::kalimba)
865 .Case("lanai", Triple::lanai)
866 .Case("renderscript32", Triple::renderscript32)
867 .Case("renderscript64", Triple::renderscript64)
868 .Case("shave", Triple::shave)
869 .Case("ve", Triple::ve)
870 .Case("wasm32", Triple::wasm32)
871 .Case("wasm64", Triple::wasm64)
872 .Case("csky", Triple::csky)
873 .Case("loongarch32", Triple::loongarch32)
874 .Case("loongarch64", Triple::loongarch64)
875 .Cases({"dxil", "dxilv1.0", "dxilv1.1", "dxilv1.2", "dxilv1.3",
876 "dxilv1.4", "dxilv1.5", "dxilv1.6", "dxilv1.7", "dxilv1.8",
877 "dxilv1.9"},
879 .Case("xtensa", Triple::xtensa)
881
882 // Some architectures require special parsing logic just to compute the
883 // ArchType result.
884 if (AT == Triple::UnknownArch) {
885 if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
886 ArchName.starts_with("aarch64"))
887 return parseARMArch(ArchName);
888 if (ArchName.starts_with("bpf"))
889 return parseBPFArch(ArchName);
890 }
891
892 return AT;
893}
894
896 return StringSwitch<Triple::VendorType>(VendorName)
897 .Case("apple", Triple::Apple)
898 .Case("pc", Triple::PC)
899 .Case("scei", Triple::SCEI)
900 .Case("sie", Triple::SCEI)
901 .Case("fsl", Triple::Freescale)
902 .Case("ibm", Triple::IBM)
905 .Case("nvidia", Triple::NVIDIA)
906 .Case("csr", Triple::CSR)
907 .Case("amd", Triple::AMD)
908 .Case("mesa", Triple::Mesa)
909 .Case("suse", Triple::SUSE)
911 .Case("intel", Triple::Intel)
912 .Case("meta", Triple::Meta)
914}
915
917 return StringSwitch<Triple::OSType>(OSName)
918 .StartsWith("darwin", Triple::Darwin)
919 .StartsWith("dragonfly", Triple::DragonFly)
920 .StartsWith("freebsd", Triple::FreeBSD)
921 .StartsWith("fuchsia", Triple::Fuchsia)
922 .StartsWith("ios", Triple::IOS)
923 .StartsWith("kfreebsd", Triple::KFreeBSD)
924 .StartsWith("linux", Triple::Linux)
925 .StartsWith("lv2", Triple::Lv2)
926 .StartsWith("macos", Triple::MacOSX)
927 .StartsWith("managarm", Triple::Managarm)
928 .StartsWith("netbsd", Triple::NetBSD)
929 .StartsWith("openbsd", Triple::OpenBSD)
930 .StartsWith("solaris", Triple::Solaris)
931 .StartsWith("uefi", Triple::UEFI)
932 .StartsWith("win32", Triple::Win32)
933 .StartsWith("windows", Triple::Win32)
934 .StartsWith("zos", Triple::ZOS)
935 .StartsWith("haiku", Triple::Haiku)
936 .StartsWith("rtems", Triple::RTEMS)
937 .StartsWith("aix", Triple::AIX)
938 .StartsWith("cuda", Triple::CUDA)
939 .StartsWith("nvcl", Triple::NVCL)
940 .StartsWith("amdhsa", Triple::AMDHSA)
941 .StartsWith("ps4", Triple::PS4)
942 .StartsWith("ps5", Triple::PS5)
943 .StartsWith("elfiamcu", Triple::ELFIAMCU)
944 .StartsWith("tvos", Triple::TvOS)
945 .StartsWith("watchos", Triple::WatchOS)
946 .StartsWith("bridgeos", Triple::BridgeOS)
947 .StartsWith("driverkit", Triple::DriverKit)
948 .StartsWith("xros", Triple::XROS)
949 .StartsWith("visionos", Triple::XROS)
950 .StartsWith("mesa3d", Triple::Mesa3D)
951 .StartsWith("amdpal", Triple::AMDPAL)
953 .StartsWith("hurd", Triple::Hurd)
954 .StartsWith("wasip1", Triple::WASIp1)
955 .StartsWith("wasip2", Triple::WASIp2)
956 .StartsWith("wasip3", Triple::WASIp3)
957 .StartsWith("wasi", Triple::WASI)
958 .StartsWith("emscripten", Triple::Emscripten)
959 .StartsWith("shadermodel", Triple::ShaderModel)
960 .StartsWith("liteos", Triple::LiteOS)
961 .StartsWith("serenity", Triple::Serenity)
962 .StartsWith("vulkan", Triple::Vulkan)
963 .StartsWith("cheriotrtos", Triple::CheriotRTOS)
964 .StartsWith("opencl", Triple::OpenCL)
965 .StartsWith("chipstar", Triple::ChipStar)
966 .StartsWith("firmware", Triple::Firmware)
967 .StartsWith("qurt", Triple::QURT)
969}
970
972 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
973 .StartsWith("eabihf", Triple::EABIHF)
974 .StartsWith("eabi", Triple::EABI)
975 .StartsWith("gnuabin32", Triple::GNUABIN32)
976 .StartsWith("gnuabi64", Triple::GNUABI64)
977 .StartsWith("gnueabihft64", Triple::GNUEABIHFT64)
978 .StartsWith("gnueabihf", Triple::GNUEABIHF)
979 .StartsWith("gnueabit64", Triple::GNUEABIT64)
980 .StartsWith("gnueabi", Triple::GNUEABI)
981 .StartsWith("gnuf32", Triple::GNUF32)
982 .StartsWith("gnuf64", Triple::GNUF64)
983 .StartsWith("gnusf", Triple::GNUSF)
984 .StartsWith("gnux32", Triple::GNUX32)
985 .StartsWith("gnu_ilp32", Triple::GNUILP32)
986 .StartsWith("code16", Triple::CODE16)
987 .StartsWith("gnut64", Triple::GNUT64)
988 .StartsWith("gnu", Triple::GNU)
989 .StartsWith("android", Triple::Android)
990 .StartsWith("muslabin32", Triple::MuslABIN32)
991 .StartsWith("muslabi64", Triple::MuslABI64)
992 .StartsWith("musleabihf", Triple::MuslEABIHF)
993 .StartsWith("musleabi", Triple::MuslEABI)
994 .StartsWith("muslf32", Triple::MuslF32)
995 .StartsWith("muslsf", Triple::MuslSF)
996 .StartsWith("muslx32", Triple::MuslX32)
997 .StartsWith("muslwali", Triple::MuslWALI)
998 .StartsWith("musl", Triple::Musl)
999 .StartsWith("msvc", Triple::MSVC)
1000 .StartsWith("itanium", Triple::Itanium)
1001 .StartsWith("cygnus", Triple::Cygnus)
1002 .StartsWith("coreclr", Triple::CoreCLR)
1003 .StartsWith("simulator", Triple::Simulator)
1004 .StartsWith("macabi", Triple::MacABI)
1005 .StartsWith("pixel", Triple::Pixel)
1006 .StartsWith("vertex", Triple::Vertex)
1007 .StartsWith("geometry", Triple::Geometry)
1008 .StartsWith("hull", Triple::Hull)
1009 .StartsWith("domain", Triple::Domain)
1010 .StartsWith("compute", Triple::Compute)
1011 .StartsWith("library", Triple::Library)
1012 .StartsWith("raygeneration", Triple::RayGeneration)
1013 .StartsWith("intersection", Triple::Intersection)
1014 .StartsWith("anyhit", Triple::AnyHit)
1015 .StartsWith("closesthit", Triple::ClosestHit)
1016 .StartsWith("miss", Triple::Miss)
1017 .StartsWith("callable", Triple::Callable)
1018 .StartsWith("mesh", Triple::Mesh)
1019 .StartsWith("amplification", Triple::Amplification)
1020 .StartsWith("rootsignature", Triple::RootSignature)
1021 .StartsWith("ohos", Triple::OpenHOS)
1022 .StartsWith("pauthtest", Triple::PAuthTest)
1023 .StartsWith("llvm", Triple::LLVM)
1024 .StartsWith("mlibc", Triple::Mlibc)
1025 .StartsWith("mtia", Triple::MTIA)
1027}
1028
1030 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
1031 // "xcoff" must come before "coff" because of the order-dependendent
1032 // pattern matching.
1033 .EndsWith("xcoff", Triple::XCOFF)
1034 .EndsWith("coff", Triple::COFF)
1035 .EndsWith("elf", Triple::ELF)
1036 .EndsWith("goff", Triple::GOFF)
1037 .EndsWith("macho", Triple::MachO)
1038 .EndsWith("wasm", Triple::Wasm)
1039 .EndsWith("spirv", Triple::SPIRV)
1041}
1042
1044 if (SubArchName.starts_with("mips") &&
1045 (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
1047
1048 if (SubArchName == "powerpcspe")
1050
1051 if (SubArchName == "arm64e")
1053
1054 if (SubArchName == "arm64ec")
1056
1057 if (SubArchName == "aarch64_lfi")
1059
1060 if (SubArchName.starts_with("spirv"))
1061 return StringSwitch<Triple::SubArchType>(SubArchName)
1070
1071 if (SubArchName.starts_with("dxil"))
1072 return StringSwitch<Triple::SubArchType>(SubArchName)
1084
1085 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
1086
1087 // For now, this is the small part. Early return.
1088 if (ARMSubArch.empty())
1089 return StringSwitch<Triple::SubArchType>(SubArchName)
1094
1095 // ARM sub arch.
1096 switch (ARM::parseArch(ARMSubArch)) {
1097 case ARM::ArchKind::ARMV4:
1098 return Triple::NoSubArch;
1099 case ARM::ArchKind::ARMV4T:
1101 case ARM::ArchKind::ARMV5T:
1102 return Triple::ARMSubArch_v5;
1103 case ARM::ArchKind::ARMV5TE:
1104 case ARM::ArchKind::IWMMXT:
1105 case ARM::ArchKind::IWMMXT2:
1106 case ARM::ArchKind::XSCALE:
1107 case ARM::ArchKind::ARMV5TEJ:
1109 case ARM::ArchKind::ARMV6:
1110 return Triple::ARMSubArch_v6;
1111 case ARM::ArchKind::ARMV6K:
1112 case ARM::ArchKind::ARMV6KZ:
1114 case ARM::ArchKind::ARMV6T2:
1116 case ARM::ArchKind::ARMV6M:
1118 case ARM::ArchKind::ARMV7A:
1119 case ARM::ArchKind::ARMV7R:
1120 return Triple::ARMSubArch_v7;
1121 case ARM::ArchKind::ARMV7VE:
1123 case ARM::ArchKind::ARMV7K:
1125 case ARM::ArchKind::ARMV7M:
1127 case ARM::ArchKind::ARMV7S:
1129 case ARM::ArchKind::ARMV7EM:
1131 case ARM::ArchKind::ARMV8A:
1132 return Triple::ARMSubArch_v8;
1133 case ARM::ArchKind::ARMV8_1A:
1135 case ARM::ArchKind::ARMV8_2A:
1137 case ARM::ArchKind::ARMV8_3A:
1139 case ARM::ArchKind::ARMV8_4A:
1141 case ARM::ArchKind::ARMV8_5A:
1143 case ARM::ArchKind::ARMV8_6A:
1145 case ARM::ArchKind::ARMV8_7A:
1147 case ARM::ArchKind::ARMV8_8A:
1149 case ARM::ArchKind::ARMV8_9A:
1151 case ARM::ArchKind::ARMV9A:
1152 return Triple::ARMSubArch_v9;
1153 case ARM::ArchKind::ARMV9_1A:
1155 case ARM::ArchKind::ARMV9_2A:
1157 case ARM::ArchKind::ARMV9_3A:
1159 case ARM::ArchKind::ARMV9_4A:
1161 case ARM::ArchKind::ARMV9_5A:
1163 case ARM::ArchKind::ARMV9_6A:
1165 case ARM::ArchKind::ARMV9_7A:
1167 case ARM::ArchKind::ARMV8R:
1169 case ARM::ArchKind::ARMV8MBaseline:
1171 case ARM::ArchKind::ARMV8MMainline:
1173 case ARM::ArchKind::ARMV8_1MMainline:
1175 default:
1176 return Triple::NoSubArch;
1177 }
1178}
1179
1181 switch (T.getArch()) {
1183 case Triple::aarch64:
1184 case Triple::aarch64_32:
1185 case Triple::arm:
1186 case Triple::thumb:
1187 case Triple::x86:
1188 case Triple::x86_64:
1189 switch (T.getOS()) {
1190 case Triple::Win32:
1191 case Triple::UEFI:
1192 return Triple::COFF;
1193 default:
1194 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
1195 }
1196 case Triple::aarch64_be:
1197 case Triple::amdgcn:
1198 case Triple::amdil64:
1199 case Triple::amdil:
1200 case Triple::arc:
1201 case Triple::armeb:
1202 case Triple::avr:
1203 case Triple::bpfeb:
1204 case Triple::bpfel:
1205 case Triple::csky:
1206 case Triple::hexagon:
1207 case Triple::hsail64:
1208 case Triple::hsail:
1209 case Triple::kalimba:
1210 case Triple::lanai:
1213 case Triple::m68k:
1214 case Triple::mips64:
1215 case Triple::mips64el:
1216 case Triple::mips:
1217 case Triple::msp430:
1218 case Triple::nvptx64:
1219 case Triple::nvptx:
1220 case Triple::ppc64le:
1221 case Triple::ppcle:
1222 case Triple::r600:
1225 case Triple::riscv32:
1226 case Triple::riscv64:
1227 case Triple::riscv32be:
1228 case Triple::riscv64be:
1229 case Triple::shave:
1230 case Triple::sparc:
1231 case Triple::sparcel:
1232 case Triple::sparcv9:
1233 case Triple::spir64:
1234 case Triple::spir:
1235 case Triple::tce:
1236 case Triple::tcele:
1237 case Triple::tcele64:
1238 case Triple::thumbeb:
1239 case Triple::ve:
1240 case Triple::xcore:
1241 case Triple::xtensa:
1242 return Triple::ELF;
1243
1244 case Triple::mipsel:
1245 if (T.isOSWindows())
1246 return Triple::COFF;
1247 return Triple::ELF;
1248
1249 case Triple::ppc64:
1250 case Triple::ppc:
1251 if (T.isOSAIX())
1252 return Triple::XCOFF;
1253 if (T.isOSDarwin())
1254 return Triple::MachO;
1255 return Triple::ELF;
1256
1257 case Triple::systemz:
1258 if (T.isOSzOS())
1259 return Triple::GOFF;
1260 return Triple::ELF;
1261
1262 case Triple::wasm32:
1263 case Triple::wasm64:
1264 return Triple::Wasm;
1265
1266 case Triple::spirv:
1267 case Triple::spirv32:
1268 case Triple::spirv64:
1269 return Triple::SPIRV;
1270
1271 case Triple::dxil:
1272 return Triple::DXContainer;
1273 }
1274 llvm_unreachable("unknown architecture");
1275}
1276
1277/// Construct a triple from the string representation provided.
1278///
1279/// This stores the string representation and parses the various pieces into
1280/// enum members.
1281Triple::Triple(std::string &&Str) : Data(std::move(Str)) {
1282 // Do minimal parsing by hand here.
1283 SmallVector<StringRef, 4> Components;
1284 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
1285 if (Components.size() > 0) {
1286 Arch = parseArch(Components[0]);
1287 SubArch = parseSubArch(Components[0]);
1288 if (Components.size() > 1) {
1289 Vendor = parseVendor(Components[1]);
1290 if (Components.size() > 2) {
1291 OS = parseOS(Components[2]);
1292 if (Components.size() > 3) {
1293 Environment = parseEnvironment(Components[3]);
1294 ObjectFormat = parseFormat(Components[3]);
1295 }
1296 }
1297 } else {
1298 Environment =
1300 .StartsWith("mipsn32", Triple::GNUABIN32)
1301 .StartsWith("mips64", Triple::GNUABI64)
1302 .StartsWith("mipsisa64", Triple::GNUABI64)
1303 .StartsWith("mipsisa32", Triple::GNU)
1304 .Cases({"mips", "mipsel", "mipsr6", "mipsr6el"}, Triple::GNU)
1306 }
1307 }
1308 if (ObjectFormat == UnknownObjectFormat)
1309 ObjectFormat = getDefaultFormat(*this);
1310}
1311
1312Triple::Triple(const Twine &Str) : Triple(Str.str()) {}
1313
1314/// Construct a triple from string representations of the architecture,
1315/// vendor, and OS.
1316///
1317/// This joins each argument into a canonical string representation and parses
1318/// them into enum members. It leaves the environment unknown and omits it from
1319/// the string representation.
1320Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1321 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1322 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1323 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1324 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1325 ObjectFormat = getDefaultFormat(*this);
1326}
1327
1328/// Construct a triple from string representations of the architecture,
1329/// vendor, OS, and environment.
1330///
1331/// This joins each argument into a canonical string representation and parses
1332/// them into enum members.
1333Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1334 const Twine &EnvironmentStr)
1335 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1336 EnvironmentStr)
1337 .str()),
1338 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1339 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1340 Environment(parseEnvironment(EnvironmentStr.str())),
1341 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1342 if (ObjectFormat == Triple::UnknownObjectFormat)
1343 ObjectFormat = getDefaultFormat(*this);
1344}
1345
1347
1349 VersionTuple Ver =
1350 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1351 // Default DXIL minor version when Shader Model version is anything other
1352 // than 6.[0...9] or 6.x (which translates to latest current SM version)
1353 const unsigned SMMajor = 6;
1354 if (!Ver.empty()) {
1355 if (Ver.getMajor() == SMMajor) {
1356 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1357 switch (*SMMinor) {
1358 case 0:
1360 case 1:
1362 case 2:
1364 case 3:
1366 case 4:
1368 case 5:
1370 case 6:
1372 case 7:
1374 case 8:
1376 case 9:
1378 default:
1379 report_fatal_error("Unsupported Shader Model version", false);
1380 }
1381 }
1382 }
1383 } else {
1384 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1385 // shadermodel6.x is
1386 if (ShaderModelStr == "shadermodel6.x") {
1388 }
1389 }
1390 // DXIL version corresponding to Shader Model version other than 6.Minor
1391 // is 1.0
1393}
1394
1396 bool IsMinGW32 = false;
1397 bool IsCygwin = false;
1398
1399 // Parse into components.
1400 SmallVector<StringRef, 4> Components;
1401 Str.split(Components, '-');
1402
1403 // If the first component corresponds to a known architecture, preferentially
1404 // use it for the architecture. If the second component corresponds to a
1405 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1406 // component movement when a component parses as (eg) both a valid arch and a
1407 // valid os.
1408 ArchType Arch = UnknownArch;
1409 if (Components.size() > 0)
1410 Arch = parseArch(Components[0]);
1411 VendorType Vendor = UnknownVendor;
1412 if (Components.size() > 1)
1413 Vendor = parseVendor(Components[1]);
1414 OSType OS = UnknownOS;
1415 if (Components.size() > 2) {
1416 OS = parseOS(Components[2]);
1417 IsCygwin = Components[2].starts_with("cygwin") ||
1418 Components[2].starts_with("msys");
1419 IsMinGW32 = Components[2].starts_with("mingw");
1420 }
1421 EnvironmentType Environment = UnknownEnvironment;
1422 if (Components.size() > 3)
1423 Environment = parseEnvironment(Components[3]);
1425 if (Components.size() > 4)
1426 ObjectFormat = parseFormat(Components[4]);
1427
1428 // Note which components are already in their final position. These will not
1429 // be moved.
1430 bool Found[4];
1431 Found[0] = Arch != UnknownArch;
1432 Found[1] = Vendor != UnknownVendor;
1433 Found[2] = OS != UnknownOS;
1434 Found[3] = Environment != UnknownEnvironment;
1435
1436 // If they are not there already, permute the components into their canonical
1437 // positions by seeing if they parse as a valid architecture, and if so moving
1438 // the component to the architecture position etc.
1439 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1440 if (Found[Pos])
1441 continue; // Already in the canonical position.
1442
1443 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1444 // Do not reparse any components that already matched.
1445 if (Idx < std::size(Found) && Found[Idx])
1446 continue;
1447
1448 // Does this component parse as valid for the target position?
1449 bool Valid = false;
1450 StringRef Comp = Components[Idx];
1451 switch (Pos) {
1452 default:
1453 llvm_unreachable("unexpected component type!");
1454 case 0:
1455 Arch = parseArch(Comp);
1456 Valid = Arch != UnknownArch;
1457 break;
1458 case 1:
1459 Vendor = parseVendor(Comp);
1460 Valid = Vendor != UnknownVendor;
1461 break;
1462 case 2:
1463 OS = parseOS(Comp);
1464 IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
1465 IsMinGW32 = Comp.starts_with("mingw");
1466 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1467 break;
1468 case 3:
1469 Environment = parseEnvironment(Comp);
1470 Valid = Environment != UnknownEnvironment;
1471 if (!Valid) {
1472 ObjectFormat = parseFormat(Comp);
1473 Valid = ObjectFormat != UnknownObjectFormat;
1474 }
1475 break;
1476 }
1477 if (!Valid)
1478 continue; // Nope, try the next component.
1479
1480 // Move the component to the target position, pushing any non-fixed
1481 // components that are in the way to the right. This tends to give
1482 // good results in the common cases of a forgotten vendor component
1483 // or a wrongly positioned environment.
1484 if (Pos < Idx) {
1485 // Insert left, pushing the existing components to the right. For
1486 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1487 StringRef CurrentComponent(""); // The empty component.
1488 // Replace the component we are moving with an empty component.
1489 std::swap(CurrentComponent, Components[Idx]);
1490 // Insert the component being moved at Pos, displacing any existing
1491 // components to the right.
1492 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1493 // Skip over any fixed components.
1494 while (i < std::size(Found) && Found[i])
1495 ++i;
1496 // Place the component at the new position, getting the component
1497 // that was at this position - it will be moved right.
1498 std::swap(CurrentComponent, Components[i]);
1499 }
1500 } else if (Pos > Idx) {
1501 // Push right by inserting empty components until the component at Idx
1502 // reaches the target position Pos. For example, pc-a -> -pc-a when
1503 // moving pc to the second position.
1504 do {
1505 // Insert one empty component at Idx.
1506 StringRef CurrentComponent(""); // The empty component.
1507 for (unsigned i = Idx; i < Components.size();) {
1508 // Place the component at the new position, getting the component
1509 // that was at this position - it will be moved right.
1510 std::swap(CurrentComponent, Components[i]);
1511 // If it was placed on top of an empty component then we are done.
1512 if (CurrentComponent.empty())
1513 break;
1514 // Advance to the next component, skipping any fixed components.
1515 while (++i < std::size(Found) && Found[i])
1516 ;
1517 }
1518 // The last component was pushed off the end - append it.
1519 if (!CurrentComponent.empty())
1520 Components.push_back(CurrentComponent);
1521
1522 // Advance Idx to the component's new position.
1523 while (++Idx < std::size(Found) && Found[Idx])
1524 ;
1525 } while (Idx < Pos); // Add more until the final position is reached.
1526 }
1527 assert(Pos < Components.size() && Components[Pos] == Comp &&
1528 "Component moved wrong!");
1529 Found[Pos] = true;
1530 break;
1531 }
1532 }
1533
1534 // If "none" is in the middle component in a three-component triple, treat it
1535 // as the OS (Components[2]) instead of the vendor (Components[1]).
1536 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1537 Components[1] == "none" && Components[2].empty())
1538 std::swap(Components[1], Components[2]);
1539
1540 // Replace empty components with "unknown" value.
1541 for (StringRef &C : Components)
1542 if (C.empty())
1543 C = "unknown";
1544
1545 // Special case logic goes here. At this point Arch, Vendor and OS have the
1546 // correct values for the computed components.
1547 std::string NormalizedEnvironment;
1548 if (Environment == Triple::Android &&
1549 Components[3].starts_with("androideabi")) {
1550 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1551 if (AndroidVersion.empty()) {
1552 Components[3] = "android";
1553 } else {
1554 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1555 Components[3] = NormalizedEnvironment;
1556 }
1557 }
1558
1559 // SUSE uses "gnueabi" to mean "gnueabihf"
1560 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1561 Components[3] = "gnueabihf";
1562
1563 if (OS == Triple::Win32) {
1564 Components.resize(4);
1565 Components[2] = "windows";
1566 if (Environment == UnknownEnvironment) {
1567 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1568 Components[3] = "msvc";
1569 else
1570 Components[3] = getObjectFormatTypeName(ObjectFormat);
1571 }
1572 } else if (IsMinGW32) {
1573 Components.resize(4);
1574 Components[2] = "windows";
1575 Components[3] = "gnu";
1576 } else if (IsCygwin) {
1577 Components.resize(4);
1578 Components[2] = "windows";
1579 Components[3] = "cygnus";
1580 }
1581 if (IsMinGW32 || IsCygwin ||
1582 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1583 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1584 Components.resize(5);
1585 Components[4] = getObjectFormatTypeName(ObjectFormat);
1586 }
1587 }
1588
1589 // Normalize DXIL triple if it does not include DXIL version number.
1590 // Determine DXIL version number using the minor version number of Shader
1591 // Model version specified in target triple, if any. Prior to decoupling DXIL
1592 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1593 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1594 if (Components[0] == "dxil") {
1595 if (Components.size() > 4) {
1596 Components.resize(4);
1597 }
1598 // Add DXIL version only if shadermodel is specified in the triple
1599 if (OS == Triple::ShaderModel) {
1600 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1601 }
1602 }
1603
1604 // Currently the firmware OS is an Apple specific concept.
1605 if ((Components.size() > 2) && (Components[2] == "firmware") &&
1606 (Components[1] != "apple"))
1608 "the firmware target os is only supported for the apple vendor");
1609
1610 // Canonicalize the components if necessary.
1611 switch (Form) {
1612 case CanonicalForm::ANY:
1613 break;
1617 Components.resize(static_cast<unsigned>(Form), "unknown");
1618 break;
1619 }
1620 }
1621
1622 // Stick the corrected components back together to form the normalized string.
1623 return join(Components, "-");
1624}
1625
1627 return StringRef(Data).split('-').first; // Isolate first component
1628}
1629
1631 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1632 return Tmp.split('-').first; // Isolate second component
1633}
1634
1636 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1637 Tmp = Tmp.split('-').second; // Strip second component
1638 return Tmp.split('-').first; // Isolate third component
1639}
1640
1642 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1643 Tmp = Tmp.split('-').second; // Strip second component
1644 return Tmp.split('-').second; // Strip third component
1645}
1646
1648 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1649 return Tmp.split('-').second; // Strip second component
1650}
1651
1653 VersionTuple Version;
1654 Version.tryParse(Name);
1655 return Version.withoutBuild();
1656}
1657
1661
1663 StringRef EnvironmentName = getEnvironmentName();
1664
1665 // none is a valid environment type - it basically amounts to a freestanding
1666 // environment.
1667 if (EnvironmentName == "none")
1668 return "";
1669
1670 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1671 EnvironmentName.consume_front(EnvironmentTypeName);
1672
1673 if (EnvironmentName.contains("-")) {
1674 // -obj is the suffix
1676 StringRef ObjectFormatTypeName =
1678 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1679 EnvironmentName.consume_back(tmp);
1680 }
1681 }
1682 return EnvironmentName;
1683}
1684
1686 StringRef OSName = getOSName();
1687 // Assume that the OS portion of the triple starts with the canonical name.
1688 StringRef OSTypeName = getOSTypeName(getOS());
1689 if (OSName.starts_with(OSTypeName))
1690 OSName = OSName.substr(OSTypeName.size());
1691 else if (getOS() == MacOSX)
1692 OSName.consume_front("macos");
1693 else if (OSName.starts_with("visionos"))
1694 OSName.consume_front("visionos");
1695
1696 return parseVersionFromName(OSName);
1697}
1698
1701
1702 switch (getOS()) {
1703 default:
1704 llvm_unreachable("unexpected OS for Darwin triple");
1705 case Darwin:
1706 // Default to darwin8, i.e., MacOSX 10.4.
1707 if (Version.getMajor() == 0)
1708 Version = VersionTuple(8);
1709 // Darwin version numbers are skewed from OS X versions.
1710 if (Version.getMajor() < 4) {
1711 return false;
1712 }
1713 if (Version.getMajor() <= 19) {
1714 Version = VersionTuple(10, Version.getMajor() - 4);
1715 } else if (Version.getMajor() < 25) {
1716 // darwin20-24 corresponds to macOS 11-15.
1717 Version = VersionTuple(11 + Version.getMajor() - 20);
1718 } else {
1719 // darwin25 corresponds with macOS26+.
1720 Version = VersionTuple(Version.getMajor() + 1);
1721 }
1722 break;
1723 case MacOSX:
1724 // Default to 10.4.
1725 if (Version.getMajor() == 0) {
1726 Version = VersionTuple(10, 4);
1727 } else if (Version.getMajor() < 10) {
1728 return false;
1729 }
1730 break;
1731 case IOS:
1732 case TvOS:
1733 case WatchOS:
1734 // Ignore the version from the triple. This is only handled because the
1735 // the clang driver combines OS X and IOS support into a common Darwin
1736 // toolchain that wants to know the OS X version number even when targeting
1737 // IOS.
1738 Version = VersionTuple(10, 4);
1739 break;
1740 case XROS:
1741 llvm_unreachable("OSX version isn't relevant for xrOS");
1742 case DriverKit:
1743 llvm_unreachable("OSX version isn't relevant for DriverKit");
1744 case Firmware:
1745 llvm_unreachable("OSX version isn't relevant for Firmware");
1746 }
1747 return true;
1748}
1749
1751 switch (getOS()) {
1752 default:
1753 llvm_unreachable("unexpected OS for Darwin triple");
1754 case Darwin:
1755 case MacOSX:
1756 // Ignore the version from the triple. This is only handled because the
1757 // the clang driver combines OS X and IOS support into a common Darwin
1758 // toolchain that wants to know the iOS version number even when targeting
1759 // OS X.
1760 return VersionTuple(5);
1761 case IOS:
1762 case TvOS: {
1764 // Default to 5.0 (or 7.0 for arm64).
1765 if (Version.getMajor() == 0)
1766 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1767 if (Version.getMajor() == 19)
1768 // tvOS 19 corresponds to ios26.
1769 return VersionTuple(26);
1772 }
1773 case XROS: {
1775 // xrOS 1 is aligned with iOS 17.
1776 if (Version.getMajor() < 3)
1777 return Version.withMajorReplaced(Version.getMajor() + 16);
1778 // visionOS 3 corresponds to ios 26+.
1779 if (Version.getMajor() == 3)
1780 return VersionTuple(26);
1783 }
1784 case WatchOS: {
1786 // watchOS 12 corresponds to ios 26.
1787 if (Version.getMajor() == 12)
1788 return VersionTuple(26);
1792 }
1793 case BridgeOS:
1794 llvm_unreachable("conflicting triple info");
1795 case DriverKit:
1796 llvm_unreachable("DriverKit doesn't have an iOS version");
1797 case Firmware:
1798 llvm_unreachable("iOS version isn't relevant for Firmware");
1799 }
1800}
1801
1803 switch (getOS()) {
1804 default:
1805 llvm_unreachable("unexpected OS for Darwin triple");
1806 case Darwin:
1807 case MacOSX:
1808 // Ignore the version from the triple. This is only handled because the
1809 // the clang driver combines OS X and IOS support into a common Darwin
1810 // toolchain that wants to know the iOS version number even when targeting
1811 // OS X.
1812 return VersionTuple(2);
1813 case WatchOS: {
1815 if (Version.getMajor() == 0)
1816 return VersionTuple(2);
1817 return Version;
1818 }
1819 case IOS:
1820 llvm_unreachable("conflicting triple info");
1821 case XROS:
1822 llvm_unreachable("watchOS version isn't relevant for xrOS");
1823 case DriverKit:
1824 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1825 case Firmware:
1826 llvm_unreachable("watchOS version isn't relevant for Firmware");
1827 }
1828}
1829
1831 switch (getOS()) {
1832 default:
1833 llvm_unreachable("unexpected OS for Darwin triple");
1834 case DriverKit:
1836 if (Version.getMajor() == 0)
1837 return Version.withMajorReplaced(19);
1838 return Version;
1839 }
1840}
1841
1843 if (getArch() != spirv || getOS() != Vulkan)
1844 llvm_unreachable("invalid Vulkan SPIR-V triple");
1845
1846 VersionTuple VulkanVersion = getOSVersion();
1847 SubArchType SpirvVersion = getSubArch();
1848
1850 // Vulkan 1.2 -> SPIR-V 1.5.
1852 // Vulkan 1.3 -> SPIR-V 1.6.
1854
1855 // If Vulkan version is unset, default to 1.2.
1856 if (VulkanVersion == VersionTuple(0))
1857 VulkanVersion = VersionTuple(1, 2);
1858
1859 if (ValidVersionMap.contains(VulkanVersion) &&
1860 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1861 SpirvVersion == NoSubArch))
1862 return VulkanVersion;
1863
1864 return VersionTuple(0);
1865}
1866
1868 if (getArch() != dxil || getOS() != ShaderModel)
1869 llvm_unreachable("invalid DXIL triple");
1870 StringRef Arch = getArchName();
1871 if (getSubArch() == NoSubArch)
1873 Arch.consume_front("dxilv");
1874 VersionTuple DXILVersion = parseVersionFromName(Arch);
1875 // FIXME: validate DXIL version against Shader Model version.
1876 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1877 return DXILVersion;
1878}
1879
1880void Triple::setTriple(const Twine &Str) { *this = Triple(Str); }
1881
1883 setArchName(getArchName(Kind, SubArch));
1884}
1885
1889
1891
1893 if (ObjectFormat == getDefaultFormat(*this))
1895
1897 getObjectFormatTypeName(ObjectFormat))
1898 .str());
1899}
1900
1902 if (Environment == UnknownEnvironment)
1904
1905 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1907 .str());
1908}
1909
1911 setTriple(Str + "-" + getVendorName() + "-" + getOSAndEnvironmentName());
1912}
1913
1915 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1916}
1917
1919 if (hasEnvironment())
1920 setTriple(getArchName() + "-" + getVendorName() + "-" + Str + "-" +
1922 else
1923 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1924}
1925
1927 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() + "-" +
1928 Str);
1929}
1930
1932 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1933}
1934
1936 switch (Arch) {
1938 return 0;
1939
1940 case llvm::Triple::avr:
1942 return 16;
1943
1946 case llvm::Triple::arc:
1947 case llvm::Triple::arm:
1949 case llvm::Triple::csky:
1950 case llvm::Triple::dxil:
1956 case llvm::Triple::m68k:
1957 case llvm::Triple::mips:
1960 case llvm::Triple::ppc:
1962 case llvm::Triple::r600:
1969 case llvm::Triple::spir:
1971 case llvm::Triple::tce:
1976 case llvm::Triple::x86:
1979 return 32;
1980
2003 case llvm::Triple::ve:
2006 return 64;
2007 }
2008 llvm_unreachable("Invalid architecture value");
2009}
2010
2012 switch (getArch()) {
2013 default:
2014 break;
2015 case Triple::ppc:
2016 case Triple::ppcle:
2017 if (isOSLinux())
2018 return 40;
2019 break;
2020 case Triple::ppc64:
2021 case Triple::ppc64le:
2022 if (isOSLinux())
2023 return 48;
2024 break;
2025 }
2026 return 32;
2027}
2028
2030 return getArchPointerBitWidth(getArch()) == 64;
2031}
2032
2034 return getArchPointerBitWidth(getArch()) == 32;
2035}
2036
2038 return getArchPointerBitWidth(getArch()) == 16;
2039}
2040
2042 Triple T(*this);
2043 switch (getArch()) {
2045 case Triple::amdgcn:
2046 case Triple::avr:
2047 case Triple::bpfeb:
2048 case Triple::bpfel:
2049 case Triple::msp430:
2050 case Triple::systemz:
2051 case Triple::ve:
2052 T.setArch(UnknownArch);
2053 break;
2054
2055 case Triple::aarch64_32:
2056 case Triple::amdil:
2057 case Triple::arc:
2058 case Triple::arm:
2059 case Triple::armeb:
2060 case Triple::csky:
2061 case Triple::dxil:
2062 case Triple::hexagon:
2063 case Triple::hsail:
2064 case Triple::kalimba:
2065 case Triple::lanai:
2067 case Triple::m68k:
2068 case Triple::mips:
2069 case Triple::mipsel:
2070 case Triple::nvptx:
2071 case Triple::ppc:
2072 case Triple::ppcle:
2073 case Triple::r600:
2075 case Triple::riscv32:
2076 case Triple::riscv32be:
2077 case Triple::shave:
2078 case Triple::sparc:
2079 case Triple::sparcel:
2080 case Triple::spir:
2081 case Triple::spirv32:
2082 case Triple::tce:
2083 case Triple::tcele:
2084 case Triple::thumb:
2085 case Triple::thumbeb:
2086 case Triple::wasm32:
2087 case Triple::x86:
2088 case Triple::xcore:
2089 case Triple::xtensa:
2090 // Already 32-bit.
2091 break;
2092
2093 case Triple::aarch64:
2094 T.setArch(Triple::arm);
2095 break;
2096 case Triple::aarch64_be:
2097 T.setArch(Triple::armeb);
2098 break;
2099 case Triple::amdil64:
2100 T.setArch(Triple::amdil);
2101 break;
2102 case Triple::hsail64:
2103 T.setArch(Triple::hsail);
2104 break;
2106 T.setArch(Triple::loongarch32);
2107 break;
2108 case Triple::mips64:
2109 T.setArch(Triple::mips, getSubArch());
2110 break;
2111 case Triple::mips64el:
2112 T.setArch(Triple::mipsel, getSubArch());
2113 break;
2114 case Triple::nvptx64:
2115 T.setArch(Triple::nvptx);
2116 break;
2117 case Triple::ppc64:
2118 T.setArch(Triple::ppc);
2119 break;
2120 case Triple::ppc64le:
2121 T.setArch(Triple::ppcle);
2122 break;
2124 T.setArch(Triple::renderscript32);
2125 break;
2126 case Triple::riscv64:
2127 T.setArch(Triple::riscv32);
2128 break;
2129 case Triple::riscv64be:
2130 T.setArch(Triple::riscv32be);
2131 break;
2132 case Triple::sparcv9:
2133 T.setArch(Triple::sparc);
2134 break;
2135 case Triple::spir64:
2136 T.setArch(Triple::spir);
2137 break;
2138 case Triple::spirv:
2139 case Triple::spirv64:
2140 T.setArch(Triple::spirv32, getSubArch());
2141 break;
2142 case Triple::tcele64:
2143 T.setArch(Triple::tcele);
2144 break;
2145 case Triple::wasm64:
2146 T.setArch(Triple::wasm32);
2147 break;
2148 case Triple::x86_64:
2149 T.setArch(Triple::x86);
2150 break;
2151 }
2152 return T;
2153}
2154
2156 Triple T(*this);
2157 switch (getArch()) {
2159 case Triple::arc:
2160 case Triple::avr:
2161 case Triple::csky:
2162 case Triple::dxil:
2163 case Triple::hexagon:
2164 case Triple::kalimba:
2165 case Triple::lanai:
2166 case Triple::m68k:
2167 case Triple::msp430:
2168 case Triple::r600:
2169 case Triple::shave:
2170 case Triple::sparcel:
2171 case Triple::tce:
2172 case Triple::xcore:
2173 case Triple::xtensa:
2174 T.setArch(UnknownArch);
2175 break;
2176
2177 case Triple::aarch64:
2178 case Triple::aarch64_be:
2179 case Triple::amdgcn:
2180 case Triple::amdil64:
2181 case Triple::bpfeb:
2182 case Triple::bpfel:
2183 case Triple::hsail64:
2185 case Triple::mips64:
2186 case Triple::mips64el:
2187 case Triple::nvptx64:
2188 case Triple::ppc64:
2189 case Triple::ppc64le:
2191 case Triple::riscv64:
2192 case Triple::riscv64be:
2193 case Triple::sparcv9:
2194 case Triple::spir64:
2195 case Triple::spirv64:
2196 case Triple::systemz:
2197 case Triple::tcele64:
2198 case Triple::ve:
2199 case Triple::wasm64:
2200 case Triple::x86_64:
2201 // Already 64-bit.
2202 break;
2203
2204 case Triple::aarch64_32:
2205 T.setArch(Triple::aarch64);
2206 break;
2207 case Triple::amdil:
2208 T.setArch(Triple::amdil64);
2209 break;
2210 case Triple::arm:
2211 T.setArch(Triple::aarch64);
2212 break;
2213 case Triple::armeb:
2214 T.setArch(Triple::aarch64_be);
2215 break;
2216 case Triple::hsail:
2217 T.setArch(Triple::hsail64);
2218 break;
2220 T.setArch(Triple::loongarch64);
2221 break;
2222 case Triple::mips:
2223 T.setArch(Triple::mips64, getSubArch());
2224 break;
2225 case Triple::mipsel:
2226 T.setArch(Triple::mips64el, getSubArch());
2227 break;
2228 case Triple::nvptx:
2229 T.setArch(Triple::nvptx64);
2230 break;
2231 case Triple::ppc:
2232 T.setArch(Triple::ppc64);
2233 break;
2234 case Triple::ppcle:
2235 T.setArch(Triple::ppc64le);
2236 break;
2238 T.setArch(Triple::renderscript64);
2239 break;
2240 case Triple::riscv32:
2241 T.setArch(Triple::riscv64);
2242 break;
2243 case Triple::riscv32be:
2244 T.setArch(Triple::riscv64be);
2245 break;
2246 case Triple::sparc:
2247 T.setArch(Triple::sparcv9);
2248 break;
2249 case Triple::spir:
2250 T.setArch(Triple::spir64);
2251 break;
2252 case Triple::spirv:
2253 case Triple::spirv32:
2254 T.setArch(Triple::spirv64, getSubArch());
2255 break;
2256 case Triple::tcele:
2257 T.setArch(Triple::tcele64);
2258 break;
2259 case Triple::thumb:
2260 T.setArch(Triple::aarch64);
2261 break;
2262 case Triple::thumbeb:
2263 T.setArch(Triple::aarch64_be);
2264 break;
2265 case Triple::wasm32:
2266 T.setArch(Triple::wasm64);
2267 break;
2268 case Triple::x86:
2269 T.setArch(Triple::x86_64);
2270 break;
2271 }
2272 return T;
2273}
2274
2276 Triple T(*this);
2277 // Already big endian.
2278 if (!isLittleEndian())
2279 return T;
2280 switch (getArch()) {
2282 case Triple::amdgcn:
2283 case Triple::amdil64:
2284 case Triple::amdil:
2285 case Triple::avr:
2286 case Triple::dxil:
2287 case Triple::hexagon:
2288 case Triple::hsail64:
2289 case Triple::hsail:
2290 case Triple::kalimba:
2293 case Triple::msp430:
2294 case Triple::nvptx64:
2295 case Triple::nvptx:
2296 case Triple::r600:
2299 case Triple::shave:
2300 case Triple::spir64:
2301 case Triple::spir:
2302 case Triple::spirv:
2303 case Triple::spirv32:
2304 case Triple::spirv64:
2305 case Triple::tcele64:
2306 case Triple::wasm32:
2307 case Triple::wasm64:
2308 case Triple::x86:
2309 case Triple::x86_64:
2310 case Triple::xcore:
2311 case Triple::ve:
2312 case Triple::csky:
2313 case Triple::xtensa:
2314
2315 // ARM is intentionally unsupported here, changing the architecture would
2316 // drop any arch suffixes.
2317 case Triple::arm:
2318 case Triple::thumb:
2319 T.setArch(UnknownArch);
2320 break;
2321
2322 case Triple::aarch64:
2323 T.setArch(Triple::aarch64_be);
2324 break;
2325 case Triple::bpfel:
2326 T.setArch(Triple::bpfeb);
2327 break;
2328 case Triple::mips64el:
2329 T.setArch(Triple::mips64, getSubArch());
2330 break;
2331 case Triple::mipsel:
2332 T.setArch(Triple::mips, getSubArch());
2333 break;
2334 case Triple::ppcle:
2335 T.setArch(Triple::ppc);
2336 break;
2337 case Triple::ppc64le:
2338 T.setArch(Triple::ppc64);
2339 break;
2340 case Triple::riscv32:
2341 T.setArch(Triple::riscv32be);
2342 break;
2343 case Triple::riscv64:
2344 T.setArch(Triple::riscv64be);
2345 break;
2346 case Triple::sparcel:
2347 T.setArch(Triple::sparc);
2348 break;
2349 case Triple::tcele:
2350 T.setArch(Triple::tce);
2351 break;
2352 default:
2353 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
2354 }
2355 return T;
2356}
2357
2359 Triple T(*this);
2360 if (isLittleEndian())
2361 return T;
2362
2363 switch (getArch()) {
2365 case Triple::lanai:
2366 case Triple::sparcv9:
2367 case Triple::systemz:
2368 case Triple::m68k:
2369
2370 // ARM is intentionally unsupported here, changing the architecture would
2371 // drop any arch suffixes.
2372 case Triple::armeb:
2373 case Triple::thumbeb:
2374 T.setArch(UnknownArch);
2375 break;
2376
2377 case Triple::aarch64_be:
2378 T.setArch(Triple::aarch64);
2379 break;
2380 case Triple::bpfeb:
2381 T.setArch(Triple::bpfel);
2382 break;
2383 case Triple::mips64:
2384 T.setArch(Triple::mips64el, getSubArch());
2385 break;
2386 case Triple::mips:
2387 T.setArch(Triple::mipsel, getSubArch());
2388 break;
2389 case Triple::ppc:
2390 T.setArch(Triple::ppcle);
2391 break;
2392 case Triple::ppc64:
2393 T.setArch(Triple::ppc64le);
2394 break;
2395 case Triple::riscv32be:
2396 T.setArch(Triple::riscv32);
2397 break;
2398 case Triple::riscv64be:
2399 T.setArch(Triple::riscv64);
2400 break;
2401 case Triple::sparc:
2402 T.setArch(Triple::sparcel);
2403 break;
2404 case Triple::tce:
2405 T.setArch(Triple::tcele);
2406 break;
2407 default:
2408 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
2409 }
2410 return T;
2411}
2412
2414 switch (getArch()) {
2415 case Triple::aarch64:
2416 case Triple::aarch64_32:
2417 case Triple::amdgcn:
2418 case Triple::amdil64:
2419 case Triple::amdil:
2420 case Triple::arm:
2421 case Triple::avr:
2422 case Triple::bpfel:
2423 case Triple::csky:
2424 case Triple::dxil:
2425 case Triple::hexagon:
2426 case Triple::hsail64:
2427 case Triple::hsail:
2428 case Triple::kalimba:
2431 case Triple::mips64el:
2432 case Triple::mipsel:
2433 case Triple::msp430:
2434 case Triple::nvptx64:
2435 case Triple::nvptx:
2436 case Triple::ppcle:
2437 case Triple::ppc64le:
2438 case Triple::r600:
2441 case Triple::riscv32:
2442 case Triple::riscv64:
2443 case Triple::shave:
2444 case Triple::sparcel:
2445 case Triple::spir64:
2446 case Triple::spir:
2447 case Triple::spirv:
2448 case Triple::spirv32:
2449 case Triple::spirv64:
2450 case Triple::tcele:
2451 case Triple::tcele64:
2452 case Triple::thumb:
2453 case Triple::ve:
2454 case Triple::wasm32:
2455 case Triple::wasm64:
2456 case Triple::x86:
2457 case Triple::x86_64:
2458 case Triple::xcore:
2459 case Triple::xtensa:
2460 return true;
2461 default:
2462 return false;
2463 }
2464}
2465
2467 if (getArch() == Triple::xcore)
2468 return 1;
2470 return 2;
2471 if (isOSAIX() && isArch32Bit())
2472 return 2;
2473 return 4;
2474}
2475
2477 // On MinGW, C code is usually built with a "w64" vendor, while Rust
2478 // often uses a "pc" vendor.
2479 bool IgnoreVendor = isWindowsGNUEnvironment();
2480
2481 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
2482 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2483 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2484 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2485 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2486 if (getVendor() == Triple::Apple)
2487 return getSubArch() == Other.getSubArch() &&
2488 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2489 else
2490 return getSubArch() == Other.getSubArch() &&
2491 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2492 getOS() == Other.getOS() &&
2493 getEnvironment() == Other.getEnvironment() &&
2494 getObjectFormat() == Other.getObjectFormat();
2495 }
2496
2497 // If vendor is apple, ignore the version number (the environment field)
2498 // and the object format.
2499 if (getVendor() == Triple::Apple)
2500 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2501 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2502 getOS() == Other.getOS();
2503
2504 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2505 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2506 getOS() == Other.getOS() &&
2507 getEnvironment() == Other.getEnvironment() &&
2508 getObjectFormat() == Other.getObjectFormat();
2509}
2510
2511std::string Triple::merge(const Triple &Other) const {
2512 // If vendor is apple, pick the triple with the larger version number.
2513 if (getVendor() == Triple::Apple)
2514 if (Other.isOSVersionLT(*this))
2515 return str();
2516
2517 return Other.str();
2518}
2519
2520bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2521 unsigned Micro) const {
2522 assert(isMacOSX() && "Not an OS X triple!");
2523
2524 // If this is OS X, expect a sane version number.
2525 if (getOS() == Triple::MacOSX)
2526 return isOSVersionLT(Major, Minor, Micro);
2527
2528 // Otherwise, compare to the "Darwin" number.
2529 if (Major == 10)
2530 return isOSVersionLT(Minor + 4, Micro, 0);
2531 assert(Major >= 11 && "Unexpected major version");
2532 if (Major < 25)
2533 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2534 return isOSVersionLT(Major + 1, Minor, Micro);
2535}
2536
2539 return VersionTuple();
2540 switch (getOS()) {
2541 case Triple::MacOSX:
2542 // ARM64 slice is supported starting from macOS 11.0+.
2543 return VersionTuple(11, 0, 0);
2544 case Triple::IOS:
2545 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2546 // ARM64 simulators are supported for iOS 14+.
2548 return VersionTuple(14, 0, 0);
2549 // ARM64e slice is supported starting from iOS 14.
2550 if (isArm64e())
2551 return VersionTuple(14, 0, 0);
2552 break;
2553 case Triple::TvOS:
2554 // ARM64 simulators are supported for tvOS 14+.
2556 return VersionTuple(14, 0, 0);
2557 break;
2558 case Triple::WatchOS:
2559 // ARM64 simulators are supported for watchOS 7+.
2561 return VersionTuple(7, 0, 0);
2562 // ARM64/ARM64e slices are supported starting from watchOS 26.
2563 // ARM64_32 is older though.
2565 return VersionTuple(26, 0, 0);
2566 case Triple::DriverKit:
2567 return VersionTuple(20, 0, 0);
2568 default:
2569 break;
2570 }
2571 return VersionTuple();
2572}
2573
2575 const VersionTuple &Version,
2576 bool IsInValidRange) {
2577 const unsigned MacOSRangeBump = 10;
2578 const unsigned IOSRangeBump = 7;
2579 const unsigned XROSRangeBump = 23;
2580 const unsigned WatchOSRangeBump = 14;
2581 switch (OSKind) {
2582 case MacOSX: {
2583 // macOS 10.16 is canonicalized to macOS 11.
2584 if (Version == VersionTuple(10, 16))
2585 return VersionTuple(11, 0);
2586 // macOS 16 is canonicalized to macOS 26.
2587 if (Version == VersionTuple(16, 0))
2588 return VersionTuple(26, 0);
2589 if (!IsInValidRange)
2590 return Version.withMajorReplaced(Version.getMajor() + MacOSRangeBump);
2591 break;
2592 }
2593 case IOS:
2594 case TvOS: {
2595 // Both iOS & tvOS 19.0 canonicalize to 26.
2596 if (Version == VersionTuple(19, 0))
2597 return VersionTuple(26, 0);
2598 if (!IsInValidRange)
2599 return Version.withMajorReplaced(Version.getMajor() + IOSRangeBump);
2600 break;
2601 }
2602 case XROS: {
2603 // visionOS3 is canonicalized to 26.
2604 if (Version == VersionTuple(3, 0))
2605 return VersionTuple(26, 0);
2606 if (!IsInValidRange)
2607 return Version.withMajorReplaced(Version.getMajor() + XROSRangeBump);
2608 break;
2609 }
2610 case WatchOS: {
2611 // watchOS 12 is canonicalized to 26.
2612 if (Version == VersionTuple(12, 0))
2613 return VersionTuple(26, 0);
2614 if (!IsInValidRange)
2615 return Version.withMajorReplaced(Version.getMajor() + WatchOSRangeBump);
2616 break;
2617 }
2618 default:
2619 return Version;
2620 }
2621
2622 return Version;
2623}
2624
2626 /// This constant is used to capture gaps in versioning.
2627 const VersionTuple CommonVersion(26);
2628 auto IsValid = [&](const VersionTuple &StartingVersion) {
2629 return !((Version > StartingVersion) && (Version < CommonVersion));
2630 };
2631 switch (OSKind) {
2632 case WatchOS: {
2633 const VersionTuple StartingWatchOS(12);
2634 return IsValid(StartingWatchOS);
2635 }
2636 case IOS:
2637 case TvOS: {
2638 const VersionTuple StartingIOS(19);
2639 return IsValid(StartingIOS);
2640 }
2641 case MacOSX: {
2642 const VersionTuple StartingMacOS(16);
2643 return IsValid(StartingMacOS);
2644 }
2645 case XROS: {
2646 const VersionTuple StartingXROS(3);
2647 return IsValid(StartingXROS);
2648 }
2649 default:
2650 return true;
2651 }
2652
2653 llvm_unreachable("unexpected or invalid os version");
2654}
2655
2657 if (isOSBinFormatCOFF()) {
2658 if (getArch() == Triple::x86 &&
2662 }
2663
2664 if (isOSBinFormatXCOFF())
2666 if (isOSBinFormatGOFF())
2668
2669 if (isARM() || isThumb()) {
2670 if (isOSBinFormatELF()) {
2673 }
2674
2677 }
2678
2679 if (isAArch64() || isX86() || isPPC() || isMIPS() || isSPARC() || isBPF() ||
2680 isRISCV() || isLoongArch())
2682
2683 switch (getArch()) {
2684 case Triple::arc:
2685 case Triple::csky:
2686 case Triple::hexagon:
2687 case Triple::lanai:
2688 case Triple::m68k:
2689 case Triple::msp430:
2690 case Triple::systemz:
2691 case Triple::xcore:
2692 case Triple::xtensa:
2694 default:
2695 break;
2696 }
2697
2698 // Explicitly none targets.
2699 if (isWasm() || isAMDGPU() || isNVPTX() || isSPIROrSPIRV())
2701
2702 // Default to none.
2704}
2705
2706// HLSL triple environment orders are relied on in the front end
2707static_assert(Triple::Vertex - Triple::Pixel == 1,
2708 "incorrect HLSL stage order");
2709static_assert(Triple::Geometry - Triple::Pixel == 2,
2710 "incorrect HLSL stage order");
2711static_assert(Triple::Hull - Triple::Pixel == 3, "incorrect HLSL stage order");
2712static_assert(Triple::Domain - Triple::Pixel == 4,
2713 "incorrect HLSL stage order");
2714static_assert(Triple::Compute - Triple::Pixel == 5,
2715 "incorrect HLSL stage order");
2716static_assert(Triple::Library - Triple::Pixel == 6,
2717 "incorrect HLSL stage order");
2718static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2719 "incorrect HLSL stage order");
2720static_assert(Triple::Intersection - Triple::Pixel == 8,
2721 "incorrect HLSL stage order");
2722static_assert(Triple::AnyHit - Triple::Pixel == 9,
2723 "incorrect HLSL stage order");
2724static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2725 "incorrect HLSL stage order");
2726static_assert(Triple::Miss - Triple::Pixel == 11, "incorrect HLSL stage order");
2727static_assert(Triple::Callable - Triple::Pixel == 12,
2728 "incorrect HLSL stage order");
2729static_assert(Triple::Mesh - Triple::Pixel == 13, "incorrect HLSL stage order");
2730static_assert(Triple::Amplification - Triple::Pixel == 14,
2731 "incorrect HLSL stage order");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseMap class.
Load MIR Sample Profile
#define T
This file contains some functions that are useful when dealing with strings.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
DEMANGLE_NAMESPACE_BEGIN bool starts_with(std::string_view self, char C) noexcept
static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName)
Definition Triple.cpp:971
static VersionTuple parseVersionFromName(StringRef Name)
Definition Triple.cpp:1652
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition Triple.cpp:1180
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition Triple.cpp:730
static Triple::OSType parseOS(StringRef OSName)
Definition Triple.cpp:916
static StringRef getDXILArchNameFromShaderModel(StringRef ShaderModelStr)
Definition Triple.cpp:1348
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition Triple.cpp:642
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition Triple.cpp:1043
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition Triple.cpp:1029
static Triple::VendorType parseVendor(StringRef VendorName)
Definition Triple.cpp:895
Defines the llvm::VersionTuple class, which represents a version in the form major[....
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition DenseMap.h:205
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition DenseMap.h:169
void resize(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition StringRef.h:730
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition StringRef.h:685
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:591
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:258
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:140
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition StringRef.h:629
constexpr size_t size() const
size - Get the string size.
Definition StringRef.h:143
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition StringRef.h:446
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition StringRef.h:270
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition StringRef.h:655
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & StartsWith(StringLiteral S, T Value)
StringSwitch & EndsWith(StringLiteral S, T Value)
StringSwitch & Cases(std::initializer_list< StringLiteral > CaseStrings, T Value)
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM_ABI bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
Comparison function for checking OS X version compatibility, which handles supporting skewed version ...
Definition Triple.cpp:2520
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1685
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1041
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1630
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1802
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1910
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1901
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:2041
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:728
bool isWatchABI() const
Definition Triple.h:613
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:314
@ UnknownEnvironment
Definition Triple.h:266
@ RootSignature
Definition Triple.h:322
@ Amplification
Definition Triple.h:321
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:903
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:2574
CanonicalForm
Canonical form.
Definition Triple.h:404
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:532
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2358
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1141
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:453
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:432
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1101
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1123
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:778
bool isWindowsGNUEnvironment() const
Definition Triple.h:723
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1914
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1931
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:2155
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2413
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1892
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1635
bool isSPIROrSPIRV() const
Definition Triple.h:887
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2656
@ 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:1880
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:438
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1658
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:1395
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:657
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:429
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:2011
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:775
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1641
bool isSimulatorEnvironment() const
Definition Triple.h:645
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1867
const std::string & str() const
Definition Triple.h:494
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:444
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1842
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1830
static LLVM_ABI ArchType parseArch(StringRef Str)
Parse anything recognized as an architecture for the first field of the triple.
Definition Triple.cpp:795
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:689
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:692
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:787
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:397
@ UnknownObjectFormat
Definition Triple.h:331
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:908
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2511
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:739
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1084
bool isAMDGPU() const
Definition Triple.h:900
@ 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:893
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:764
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2537
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:2029
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1647
@ 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:1699
bool isWindowsCygwinEnvironment() const
Definition Triple.h:719
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:2625
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:596
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1926
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1890
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1918
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:435
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1095
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:638
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:503
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:560
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:499
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1038
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:813
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1115
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1626
bool isMacCatalystEnvironment() const
Definition Triple.h:649
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:999
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:618
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:2037
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2275
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1750
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:1662
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:2033
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2476
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:772
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:441
unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2466
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:1882
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1886
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1025
bool isWindowsItaniumEnvironment() const
Definition Triple.h:715
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:1917
@ 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:870
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:872