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 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1348 Twine('-') + getOSTypeName(OS))
1349 .str()),
1350 Arch(A), SubArch(SA), Vendor(V), OS(OS),
1351 ObjectFormat(getDefaultFormat(*this)) {}
1352
1355 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1356 Twine('-') + getOSTypeName(OS) + Twine('-') +
1358 .str()),
1359 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1360 ObjectFormat(getDefaultFormat(*this)) {}
1361
1364 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1365 Twine('-') + getOSTypeName(OS) + Twine('-') +
1366 getEnvironmentTypeName(E) + Twine('-') +
1368 .str()),
1369 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1370 ObjectFormat(OF) {}
1371
1373
1375 VersionTuple Ver =
1376 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1377 // Default DXIL minor version when Shader Model version is anything other
1378 // than 6.[0...9] or 6.x (which translates to latest current SM version)
1379 const unsigned SMMajor = 6;
1380 if (!Ver.empty()) {
1381 if (Ver.getMajor() == SMMajor) {
1382 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1383 switch (*SMMinor) {
1384 case 0:
1386 case 1:
1388 case 2:
1390 case 3:
1392 case 4:
1394 case 5:
1396 case 6:
1398 case 7:
1400 case 8:
1402 case 9:
1404 default:
1405 report_fatal_error("Unsupported Shader Model version", false);
1406 }
1407 }
1408 }
1409 } else {
1410 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1411 // shadermodel6.x is
1412 if (ShaderModelStr == "shadermodel6.x") {
1414 }
1415 }
1416 // DXIL version corresponding to Shader Model version other than 6.Minor
1417 // is 1.0
1419}
1420
1422 bool IsMinGW32 = false;
1423 bool IsCygwin = false;
1424
1425 // Parse into components.
1426 SmallVector<StringRef, 4> Components;
1427 Str.split(Components, '-');
1428
1429 // If the first component corresponds to a known architecture, preferentially
1430 // use it for the architecture. If the second component corresponds to a
1431 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1432 // component movement when a component parses as (eg) both a valid arch and a
1433 // valid os.
1434 ArchType Arch = UnknownArch;
1435 if (Components.size() > 0)
1436 Arch = parseArch(Components[0]);
1437 VendorType Vendor = UnknownVendor;
1438 if (Components.size() > 1)
1439 Vendor = parseVendor(Components[1]);
1440 OSType OS = UnknownOS;
1441 if (Components.size() > 2) {
1442 OS = parseOS(Components[2]);
1443 IsCygwin = Components[2].starts_with("cygwin") ||
1444 Components[2].starts_with("msys");
1445 IsMinGW32 = Components[2].starts_with("mingw");
1446 }
1447 EnvironmentType Environment = UnknownEnvironment;
1448 if (Components.size() > 3)
1449 Environment = parseEnvironment(Components[3]);
1451 if (Components.size() > 4)
1452 ObjectFormat = parseFormat(Components[4]);
1453
1454 // Note which components are already in their final position. These will not
1455 // be moved.
1456 bool Found[4];
1457 Found[0] = Arch != UnknownArch;
1458 Found[1] = Vendor != UnknownVendor;
1459 Found[2] = OS != UnknownOS;
1460 Found[3] = Environment != UnknownEnvironment;
1461
1462 // If they are not there already, permute the components into their canonical
1463 // positions by seeing if they parse as a valid architecture, and if so moving
1464 // the component to the architecture position etc.
1465 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1466 if (Found[Pos])
1467 continue; // Already in the canonical position.
1468
1469 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1470 // Do not reparse any components that already matched.
1471 if (Idx < std::size(Found) && Found[Idx])
1472 continue;
1473
1474 // Does this component parse as valid for the target position?
1475 bool Valid = false;
1476 StringRef Comp = Components[Idx];
1477 switch (Pos) {
1478 default:
1479 llvm_unreachable("unexpected component type!");
1480 case 0:
1481 Arch = parseArch(Comp);
1482 Valid = Arch != UnknownArch;
1483 break;
1484 case 1:
1485 Vendor = parseVendor(Comp);
1486 Valid = Vendor != UnknownVendor;
1487 break;
1488 case 2:
1489 OS = parseOS(Comp);
1490 IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
1491 IsMinGW32 = Comp.starts_with("mingw");
1492 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1493 break;
1494 case 3:
1495 Environment = parseEnvironment(Comp);
1496 Valid = Environment != UnknownEnvironment;
1497 if (!Valid) {
1498 ObjectFormat = parseFormat(Comp);
1499 Valid = ObjectFormat != UnknownObjectFormat;
1500 }
1501 break;
1502 }
1503 if (!Valid)
1504 continue; // Nope, try the next component.
1505
1506 // Move the component to the target position, pushing any non-fixed
1507 // components that are in the way to the right. This tends to give
1508 // good results in the common cases of a forgotten vendor component
1509 // or a wrongly positioned environment.
1510 if (Pos < Idx) {
1511 // Insert left, pushing the existing components to the right. For
1512 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1513 StringRef CurrentComponent(""); // The empty component.
1514 // Replace the component we are moving with an empty component.
1515 std::swap(CurrentComponent, Components[Idx]);
1516 // Insert the component being moved at Pos, displacing any existing
1517 // components to the right.
1518 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1519 // Skip over any fixed components.
1520 while (i < std::size(Found) && Found[i])
1521 ++i;
1522 // Place the component at the new position, getting the component
1523 // that was at this position - it will be moved right.
1524 std::swap(CurrentComponent, Components[i]);
1525 }
1526 } else if (Pos > Idx) {
1527 // Push right by inserting empty components until the component at Idx
1528 // reaches the target position Pos. For example, pc-a -> -pc-a when
1529 // moving pc to the second position.
1530 do {
1531 // Insert one empty component at Idx.
1532 StringRef CurrentComponent(""); // The empty component.
1533 for (unsigned i = Idx; i < Components.size();) {
1534 // Place the component at the new position, getting the component
1535 // that was at this position - it will be moved right.
1536 std::swap(CurrentComponent, Components[i]);
1537 // If it was placed on top of an empty component then we are done.
1538 if (CurrentComponent.empty())
1539 break;
1540 // Advance to the next component, skipping any fixed components.
1541 while (++i < std::size(Found) && Found[i])
1542 ;
1543 }
1544 // The last component was pushed off the end - append it.
1545 if (!CurrentComponent.empty())
1546 Components.push_back(CurrentComponent);
1547
1548 // Advance Idx to the component's new position.
1549 while (++Idx < std::size(Found) && Found[Idx])
1550 ;
1551 } while (Idx < Pos); // Add more until the final position is reached.
1552 }
1553 assert(Pos < Components.size() && Components[Pos] == Comp &&
1554 "Component moved wrong!");
1555 Found[Pos] = true;
1556 break;
1557 }
1558 }
1559
1560 // If "none" is in the middle component in a three-component triple, treat it
1561 // as the OS (Components[2]) instead of the vendor (Components[1]).
1562 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1563 Components[1] == "none" && Components[2].empty())
1564 std::swap(Components[1], Components[2]);
1565
1566 // Replace empty components with "unknown" value.
1567 for (StringRef &C : Components)
1568 if (C.empty())
1569 C = "unknown";
1570
1571 // Special case logic goes here. At this point Arch, Vendor and OS have the
1572 // correct values for the computed components.
1573 std::string NormalizedEnvironment;
1574 if (Environment == Triple::Android &&
1575 Components[3].starts_with("androideabi")) {
1576 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1577 if (AndroidVersion.empty()) {
1578 Components[3] = "android";
1579 } else {
1580 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1581 Components[3] = NormalizedEnvironment;
1582 }
1583 }
1584
1585 // SUSE uses "gnueabi" to mean "gnueabihf"
1586 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1587 Components[3] = "gnueabihf";
1588
1589 if (OS == Triple::Win32) {
1590 Components.resize(4);
1591 Components[2] = "windows";
1592 if (Environment == UnknownEnvironment) {
1593 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1594 Components[3] = "msvc";
1595 else
1596 Components[3] = getObjectFormatTypeName(ObjectFormat);
1597 }
1598 } else if (IsMinGW32) {
1599 Components.resize(4);
1600 Components[2] = "windows";
1601 Components[3] = "gnu";
1602 } else if (IsCygwin) {
1603 Components.resize(4);
1604 Components[2] = "windows";
1605 Components[3] = "cygnus";
1606 }
1607 if (IsMinGW32 || IsCygwin ||
1608 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1609 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1610 Components.resize(5);
1611 Components[4] = getObjectFormatTypeName(ObjectFormat);
1612 }
1613 }
1614
1615 // Normalize DXIL triple if it does not include DXIL version number.
1616 // Determine DXIL version number using the minor version number of Shader
1617 // Model version specified in target triple, if any. Prior to decoupling DXIL
1618 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1619 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1620 if (Components[0] == "dxil") {
1621 if (Components.size() > 4) {
1622 Components.resize(4);
1623 }
1624 // Add DXIL version only if shadermodel is specified in the triple
1625 if (OS == Triple::ShaderModel) {
1626 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1627 }
1628 }
1629
1630 // Currently the firmware OS is an Apple specific concept.
1631 if ((Components.size() > 2) && (Components[2] == "firmware") &&
1632 (Components[1] != "apple"))
1634 "the firmware target os is only supported for the apple vendor");
1635
1636 // Canonicalize the components if necessary.
1637 switch (Form) {
1638 case CanonicalForm::ANY:
1639 break;
1643 Components.resize(static_cast<unsigned>(Form), "unknown");
1644 break;
1645 }
1646 }
1647
1648 // Stick the corrected components back together to form the normalized string.
1649 return join(Components, "-");
1650}
1651
1653 return StringRef(Data).split('-').first; // Isolate first component
1654}
1655
1657 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1658 return Tmp.split('-').first; // Isolate second component
1659}
1660
1662 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1663 Tmp = Tmp.split('-').second; // Strip second component
1664 return Tmp.split('-').first; // Isolate third component
1665}
1666
1668 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1669 Tmp = Tmp.split('-').second; // Strip second component
1670 return Tmp.split('-').second; // Strip third component
1671}
1672
1674 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1675 return Tmp.split('-').second; // Strip second component
1676}
1677
1679 VersionTuple Version;
1680 Version.tryParse(Name);
1681 return Version.withoutBuild();
1682}
1683
1687
1689 StringRef EnvironmentName = getEnvironmentName();
1690
1691 // none is a valid environment type - it basically amounts to a freestanding
1692 // environment.
1693 if (EnvironmentName == "none")
1694 return "";
1695
1696 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1697 EnvironmentName.consume_front(EnvironmentTypeName);
1698
1699 if (EnvironmentName.contains("-")) {
1700 // -obj is the suffix
1702 StringRef ObjectFormatTypeName =
1704 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1705 EnvironmentName.consume_back(tmp);
1706 }
1707 }
1708 return EnvironmentName;
1709}
1710
1712 StringRef OSName = getOSName();
1713 // Assume that the OS portion of the triple starts with the canonical name.
1714 StringRef OSTypeName = getOSTypeName(getOS());
1715 if (OSName.starts_with(OSTypeName))
1716 OSName = OSName.substr(OSTypeName.size());
1717 else if (getOS() == MacOSX)
1718 OSName.consume_front("macos");
1719 else if (OSName.starts_with("visionos"))
1720 OSName.consume_front("visionos");
1721
1722 return parseVersionFromName(OSName);
1723}
1724
1727
1728 switch (getOS()) {
1729 default:
1730 llvm_unreachable("unexpected OS for Darwin triple");
1731 case Darwin:
1732 // Default to darwin8, i.e., MacOSX 10.4.
1733 if (Version.getMajor() == 0)
1734 Version = VersionTuple(8);
1735 // Darwin version numbers are skewed from OS X versions.
1736 if (Version.getMajor() < 4) {
1737 return false;
1738 }
1739 if (Version.getMajor() <= 19) {
1740 Version = VersionTuple(10, Version.getMajor() - 4);
1741 } else if (Version.getMajor() < 25) {
1742 // darwin20-24 corresponds to macOS 11-15.
1743 Version = VersionTuple(11 + Version.getMajor() - 20);
1744 } else {
1745 // darwin25 corresponds with macOS26+.
1746 Version = VersionTuple(Version.getMajor() + 1);
1747 }
1748 break;
1749 case MacOSX:
1750 // Default to 10.4.
1751 if (Version.getMajor() == 0) {
1752 Version = VersionTuple(10, 4);
1753 } else if (Version.getMajor() < 10) {
1754 return false;
1755 }
1756 break;
1757 case IOS:
1758 case TvOS:
1759 case WatchOS:
1760 // Ignore the version from the triple. This is only handled because the
1761 // the clang driver combines OS X and IOS support into a common Darwin
1762 // toolchain that wants to know the OS X version number even when targeting
1763 // IOS.
1764 Version = VersionTuple(10, 4);
1765 break;
1766 case XROS:
1767 llvm_unreachable("OSX version isn't relevant for xrOS");
1768 case DriverKit:
1769 llvm_unreachable("OSX version isn't relevant for DriverKit");
1770 case Firmware:
1771 llvm_unreachable("OSX version isn't relevant for Firmware");
1772 }
1773 return true;
1774}
1775
1777 switch (getOS()) {
1778 default:
1779 llvm_unreachable("unexpected OS for Darwin triple");
1780 case Darwin:
1781 case MacOSX:
1782 // Ignore the version from the triple. This is only handled because the
1783 // the clang driver combines OS X and IOS support into a common Darwin
1784 // toolchain that wants to know the iOS version number even when targeting
1785 // OS X.
1786 return VersionTuple(5);
1787 case IOS:
1788 case TvOS: {
1790 // Default to 5.0 (or 7.0 for arm64).
1791 if (Version.getMajor() == 0)
1792 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1793 if (Version.getMajor() == 19)
1794 // tvOS 19 corresponds to ios26.
1795 return VersionTuple(26);
1798 }
1799 case XROS: {
1801 // xrOS 1 is aligned with iOS 17.
1802 if (Version.getMajor() < 3)
1803 return Version.withMajorReplaced(Version.getMajor() + 16);
1804 // visionOS 3 corresponds to ios 26+.
1805 if (Version.getMajor() == 3)
1806 return VersionTuple(26);
1809 }
1810 case WatchOS: {
1812 // watchOS 12 corresponds to ios 26.
1813 if (Version.getMajor() == 12)
1814 return VersionTuple(26);
1818 }
1819 case BridgeOS:
1820 llvm_unreachable("conflicting triple info");
1821 case DriverKit:
1822 llvm_unreachable("DriverKit doesn't have an iOS version");
1823 case Firmware:
1824 llvm_unreachable("iOS version isn't relevant for Firmware");
1825 }
1826}
1827
1829 switch (getOS()) {
1830 default:
1831 llvm_unreachable("unexpected OS for Darwin triple");
1832 case Darwin:
1833 case MacOSX:
1834 // Ignore the version from the triple. This is only handled because the
1835 // the clang driver combines OS X and IOS support into a common Darwin
1836 // toolchain that wants to know the iOS version number even when targeting
1837 // OS X.
1838 return VersionTuple(2);
1839 case WatchOS: {
1841 if (Version.getMajor() == 0)
1842 return VersionTuple(2);
1843 return Version;
1844 }
1845 case IOS:
1846 llvm_unreachable("conflicting triple info");
1847 case XROS:
1848 llvm_unreachable("watchOS version isn't relevant for xrOS");
1849 case DriverKit:
1850 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1851 case Firmware:
1852 llvm_unreachable("watchOS version isn't relevant for Firmware");
1853 }
1854}
1855
1857 switch (getOS()) {
1858 default:
1859 llvm_unreachable("unexpected OS for Darwin triple");
1860 case DriverKit:
1862 if (Version.getMajor() == 0)
1863 return Version.withMajorReplaced(19);
1864 return Version;
1865 }
1866}
1867
1869 if (getArch() != spirv || getOS() != Vulkan)
1870 llvm_unreachable("invalid Vulkan SPIR-V triple");
1871
1872 VersionTuple VulkanVersion = getOSVersion();
1873 SubArchType SpirvVersion = getSubArch();
1874
1876 // Vulkan 1.2 -> SPIR-V 1.5.
1878 // Vulkan 1.3 -> SPIR-V 1.6.
1880
1881 // If Vulkan version is unset, default to 1.2.
1882 if (VulkanVersion == VersionTuple(0))
1883 VulkanVersion = VersionTuple(1, 2);
1884
1885 if (ValidVersionMap.contains(VulkanVersion) &&
1886 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1887 SpirvVersion == NoSubArch))
1888 return VulkanVersion;
1889
1890 return VersionTuple(0);
1891}
1892
1894 if (getArch() != dxil || getOS() != ShaderModel)
1895 llvm_unreachable("invalid DXIL triple");
1896 StringRef Arch = getArchName();
1897 if (getSubArch() == NoSubArch)
1899 Arch.consume_front("dxilv");
1900 VersionTuple DXILVersion = parseVersionFromName(Arch);
1901 // FIXME: validate DXIL version against Shader Model version.
1902 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1903 return DXILVersion;
1904}
1905
1906void Triple::setTriple(const Twine &Str) { *this = Triple(Str); }
1907
1909 setArchName(getArchName(Kind, SubArch));
1910}
1911
1915
1917
1919 if (ObjectFormat == getDefaultFormat(*this))
1921
1923 getObjectFormatTypeName(ObjectFormat))
1924 .str());
1925}
1926
1928 if (Environment == UnknownEnvironment)
1930
1931 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1933 .str());
1934}
1935
1937 setTriple(Str + "-" + getVendorName() + "-" + getOSAndEnvironmentName());
1938}
1939
1941 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1942}
1943
1945 if (hasEnvironment())
1946 setTriple(getArchName() + "-" + getVendorName() + "-" + Str + "-" +
1948 else
1949 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1950}
1951
1953 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() + "-" +
1954 Str);
1955}
1956
1958 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1959}
1960
1962 switch (Arch) {
1964 return 0;
1965
1966 case llvm::Triple::avr:
1968 return 16;
1969
1972 case llvm::Triple::arc:
1973 case llvm::Triple::arm:
1975 case llvm::Triple::csky:
1976 case llvm::Triple::dxil:
1982 case llvm::Triple::m68k:
1983 case llvm::Triple::mips:
1986 case llvm::Triple::ppc:
1988 case llvm::Triple::r600:
1995 case llvm::Triple::spir:
1997 case llvm::Triple::tce:
2002 case llvm::Triple::x86:
2005 return 32;
2006
2029 case llvm::Triple::ve:
2032 return 64;
2033 }
2034 llvm_unreachable("Invalid architecture value");
2035}
2036
2038 switch (getArch()) {
2039 default:
2040 break;
2041 case Triple::ppc:
2042 case Triple::ppcle:
2043 if (isOSLinux())
2044 return 40;
2045 break;
2046 case Triple::ppc64:
2047 case Triple::ppc64le:
2048 if (isOSLinux())
2049 return 48;
2050 break;
2051 }
2052 return 32;
2053}
2054
2056 return getArchPointerBitWidth(getArch()) == 64;
2057}
2058
2060 return getArchPointerBitWidth(getArch()) == 32;
2061}
2062
2064 return getArchPointerBitWidth(getArch()) == 16;
2065}
2066
2068 Triple T(*this);
2069 switch (getArch()) {
2071 case Triple::amdgcn:
2072 case Triple::avr:
2073 case Triple::bpfeb:
2074 case Triple::bpfel:
2075 case Triple::msp430:
2076 case Triple::systemz:
2077 case Triple::ve:
2078 T.setArch(UnknownArch);
2079 break;
2080
2081 case Triple::aarch64_32:
2082 case Triple::amdil:
2083 case Triple::arc:
2084 case Triple::arm:
2085 case Triple::armeb:
2086 case Triple::csky:
2087 case Triple::dxil:
2088 case Triple::hexagon:
2089 case Triple::hsail:
2090 case Triple::kalimba:
2091 case Triple::lanai:
2093 case Triple::m68k:
2094 case Triple::mips:
2095 case Triple::mipsel:
2096 case Triple::nvptx:
2097 case Triple::ppc:
2098 case Triple::ppcle:
2099 case Triple::r600:
2101 case Triple::riscv32:
2102 case Triple::riscv32be:
2103 case Triple::shave:
2104 case Triple::sparc:
2105 case Triple::sparcel:
2106 case Triple::spir:
2107 case Triple::spirv32:
2108 case Triple::tce:
2109 case Triple::tcele:
2110 case Triple::thumb:
2111 case Triple::thumbeb:
2112 case Triple::wasm32:
2113 case Triple::x86:
2114 case Triple::xcore:
2115 case Triple::xtensa:
2116 // Already 32-bit.
2117 break;
2118
2119 case Triple::aarch64:
2120 T.setArch(Triple::arm);
2121 break;
2122 case Triple::aarch64_be:
2123 T.setArch(Triple::armeb);
2124 break;
2125 case Triple::amdil64:
2126 T.setArch(Triple::amdil);
2127 break;
2128 case Triple::hsail64:
2129 T.setArch(Triple::hsail);
2130 break;
2132 T.setArch(Triple::loongarch32);
2133 break;
2134 case Triple::mips64:
2135 T.setArch(Triple::mips, getSubArch());
2136 break;
2137 case Triple::mips64el:
2138 T.setArch(Triple::mipsel, getSubArch());
2139 break;
2140 case Triple::nvptx64:
2141 T.setArch(Triple::nvptx);
2142 break;
2143 case Triple::ppc64:
2144 T.setArch(Triple::ppc);
2145 break;
2146 case Triple::ppc64le:
2147 T.setArch(Triple::ppcle);
2148 break;
2150 T.setArch(Triple::renderscript32);
2151 break;
2152 case Triple::riscv64:
2153 T.setArch(Triple::riscv32);
2154 break;
2155 case Triple::riscv64be:
2156 T.setArch(Triple::riscv32be);
2157 break;
2158 case Triple::sparcv9:
2159 T.setArch(Triple::sparc);
2160 break;
2161 case Triple::spir64:
2162 T.setArch(Triple::spir);
2163 break;
2164 case Triple::spirv:
2165 case Triple::spirv64:
2166 T.setArch(Triple::spirv32, getSubArch());
2167 break;
2168 case Triple::tcele64:
2169 T.setArch(Triple::tcele);
2170 break;
2171 case Triple::wasm64:
2172 T.setArch(Triple::wasm32);
2173 break;
2174 case Triple::x86_64:
2175 T.setArch(Triple::x86);
2176 break;
2177 }
2178 return T;
2179}
2180
2182 Triple T(*this);
2183 switch (getArch()) {
2185 case Triple::arc:
2186 case Triple::avr:
2187 case Triple::csky:
2188 case Triple::dxil:
2189 case Triple::hexagon:
2190 case Triple::kalimba:
2191 case Triple::lanai:
2192 case Triple::m68k:
2193 case Triple::msp430:
2194 case Triple::r600:
2195 case Triple::shave:
2196 case Triple::sparcel:
2197 case Triple::tce:
2198 case Triple::xcore:
2199 case Triple::xtensa:
2200 T.setArch(UnknownArch);
2201 break;
2202
2203 case Triple::aarch64:
2204 case Triple::aarch64_be:
2205 case Triple::amdgcn:
2206 case Triple::amdil64:
2207 case Triple::bpfeb:
2208 case Triple::bpfel:
2209 case Triple::hsail64:
2211 case Triple::mips64:
2212 case Triple::mips64el:
2213 case Triple::nvptx64:
2214 case Triple::ppc64:
2215 case Triple::ppc64le:
2217 case Triple::riscv64:
2218 case Triple::riscv64be:
2219 case Triple::sparcv9:
2220 case Triple::spir64:
2221 case Triple::spirv64:
2222 case Triple::systemz:
2223 case Triple::tcele64:
2224 case Triple::ve:
2225 case Triple::wasm64:
2226 case Triple::x86_64:
2227 // Already 64-bit.
2228 break;
2229
2230 case Triple::aarch64_32:
2231 T.setArch(Triple::aarch64);
2232 break;
2233 case Triple::amdil:
2234 T.setArch(Triple::amdil64);
2235 break;
2236 case Triple::arm:
2237 T.setArch(Triple::aarch64);
2238 break;
2239 case Triple::armeb:
2240 T.setArch(Triple::aarch64_be);
2241 break;
2242 case Triple::hsail:
2243 T.setArch(Triple::hsail64);
2244 break;
2246 T.setArch(Triple::loongarch64);
2247 break;
2248 case Triple::mips:
2249 T.setArch(Triple::mips64, getSubArch());
2250 break;
2251 case Triple::mipsel:
2252 T.setArch(Triple::mips64el, getSubArch());
2253 break;
2254 case Triple::nvptx:
2255 T.setArch(Triple::nvptx64);
2256 break;
2257 case Triple::ppc:
2258 T.setArch(Triple::ppc64);
2259 break;
2260 case Triple::ppcle:
2261 T.setArch(Triple::ppc64le);
2262 break;
2264 T.setArch(Triple::renderscript64);
2265 break;
2266 case Triple::riscv32:
2267 T.setArch(Triple::riscv64);
2268 break;
2269 case Triple::riscv32be:
2270 T.setArch(Triple::riscv64be);
2271 break;
2272 case Triple::sparc:
2273 T.setArch(Triple::sparcv9);
2274 break;
2275 case Triple::spir:
2276 T.setArch(Triple::spir64);
2277 break;
2278 case Triple::spirv:
2279 case Triple::spirv32:
2280 T.setArch(Triple::spirv64, getSubArch());
2281 break;
2282 case Triple::tcele:
2283 T.setArch(Triple::tcele64);
2284 break;
2285 case Triple::thumb:
2286 T.setArch(Triple::aarch64);
2287 break;
2288 case Triple::thumbeb:
2289 T.setArch(Triple::aarch64_be);
2290 break;
2291 case Triple::wasm32:
2292 T.setArch(Triple::wasm64);
2293 break;
2294 case Triple::x86:
2295 T.setArch(Triple::x86_64);
2296 break;
2297 }
2298 return T;
2299}
2300
2302 Triple T(*this);
2303 // Already big endian.
2304 if (!isLittleEndian())
2305 return T;
2306 switch (getArch()) {
2308 case Triple::amdgcn:
2309 case Triple::amdil64:
2310 case Triple::amdil:
2311 case Triple::avr:
2312 case Triple::dxil:
2313 case Triple::hexagon:
2314 case Triple::hsail64:
2315 case Triple::hsail:
2316 case Triple::kalimba:
2319 case Triple::msp430:
2320 case Triple::nvptx64:
2321 case Triple::nvptx:
2322 case Triple::r600:
2325 case Triple::shave:
2326 case Triple::spir64:
2327 case Triple::spir:
2328 case Triple::spirv:
2329 case Triple::spirv32:
2330 case Triple::spirv64:
2331 case Triple::tcele64:
2332 case Triple::wasm32:
2333 case Triple::wasm64:
2334 case Triple::x86:
2335 case Triple::x86_64:
2336 case Triple::xcore:
2337 case Triple::ve:
2338 case Triple::csky:
2339 case Triple::xtensa:
2340
2341 // ARM is intentionally unsupported here, changing the architecture would
2342 // drop any arch suffixes.
2343 case Triple::arm:
2344 case Triple::thumb:
2345 T.setArch(UnknownArch);
2346 break;
2347
2348 case Triple::aarch64:
2349 T.setArch(Triple::aarch64_be);
2350 break;
2351 case Triple::bpfel:
2352 T.setArch(Triple::bpfeb);
2353 break;
2354 case Triple::mips64el:
2355 T.setArch(Triple::mips64, getSubArch());
2356 break;
2357 case Triple::mipsel:
2358 T.setArch(Triple::mips, getSubArch());
2359 break;
2360 case Triple::ppcle:
2361 T.setArch(Triple::ppc);
2362 break;
2363 case Triple::ppc64le:
2364 T.setArch(Triple::ppc64);
2365 break;
2366 case Triple::riscv32:
2367 T.setArch(Triple::riscv32be);
2368 break;
2369 case Triple::riscv64:
2370 T.setArch(Triple::riscv64be);
2371 break;
2372 case Triple::sparcel:
2373 T.setArch(Triple::sparc);
2374 break;
2375 case Triple::tcele:
2376 T.setArch(Triple::tce);
2377 break;
2378 default:
2379 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
2380 }
2381 return T;
2382}
2383
2385 Triple T(*this);
2386 if (isLittleEndian())
2387 return T;
2388
2389 switch (getArch()) {
2391 case Triple::lanai:
2392 case Triple::sparcv9:
2393 case Triple::systemz:
2394 case Triple::m68k:
2395
2396 // ARM is intentionally unsupported here, changing the architecture would
2397 // drop any arch suffixes.
2398 case Triple::armeb:
2399 case Triple::thumbeb:
2400 T.setArch(UnknownArch);
2401 break;
2402
2403 case Triple::aarch64_be:
2404 T.setArch(Triple::aarch64);
2405 break;
2406 case Triple::bpfeb:
2407 T.setArch(Triple::bpfel);
2408 break;
2409 case Triple::mips64:
2410 T.setArch(Triple::mips64el, getSubArch());
2411 break;
2412 case Triple::mips:
2413 T.setArch(Triple::mipsel, getSubArch());
2414 break;
2415 case Triple::ppc:
2416 T.setArch(Triple::ppcle);
2417 break;
2418 case Triple::ppc64:
2419 T.setArch(Triple::ppc64le);
2420 break;
2421 case Triple::riscv32be:
2422 T.setArch(Triple::riscv32);
2423 break;
2424 case Triple::riscv64be:
2425 T.setArch(Triple::riscv64);
2426 break;
2427 case Triple::sparc:
2428 T.setArch(Triple::sparcel);
2429 break;
2430 case Triple::tce:
2431 T.setArch(Triple::tcele);
2432 break;
2433 default:
2434 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
2435 }
2436 return T;
2437}
2438
2440 switch (getArch()) {
2441 case Triple::aarch64:
2442 case Triple::aarch64_32:
2443 case Triple::amdgcn:
2444 case Triple::amdil64:
2445 case Triple::amdil:
2446 case Triple::arm:
2447 case Triple::avr:
2448 case Triple::bpfel:
2449 case Triple::csky:
2450 case Triple::dxil:
2451 case Triple::hexagon:
2452 case Triple::hsail64:
2453 case Triple::hsail:
2454 case Triple::kalimba:
2457 case Triple::mips64el:
2458 case Triple::mipsel:
2459 case Triple::msp430:
2460 case Triple::nvptx64:
2461 case Triple::nvptx:
2462 case Triple::ppcle:
2463 case Triple::ppc64le:
2464 case Triple::r600:
2467 case Triple::riscv32:
2468 case Triple::riscv64:
2469 case Triple::shave:
2470 case Triple::sparcel:
2471 case Triple::spir64:
2472 case Triple::spir:
2473 case Triple::spirv:
2474 case Triple::spirv32:
2475 case Triple::spirv64:
2476 case Triple::tcele:
2477 case Triple::tcele64:
2478 case Triple::thumb:
2479 case Triple::ve:
2480 case Triple::wasm32:
2481 case Triple::wasm64:
2482 case Triple::x86:
2483 case Triple::x86_64:
2484 case Triple::xcore:
2485 case Triple::xtensa:
2486 return true;
2487 default:
2488 return false;
2489 }
2490}
2491
2493 if (getArch() == Triple::xcore)
2494 return 1;
2496 return 2;
2497 if (isOSAIX() && isArch32Bit())
2498 return 2;
2499 return 4;
2500}
2501
2503 // On MinGW, C code is usually built with a "w64" vendor, while Rust
2504 // often uses a "pc" vendor.
2505 bool IgnoreVendor = isWindowsGNUEnvironment();
2506
2507 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
2508 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2509 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2510 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2511 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2512 if (getVendor() == Triple::Apple)
2513 return getSubArch() == Other.getSubArch() &&
2514 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2515 else
2516 return getSubArch() == Other.getSubArch() &&
2517 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2518 getOS() == Other.getOS() &&
2519 getEnvironment() == Other.getEnvironment() &&
2520 getObjectFormat() == Other.getObjectFormat();
2521 }
2522
2523 // If vendor is apple, ignore the version number (the environment field)
2524 // and the object format.
2525 if (getVendor() == Triple::Apple)
2526 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2527 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2528 getOS() == Other.getOS();
2529
2530 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2531 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2532 getOS() == Other.getOS() &&
2533 getEnvironment() == Other.getEnvironment() &&
2534 getObjectFormat() == Other.getObjectFormat();
2535}
2536
2537std::string Triple::merge(const Triple &Other) const {
2538 // If vendor is apple, pick the triple with the larger version number.
2539 if (getVendor() == Triple::Apple)
2540 if (Other.isOSVersionLT(*this))
2541 return str();
2542
2543 return Other.str();
2544}
2545
2546bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2547 unsigned Micro) const {
2548 assert(isMacOSX() && "Not an OS X triple!");
2549
2550 // If this is OS X, expect a sane version number.
2551 if (getOS() == Triple::MacOSX)
2552 return isOSVersionLT(Major, Minor, Micro);
2553
2554 // Otherwise, compare to the "Darwin" number.
2555 if (Major == 10)
2556 return isOSVersionLT(Minor + 4, Micro, 0);
2557 assert(Major >= 11 && "Unexpected major version");
2558 if (Major < 25)
2559 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2560 return isOSVersionLT(Major + 1, Minor, Micro);
2561}
2562
2565 return VersionTuple();
2566 switch (getOS()) {
2567 case Triple::MacOSX:
2568 // ARM64 slice is supported starting from macOS 11.0+.
2569 return VersionTuple(11, 0, 0);
2570 case Triple::IOS:
2571 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2572 // ARM64 simulators are supported for iOS 14+.
2574 return VersionTuple(14, 0, 0);
2575 // ARM64e slice is supported starting from iOS 14.
2576 if (isArm64e())
2577 return VersionTuple(14, 0, 0);
2578 break;
2579 case Triple::TvOS:
2580 // ARM64 simulators are supported for tvOS 14+.
2582 return VersionTuple(14, 0, 0);
2583 break;
2584 case Triple::WatchOS:
2585 // ARM64 simulators are supported for watchOS 7+.
2587 return VersionTuple(7, 0, 0);
2588 // ARM64/ARM64e slices are supported starting from watchOS 26.
2589 // ARM64_32 is older though.
2591 return VersionTuple(26, 0, 0);
2592 case Triple::DriverKit:
2593 return VersionTuple(20, 0, 0);
2594 default:
2595 break;
2596 }
2597 return VersionTuple();
2598}
2599
2601 const VersionTuple &Version,
2602 bool IsInValidRange) {
2603 const unsigned MacOSRangeBump = 10;
2604 const unsigned IOSRangeBump = 7;
2605 const unsigned XROSRangeBump = 23;
2606 const unsigned WatchOSRangeBump = 14;
2607 switch (OSKind) {
2608 case MacOSX: {
2609 // macOS 10.16 is canonicalized to macOS 11.
2610 if (Version == VersionTuple(10, 16))
2611 return VersionTuple(11, 0);
2612 // macOS 16 is canonicalized to macOS 26.
2613 if (Version == VersionTuple(16, 0))
2614 return VersionTuple(26, 0);
2615 if (!IsInValidRange)
2616 return Version.withMajorReplaced(Version.getMajor() + MacOSRangeBump);
2617 break;
2618 }
2619 case IOS:
2620 case TvOS: {
2621 // Both iOS & tvOS 19.0 canonicalize to 26.
2622 if (Version == VersionTuple(19, 0))
2623 return VersionTuple(26, 0);
2624 if (!IsInValidRange)
2625 return Version.withMajorReplaced(Version.getMajor() + IOSRangeBump);
2626 break;
2627 }
2628 case XROS: {
2629 // visionOS3 is canonicalized to 26.
2630 if (Version == VersionTuple(3, 0))
2631 return VersionTuple(26, 0);
2632 if (!IsInValidRange)
2633 return Version.withMajorReplaced(Version.getMajor() + XROSRangeBump);
2634 break;
2635 }
2636 case WatchOS: {
2637 // watchOS 12 is canonicalized to 26.
2638 if (Version == VersionTuple(12, 0))
2639 return VersionTuple(26, 0);
2640 if (!IsInValidRange)
2641 return Version.withMajorReplaced(Version.getMajor() + WatchOSRangeBump);
2642 break;
2643 }
2644 default:
2645 return Version;
2646 }
2647
2648 return Version;
2649}
2650
2652 /// This constant is used to capture gaps in versioning.
2653 const VersionTuple CommonVersion(26);
2654 auto IsValid = [&](const VersionTuple &StartingVersion) {
2655 return !((Version > StartingVersion) && (Version < CommonVersion));
2656 };
2657 switch (OSKind) {
2658 case WatchOS: {
2659 const VersionTuple StartingWatchOS(12);
2660 return IsValid(StartingWatchOS);
2661 }
2662 case IOS:
2663 case TvOS: {
2664 const VersionTuple StartingIOS(19);
2665 return IsValid(StartingIOS);
2666 }
2667 case MacOSX: {
2668 const VersionTuple StartingMacOS(16);
2669 return IsValid(StartingMacOS);
2670 }
2671 case XROS: {
2672 const VersionTuple StartingXROS(3);
2673 return IsValid(StartingXROS);
2674 }
2675 default:
2676 return true;
2677 }
2678
2679 llvm_unreachable("unexpected or invalid os version");
2680}
2681
2683 if (isOSBinFormatCOFF()) {
2684 if (getArch() == Triple::x86 &&
2688 }
2689
2690 if (isOSBinFormatXCOFF())
2692 if (isOSBinFormatGOFF())
2694
2695 if (isARM() || isThumb()) {
2696 if (isOSBinFormatELF()) {
2699 }
2700
2703 }
2704
2705 if (isAArch64() || isX86() || isPPC() || isMIPS() || isSPARC() || isBPF() ||
2706 isRISCV() || isLoongArch())
2708
2709 switch (getArch()) {
2710 case Triple::arc:
2711 case Triple::csky:
2712 case Triple::hexagon:
2713 case Triple::lanai:
2714 case Triple::m68k:
2715 case Triple::msp430:
2716 case Triple::systemz:
2717 case Triple::xcore:
2718 case Triple::xtensa:
2720 default:
2721 break;
2722 }
2723
2724 // Explicitly none targets.
2725 if (isWasm() || isAMDGPU() || isNVPTX() || isSPIROrSPIRV())
2727
2728 // Default to none.
2730}
2731
2732// HLSL triple environment orders are relied on in the front end
2733static_assert(Triple::Vertex - Triple::Pixel == 1,
2734 "incorrect HLSL stage order");
2735static_assert(Triple::Geometry - Triple::Pixel == 2,
2736 "incorrect HLSL stage order");
2737static_assert(Triple::Hull - Triple::Pixel == 3, "incorrect HLSL stage order");
2738static_assert(Triple::Domain - Triple::Pixel == 4,
2739 "incorrect HLSL stage order");
2740static_assert(Triple::Compute - Triple::Pixel == 5,
2741 "incorrect HLSL stage order");
2742static_assert(Triple::Library - Triple::Pixel == 6,
2743 "incorrect HLSL stage order");
2744static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2745 "incorrect HLSL stage order");
2746static_assert(Triple::Intersection - Triple::Pixel == 8,
2747 "incorrect HLSL stage order");
2748static_assert(Triple::AnyHit - Triple::Pixel == 9,
2749 "incorrect HLSL stage order");
2750static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2751 "incorrect HLSL stage order");
2752static_assert(Triple::Miss - Triple::Pixel == 11, "incorrect HLSL stage order");
2753static_assert(Triple::Callable - Triple::Pixel == 12,
2754 "incorrect HLSL stage order");
2755static_assert(Triple::Mesh - Triple::Pixel == 13, "incorrect HLSL stage order");
2756static_assert(Triple::Amplification - Triple::Pixel == 14,
2757 "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:971
static VersionTuple parseVersionFromName(StringRef Name)
Definition Triple.cpp:1678
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:1374
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:2546
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1711
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1047
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1656
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1828
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1936
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1927
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:2067
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:734
bool isWatchABI() const
Definition Triple.h:619
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:909
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:2600
CanonicalForm
Canonical form.
Definition Triple.h:410
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:538
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2384
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1147
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:459
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:438
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1107
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1129
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:784
bool isWindowsGNUEnvironment() const
Definition Triple.h:729
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1940
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1957
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:2181
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2439
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1918
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1661
bool isSPIROrSPIRV() const
Definition Triple.h:893
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2682
@ 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:1906
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:444
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1684
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:1421
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:435
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:2037
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:781
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1667
bool isSimulatorEnvironment() const
Definition Triple.h:651
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1893
const std::string & str() const
Definition Triple.h:500
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:450
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1868
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1856
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:695
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:698
static LLVM_ABI StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition Triple.cpp:24
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition Triple.h:793
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:397
@ UnknownObjectFormat
Definition Triple.h:331
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:914
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2537
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:745
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1090
bool isAMDGPU() const
Definition Triple.h:906
@ 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:899
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:770
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2563
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:2055
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1673
@ 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:1725
bool isWindowsCygwinEnvironment() const
Definition Triple.h:725
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:2651
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:602
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1952
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1916
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1944
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:441
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1101
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:644
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:566
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:505
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1044
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:819
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1121
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1652
bool isMacCatalystEnvironment() const
Definition Triple.h:655
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1005
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:2063
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2301
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1776
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:1688
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:2059
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2502
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:778
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:447
unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2492
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:1908
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1912
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1031
bool isWindowsItaniumEnvironment() const
Definition Triple.h:721
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