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