LLVM 24.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"
21#include <cassert>
22#include <cstring>
23using namespace llvm;
24
25bool Triple::operator==(const Triple &Other) const {
26 return Arch == Other.Arch && SubArch == Other.SubArch &&
27 Vendor == Other.Vendor && OS == Other.OS &&
28 Environment == Other.Environment && ObjectFormat == Other.ObjectFormat;
29}
30
31bool Triple::operator<(const Triple &Other) const {
32 return std::tie(Arch, SubArch, Vendor, OS, Environment, ObjectFormat, Data) <
33 std::tie(Other.Arch, Other.SubArch, Other.Vendor, Other.OS,
34 Other.Environment, Other.ObjectFormat, Other.Data);
35}
36
38 switch (Kind) {
39 case UnknownArch:
40 return "unknown";
41
42 case aarch64:
43 return "aarch64";
44 case aarch64_32:
45 return "aarch64_32";
46 case aarch64_be:
47 return "aarch64_be";
48 case amdgpu:
49 return "amdgpu";
50 case amdil64:
51 return "amdil64";
52 case amdil:
53 return "amdil";
54 case arc:
55 return "arc";
56 case arm:
57 return "arm";
58 case armeb:
59 return "armeb";
60 case avr:
61 return "avr";
62 case bpfeb:
63 return "bpfeb";
64 case bpfel:
65 return "bpfel";
66 case csky:
67 return "csky";
68 case dxil:
69 return "dxil";
70 case hexagon:
71 return "hexagon";
72 case hsail64:
73 return "hsail64";
74 case hsail:
75 return "hsail";
76 case kalimba:
77 return "kalimba";
78 case lanai:
79 return "lanai";
80 case loongarch32:
81 return "loongarch32";
82 case loongarch64:
83 return "loongarch64";
84 case m68k:
85 return "m68k";
86 case mips64:
87 return "mips64";
88 case mips64el:
89 return "mips64el";
90 case mips:
91 return "mips";
92 case mipsel:
93 return "mipsel";
94 case msp430:
95 return "msp430";
96 case nanomips:
97 return "nanomips";
98 case nvptx64:
99 return "nvptx64";
100 case nvptx:
101 return "nvptx";
102 case pisa:
103 return "pisa";
104 case ppc64:
105 return "powerpc64";
106 case ppc64le:
107 return "powerpc64le";
108 case ppc:
109 return "powerpc";
110 case ppcle:
111 return "powerpcle";
112 case r600:
113 return "r600";
114 case renderscript32:
115 return "renderscript32";
116 case renderscript64:
117 return "renderscript64";
118 case riscv32:
119 return "riscv32";
120 case riscv64:
121 return "riscv64";
122 case riscv32be:
123 return "riscv32be";
124 case riscv64be:
125 return "riscv64be";
126 case shave:
127 return "shave";
128 case sparc:
129 return "sparc";
130 case sparcel:
131 return "sparcel";
132 case sparcv9:
133 return "sparcv9";
134 case spir64:
135 return "spir64";
136 case spir:
137 return "spir";
138 case spirv:
139 return "spirv";
140 case spirv32:
141 return "spirv32";
142 case spirv64:
143 return "spirv64";
144 case systemz:
145 return "s390x";
146 case tce:
147 return "tce";
148 case tcele:
149 return "tcele";
150 case tcele64:
151 return "tcele64";
152 case thumb:
153 return "thumb";
154 case thumbeb:
155 return "thumbeb";
156 case ve:
157 return "ve";
158 case wasm32:
159 return "wasm32";
160 case wasm64:
161 return "wasm64";
162 case x86:
163 return "i386";
164 case x86_64:
165 return "x86_64";
166 case xcore:
167 return "xcore";
168 case xtensa:
169 return "xtensa";
170 }
171
172 llvm_unreachable("Invalid ArchType!");
173}
174
176 switch (Kind) {
177 case Triple::mips:
178 if (SubArch == MipsSubArch_r6)
179 return "mipsisa32r6";
180 break;
181 case Triple::mipsel:
182 if (SubArch == MipsSubArch_r6)
183 return "mipsisa32r6el";
184 break;
185 case Triple::mips64:
186 if (SubArch == MipsSubArch_r6)
187 return "mipsisa64r6";
188 break;
189 case Triple::mips64el:
190 if (SubArch == MipsSubArch_r6)
191 return "mipsisa64r6el";
192 break;
193 case Triple::aarch64:
194 if (SubArch == AArch64SubArch_arm64ec)
195 return "arm64ec";
196 if (SubArch == AArch64SubArch_arm64e)
197 return "arm64e";
198 if (SubArch == AArch64SubArch_arm64e_x1)
199 return "arm64e.x1";
200 if (SubArch == AArch64SubArch_lfi)
201 return "aarch64_lfi";
202 break;
203 case Triple::x86_64:
204 if (SubArch == X86_64SubArch_lfi)
205 return "x86_64_lfi";
206 break;
207 case Triple::spirv:
208 switch (SubArch) {
210 return "spirv1.0";
212 return "spirv1.1";
214 return "spirv1.2";
216 return "spirv1.3";
218 return "spirv1.4";
220 return "spirv1.5";
222 return "spirv1.6";
223 default:
224 break;
225 }
226 break;
227 case Triple::dxil:
228 switch (SubArch) {
231 return "dxilv1.0";
233 return "dxilv1.1";
235 return "dxilv1.2";
237 return "dxilv1.3";
239 return "dxilv1.4";
241 return "dxilv1.5";
243 return "dxilv1.6";
245 return "dxilv1.7";
247 return "dxilv1.8";
249 return "dxilv1.9";
251 return "dxilv1.10";
252 default:
253 break;
254 }
255 break;
256 case Triple::amdgpu:
257 return AMDGPU::getSubArchName(SubArch);
258 default:
259 break;
260 }
261 return getArchTypeName(Kind);
262}
263
265 switch (Kind) {
266 default:
267 return StringRef();
268
269 case aarch64:
270 case aarch64_be:
271 case aarch64_32:
272 return "aarch64";
273
274 case arc:
275 return "arc";
276
277 case arm:
278 case armeb:
279 case thumb:
280 case thumbeb:
281 return "arm";
282
283 case avr:
284 return "avr";
285
286 case ppc64:
287 case ppc64le:
288 case ppc:
289 case ppcle:
290 return "ppc";
291
292 case m68k:
293 return "m68k";
294
295 case nanomips:
296 case mips:
297 case mipsel:
298 case mips64:
299 case mips64el:
300 return "mips";
301
302 case hexagon:
303 return "hexagon";
304
305 // Intrinsics use amdgcn prefix.
306 case amdgpu:
307 return "amdgcn";
308 case r600:
309 return "r600";
310
311 case bpfel:
312 case bpfeb:
313 return "bpf";
314
315 case sparcv9:
316 case sparcel:
317 case sparc:
318 return "sparc";
319
320 case systemz:
321 return "s390";
322
323 case x86:
324 case x86_64:
325 return "x86";
326
327 case xcore:
328 return "xcore";
329
330 // NVPTX intrinsics are namespaced under nvvm.
331 case nvptx:
332 return "nvvm";
333 case nvptx64:
334 return "nvvm";
335
336 case amdil:
337 case amdil64:
338 return "amdil";
339
340 case hsail:
341 case hsail64:
342 return "hsail";
343
344 case spir:
345 case spir64:
346 return "spir";
347
348 case spirv:
349 case spirv32:
350 case spirv64:
351 return "spv";
352
353 case kalimba:
354 return "kalimba";
355 case lanai:
356 return "lanai";
357 case shave:
358 return "shave";
359 case wasm32:
360 case wasm64:
361 return "wasm";
362
363 case riscv32:
364 case riscv64:
365 case riscv32be:
366 case riscv64be:
367 return "riscv";
368
369 case ve:
370 return "ve";
371 case csky:
372 return "csky";
373
374 case loongarch32:
375 case loongarch64:
376 return "loongarch";
377
378 case pisa:
379 return "pisa";
380
381 case dxil:
382 return "dx";
383
384 case xtensa:
385 return "xtensa";
386 }
387}
388
390 switch (Kind) {
391 case UnknownVendor:
392 return "unknown";
393#define TRIPLE_VENDOR(Enum, Name) \
394 case Enum: \
395 return Name;
396#include "llvm/TargetParser/TripleName.def"
397 }
398
399 llvm_unreachable("Invalid VendorType!");
400}
401
403 switch (Kind) {
404 case UnknownOS:
405 return "unknown";
406#define TRIPLE_OS(Enum, Name, CMakeName) \
407 case Enum: \
408 return Name;
409#include "llvm/TargetParser/TripleName.def"
410 }
411
412 llvm_unreachable("Invalid OSType");
413}
414
416 switch (Kind) {
418 return "unknown";
419#define TRIPLE_ENV(Enum, Name, CMakeOverride) \
420 case Enum: \
421 return Name;
422#include "llvm/TargetParser/TripleName.def"
423 }
424
425 llvm_unreachable("Invalid EnvironmentType!");
426}
427
429 switch (Kind) {
431 return "";
432 case COFF:
433 return "coff";
434 case ELF:
435 return "elf";
436 case GOFF:
437 return "goff";
438 case MachO:
439 return "macho";
440 case Wasm:
441 return "wasm";
442 case XCOFF:
443 return "xcoff";
444 case DXContainer:
445 return "dxcontainer";
446 case SPIRV:
447 return "spirv";
448 }
449 llvm_unreachable("unknown object format type");
450}
451
453 if (ArchName == "bpf") {
455 return Triple::bpfel;
456 else
457 return Triple::bpfeb;
458 } else if (ArchName == "bpf_be" || ArchName == "bpfeb") {
459 return Triple::bpfeb;
460 } else if (ArchName == "bpf_le" || ArchName == "bpfel") {
461 return Triple::bpfel;
462 } else {
463 return Triple::UnknownArch;
464 }
465}
466
468 Triple::ArchType BPFArch(parseBPFArch(Name));
470 .Case("aarch64", aarch64)
471 .Case("aarch64_be", aarch64_be)
472 .Case("aarch64_32", aarch64_32)
473 .Case("arc", arc)
474 .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
475 .Case("arm64_32", aarch64_32)
476 .Case("arm", arm)
477 .Case("armeb", armeb)
478 .Case("avr", avr)
479 .StartsWith("bpf", BPFArch)
480 .Case("m68k", m68k)
481 .Case("mips", mips)
482 .Case("mipsel", mipsel)
483 .Case("mips64", mips64)
484 .Case("mips64el", mips64el)
485 .Case("msp430", msp430)
486 .Case("nanomips", nanomips)
487 .Case("ppc64", ppc64)
488 .Case("ppc32", ppc)
489 .Case("ppc", ppc)
490 .Case("ppc32le", ppcle)
491 .Case("ppcle", ppcle)
492 .Case("ppc64le", ppc64le)
493 .Case("amdgpu", amdgpu)
494 .Case("amdgcn", amdgpu) // Legacy name
495 .Case("r600", r600)
496 .Case("riscv32", riscv32)
497 .Case("riscv64", riscv64)
498 .Case("riscv32be", riscv32be)
499 .Case("riscv64be", riscv64be)
500 .Case("hexagon", hexagon)
501 .Case("sparc", sparc)
502 .Case("sparcel", sparcel)
503 .Case("sparcv9", sparcv9)
504 .Case("s390x", systemz)
505 .Case("systemz", systemz)
506 .Case("tce", tce)
507 .Case("tcele", tcele)
508 .Case("tcele64", tcele64)
509 .Case("thumb", thumb)
510 .Case("thumbeb", thumbeb)
511 .Case("x86", x86)
512 .Case("i386", x86)
513 .Case("x86-64", x86_64)
514 .Case("xcore", xcore)
515 .Case("nvptx", nvptx)
516 .Case("nvptx64", nvptx64)
517 .Case("pisa", pisa)
518 .Case("amdil", amdil)
519 .Case("amdil64", amdil64)
520 .Case("hsail", hsail)
521 .Case("hsail64", hsail64)
522 .Case("spir", spir)
523 .Case("spir64", spir64)
524 .Case("spirv", spirv)
525 .Case("spirv32", spirv32)
526 .Case("spirv64", spirv64)
527 .Case("kalimba", kalimba)
528 .Case("lanai", lanai)
529 .Case("shave", shave)
530 .Case("wasm32", wasm32)
531 .Case("wasm64", wasm64)
532 .Case("renderscript32", renderscript32)
533 .Case("renderscript64", renderscript64)
534 .Case("ve", ve)
535 .Case("csky", csky)
536 .Case("loongarch32", loongarch32)
537 .Case("loongarch64", loongarch64)
538 .Case("dxil", dxil)
539 .Case("xtensa", xtensa)
541}
542
544 ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
545 ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
546
548 switch (ENDIAN) {
550 switch (ISA) {
552 arch = Triple::arm;
553 break;
555 arch = Triple::thumb;
556 break;
558 arch = Triple::aarch64;
559 break;
561 break;
562 }
563 break;
564 }
566 switch (ISA) {
568 arch = Triple::armeb;
569 break;
571 arch = Triple::thumbeb;
572 break;
574 arch = Triple::aarch64_be;
575 break;
577 break;
578 }
579 break;
580 }
582 break;
583 }
584 }
585
586 ArchName = ARM::getCanonicalArchName(ArchName);
587 if (ArchName.empty())
588 return Triple::UnknownArch;
589
590 // Thumb only exists in v4+
591 if (ISA == ARM::ISAKind::THUMB &&
592 (ArchName.starts_with("v2") || ArchName.starts_with("v3")))
593 return Triple::UnknownArch;
594
595 // Thumb only for v6m
597 unsigned Version = ARM::parseArchVersion(ArchName);
598 if (Profile == ARM::ProfileKind::M && Version == 6) {
599 if (ENDIAN == ARM::EndianKind::BIG)
600 return Triple::thumbeb;
601 else
602 return Triple::thumb;
603 }
604
605 return arch;
606}
607
609 auto AT =
611 .Cases({"i386", "i486", "i586", "i686"}, Triple::x86)
612 // FIXME: Do we need to support these?
613 .Cases({"i786", "i886", "i986"}, Triple::x86)
614 .Cases({"amd64", "x86_64", "x86_64h", "x86_64_lfi"}, Triple::x86_64)
615 .Cases({"powerpc", "powerpcspe", "ppc", "ppc32"}, Triple::ppc)
616 .Cases({"powerpcle", "ppcle", "ppc32le"}, Triple::ppcle)
617 .Cases({"powerpc64", "ppu", "ppc64"}, Triple::ppc64)
618 .Cases({"powerpc64le", "ppc64le"}, Triple::ppc64le)
619 .Case("xscale", Triple::arm)
620 .Case("xscaleeb", Triple::armeb)
621 .Case("aarch64", Triple::aarch64)
622 .Case("aarch64_be", Triple::aarch64_be)
623 .Case("aarch64_32", Triple::aarch64_32)
624 .Case("aarch64_lfi", Triple::aarch64)
625 .Case("arc", Triple::arc)
626 .Case("arm64", Triple::aarch64)
627 .Case("arm64_32", Triple::aarch64_32)
628 .Case("arm64e", Triple::aarch64)
629 .Case("arm64e.x1", Triple::aarch64)
630 .Case("arm64ec", Triple::aarch64)
631 .Case("arm", Triple::arm)
632 .Case("armeb", Triple::armeb)
633 .Case("thumb", Triple::thumb)
634 .Case("thumbeb", Triple::thumbeb)
635 .Case("avr", Triple::avr)
636 .Case("m68k", Triple::m68k)
637 .Case("msp430", Triple::msp430)
638 .Cases({"mips", "mipseb", "mipsallegrex", "mipsisa32r6", "mipsr6"},
640 .Cases({"mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el"},
642 .Cases({"mips64", "mips64eb", "mipsn32", "mipsisa64r6", "mips64r6",
643 "mipsn32r6"},
645 .Cases({"mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
646 "mipsn32r6el"},
648 .StartsWith("amdgpu", Triple::amdgpu)
649 .Case("amdgcn", Triple::amdgpu)
650 .Case("r600", Triple::r600)
651 .Case("riscv32", Triple::riscv32)
652 .Case("riscv64", Triple::riscv64)
653 .Case("riscv32be", Triple::riscv32be)
654 .Case("riscv64be", Triple::riscv64be)
655 .Case("hexagon", Triple::hexagon)
656 .Cases({"s390x", "systemz"}, Triple::systemz)
657 .Case("sparc", Triple::sparc)
658 .Case("sparcel", Triple::sparcel)
659 .Cases({"sparcv9", "sparc64"}, Triple::sparcv9)
660 .Case("tce", Triple::tce)
661 .Case("tcele", Triple::tcele)
662 .Case("tcele64", Triple::tcele64)
663 .Case("xcore", Triple::xcore)
664 .Case("nvptx", Triple::nvptx)
665 .Case("nvptx64", Triple::nvptx64)
666 .Case("pisa", Triple::pisa)
667 .Case("amdil", Triple::amdil)
668 .Case("amdil64", Triple::amdil64)
669 .Case("hsail", Triple::hsail)
670 .Case("hsail64", Triple::hsail64)
671 .Case("spir", Triple::spir)
672 .Case("spir64", Triple::spir64)
673 .Cases({"spirv", "spirv1.5", "spirv1.6"}, Triple::spirv)
674 .Cases({"spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
675 "spirv32v1.3", "spirv32v1.4", "spirv32v1.5", "spirv32v1.6"},
677 .Cases({"spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
678 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5", "spirv64v1.6"},
680 .StartsWith("kalimba", Triple::kalimba)
681 .Case("lanai", Triple::lanai)
682 .Case("renderscript32", Triple::renderscript32)
683 .Case("renderscript64", Triple::renderscript64)
684 .Case("shave", Triple::shave)
685 .Case("ve", Triple::ve)
686 .Case("wasm32", Triple::wasm32)
687 .Case("wasm64", Triple::wasm64)
688 .Case("csky", Triple::csky)
689 .Case("loongarch32", Triple::loongarch32)
690 .Case("loongarch64", Triple::loongarch64)
691 .Cases({"dxil", "dxilv1.0", "dxilv1.1", "dxilv1.2", "dxilv1.3",
692 "dxilv1.4", "dxilv1.5", "dxilv1.6", "dxilv1.7", "dxilv1.8",
693 "dxilv1.9", "dxilv1.10"},
695 .Case("xtensa", Triple::xtensa)
696 .Case("nanomips", Triple::nanomips)
698
699 // Some architectures require special parsing logic just to compute the
700 // ArchType result.
701 if (AT == Triple::UnknownArch) {
702 if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
703 ArchName.starts_with("aarch64"))
704 return parseARMArch(ArchName);
705 if (ArchName.starts_with("bpf"))
706 return parseBPFArch(ArchName);
707 }
708
709 return AT;
710}
711
713 return StringSwitch<Triple::VendorType>(VendorName)
714#define TRIPLE_VENDOR(Enum, Name) .Case(Name, Triple::Enum)
715#define TRIPLE_VENDOR_ALIAS(Enum, AliasName) .Case(AliasName, Triple::Enum)
716#include "llvm/TargetParser/TripleName.def"
718}
719
721 return StringSwitch<Triple::OSType>(OSName)
722#define TRIPLE_OS(Enum, Name, CMakeName) .StartsWith(Name, Triple::Enum)
723#define TRIPLE_OS_ALIAS(Enum, AliasName) .StartsWith(AliasName, Triple::Enum)
724#include "llvm/TargetParser/TripleName.def"
726}
727
729 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
730#define TRIPLE_ENV(Enum, Name, CMakeOverride) .StartsWith(Name, Triple::Enum)
731#include "llvm/TargetParser/TripleName.def"
733}
734
736 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
737 // "xcoff" must come before "coff" because of the order-dependendent
738 // pattern matching.
739 .EndsWith("xcoff", Triple::XCOFF)
740 .EndsWith("coff", Triple::COFF)
741 .EndsWith("elf", Triple::ELF)
742 .EndsWith("goff", Triple::GOFF)
743 .EndsWith("macho", Triple::MachO)
744 .EndsWith("wasm", Triple::Wasm)
745 .EndsWith("spirv", Triple::SPIRV)
747}
748
750 if (SubArchName.starts_with("mips") &&
751 (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
753
754 if (SubArchName == "powerpcspe")
756
757 if (SubArchName == "arm64e")
759 if (SubArchName == "arm64e.x1")
761
762 if (SubArchName == "arm64ec")
764
765 if (SubArchName == "aarch64_lfi")
767
768 if (SubArchName == "x86_64_lfi")
770
771 if (SubArchName.starts_with("spirv"))
772 return StringSwitch<Triple::SubArchType>(SubArchName)
781
782 if (SubArchName.starts_with("dxil"))
783 return StringSwitch<Triple::SubArchType>(SubArchName)
796
797 if (SubArchName.consume_front("amdgpu")) {
798 return StringSwitch<Triple::SubArchType>(SubArchName)
867 }
868
869 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
870
871 // For now, this is the small part. Early return.
872 if (ARMSubArch.empty())
873 return StringSwitch<Triple::SubArchType>(SubArchName)
878
879 // ARM sub arch.
880 switch (ARM::parseArch(ARMSubArch)) {
881 case ARM::ArchKind::ARMV4:
882 return Triple::NoSubArch;
883 case ARM::ArchKind::ARMV4T:
885 case ARM::ArchKind::ARMV5T:
887 case ARM::ArchKind::ARMV5TE:
888 case ARM::ArchKind::IWMMXT:
889 case ARM::ArchKind::IWMMXT2:
890 case ARM::ArchKind::XSCALE:
891 case ARM::ArchKind::ARMV5TEJ:
893 case ARM::ArchKind::ARMV6:
895 case ARM::ArchKind::ARMV6K:
896 case ARM::ArchKind::ARMV6KZ:
898 case ARM::ArchKind::ARMV6T2:
900 case ARM::ArchKind::ARMV6M:
902 case ARM::ArchKind::ARMV7A:
903 case ARM::ArchKind::ARMV7R:
905 case ARM::ArchKind::ARMV7VE:
907 case ARM::ArchKind::ARMV7K:
909 case ARM::ArchKind::ARMV7M:
911 case ARM::ArchKind::ARMV7S:
913 case ARM::ArchKind::ARMV7EM:
915 case ARM::ArchKind::ARMV8A:
917 case ARM::ArchKind::ARMV8_1A:
919 case ARM::ArchKind::ARMV8_2A:
921 case ARM::ArchKind::ARMV8_3A:
923 case ARM::ArchKind::ARMV8_4A:
925 case ARM::ArchKind::ARMV8_5A:
927 case ARM::ArchKind::ARMV8_6A:
929 case ARM::ArchKind::ARMV8_7A:
931 case ARM::ArchKind::ARMV8_8A:
933 case ARM::ArchKind::ARMV8_9A:
935 case ARM::ArchKind::ARMV9A:
937 case ARM::ArchKind::ARMV9_1A:
939 case ARM::ArchKind::ARMV9_2A:
941 case ARM::ArchKind::ARMV9_3A:
943 case ARM::ArchKind::ARMV9_4A:
945 case ARM::ArchKind::ARMV9_5A:
947 case ARM::ArchKind::ARMV9_6A:
949 case ARM::ArchKind::ARMV9_7A:
951 case ARM::ArchKind::ARMV9_8A:
953 case ARM::ArchKind::ARMV8R:
955 case ARM::ArchKind::ARMV8MBaseline:
957 case ARM::ArchKind::ARMV8MMainline:
959 case ARM::ArchKind::ARMV8_1MMainline:
961 default:
962 return Triple::NoSubArch;
963 }
964}
965
967 switch (T.getArch()) {
969 case Triple::aarch64:
971 case Triple::arm:
972 case Triple::thumb:
973 case Triple::x86:
974 case Triple::x86_64:
975 switch (T.getOS()) {
976 case Triple::Win32:
977 case Triple::UEFI:
978 return Triple::COFF;
979 default:
980 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
981 }
983 case Triple::amdgpu:
984 case Triple::amdil64:
985 case Triple::amdil:
986 case Triple::arc:
987 case Triple::armeb:
988 case Triple::avr:
989 case Triple::bpfeb:
990 case Triple::bpfel:
991 case Triple::csky:
992 case Triple::hexagon:
993 case Triple::hsail64:
994 case Triple::hsail:
995 case Triple::kalimba:
996 case Triple::lanai:
999 case Triple::m68k:
1000 case Triple::mips64:
1001 case Triple::mips64el:
1002 case Triple::mips:
1003 case Triple::msp430:
1004 case Triple::nanomips:
1005 case Triple::nvptx64:
1006 case Triple::nvptx:
1007 case Triple::pisa:
1008 case Triple::ppc64le:
1009 case Triple::ppcle:
1010 case Triple::r600:
1013 case Triple::riscv32:
1014 case Triple::riscv64:
1015 case Triple::riscv32be:
1016 case Triple::riscv64be:
1017 case Triple::shave:
1018 case Triple::sparc:
1019 case Triple::sparcel:
1020 case Triple::sparcv9:
1021 case Triple::spir64:
1022 case Triple::spir:
1023 case Triple::tce:
1024 case Triple::tcele:
1025 case Triple::tcele64:
1026 case Triple::thumbeb:
1027 case Triple::ve:
1028 case Triple::xcore:
1029 case Triple::xtensa:
1030 return Triple::ELF;
1031
1032 case Triple::mipsel:
1033 if (T.isOSWindows())
1034 return Triple::COFF;
1035 return Triple::ELF;
1036
1037 case Triple::ppc64:
1038 case Triple::ppc:
1039 if (T.isOSAIX())
1040 return Triple::XCOFF;
1041 if (T.isOSDarwin())
1042 return Triple::MachO;
1043 return Triple::ELF;
1044
1045 case Triple::systemz:
1046 if (T.isOSzOS())
1047 return Triple::GOFF;
1048 return Triple::ELF;
1049
1050 case Triple::wasm32:
1051 case Triple::wasm64:
1052 return Triple::Wasm;
1053
1054 case Triple::spirv:
1055 case Triple::spirv32:
1056 case Triple::spirv64:
1057 return Triple::SPIRV;
1058
1059 case Triple::dxil:
1060 return Triple::DXContainer;
1061 }
1062 llvm_unreachable("unknown architecture");
1063}
1064
1065/// Construct a triple from the string representation provided.
1066///
1067/// This stores the string representation and parses the various pieces into
1068/// enum members.
1069Triple::Triple(std::string &&Str) : Data(std::move(Str)) {
1070 // Do minimal parsing by hand here.
1071 SmallVector<StringRef, 4> Components;
1072 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
1073 if (Components.size() > 0) {
1074 Arch = parseArch(Components[0]);
1075 SubArch = parseSubArch(Components[0]);
1076 if (Components.size() > 1) {
1077 Vendor = parseVendor(Components[1]);
1078 if (Components.size() > 2) {
1079 OS = parseOS(Components[2]);
1080 if (Components.size() > 3) {
1081 Environment = parseEnvironment(Components[3]);
1082 ObjectFormat = parseFormat(Components[3]);
1083 }
1084 }
1085 } else {
1086 Environment =
1088 .StartsWith("mipsn32", Triple::GNUABIN32)
1089 .StartsWith("mips64", Triple::GNUABI64)
1090 .StartsWith("mipsisa64", Triple::GNUABI64)
1091 .StartsWith("mipsisa32", Triple::GNU)
1092 .Cases({"mips", "mipsel", "mipsr6", "mipsr6el"}, Triple::GNU)
1094 }
1095 }
1096 if (ObjectFormat == UnknownObjectFormat)
1097 ObjectFormat = getDefaultFormat(*this);
1098}
1099
1100Triple::Triple(const Twine &Str) : Triple(Str.str()) {}
1101
1102/// Construct a triple from string representations of the architecture,
1103/// vendor, and OS.
1104///
1105/// This joins each argument into a canonical string representation and parses
1106/// them into enum members. It leaves the environment unknown and omits it from
1107/// the string representation.
1108Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1109 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1110 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1111 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1112 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1113 ObjectFormat = getDefaultFormat(*this);
1114}
1115
1116/// Construct a triple from string representations of the architecture,
1117/// vendor, OS, and environment.
1118///
1119/// This joins each argument into a canonical string representation and parses
1120/// them into enum members.
1121Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1122 const Twine &EnvironmentStr)
1123 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1124 EnvironmentStr)
1125 .str()),
1126 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1127 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1128 Environment(parseEnvironment(EnvironmentStr.str())),
1129 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1130 if (ObjectFormat == Triple::UnknownObjectFormat)
1131 ObjectFormat = getDefaultFormat(*this);
1132}
1133
1135 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1136 Twine('-') + getOSTypeName(OS))
1137 .str()),
1138 Arch(A), SubArch(SA), Vendor(V), OS(OS),
1139 ObjectFormat(getDefaultFormat(*this)) {}
1140
1143 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1144 Twine('-') + getOSTypeName(OS) + Twine('-') +
1146 .str()),
1147 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1148 ObjectFormat(getDefaultFormat(*this)) {}
1149
1152 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1153 Twine('-') + getOSTypeName(OS) + Twine('-') +
1154 getEnvironmentTypeName(E) + Twine('-') +
1156 .str()),
1157 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1158 ObjectFormat(OF) {}
1159
1161
1163 VersionTuple Ver =
1164 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1165 // Default DXIL minor version when Shader Model version is anything other
1166 // than 6.[0...10] or 6.x (which translates to latest current SM version)
1167 const unsigned SMMajor = 6;
1168 if (!Ver.empty()) {
1169 if (Ver.getMajor() == SMMajor) {
1170 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1171 switch (*SMMinor) {
1172 case 0:
1174 case 1:
1176 case 2:
1178 case 3:
1180 case 4:
1182 case 5:
1184 case 6:
1186 case 7:
1188 case 8:
1190 case 9:
1192 case 10:
1194 default:
1195 report_fatal_error("Unsupported Shader Model version", false);
1196 }
1197 }
1198 }
1199 } else {
1200 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1201 // shadermodel6.x is
1202 if (ShaderModelStr == "shadermodel6.x") {
1204 }
1205 }
1206 // DXIL version corresponding to Shader Model version other than 6.Minor
1207 // is 1.0
1209}
1210
1212 bool IsMinGW32 = false;
1213 bool IsCygwin = false;
1214
1215 // Parse into components.
1216 SmallVector<StringRef, 4> Components;
1217 Str.split(Components, '-');
1218
1219 // If the first component corresponds to a known architecture, preferentially
1220 // use it for the architecture. If the second component corresponds to a
1221 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1222 // component movement when a component parses as (eg) both a valid arch and a
1223 // valid os.
1224 ArchType Arch = UnknownArch;
1225 if (Components.size() > 0)
1226 Arch = parseArch(Components[0]);
1227 VendorType Vendor = UnknownVendor;
1228 if (Components.size() > 1)
1229 Vendor = parseVendor(Components[1]);
1230 OSType OS = UnknownOS;
1231 if (Components.size() > 2) {
1232 OS = parseOS(Components[2]);
1233 IsCygwin = Components[2].starts_with("cygwin") ||
1234 Components[2].starts_with("msys");
1235 IsMinGW32 = Components[2].starts_with("mingw");
1236 }
1237 EnvironmentType Environment = UnknownEnvironment;
1238 if (Components.size() > 3)
1239 Environment = parseEnvironment(Components[3]);
1241 if (Components.size() > 4)
1242 ObjectFormat = parseFormat(Components[4]);
1243
1244 // Note which components are already in their final position. These will not
1245 // be moved.
1246 bool Found[4];
1247 Found[0] = Arch != UnknownArch;
1248 Found[1] = Vendor != UnknownVendor;
1249 Found[2] = OS != UnknownOS;
1250 Found[3] = Environment != UnknownEnvironment;
1251
1252 // If they are not there already, permute the components into their canonical
1253 // positions by seeing if they parse as a valid architecture, and if so moving
1254 // the component to the architecture position etc.
1255 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1256 if (Found[Pos])
1257 continue; // Already in the canonical position.
1258
1259 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1260 // Do not reparse any components that already matched.
1261 if (Idx < std::size(Found) && Found[Idx])
1262 continue;
1263
1264 // Does this component parse as valid for the target position?
1265 bool Valid = false;
1266 StringRef Comp = Components[Idx];
1267 switch (Pos) {
1268 default:
1269 llvm_unreachable("unexpected component type!");
1270 case 0:
1271 Arch = parseArch(Comp);
1272 Valid = Arch != UnknownArch;
1273 break;
1274 case 1:
1275 Vendor = parseVendor(Comp);
1276 Valid = Vendor != UnknownVendor;
1277 break;
1278 case 2:
1279 OS = parseOS(Comp);
1280 IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
1281 IsMinGW32 = Comp.starts_with("mingw");
1282 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1283 break;
1284 case 3:
1285 Environment = parseEnvironment(Comp);
1286 Valid = Environment != UnknownEnvironment;
1287 if (!Valid) {
1288 ObjectFormat = parseFormat(Comp);
1289 Valid = ObjectFormat != UnknownObjectFormat;
1290 }
1291 break;
1292 }
1293 if (!Valid)
1294 continue; // Nope, try the next component.
1295
1296 // Move the component to the target position, pushing any non-fixed
1297 // components that are in the way to the right. This tends to give
1298 // good results in the common cases of a forgotten vendor component
1299 // or a wrongly positioned environment.
1300 if (Pos < Idx) {
1301 // Insert left, pushing the existing components to the right. For
1302 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1303 StringRef CurrentComponent(""); // The empty component.
1304 // Replace the component we are moving with an empty component.
1305 std::swap(CurrentComponent, Components[Idx]);
1306 // Insert the component being moved at Pos, displacing any existing
1307 // components to the right.
1308 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1309 // Skip over any fixed components.
1310 while (i < std::size(Found) && Found[i])
1311 ++i;
1312 // Place the component at the new position, getting the component
1313 // that was at this position - it will be moved right.
1314 std::swap(CurrentComponent, Components[i]);
1315 }
1316 } else if (Pos > Idx) {
1317 // Push right by inserting empty components until the component at Idx
1318 // reaches the target position Pos. For example, pc-a -> -pc-a when
1319 // moving pc to the second position.
1320 do {
1321 // Insert one empty component at Idx.
1322 StringRef CurrentComponent(""); // The empty component.
1323 for (unsigned i = Idx; i < Components.size();) {
1324 // Place the component at the new position, getting the component
1325 // that was at this position - it will be moved right.
1326 std::swap(CurrentComponent, Components[i]);
1327 // If it was placed on top of an empty component then we are done.
1328 if (CurrentComponent.empty())
1329 break;
1330 // Advance to the next component, skipping any fixed components.
1331 while (++i < std::size(Found) && Found[i])
1332 ;
1333 }
1334 // The last component was pushed off the end - append it.
1335 if (!CurrentComponent.empty())
1336 Components.push_back(CurrentComponent);
1337
1338 // Advance Idx to the component's new position.
1339 while (++Idx < std::size(Found) && Found[Idx])
1340 ;
1341 } while (Idx < Pos); // Add more until the final position is reached.
1342 }
1343 assert(Pos < Components.size() && Components[Pos] == Comp &&
1344 "Component moved wrong!");
1345 Found[Pos] = true;
1346 break;
1347 }
1348 }
1349
1350 // If "none" is in the middle component in a three-component triple, treat it
1351 // as the OS (Components[2]) instead of the vendor (Components[1]).
1352 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1353 Components[1] == "none" && Components[2].empty())
1354 std::swap(Components[1], Components[2]);
1355
1356 // Replace empty components with "unknown" value.
1357 for (StringRef &C : Components)
1358 if (C.empty())
1359 C = "unknown";
1360
1361 // Special case logic goes here. At this point Arch, Vendor and OS have the
1362 // correct values for the computed components.
1363 std::string NormalizedEnvironment;
1364 if (Environment == Triple::Android &&
1365 Components[3].starts_with("androideabi")) {
1366 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1367 if (AndroidVersion.empty()) {
1368 Components[3] = "android";
1369 } else {
1370 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1371 Components[3] = NormalizedEnvironment;
1372 }
1373 }
1374
1375 // SUSE uses "gnueabi" to mean "gnueabihf"
1376 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1377 Components[3] = "gnueabihf";
1378
1379 if (OS == Triple::Win32) {
1380 Components.resize(4);
1381 Components[2] = "windows";
1382 if (Environment == UnknownEnvironment) {
1383 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1384 Components[3] = "msvc";
1385 else
1386 Components[3] = getObjectFormatTypeName(ObjectFormat);
1387 }
1388 } else if (IsMinGW32) {
1389 Components.resize(4);
1390 Components[2] = "windows";
1391 Components[3] = "gnu";
1392 } else if (IsCygwin) {
1393 Components.resize(4);
1394 Components[2] = "windows";
1395 Components[3] = "cygnus";
1396 }
1397 if (IsMinGW32 || IsCygwin ||
1398 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1399 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1400 Components.resize(5);
1401 Components[4] = getObjectFormatTypeName(ObjectFormat);
1402 }
1403 }
1404
1405 // Normalize DXIL triple if it does not include DXIL version number.
1406 // Determine DXIL version number using the minor version number of Shader
1407 // Model version specified in target triple, if any. Prior to decoupling DXIL
1408 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1409 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1410 if (Components[0] == "dxil") {
1411 if (Components.size() > 4) {
1412 Components.resize(4);
1413 }
1414 // Add DXIL version only if shadermodel is specified in the triple
1415 if (OS == Triple::ShaderModel) {
1416 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1417 }
1418 }
1419
1420 // Currently the firmware OS is an Apple specific concept.
1421 if ((Components.size() > 2) && (Components[2] == "firmware") &&
1422 (Components[1] != "apple"))
1424 "the firmware target os is only supported for the apple vendor");
1425
1426 // Canonicalize the components if necessary.
1427 switch (Form) {
1428 case CanonicalForm::ANY:
1429 break;
1433 Components.resize(static_cast<unsigned>(Form), "unknown");
1434 break;
1435 }
1436 }
1437
1438 // Stick the corrected components back together to form the normalized string.
1439 return join(Components, "-");
1440}
1441
1443 return StringRef(Data).split('-').first; // Isolate first component
1444}
1445
1447 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1448 return Tmp.split('-').first; // Isolate second component
1449}
1450
1452 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1453 Tmp = Tmp.split('-').second; // Strip second component
1454 return Tmp.split('-').first; // Isolate third component
1455}
1456
1458 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1459 Tmp = Tmp.split('-').second; // Strip second component
1460 return Tmp.split('-').second; // Strip third component
1461}
1462
1464 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1465 return Tmp.split('-').second; // Strip second component
1466}
1467
1469 VersionTuple Version;
1470 Version.tryParse(Name);
1471 return Version.withoutBuild();
1472}
1473
1477
1479 StringRef EnvironmentName = getEnvironmentName();
1480
1481 // none is a valid environment type - it basically amounts to a freestanding
1482 // environment.
1483 if (EnvironmentName == "none")
1484 return "";
1485
1486 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1487 EnvironmentName.consume_front(EnvironmentTypeName);
1488
1489 if (EnvironmentName.contains("-")) {
1490 // -obj is the suffix
1492 StringRef ObjectFormatTypeName =
1494 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1495 EnvironmentName.consume_back(tmp);
1496 }
1497 }
1498 return EnvironmentName;
1499}
1500
1502 StringRef OSName = getOSName();
1503 // Assume that the OS portion of the triple starts with the canonical name.
1504 StringRef OSTypeName = getOSTypeName(getOS());
1505 if (OSName.starts_with(OSTypeName))
1506 OSName = OSName.substr(OSTypeName.size());
1507 else if (getOS() == MacOSX)
1508 OSName.consume_front("macos");
1509 else if (OSName.starts_with("visionos"))
1510 OSName.consume_front("visionos");
1511
1512 return parseVersionFromName(OSName);
1513}
1514
1517
1518 switch (getOS()) {
1519 default:
1520 llvm_unreachable("unexpected OS for Darwin triple");
1521 case Darwin:
1522 // Default to darwin8, i.e., MacOSX 10.4.
1523 if (Version.getMajor() == 0)
1524 Version = VersionTuple(8);
1525 // Darwin version numbers are skewed from OS X versions.
1526 if (Version.getMajor() < 4) {
1527 return false;
1528 }
1529 if (Version.getMajor() <= 19) {
1530 Version = VersionTuple(10, Version.getMajor() - 4);
1531 } else if (Version.getMajor() < 25) {
1532 // darwin20-24 corresponds to macOS 11-15.
1533 Version = VersionTuple(11 + Version.getMajor() - 20);
1534 } else if ((Version.getMajor() == 25) || (Version.getMajor() == 26)) {
1535 // darwin25-26 corresponds to macOS 26-27.
1536 Version = VersionTuple(Version.getMajor() + 1);
1537 } else {
1538 // Starting with darwin27, it naturally corresponds to the same macOS
1539 // version.
1540 }
1541 break;
1542 case MacOSX:
1543 // Default to 10.4.
1544 if (Version.getMajor() == 0) {
1545 Version = VersionTuple(10, 4);
1546 } else if (Version.getMajor() < 10) {
1547 return false;
1548 }
1549 break;
1550 case IOS:
1551 case TvOS:
1552 case WatchOS:
1553 // Ignore the version from the triple. This is only handled because the
1554 // the clang driver combines OS X and IOS support into a common Darwin
1555 // toolchain that wants to know the OS X version number even when targeting
1556 // IOS.
1557 Version = VersionTuple(10, 4);
1558 break;
1559 case XROS:
1560 llvm_unreachable("OSX version isn't relevant for xrOS");
1561 case DriverKit:
1562 llvm_unreachable("OSX version isn't relevant for DriverKit");
1563 case Firmware:
1564 llvm_unreachable("OSX version isn't relevant for Firmware");
1565 }
1566 return true;
1567}
1568
1570 switch (getOS()) {
1571 default:
1572 llvm_unreachable("unexpected OS for Darwin triple");
1573 case Darwin:
1574 case MacOSX:
1575 // Ignore the version from the triple. This is only handled because the
1576 // the clang driver combines OS X and IOS support into a common Darwin
1577 // toolchain that wants to know the iOS version number even when targeting
1578 // OS X.
1579 return VersionTuple(5);
1580 case IOS:
1581 case TvOS: {
1583 // Default to 5.0 (or 7.0 for arm64).
1584 if (Version.getMajor() == 0)
1585 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1586 if (Version.getMajor() == 19)
1587 // tvOS 19 corresponds to ios26.
1588 return VersionTuple(26);
1591 }
1592 case XROS: {
1594 // xrOS 1 is aligned with iOS 17.
1595 if (Version.getMajor() < 3)
1596 return Version.withMajorReplaced(Version.getMajor() + 16);
1597 // visionOS 3 corresponds to ios 26+.
1598 if (Version.getMajor() == 3)
1599 return VersionTuple(26);
1602 }
1603 case WatchOS: {
1605 // watchOS 12 corresponds to ios 26.
1606 if (Version.getMajor() == 12)
1607 return VersionTuple(26);
1611 }
1612 case BridgeOS:
1613 llvm_unreachable("conflicting triple info");
1614 case DriverKit:
1615 llvm_unreachable("DriverKit doesn't have an iOS version");
1616 case Firmware:
1617 llvm_unreachable("iOS version isn't relevant for Firmware");
1618 }
1619}
1620
1622 switch (getOS()) {
1623 default:
1624 llvm_unreachable("unexpected OS for Darwin triple");
1625 case Darwin:
1626 case MacOSX:
1627 // Ignore the version from the triple. This is only handled because the
1628 // the clang driver combines OS X and IOS support into a common Darwin
1629 // toolchain that wants to know the iOS version number even when targeting
1630 // OS X.
1631 return VersionTuple(2);
1632 case WatchOS: {
1634 if (Version.getMajor() == 0)
1635 return VersionTuple(2);
1636 return Version;
1637 }
1638 case IOS:
1639 llvm_unreachable("conflicting triple info");
1640 case XROS:
1641 llvm_unreachable("watchOS version isn't relevant for xrOS");
1642 case DriverKit:
1643 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1644 case Firmware:
1645 llvm_unreachable("watchOS version isn't relevant for Firmware");
1646 }
1647}
1648
1650 switch (getOS()) {
1651 default:
1652 llvm_unreachable("unexpected OS for Darwin triple");
1653 case DriverKit:
1655 if (Version.getMajor() == 0)
1656 return Version.withMajorReplaced(19);
1657 return Version;
1658 }
1659}
1660
1662 if (getArch() != spirv || getOS() != Vulkan)
1663 llvm_unreachable("invalid Vulkan SPIR-V triple");
1664
1665 VersionTuple VulkanVersion = getOSVersion();
1666 SubArchType SpirvVersion = getSubArch();
1667
1669 // Vulkan 1.2 -> SPIR-V 1.5.
1671 // Vulkan 1.3 -> SPIR-V 1.6.
1673
1674 // If Vulkan version is unset, default to 1.2.
1675 if (VulkanVersion == VersionTuple(0))
1676 VulkanVersion = VersionTuple(1, 2);
1677
1678 if (ValidVersionMap.contains(VulkanVersion) &&
1679 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1680 SpirvVersion == NoSubArch))
1681 return VulkanVersion;
1682
1683 return VersionTuple(0);
1684}
1685
1687 if (getArch() != dxil || getOS() != ShaderModel)
1688 llvm_unreachable("invalid DXIL triple");
1689 StringRef Arch = getArchName();
1690 if (getSubArch() == NoSubArch)
1692 Arch.consume_front("dxilv");
1693 VersionTuple DXILVersion = parseVersionFromName(Arch);
1694 // FIXME: validate DXIL version against Shader Model version.
1695 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1696 return DXILVersion;
1697}
1698
1699void Triple::setTriple(const Twine &Str) { *this = Triple(Str); }
1700
1702 setArchName(getArchName(Kind, SubArch));
1703}
1704
1708
1710
1712 if (ObjectFormat == getDefaultFormat(*this))
1714
1716 getObjectFormatTypeName(ObjectFormat))
1717 .str());
1718}
1719
1721 if (Environment == UnknownEnvironment)
1723
1724 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1726 .str());
1727}
1728
1730 setTriple(Str + "-" + getVendorName() + "-" + getOSAndEnvironmentName());
1731}
1732
1734 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1735}
1736
1738 if (hasEnvironment())
1739 setTriple(getArchName() + "-" + getVendorName() + "-" + Str + "-" +
1741 else
1742 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1743}
1744
1746 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() + "-" +
1747 Str);
1748}
1749
1751 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1752}
1753
1755 switch (Arch) {
1757 return 0;
1758
1759 case llvm::Triple::avr:
1761 return 16;
1762
1765 case llvm::Triple::arc:
1766 case llvm::Triple::arm:
1768 case llvm::Triple::csky:
1769 case llvm::Triple::dxil:
1775 case llvm::Triple::m68k:
1776 case llvm::Triple::mips:
1780 case llvm::Triple::ppc:
1782 case llvm::Triple::r600:
1789 case llvm::Triple::spir:
1791 case llvm::Triple::tce:
1796 case llvm::Triple::x86:
1799 return 32;
1800
1812 case llvm::Triple::pisa:
1824 case llvm::Triple::ve:
1827 return 64;
1828 }
1829 llvm_unreachable("Invalid architecture value");
1830}
1831
1833 switch (getArch()) {
1834 default:
1835 break;
1836 case Triple::ppc:
1837 case Triple::ppcle:
1838 if (isOSLinux())
1839 return 40;
1840 break;
1841 case Triple::ppc64:
1842 case Triple::ppc64le:
1843 if (isOSLinux())
1844 return 48;
1845 break;
1846 }
1847 return 32;
1848}
1849
1851 return getArchPointerBitWidth(getArch()) == 64;
1852}
1853
1855 return getArchPointerBitWidth(getArch()) == 32;
1856}
1857
1859 return getArchPointerBitWidth(getArch()) == 16;
1860}
1861
1863 Triple T(*this);
1864 switch (getArch()) {
1866 case Triple::amdgpu:
1867 case Triple::avr:
1868 case Triple::bpfeb:
1869 case Triple::bpfel:
1870 case Triple::msp430:
1871 case Triple::pisa:
1872 case Triple::systemz:
1873 case Triple::ve:
1874 T.setArch(UnknownArch);
1875 break;
1876
1877 case Triple::aarch64_32:
1878 case Triple::amdil:
1879 case Triple::arc:
1880 case Triple::arm:
1881 case Triple::armeb:
1882 case Triple::csky:
1883 case Triple::dxil:
1884 case Triple::hexagon:
1885 case Triple::hsail:
1886 case Triple::kalimba:
1887 case Triple::lanai:
1889 case Triple::m68k:
1890 case Triple::mips:
1891 case Triple::mipsel:
1892 case Triple::nanomips:
1893 case Triple::nvptx:
1894 case Triple::ppc:
1895 case Triple::ppcle:
1896 case Triple::r600:
1898 case Triple::riscv32:
1899 case Triple::riscv32be:
1900 case Triple::shave:
1901 case Triple::sparc:
1902 case Triple::sparcel:
1903 case Triple::spir:
1904 case Triple::spirv32:
1905 case Triple::tce:
1906 case Triple::tcele:
1907 case Triple::thumb:
1908 case Triple::thumbeb:
1909 case Triple::wasm32:
1910 case Triple::x86:
1911 case Triple::xcore:
1912 case Triple::xtensa:
1913 // Already 32-bit.
1914 break;
1915
1916 case Triple::aarch64:
1917 T.setArch(Triple::arm);
1918 break;
1919 case Triple::aarch64_be:
1920 T.setArch(Triple::armeb);
1921 break;
1922 case Triple::amdil64:
1923 T.setArch(Triple::amdil);
1924 break;
1925 case Triple::hsail64:
1926 T.setArch(Triple::hsail);
1927 break;
1929 T.setArch(Triple::loongarch32);
1930 break;
1931 case Triple::mips64:
1932 T.setArch(Triple::mips, getSubArch());
1933 break;
1934 case Triple::mips64el:
1935 T.setArch(Triple::mipsel, getSubArch());
1936 break;
1937 case Triple::nvptx64:
1938 T.setArch(Triple::nvptx);
1939 break;
1940 case Triple::ppc64:
1941 T.setArch(Triple::ppc);
1942 break;
1943 case Triple::ppc64le:
1944 T.setArch(Triple::ppcle);
1945 break;
1947 T.setArch(Triple::renderscript32);
1948 break;
1949 case Triple::riscv64:
1950 T.setArch(Triple::riscv32);
1951 break;
1952 case Triple::riscv64be:
1953 T.setArch(Triple::riscv32be);
1954 break;
1955 case Triple::sparcv9:
1956 T.setArch(Triple::sparc);
1957 break;
1958 case Triple::spir64:
1959 T.setArch(Triple::spir);
1960 break;
1961 case Triple::spirv:
1962 case Triple::spirv64:
1963 T.setArch(Triple::spirv32, getSubArch());
1964 break;
1965 case Triple::tcele64:
1966 T.setArch(Triple::tcele);
1967 break;
1968 case Triple::wasm64:
1969 T.setArch(Triple::wasm32);
1970 break;
1971 case Triple::x86_64:
1972 T.setArch(Triple::x86);
1973 break;
1974 }
1975 return T;
1976}
1977
1979 Triple T(*this);
1980 switch (getArch()) {
1982 case Triple::arc:
1983 case Triple::avr:
1984 case Triple::csky:
1985 case Triple::dxil:
1986 case Triple::hexagon:
1987 case Triple::kalimba:
1988 case Triple::lanai:
1989 case Triple::m68k:
1990 case Triple::msp430:
1991 case Triple::nanomips:
1992 case Triple::r600:
1993 case Triple::shave:
1994 case Triple::sparcel:
1995 case Triple::tce:
1996 case Triple::xcore:
1997 case Triple::xtensa:
1998 T.setArch(UnknownArch);
1999 break;
2000
2001 case Triple::aarch64:
2002 case Triple::aarch64_be:
2003 case Triple::amdgpu:
2004 case Triple::amdil64:
2005 case Triple::bpfeb:
2006 case Triple::bpfel:
2007 case Triple::hsail64:
2009 case Triple::mips64:
2010 case Triple::mips64el:
2011 case Triple::nvptx64:
2012 case Triple::pisa:
2013 case Triple::ppc64:
2014 case Triple::ppc64le:
2016 case Triple::riscv64:
2017 case Triple::riscv64be:
2018 case Triple::sparcv9:
2019 case Triple::spir64:
2020 case Triple::spirv64:
2021 case Triple::systemz:
2022 case Triple::tcele64:
2023 case Triple::ve:
2024 case Triple::wasm64:
2025 case Triple::x86_64:
2026 // Already 64-bit.
2027 break;
2028
2029 case Triple::aarch64_32:
2030 T.setArch(Triple::aarch64);
2031 break;
2032 case Triple::amdil:
2033 T.setArch(Triple::amdil64);
2034 break;
2035 case Triple::arm:
2036 T.setArch(Triple::aarch64);
2037 break;
2038 case Triple::armeb:
2039 T.setArch(Triple::aarch64_be);
2040 break;
2041 case Triple::hsail:
2042 T.setArch(Triple::hsail64);
2043 break;
2045 T.setArch(Triple::loongarch64);
2046 break;
2047 case Triple::mips:
2048 T.setArch(Triple::mips64, getSubArch());
2049 break;
2050 case Triple::mipsel:
2051 T.setArch(Triple::mips64el, getSubArch());
2052 break;
2053 case Triple::nvptx:
2054 T.setArch(Triple::nvptx64);
2055 break;
2056 case Triple::ppc:
2057 T.setArch(Triple::ppc64);
2058 break;
2059 case Triple::ppcle:
2060 T.setArch(Triple::ppc64le);
2061 break;
2063 T.setArch(Triple::renderscript64);
2064 break;
2065 case Triple::riscv32:
2066 T.setArch(Triple::riscv64);
2067 break;
2068 case Triple::riscv32be:
2069 T.setArch(Triple::riscv64be);
2070 break;
2071 case Triple::sparc:
2072 T.setArch(Triple::sparcv9);
2073 break;
2074 case Triple::spir:
2075 T.setArch(Triple::spir64);
2076 break;
2077 case Triple::spirv:
2078 case Triple::spirv32:
2079 T.setArch(Triple::spirv64, getSubArch());
2080 break;
2081 case Triple::tcele:
2082 T.setArch(Triple::tcele64);
2083 break;
2084 case Triple::thumb:
2085 T.setArch(Triple::aarch64);
2086 break;
2087 case Triple::thumbeb:
2088 T.setArch(Triple::aarch64_be);
2089 break;
2090 case Triple::wasm32:
2091 T.setArch(Triple::wasm64);
2092 break;
2093 case Triple::x86:
2094 T.setArch(Triple::x86_64);
2095 break;
2096 }
2097 return T;
2098}
2099
2101 Triple T(*this);
2102 // Already big endian.
2103 if (!isLittleEndian())
2104 return T;
2105 switch (getArch()) {
2107 case Triple::amdgpu:
2108 case Triple::amdil64:
2109 case Triple::amdil:
2110 case Triple::avr:
2111 case Triple::dxil:
2112 case Triple::hexagon:
2113 case Triple::hsail64:
2114 case Triple::hsail:
2115 case Triple::kalimba:
2118 case Triple::msp430:
2119 case Triple::nanomips:
2120 case Triple::nvptx64:
2121 case Triple::nvptx:
2122 case Triple::pisa:
2123 case Triple::r600:
2126 case Triple::shave:
2127 case Triple::spir64:
2128 case Triple::spir:
2129 case Triple::spirv:
2130 case Triple::spirv32:
2131 case Triple::spirv64:
2132 case Triple::tcele64:
2133 case Triple::wasm32:
2134 case Triple::wasm64:
2135 case Triple::x86:
2136 case Triple::x86_64:
2137 case Triple::xcore:
2138 case Triple::ve:
2139 case Triple::csky:
2140 case Triple::xtensa:
2141
2142 // ARM is intentionally unsupported here, changing the architecture would
2143 // drop any arch suffixes.
2144 case Triple::arm:
2145 case Triple::thumb:
2146 T.setArch(UnknownArch);
2147 break;
2148
2149 case Triple::aarch64:
2150 T.setArch(Triple::aarch64_be);
2151 break;
2152 case Triple::bpfel:
2153 T.setArch(Triple::bpfeb);
2154 break;
2155 case Triple::mips64el:
2156 T.setArch(Triple::mips64, getSubArch());
2157 break;
2158 case Triple::mipsel:
2159 T.setArch(Triple::mips, getSubArch());
2160 break;
2161 case Triple::ppcle:
2162 T.setArch(Triple::ppc);
2163 break;
2164 case Triple::ppc64le:
2165 T.setArch(Triple::ppc64);
2166 break;
2167 case Triple::riscv32:
2168 T.setArch(Triple::riscv32be);
2169 break;
2170 case Triple::riscv64:
2171 T.setArch(Triple::riscv64be);
2172 break;
2173 case Triple::sparcel:
2174 T.setArch(Triple::sparc);
2175 break;
2176 case Triple::tcele:
2177 T.setArch(Triple::tce);
2178 break;
2179 default:
2180 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
2181 }
2182 return T;
2183}
2184
2186 Triple T(*this);
2187 if (isLittleEndian())
2188 return T;
2189
2190 switch (getArch()) {
2192 case Triple::lanai:
2193 case Triple::sparcv9:
2194 case Triple::systemz:
2195 case Triple::m68k:
2196
2197 // ARM is intentionally unsupported here, changing the architecture would
2198 // drop any arch suffixes.
2199 case Triple::armeb:
2200 case Triple::thumbeb:
2201 T.setArch(UnknownArch);
2202 break;
2203
2204 case Triple::aarch64_be:
2205 T.setArch(Triple::aarch64);
2206 break;
2207 case Triple::bpfeb:
2208 T.setArch(Triple::bpfel);
2209 break;
2210 case Triple::mips64:
2211 T.setArch(Triple::mips64el, getSubArch());
2212 break;
2213 case Triple::mips:
2214 T.setArch(Triple::mipsel, getSubArch());
2215 break;
2216 case Triple::ppc:
2217 T.setArch(Triple::ppcle);
2218 break;
2219 case Triple::ppc64:
2220 T.setArch(Triple::ppc64le);
2221 break;
2222 case Triple::riscv32be:
2223 T.setArch(Triple::riscv32);
2224 break;
2225 case Triple::riscv64be:
2226 T.setArch(Triple::riscv64);
2227 break;
2228 case Triple::sparc:
2229 T.setArch(Triple::sparcel);
2230 break;
2231 case Triple::tce:
2232 T.setArch(Triple::tcele);
2233 break;
2234 default:
2235 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
2236 }
2237 return T;
2238}
2239
2241 switch (getArch()) {
2242 case Triple::aarch64:
2243 case Triple::aarch64_32:
2244 case Triple::amdgpu:
2245 case Triple::amdil64:
2246 case Triple::amdil:
2247 case Triple::arm:
2248 case Triple::avr:
2249 case Triple::bpfel:
2250 case Triple::csky:
2251 case Triple::dxil:
2252 case Triple::hexagon:
2253 case Triple::hsail64:
2254 case Triple::hsail:
2255 case Triple::kalimba:
2258 case Triple::mips64el:
2259 case Triple::mipsel:
2260 case Triple::msp430:
2261 case Triple::nanomips:
2262 case Triple::nvptx64:
2263 case Triple::nvptx:
2264 case Triple::pisa:
2265 case Triple::ppcle:
2266 case Triple::ppc64le:
2267 case Triple::r600:
2270 case Triple::riscv32:
2271 case Triple::riscv64:
2272 case Triple::shave:
2273 case Triple::sparcel:
2274 case Triple::spir64:
2275 case Triple::spir:
2276 case Triple::spirv:
2277 case Triple::spirv32:
2278 case Triple::spirv64:
2279 case Triple::tcele:
2280 case Triple::tcele64:
2281 case Triple::thumb:
2282 case Triple::ve:
2283 case Triple::wasm32:
2284 case Triple::wasm64:
2285 case Triple::x86:
2286 case Triple::x86_64:
2287 case Triple::xcore:
2288 case Triple::xtensa:
2289 return true;
2290 default:
2291 return false;
2292 }
2293}
2294
2296 if (getArch() == Triple::xcore)
2297 return 1;
2298 if (isArch16Bit())
2299 return 2;
2300 if (isOSWindowsOrUEFI() || isPS())
2301 return 2;
2302 if (isOSAIX() && isArch32Bit())
2303 return 2;
2304 return 4;
2305}
2306
2308 switch (getArch()) {
2309 case Triple::amdgpu:
2310 case Triple::r600:
2311 case Triple::nvptx:
2312 case Triple::nvptx64:
2313 case Triple::spir:
2314 case Triple::spir64:
2315 case Triple::spirv:
2316 case Triple::spirv32:
2317 case Triple::spirv64:
2318 return false;
2319 default:
2320 break;
2321 }
2322
2323 switch (getOS()) {
2324 case Triple::Emscripten:
2325 case Triple::FreeBSD:
2326 case Triple::Fuchsia:
2327 case Triple::OpenBSD:
2328 case Triple::WASI:
2329 case Triple::WASIp1:
2330 case Triple::WASIp2:
2331 case Triple::WASIp3:
2332 return false;
2333 default:
2334 break;
2335 }
2336
2337 return !isOSDarwin() && !isAndroid() && !isMusl();
2338}
2339
2341 // On MinGW, C code is usually built with a "w64" vendor, while Rust
2342 // often uses a "pc" vendor.
2343 bool IgnoreVendor = isWindowsGNUEnvironment();
2344
2345 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
2346 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2347 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2348 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2349 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2350 if (getVendor() == Triple::Apple)
2351 return getSubArch() == Other.getSubArch() &&
2352 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2353 else
2354 return getSubArch() == Other.getSubArch() &&
2355 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2356 getOS() == Other.getOS() &&
2357 getEnvironment() == Other.getEnvironment() &&
2358 getObjectFormat() == Other.getObjectFormat();
2359 }
2360
2361 if (getArch() == Triple::amdgpu && Other.getArch() == Triple::amdgpu) {
2362 if (getOS() != Other.getOS() || getVendor() != Other.getVendor() ||
2363 getEnvironment() != Other.getEnvironment() ||
2364 getObjectFormat() != Other.getObjectFormat())
2365 return false;
2366 return AMDGPU::isSubArchCompatible(*this, Other);
2367 }
2368
2369 // If vendor is apple, ignore the version number (the environment field)
2370 // and the object format.
2371 if (getVendor() == Triple::Apple)
2372 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2373 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2374 getOS() == Other.getOS();
2375
2376 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2377 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2378 getOS() == Other.getOS() &&
2379 getEnvironment() == Other.getEnvironment() &&
2380 getObjectFormat() == Other.getObjectFormat();
2381}
2382
2383std::string Triple::merge(const Triple &Other) const {
2384 // If vendor is apple, pick the triple with the larger version number.
2385 if (getVendor() == Triple::Apple && Other.isOSVersionLT(*this))
2386 return str();
2387
2388 if (isAMDGCN() && Other.isAMDGCN() && getOS() == Other.getOS() &&
2389 getVendor() == Other.getVendor())
2390 return AMDGPU::mergeSubArch(*this, Other);
2391
2392 return Other.str();
2393}
2394
2395bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2396 unsigned Micro) const {
2397 assert(isMacOSX() && "Not an OS X triple!");
2398
2399 // If this is OS X, expect a sane version number.
2400 if (getOS() == Triple::MacOSX)
2401 return isOSVersionLT(Major, Minor, Micro);
2402
2403 // Otherwise, compare to the "Darwin" number.
2404 if (Major == 10)
2405 return isOSVersionLT(Minor + 4, Micro, 0);
2406 assert(Major >= 11 && "Unexpected major version");
2407 if (Major < 25)
2408 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2409 return isOSVersionLT(Major + 1, Minor, Micro);
2410}
2411
2414 return VersionTuple();
2415 switch (getOS()) {
2416 case Triple::MacOSX:
2417 // ARM64 slice is supported starting from macOS 11.0+.
2418 return VersionTuple(11, 0, 0);
2419 case Triple::IOS:
2420 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2421 // ARM64 simulators are supported for iOS 14+.
2423 return VersionTuple(14, 0, 0);
2424 // ARM64e slice is supported starting from iOS 14.
2425 if (isArm64e())
2426 return VersionTuple(14, 0, 0);
2427 break;
2428 case Triple::TvOS:
2429 // ARM64 simulators are supported for tvOS 14+.
2431 return VersionTuple(14, 0, 0);
2432 break;
2433 case Triple::WatchOS:
2434 // ARM64 simulators are supported for watchOS 7+.
2436 return VersionTuple(7, 0, 0);
2437 // ARM64/ARM64e slices are supported starting from watchOS 26.
2438 // ARM64_32 is older though.
2440 return VersionTuple(26, 0, 0);
2441 case Triple::DriverKit:
2442 return VersionTuple(20, 0, 0);
2443 default:
2444 break;
2445 }
2446 return VersionTuple();
2447}
2448
2450 const VersionTuple &Version,
2451 bool IsInValidRange) {
2452 const unsigned MacOSRangeBump = 10;
2453 const unsigned IOSRangeBump = 7;
2454 const unsigned XROSRangeBump = 23;
2455 const unsigned WatchOSRangeBump = 14;
2456 switch (OSKind) {
2457 case MacOSX: {
2458 // macOS 10.16 is canonicalized to macOS 11.
2459 if (Version == VersionTuple(10, 16))
2460 return VersionTuple(11, 0);
2461 // macOS 16 is canonicalized to macOS 26.
2462 if (Version == VersionTuple(16, 0))
2463 return VersionTuple(26, 0);
2464 if (!IsInValidRange)
2465 return Version.withMajorReplaced(Version.getMajor() + MacOSRangeBump);
2466 break;
2467 }
2468 case IOS:
2469 case TvOS: {
2470 // Both iOS & tvOS 19.0 canonicalize to 26.
2471 if (Version == VersionTuple(19, 0))
2472 return VersionTuple(26, 0);
2473 if (!IsInValidRange)
2474 return Version.withMajorReplaced(Version.getMajor() + IOSRangeBump);
2475 break;
2476 }
2477 case XROS: {
2478 // visionOS3 is canonicalized to 26.
2479 if (Version == VersionTuple(3, 0))
2480 return VersionTuple(26, 0);
2481 if (!IsInValidRange)
2482 return Version.withMajorReplaced(Version.getMajor() + XROSRangeBump);
2483 break;
2484 }
2485 case WatchOS: {
2486 // watchOS 12 is canonicalized to 26.
2487 if (Version == VersionTuple(12, 0))
2488 return VersionTuple(26, 0);
2489 if (!IsInValidRange)
2490 return Version.withMajorReplaced(Version.getMajor() + WatchOSRangeBump);
2491 break;
2492 }
2493 case DriverKit: {
2494 // DriverKit26 is canonicalized to 27.
2495 if (Version.getMajor() == 26U)
2496 return Version.withMajorReplaced(27);
2497 break;
2498 }
2499 default:
2500 return Version;
2501 }
2502
2503 return Version;
2504}
2505
2507 /// This constant is used to capture gaps in versioning.
2508 const VersionTuple CommonVersion(26);
2509 auto IsValid = [&](const VersionTuple &StartingVersion) {
2510 return !((Version > StartingVersion) && (Version < CommonVersion));
2511 };
2512 switch (OSKind) {
2513 case WatchOS: {
2514 const VersionTuple StartingWatchOS(12);
2515 return IsValid(StartingWatchOS);
2516 }
2517 case IOS:
2518 case TvOS: {
2519 const VersionTuple StartingIOS(19);
2520 return IsValid(StartingIOS);
2521 }
2522 case MacOSX: {
2523 const VersionTuple StartingMacOS(16);
2524 return IsValid(StartingMacOS);
2525 }
2526 case XROS: {
2527 const VersionTuple StartingXROS(3);
2528 return IsValid(StartingXROS);
2529 }
2530 default:
2531 return true;
2532 }
2533
2534 llvm_unreachable("unexpected or invalid os version");
2535}
2536
2538 if (isOSBinFormatCOFF()) {
2539 if (getArch() == Triple::x86 &&
2543 }
2544
2545 if (isOSBinFormatXCOFF())
2547 if (isOSBinFormatGOFF())
2549
2550 if (isARM() || isThumb()) {
2551 if (isOSBinFormatELF()) {
2554 }
2555
2558 }
2559
2560 if (isAArch64() || isX86() || isPPC() || isMIPS() || isSPARC() || isBPF() ||
2561 isRISCV() || isLoongArch())
2563
2564 switch (getArch()) {
2565 case Triple::arc:
2566 case Triple::csky:
2567 case Triple::hexagon:
2568 case Triple::lanai:
2569 case Triple::m68k:
2570 case Triple::msp430:
2571 case Triple::nanomips:
2572 case Triple::systemz:
2573 case Triple::xcore:
2574 case Triple::xtensa:
2576 case Triple::ve:
2578 default:
2579 break;
2580 }
2581
2582 // Explicitly none targets.
2583 if (isWasm() || isAMDGPU() || isNVPTX() || isSPIROrSPIRV())
2585
2586 // Default to none.
2588}
2589
2591 StringRef ABIName) {
2592 Triple::EnvironmentType Env = T.getEnvironment();
2593 bool IsHard =
2594 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
2595 Env == Triple::MuslEABIHF || Env == Triple::EABIHF ||
2596 (T.isOSBinFormatMachO() && T.getSubArch() == Triple::ARMSubArch_v7em) ||
2597 T.isOSWindows() ||
2599 return IsHard ? FloatABI::Hard : FloatABI::Soft;
2600}
2601
2603 if (isARM() || isThumb())
2604 return getARMDefaultFloatABI(*this, ABIName);
2605
2606 // MIPS defaults to hard float, except on FreeBSD which uses soft float.
2607 if (isMIPS())
2609
2610 if (isCSKY() || isAVR() || getArch() == msp430)
2611 return FloatABI::Soft;
2612
2613 // Most targets use hard float unless soft float is explicitly requested.
2614 return FloatABI::Hard;
2615}
2616
2618
2620 switch (getArch()) {
2621 case loongarch32:
2622 case loongarch64:
2623 case riscv32:
2624 case riscv64:
2625 case riscv32be:
2626 case riscv64be:
2627 case sparcv9:
2628 case systemz:
2629 case ve:
2630 case wasm32:
2631 case wasm64:
2633 case sparc:
2634 case sparcel:
2635 // GCC uses IEEE double for bare-metal, NetBSD, and RTEMS SPARC V8 targets.
2636 if (getOS() == UnknownOS || getOS() == NetBSD || getOS() == RTEMS)
2639 case ppc:
2640 case ppcle:
2641 case ppc64:
2642 case ppc64le:
2643 // PowerPC uses IBM double-double, except with SPE, musl and a handful of
2644 // OSes that use plain IEEE double. NetBSD only switches to IEEE double on
2645 // 32-bit PowerPC.
2646 if (isOSAIX() || isOSFreeBSD() || isOSOpenBSD() ||
2647 getSubArch() == PPCSubArch_spe || isMusl() ||
2648 (isOSNetBSD() && isPPC32()))
2651 case x86:
2652 case x86_64:
2653 // Android and OHOS use IEEE double on 32-bit and IEEE quad on 64-bit.
2654 if (isAndroid() || isOHOSFamily())
2657 // Windows-MSVC and UEFI use IEEE double. MinGW and Cygwin keep x87.
2661 case aarch64:
2662 case aarch64_be:
2663 case aarch64_32:
2664 // AArch64 uses IEEE quad, except on Windows and Darwin.
2665 if (isOSWindows() || isOSDarwin() || isUEFI())
2668 case mips64:
2669 case mips64el:
2670 // 64-bit MIPS uses IEEE quad, except on FreeBSD.
2671 if (isOSFreeBSD())
2674 case avr:
2675 case tce:
2676 case tcele:
2677 // AVR and 32-bit OpenASIP use IEEE single precision.
2679 case tcele64:
2680 // 64-bit OpenASIP uses IEEE double, unlike its 32-bit variants.
2682 default:
2684 }
2685}
2686
2688 if (isOSDarwin())
2689 return DebuggerKind::LLDB;
2690 if (isPS())
2691 return DebuggerKind::SCE;
2692 if (isOSAIX())
2693 return DebuggerKind::DBX;
2694 return DebuggerKind::GDB;
2695}
2696
2697// HLSL triple environment orders are relied on in the front end
2698static_assert(Triple::Vertex - Triple::Pixel == 1,
2699 "incorrect HLSL stage order");
2700static_assert(Triple::Geometry - Triple::Pixel == 2,
2701 "incorrect HLSL stage order");
2702static_assert(Triple::Hull - Triple::Pixel == 3, "incorrect HLSL stage order");
2703static_assert(Triple::Domain - Triple::Pixel == 4,
2704 "incorrect HLSL stage order");
2705static_assert(Triple::Compute - Triple::Pixel == 5,
2706 "incorrect HLSL stage order");
2707static_assert(Triple::Library - Triple::Pixel == 6,
2708 "incorrect HLSL stage order");
2709static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2710 "incorrect HLSL stage order");
2711static_assert(Triple::Intersection - Triple::Pixel == 8,
2712 "incorrect HLSL stage order");
2713static_assert(Triple::AnyHit - Triple::Pixel == 9,
2714 "incorrect HLSL stage order");
2715static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2716 "incorrect HLSL stage order");
2717static_assert(Triple::Miss - Triple::Pixel == 11, "incorrect HLSL stage order");
2718static_assert(Triple::Callable - Triple::Pixel == 12,
2719 "incorrect HLSL stage order");
2720static_assert(Triple::Mesh - Triple::Pixel == 13, "incorrect HLSL stage order");
2721static_assert(Triple::Amplification - Triple::Pixel == 14,
2722 "incorrect HLSL stage order");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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:728
static FloatABI::ABIType getARMDefaultFloatABI(const Triple &T, StringRef ABIName)
Definition Triple.cpp:2590
static VersionTuple parseVersionFromName(StringRef Name)
Definition Triple.cpp:1468
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition Triple.cpp:966
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition Triple.cpp:543
static Triple::OSType parseOS(StringRef OSName)
Definition Triple.cpp:720
static StringRef getDXILArchNameFromShaderModel(StringRef ShaderModelStr)
Definition Triple.cpp:1162
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition Triple.cpp:452
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition Triple.cpp:735
static Triple::VendorType parseVendor(StringRef VendorName)
Definition Triple.cpp:712
Defines the llvm::VersionTuple class, which represents a version in the form major[....
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition DenseMap.h:757
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:793
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:728
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition StringRef.h:683
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:589
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:627
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:438
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:653
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:48
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:2395
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1501
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1150
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1446
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1621
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1729
LLVM_ABI DebuggerKind getDefaultDebuggerTuning() const
Returns the default debugger tuning for this target triple, i.e.
Definition Triple.cpp:2687
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1720
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:1862
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:823
bool isWatchABI() const
Definition Triple.h:702
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:408
@ UnknownEnvironment
Definition Triple.h:360
@ Amplification
Definition Triple.h:415
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:1007
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1215
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:2449
CanonicalForm
Canonical form.
Definition Triple.h:493
LLVM_ABI bool operator<(const Triple &Other) const
Definition Triple.cpp:31
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition Triple.h:621
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2185
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1252
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition Triple.cpp:389
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition Triple.h:542
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:521
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1207
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1229
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:876
bool isWindowsGNUEnvironment() const
Definition Triple.h:818
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1733
bool isOSNetBSD() const
Definition Triple.h:748
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1750
bool isAndroid() const
Tests whether the target is Android.
Definition Triple.h:914
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:1978
LLVM_ABI FloatABI::ABIType getDefaultFloatABI(StringRef ABIName="") const
Returns the default floating-point ABI for this target triple, i.e.
Definition Triple.cpp:2602
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2240
LLVM_ABI bool supportsMathErrno() const
Tests whether the target's math library may set errno.
Definition Triple.cpp:2307
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1711
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1451
bool isAVR() const
Definition Triple.h:1122
bool isSPIROrSPIRV() const
Definition Triple.h:988
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2537
@ loongarch32
Definition Triple.h:65
@ renderscript64
Definition Triple.h:118
@ UnknownArch
Definition Triple.h:51
@ loongarch64
Definition Triple.h:66
@ renderscript32
Definition Triple.h:117
LLVM_ABI ThreadModel getDefaultThreadModel() const
Returns the default threading model for this target triple, i.e.
Definition Triple.cpp:2617
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1699
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:527
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1474
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:1211
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition Triple.cpp:467
bool isPPC32() const
Tests whether the target is 32-bit PowerPC (little and big endian).
Definition Triple.h:1156
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:518
LLVM_ABI bool operator==(const Triple &Other) const
Definition Triple.cpp:25
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition Triple.cpp:1832
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:873
bool isCSKY() const
Definition Triple.h:1226
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1457
bool isSimulatorEnvironment() const
Definition Triple.h:734
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1686
const std::string & str() const
Definition Triple.h:583
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:947
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:533
bool isOSOpenBSD() const
Definition Triple.h:750
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1661
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1649
static LLVM_ABI ArchType parseArch(StringRef Str)
Parse anything recognized as an architecture for the first field of the triple.
Definition Triple.cpp:608
bool isUEFI() const
Tests whether the OS is UEFI.
Definition Triple.h:778
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:781
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:932
LLVM_ABI LongDoubleFormat getDefaultLongDoubleFormat() const
Returns the default floating-point format for the "long double" type.
Definition Triple.cpp:2619
bool isOSWindowsOrUEFI() const
Tests whether the OS is Windows or UEFI.
Definition Triple.h:787
static LLVM_ABI StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition Triple.cpp:37
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition Triple.h:885
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:402
@ UnknownObjectFormat
Definition Triple.h:425
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:1012
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2383
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:834
static LLVM_ABI SubArchType parseSubArch(StringRef Str)
Parse the subarchitecture encoded in the first (architecture) field of the triple (e....
Definition Triple.cpp:749
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition Triple.h:1190
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition Triple.h:1002
bool isAMDGPU() const
Definition Triple.h:1004
@ UnknownVendor
Definition Triple.h:286
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:994
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:859
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2412
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1850
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1463
@ ARMSubArch_v6t2
Definition Triple.h:157
@ AMDGPUSubArch600
Definition Triple.h:202
@ MipsSubArch_r6
Definition Triple.h:173
@ X86_64SubArch_lfi
Definition Triple.h:167
@ DXILSubArch_v1_2
Definition Triple.h:189
@ ARMSubArch_v7
Definition Triple.h:148
@ ARMSubArch_v8m_mainline
Definition Triple.h:146
@ AMDGPUSubArch1153
Definition Triple.h:263
@ ARMSubArch_v9_6a
Definition Triple.h:127
@ AMDGPUSubArch1012
Definition Triple.h:243
@ ARMSubArch_v8r
Definition Triple.h:144
@ AMDGPUSubArch1150
Definition Triple.h:260
@ ARMSubArch_v9_1a
Definition Triple.h:132
@ AMDGPUSubArch1250S
Definition Triple.h:276
@ DXILSubArch_v1_1
Definition Triple.h:188
@ AMDGPUSubArch703
Definition Triple.h:210
@ AMDGPUSubArch1201
Definition Triple.h:273
@ LatestDXILSubArch
Definition Triple.h:198
@ SPIRVSubArch_v10
Definition Triple.h:178
@ AMDGPUSubArch9
Definition Triple.h:223
@ SPIRVSubArch_v13
Definition Triple.h:181
@ AMDGPUSubArch1172
Definition Triple.h:269
@ AMDGPUSubArch1035
Definition Triple.h:252
@ DXILSubArch_v1_10
Definition Triple.h:197
@ ARMSubArch_v7k
Definition Triple.h:152
@ AMDGPUSubArch9_4
Definition Triple.h:236
@ AMDGPUSubArch6
Definition Triple.h:201
@ AMDGPUSubArch1033
Definition Triple.h:250
@ AMDGPUSubArch1103
Definition Triple.h:259
@ ARMSubArch_v8_7a
Definition Triple.h:136
@ AMDGPUSubArch1034
Definition Triple.h:251
@ AMDGPUSubArch1154
Definition Triple.h:264
@ ARMSubArch_v8
Definition Triple.h:143
@ SPIRVSubArch_v16
Definition Triple.h:184
@ ARMSubArch_v8_1a
Definition Triple.h:142
@ ARMSubArch_v9_2a
Definition Triple.h:131
@ AMDGPUSubArch1200
Definition Triple.h:272
@ AMDGPUSubArch10_3
Definition Triple.h:246
@ DXILSubArch_v1_3
Definition Triple.h:190
@ ARMSubArch_v9_8a
Definition Triple.h:125
@ SPIRVSubArch_v15
Definition Triple.h:183
@ ARMSubArch_v7m
Definition Triple.h:150
@ AMDGPUSubArch1102
Definition Triple.h:258
@ ARMSubArch_v9_7a
Definition Triple.h:126
@ AMDGPUSubArch1013
Definition Triple.h:244
@ AMDGPUSubArch902
Definition Triple.h:225
@ ARMSubArch_v6k
Definition Triple.h:156
@ AMDGPUSubArch1010
Definition Triple.h:241
@ AMDGPUSubArch90A
Definition Triple.h:234
@ ARMSubArch_v5
Definition Triple.h:158
@ AMDGPUSubArch1170
Definition Triple.h:267
@ AArch64SubArch_arm64e
Definition Triple.h:162
@ AMDGPUSubArch810
Definition Triple.h:221
@ ARMSubArch_v6
Definition Triple.h:154
@ AMDGPUSubArch11
Definition Triple.h:255
@ AMDGPUSubArch1151
Definition Triple.h:261
@ ARMSubArch_v9_5a
Definition Triple.h:128
@ AMDGPUSubArch602
Definition Triple.h:204
@ ARMSubArch_v7ve
Definition Triple.h:153
@ ARMSubArch_v8m_baseline
Definition Triple.h:145
@ ARMSubArch_v8_8a
Definition Triple.h:135
@ AArch64SubArch_arm64e_x1
Definition Triple.h:163
@ AMDGPUSubArch942
Definition Triple.h:237
@ AMDGPUSubArch7
Definition Triple.h:206
@ AMDGPUSubArch702
Definition Triple.h:209
@ AMDGPUSubArch950
Definition Triple.h:238
@ ARMSubArch_v8_2a
Definition Triple.h:141
@ ARMSubArch_v7s
Definition Triple.h:151
@ AMDGPUSubArch1251
Definition Triple.h:278
@ AMDGPUSubArch805
Definition Triple.h:218
@ DXILSubArch_v1_0
Definition Triple.h:187
@ DXILSubArch_v1_7
Definition Triple.h:194
@ AMDGPUSubArch12_5
Definition Triple.h:275
@ KalimbaSubArch_v3
Definition Triple.h:169
@ DXILSubArch_v1_5
Definition Triple.h:192
@ AMDGPUSubArch1250
Definition Triple.h:277
@ AMDGPUSubArch1030
Definition Triple.h:247
@ ARMSubArch_v8_4a
Definition Triple.h:139
@ AMDGPUSubArch803
Definition Triple.h:217
@ AMDGPUSubArch601
Definition Triple.h:203
@ ARMSubArch_v8_9a
Definition Triple.h:134
@ AMDGPUSubArch10_1
Definition Triple.h:240
@ AMDGPUSubArch904
Definition Triple.h:226
@ AMDGPUSubArch11_7
Definition Triple.h:266
@ AMDGPUSubArch705
Definition Triple.h:212
@ AMDGPUSubArch802
Definition Triple.h:216
@ AMDGPUSubArch8
Definition Triple.h:214
@ ARMSubArch_v7em
Definition Triple.h:149
@ SPIRVSubArch_v12
Definition Triple.h:180
@ AMDGPUSubArch90C
Definition Triple.h:229
@ SPIRVSubArch_v14
Definition Triple.h:182
@ AMDGPUSubArch1100
Definition Triple.h:256
@ KalimbaSubArch_v4
Definition Triple.h:170
@ AMDGPUSubArch909
Definition Triple.h:228
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:147
@ AMDGPUSubArch1036
Definition Triple.h:253
@ ARMSubArch_v8_3a
Definition Triple.h:140
@ AArch64SubArch_arm64ec
Definition Triple.h:164
@ ARMSubArch_v8_6a
Definition Triple.h:137
@ ARMSubArch_v5te
Definition Triple.h:159
@ KalimbaSubArch_v5
Definition Triple.h:171
@ AMDGPUSubArch701
Definition Triple.h:208
@ ARMSubArch_v4t
Definition Triple.h:160
@ AMDGPUSubArch1171
Definition Triple.h:268
@ DXILSubArch_v1_6
Definition Triple.h:193
@ AMDGPUSubArch1011
Definition Triple.h:242
@ AMDGPUSubArch906
Definition Triple.h:227
@ AMDGPUSubArch900
Definition Triple.h:224
@ AMDGPUSubArch1152
Definition Triple.h:262
@ DXILSubArch_v1_8
Definition Triple.h:195
@ AMDGPUSubArch801
Definition Triple.h:215
@ ARMSubArch_v9_4a
Definition Triple.h:129
@ ARMSubArch_v8_5a
Definition Triple.h:138
@ AArch64SubArch_lfi
Definition Triple.h:165
@ ARMSubArch_v6m
Definition Triple.h:155
@ ARMSubArch_v9_3a
Definition Triple.h:130
@ DXILSubArch_v1_9
Definition Triple.h:196
@ AMDGPUSubArch704
Definition Triple.h:211
@ AMDGPUSubArch1031
Definition Triple.h:248
@ AMDGPUSubArch1101
Definition Triple.h:257
@ ARMSubArch_v9
Definition Triple.h:133
@ AMDGPUSubArch13
Definition Triple.h:280
@ AMDGPUSubArch12
Definition Triple.h:271
@ DXILSubArch_v1_4
Definition Triple.h:191
@ AMDGPUSubArch700
Definition Triple.h:207
@ SPIRVSubArch_v11
Definition Triple.h:179
@ PPCSubArch_spe
Definition Triple.h:175
@ AMDGPUSubArch1032
Definition Triple.h:249
@ AMDGPUSubArch1310
Definition Triple.h:281
@ AMDGPUSubArch908
Definition Triple.h:233
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:1515
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:2506
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:685
bool isOSFreeBSD() const
Definition Triple.h:752
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1745
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1709
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1737
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:524
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1201
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:727
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition Triple.cpp:415
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:649
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:588
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1147
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:911
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1221
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1442
bool isMacCatalystEnvironment() const
Definition Triple.h:738
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1105
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition Triple.cpp:428
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition Triple.cpp:1858
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2100
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1569
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:1478
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:1854
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2340
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:870
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:795
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:530
LLVM_ABI unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2295
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition Triple.cpp:264
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition Triple.cpp:1701
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1705
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1131
bool isWindowsItaniumEnvironment() const
Definition Triple.h:810
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 std::string mergeSubArch(const Triple &A, const Triple &B)
Returns the effective triple appropriate to use when linking B into A by merging the subarches in cas...
LLVM_ABI bool isSubArchCompatible(const Triple &A, const Triple &B)
Return true if subarch A is compatible with subarch B, i.e.
LLVM_ABI StringRef getSubArchName(Triple::SubArchType SubArch)
Returns the triple subarch name for an AMDGPU subarch, e.g.
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 LLVM_READONLY ARMABI computeTargetABI(const Triple &TT, StringRef ABIName="")
LLVM_ABI ArchKind parseArch(StringRef Arch)
LLVM_ABI ProfileKind parseArchProfile(StringRef Arch)
LLVM_ABI unsigned parseArchVersion(StringRef Arch)
LLVM_ABI EndianKind parseArchEndian(StringRef Arch)
constexpr bool IsLittleEndianHost
This is an optimization pass for GlobalISel generic memory operations.
LongDoubleFormat
The floating-point format used for the target's "long double" type.
Definition CodeGen.h:117
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.
ThreadModel
The threading model to assume for lowering, e.g. of atomics.
Definition CodeGen.h:191
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:1933
ExceptionHandling
Definition CodeGen.h:54
@ SjLj
setjmp/longjmp based exceptions
Definition CodeGen.h:58
@ ZOS
z/OS MVS Exception Handling.
Definition CodeGen.h:64
@ None
No exception support.
Definition CodeGen.h:56
@ AIX
AIX Exception Handling.
Definition CodeGen.h:63
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:57
@ WinEH
Windows Exception Handling.
Definition CodeGen.h:60
DebuggerKind
Identify a debugger for "tuning" the debug info.
Definition CodeGen.h:231
@ SCE
Tune debug info for SCE targets (e.g. PS4).
Definition CodeGen.h:235
@ DBX
Tune debug info for dbx.
Definition CodeGen.h:236
@ GDB
Tune debug info for gdb.
Definition CodeGen.h:233
@ LLDB
Tune debug info for lldb.
Definition CodeGen.h:234
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:879
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:881