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