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