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