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