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::ARMV8R:
938 case ARM::ArchKind::ARMV8MBaseline:
940 case ARM::ArchKind::ARMV8MMainline:
942 case ARM::ArchKind::ARMV8_1MMainline:
944 default:
945 return Triple::NoSubArch;
946 }
947}
948
950 switch (T.getArch()) {
952 case Triple::aarch64:
954 case Triple::arm:
955 case Triple::thumb:
956 case Triple::x86:
957 case Triple::x86_64:
958 switch (T.getOS()) {
959 case Triple::Win32:
960 case Triple::UEFI:
961 return Triple::COFF;
962 default:
963 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
964 }
966 case Triple::amdgpu:
967 case Triple::amdil64:
968 case Triple::amdil:
969 case Triple::arc:
970 case Triple::armeb:
971 case Triple::avr:
972 case Triple::bpfeb:
973 case Triple::bpfel:
974 case Triple::csky:
975 case Triple::hexagon:
976 case Triple::hsail64:
977 case Triple::hsail:
978 case Triple::kalimba:
979 case Triple::lanai:
982 case Triple::m68k:
983 case Triple::mips64:
984 case Triple::mips64el:
985 case Triple::mips:
986 case Triple::msp430:
987 case Triple::nvptx64:
988 case Triple::nvptx:
989 case Triple::ppc64le:
990 case Triple::ppcle:
991 case Triple::r600:
994 case Triple::riscv32:
995 case Triple::riscv64:
998 case Triple::shave:
999 case Triple::sparc:
1000 case Triple::sparcel:
1001 case Triple::sparcv9:
1002 case Triple::spir64:
1003 case Triple::spir:
1004 case Triple::tce:
1005 case Triple::tcele:
1006 case Triple::tcele64:
1007 case Triple::thumbeb:
1008 case Triple::ve:
1009 case Triple::xcore:
1010 case Triple::xtensa:
1011 return Triple::ELF;
1012
1013 case Triple::mipsel:
1014 if (T.isOSWindows())
1015 return Triple::COFF;
1016 return Triple::ELF;
1017
1018 case Triple::ppc64:
1019 case Triple::ppc:
1020 if (T.isOSAIX())
1021 return Triple::XCOFF;
1022 if (T.isOSDarwin())
1023 return Triple::MachO;
1024 return Triple::ELF;
1025
1026 case Triple::systemz:
1027 if (T.isOSzOS())
1028 return Triple::GOFF;
1029 return Triple::ELF;
1030
1031 case Triple::wasm32:
1032 case Triple::wasm64:
1033 return Triple::Wasm;
1034
1035 case Triple::spirv:
1036 case Triple::spirv32:
1037 case Triple::spirv64:
1038 return Triple::SPIRV;
1039
1040 case Triple::dxil:
1041 return Triple::DXContainer;
1042 }
1043 llvm_unreachable("unknown architecture");
1044}
1045
1046/// Construct a triple from the string representation provided.
1047///
1048/// This stores the string representation and parses the various pieces into
1049/// enum members.
1050Triple::Triple(std::string &&Str) : Data(std::move(Str)) {
1051 // Do minimal parsing by hand here.
1052 SmallVector<StringRef, 4> Components;
1053 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
1054 if (Components.size() > 0) {
1055 Arch = parseArch(Components[0]);
1056 SubArch = parseSubArch(Components[0]);
1057 if (Components.size() > 1) {
1058 Vendor = parseVendor(Components[1]);
1059 if (Components.size() > 2) {
1060 OS = parseOS(Components[2]);
1061 if (Components.size() > 3) {
1062 Environment = parseEnvironment(Components[3]);
1063 ObjectFormat = parseFormat(Components[3]);
1064 }
1065 }
1066 } else {
1067 Environment =
1069 .StartsWith("mipsn32", Triple::GNUABIN32)
1070 .StartsWith("mips64", Triple::GNUABI64)
1071 .StartsWith("mipsisa64", Triple::GNUABI64)
1072 .StartsWith("mipsisa32", Triple::GNU)
1073 .Cases({"mips", "mipsel", "mipsr6", "mipsr6el"}, Triple::GNU)
1075 }
1076 }
1077 if (ObjectFormat == UnknownObjectFormat)
1078 ObjectFormat = getDefaultFormat(*this);
1079}
1080
1081Triple::Triple(const Twine &Str) : Triple(Str.str()) {}
1082
1083/// Construct a triple from string representations of the architecture,
1084/// vendor, and OS.
1085///
1086/// This joins each argument into a canonical string representation and parses
1087/// them into enum members. It leaves the environment unknown and omits it from
1088/// the string representation.
1089Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1090 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1091 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1092 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1093 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1094 ObjectFormat = getDefaultFormat(*this);
1095}
1096
1097/// Construct a triple from string representations of the architecture,
1098/// vendor, OS, and environment.
1099///
1100/// This joins each argument into a canonical string representation and parses
1101/// them into enum members.
1102Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1103 const Twine &EnvironmentStr)
1104 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1105 EnvironmentStr)
1106 .str()),
1107 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1108 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1109 Environment(parseEnvironment(EnvironmentStr.str())),
1110 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1111 if (ObjectFormat == Triple::UnknownObjectFormat)
1112 ObjectFormat = getDefaultFormat(*this);
1113}
1114
1116 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1117 Twine('-') + getOSTypeName(OS))
1118 .str()),
1119 Arch(A), SubArch(SA), Vendor(V), OS(OS),
1120 ObjectFormat(getDefaultFormat(*this)) {}
1121
1124 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1125 Twine('-') + getOSTypeName(OS) + Twine('-') +
1127 .str()),
1128 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1129 ObjectFormat(getDefaultFormat(*this)) {}
1130
1133 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1134 Twine('-') + getOSTypeName(OS) + Twine('-') +
1135 getEnvironmentTypeName(E) + Twine('-') +
1137 .str()),
1138 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1139 ObjectFormat(OF) {}
1140
1142
1144 VersionTuple Ver =
1145 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1146 // Default DXIL minor version when Shader Model version is anything other
1147 // than 6.[0...9] or 6.x (which translates to latest current SM version)
1148 const unsigned SMMajor = 6;
1149 if (!Ver.empty()) {
1150 if (Ver.getMajor() == SMMajor) {
1151 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1152 switch (*SMMinor) {
1153 case 0:
1155 case 1:
1157 case 2:
1159 case 3:
1161 case 4:
1163 case 5:
1165 case 6:
1167 case 7:
1169 case 8:
1171 case 9:
1173 default:
1174 report_fatal_error("Unsupported Shader Model version", false);
1175 }
1176 }
1177 }
1178 } else {
1179 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1180 // shadermodel6.x is
1181 if (ShaderModelStr == "shadermodel6.x") {
1183 }
1184 }
1185 // DXIL version corresponding to Shader Model version other than 6.Minor
1186 // is 1.0
1188}
1189
1191 bool IsMinGW32 = false;
1192 bool IsCygwin = false;
1193
1194 // Parse into components.
1195 SmallVector<StringRef, 4> Components;
1196 Str.split(Components, '-');
1197
1198 // If the first component corresponds to a known architecture, preferentially
1199 // use it for the architecture. If the second component corresponds to a
1200 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1201 // component movement when a component parses as (eg) both a valid arch and a
1202 // valid os.
1203 ArchType Arch = UnknownArch;
1204 if (Components.size() > 0)
1205 Arch = parseArch(Components[0]);
1206 VendorType Vendor = UnknownVendor;
1207 if (Components.size() > 1)
1208 Vendor = parseVendor(Components[1]);
1209 OSType OS = UnknownOS;
1210 if (Components.size() > 2) {
1211 OS = parseOS(Components[2]);
1212 IsCygwin = Components[2].starts_with("cygwin") ||
1213 Components[2].starts_with("msys");
1214 IsMinGW32 = Components[2].starts_with("mingw");
1215 }
1216 EnvironmentType Environment = UnknownEnvironment;
1217 if (Components.size() > 3)
1218 Environment = parseEnvironment(Components[3]);
1220 if (Components.size() > 4)
1221 ObjectFormat = parseFormat(Components[4]);
1222
1223 // Note which components are already in their final position. These will not
1224 // be moved.
1225 bool Found[4];
1226 Found[0] = Arch != UnknownArch;
1227 Found[1] = Vendor != UnknownVendor;
1228 Found[2] = OS != UnknownOS;
1229 Found[3] = Environment != UnknownEnvironment;
1230
1231 // If they are not there already, permute the components into their canonical
1232 // positions by seeing if they parse as a valid architecture, and if so moving
1233 // the component to the architecture position etc.
1234 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1235 if (Found[Pos])
1236 continue; // Already in the canonical position.
1237
1238 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1239 // Do not reparse any components that already matched.
1240 if (Idx < std::size(Found) && Found[Idx])
1241 continue;
1242
1243 // Does this component parse as valid for the target position?
1244 bool Valid = false;
1245 StringRef Comp = Components[Idx];
1246 switch (Pos) {
1247 default:
1248 llvm_unreachable("unexpected component type!");
1249 case 0:
1250 Arch = parseArch(Comp);
1251 Valid = Arch != UnknownArch;
1252 break;
1253 case 1:
1254 Vendor = parseVendor(Comp);
1255 Valid = Vendor != UnknownVendor;
1256 break;
1257 case 2:
1258 OS = parseOS(Comp);
1259 IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
1260 IsMinGW32 = Comp.starts_with("mingw");
1261 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1262 break;
1263 case 3:
1264 Environment = parseEnvironment(Comp);
1265 Valid = Environment != UnknownEnvironment;
1266 if (!Valid) {
1267 ObjectFormat = parseFormat(Comp);
1268 Valid = ObjectFormat != UnknownObjectFormat;
1269 }
1270 break;
1271 }
1272 if (!Valid)
1273 continue; // Nope, try the next component.
1274
1275 // Move the component to the target position, pushing any non-fixed
1276 // components that are in the way to the right. This tends to give
1277 // good results in the common cases of a forgotten vendor component
1278 // or a wrongly positioned environment.
1279 if (Pos < Idx) {
1280 // Insert left, pushing the existing components to the right. For
1281 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1282 StringRef CurrentComponent(""); // The empty component.
1283 // Replace the component we are moving with an empty component.
1284 std::swap(CurrentComponent, Components[Idx]);
1285 // Insert the component being moved at Pos, displacing any existing
1286 // components to the right.
1287 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1288 // Skip over any fixed components.
1289 while (i < std::size(Found) && Found[i])
1290 ++i;
1291 // Place the component at the new position, getting the component
1292 // that was at this position - it will be moved right.
1293 std::swap(CurrentComponent, Components[i]);
1294 }
1295 } else if (Pos > Idx) {
1296 // Push right by inserting empty components until the component at Idx
1297 // reaches the target position Pos. For example, pc-a -> -pc-a when
1298 // moving pc to the second position.
1299 do {
1300 // Insert one empty component at Idx.
1301 StringRef CurrentComponent(""); // The empty component.
1302 for (unsigned i = Idx; i < Components.size();) {
1303 // Place the component at the new position, getting the component
1304 // that was at this position - it will be moved right.
1305 std::swap(CurrentComponent, Components[i]);
1306 // If it was placed on top of an empty component then we are done.
1307 if (CurrentComponent.empty())
1308 break;
1309 // Advance to the next component, skipping any fixed components.
1310 while (++i < std::size(Found) && Found[i])
1311 ;
1312 }
1313 // The last component was pushed off the end - append it.
1314 if (!CurrentComponent.empty())
1315 Components.push_back(CurrentComponent);
1316
1317 // Advance Idx to the component's new position.
1318 while (++Idx < std::size(Found) && Found[Idx])
1319 ;
1320 } while (Idx < Pos); // Add more until the final position is reached.
1321 }
1322 assert(Pos < Components.size() && Components[Pos] == Comp &&
1323 "Component moved wrong!");
1324 Found[Pos] = true;
1325 break;
1326 }
1327 }
1328
1329 // If "none" is in the middle component in a three-component triple, treat it
1330 // as the OS (Components[2]) instead of the vendor (Components[1]).
1331 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1332 Components[1] == "none" && Components[2].empty())
1333 std::swap(Components[1], Components[2]);
1334
1335 // Replace empty components with "unknown" value.
1336 for (StringRef &C : Components)
1337 if (C.empty())
1338 C = "unknown";
1339
1340 // Special case logic goes here. At this point Arch, Vendor and OS have the
1341 // correct values for the computed components.
1342 std::string NormalizedEnvironment;
1343 if (Environment == Triple::Android &&
1344 Components[3].starts_with("androideabi")) {
1345 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1346 if (AndroidVersion.empty()) {
1347 Components[3] = "android";
1348 } else {
1349 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1350 Components[3] = NormalizedEnvironment;
1351 }
1352 }
1353
1354 // SUSE uses "gnueabi" to mean "gnueabihf"
1355 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1356 Components[3] = "gnueabihf";
1357
1358 if (OS == Triple::Win32) {
1359 Components.resize(4);
1360 Components[2] = "windows";
1361 if (Environment == UnknownEnvironment) {
1362 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1363 Components[3] = "msvc";
1364 else
1365 Components[3] = getObjectFormatTypeName(ObjectFormat);
1366 }
1367 } else if (IsMinGW32) {
1368 Components.resize(4);
1369 Components[2] = "windows";
1370 Components[3] = "gnu";
1371 } else if (IsCygwin) {
1372 Components.resize(4);
1373 Components[2] = "windows";
1374 Components[3] = "cygnus";
1375 }
1376 if (IsMinGW32 || IsCygwin ||
1377 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1378 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1379 Components.resize(5);
1380 Components[4] = getObjectFormatTypeName(ObjectFormat);
1381 }
1382 }
1383
1384 // Normalize DXIL triple if it does not include DXIL version number.
1385 // Determine DXIL version number using the minor version number of Shader
1386 // Model version specified in target triple, if any. Prior to decoupling DXIL
1387 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1388 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1389 if (Components[0] == "dxil") {
1390 if (Components.size() > 4) {
1391 Components.resize(4);
1392 }
1393 // Add DXIL version only if shadermodel is specified in the triple
1394 if (OS == Triple::ShaderModel) {
1395 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1396 }
1397 }
1398
1399 // Currently the firmware OS is an Apple specific concept.
1400 if ((Components.size() > 2) && (Components[2] == "firmware") &&
1401 (Components[1] != "apple"))
1403 "the firmware target os is only supported for the apple vendor");
1404
1405 // Canonicalize the components if necessary.
1406 switch (Form) {
1407 case CanonicalForm::ANY:
1408 break;
1412 Components.resize(static_cast<unsigned>(Form), "unknown");
1413 break;
1414 }
1415 }
1416
1417 // Stick the corrected components back together to form the normalized string.
1418 return join(Components, "-");
1419}
1420
1422 return StringRef(Data).split('-').first; // Isolate first component
1423}
1424
1426 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1427 return Tmp.split('-').first; // Isolate second component
1428}
1429
1431 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1432 Tmp = Tmp.split('-').second; // Strip second component
1433 return Tmp.split('-').first; // Isolate third component
1434}
1435
1437 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1438 Tmp = Tmp.split('-').second; // Strip second component
1439 return Tmp.split('-').second; // Strip third component
1440}
1441
1443 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1444 return Tmp.split('-').second; // Strip second component
1445}
1446
1448 VersionTuple Version;
1449 Version.tryParse(Name);
1450 return Version.withoutBuild();
1451}
1452
1456
1458 StringRef EnvironmentName = getEnvironmentName();
1459
1460 // none is a valid environment type - it basically amounts to a freestanding
1461 // environment.
1462 if (EnvironmentName == "none")
1463 return "";
1464
1465 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1466 EnvironmentName.consume_front(EnvironmentTypeName);
1467
1468 if (EnvironmentName.contains("-")) {
1469 // -obj is the suffix
1471 StringRef ObjectFormatTypeName =
1473 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1474 EnvironmentName.consume_back(tmp);
1475 }
1476 }
1477 return EnvironmentName;
1478}
1479
1481 StringRef OSName = getOSName();
1482 // Assume that the OS portion of the triple starts with the canonical name.
1483 StringRef OSTypeName = getOSTypeName(getOS());
1484 if (OSName.starts_with(OSTypeName))
1485 OSName = OSName.substr(OSTypeName.size());
1486 else if (getOS() == MacOSX)
1487 OSName.consume_front("macos");
1488 else if (OSName.starts_with("visionos"))
1489 OSName.consume_front("visionos");
1490
1491 return parseVersionFromName(OSName);
1492}
1493
1496
1497 switch (getOS()) {
1498 default:
1499 llvm_unreachable("unexpected OS for Darwin triple");
1500 case Darwin:
1501 // Default to darwin8, i.e., MacOSX 10.4.
1502 if (Version.getMajor() == 0)
1503 Version = VersionTuple(8);
1504 // Darwin version numbers are skewed from OS X versions.
1505 if (Version.getMajor() < 4) {
1506 return false;
1507 }
1508 if (Version.getMajor() <= 19) {
1509 Version = VersionTuple(10, Version.getMajor() - 4);
1510 } else if (Version.getMajor() < 25) {
1511 // darwin20-24 corresponds to macOS 11-15.
1512 Version = VersionTuple(11 + Version.getMajor() - 20);
1513 } else if ((Version.getMajor() == 25) || (Version.getMajor() == 26)) {
1514 // darwin25-26 corresponds to macOS 26-27.
1515 Version = VersionTuple(Version.getMajor() + 1);
1516 } else {
1517 // Starting with darwin27, it naturally corresponds to the same macOS
1518 // version.
1519 }
1520 break;
1521 case MacOSX:
1522 // Default to 10.4.
1523 if (Version.getMajor() == 0) {
1524 Version = VersionTuple(10, 4);
1525 } else if (Version.getMajor() < 10) {
1526 return false;
1527 }
1528 break;
1529 case IOS:
1530 case TvOS:
1531 case WatchOS:
1532 // Ignore the version from the triple. This is only handled because the
1533 // the clang driver combines OS X and IOS support into a common Darwin
1534 // toolchain that wants to know the OS X version number even when targeting
1535 // IOS.
1536 Version = VersionTuple(10, 4);
1537 break;
1538 case XROS:
1539 llvm_unreachable("OSX version isn't relevant for xrOS");
1540 case DriverKit:
1541 llvm_unreachable("OSX version isn't relevant for DriverKit");
1542 case Firmware:
1543 llvm_unreachable("OSX version isn't relevant for Firmware");
1544 }
1545 return true;
1546}
1547
1549 switch (getOS()) {
1550 default:
1551 llvm_unreachable("unexpected OS for Darwin triple");
1552 case Darwin:
1553 case MacOSX:
1554 // Ignore the version from the triple. This is only handled because the
1555 // the clang driver combines OS X and IOS support into a common Darwin
1556 // toolchain that wants to know the iOS version number even when targeting
1557 // OS X.
1558 return VersionTuple(5);
1559 case IOS:
1560 case TvOS: {
1562 // Default to 5.0 (or 7.0 for arm64).
1563 if (Version.getMajor() == 0)
1564 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1565 if (Version.getMajor() == 19)
1566 // tvOS 19 corresponds to ios26.
1567 return VersionTuple(26);
1570 }
1571 case XROS: {
1573 // xrOS 1 is aligned with iOS 17.
1574 if (Version.getMajor() < 3)
1575 return Version.withMajorReplaced(Version.getMajor() + 16);
1576 // visionOS 3 corresponds to ios 26+.
1577 if (Version.getMajor() == 3)
1578 return VersionTuple(26);
1581 }
1582 case WatchOS: {
1584 // watchOS 12 corresponds to ios 26.
1585 if (Version.getMajor() == 12)
1586 return VersionTuple(26);
1590 }
1591 case BridgeOS:
1592 llvm_unreachable("conflicting triple info");
1593 case DriverKit:
1594 llvm_unreachable("DriverKit doesn't have an iOS version");
1595 case Firmware:
1596 llvm_unreachable("iOS version isn't relevant for Firmware");
1597 }
1598}
1599
1601 switch (getOS()) {
1602 default:
1603 llvm_unreachable("unexpected OS for Darwin triple");
1604 case Darwin:
1605 case MacOSX:
1606 // Ignore the version from the triple. This is only handled because the
1607 // the clang driver combines OS X and IOS support into a common Darwin
1608 // toolchain that wants to know the iOS version number even when targeting
1609 // OS X.
1610 return VersionTuple(2);
1611 case WatchOS: {
1613 if (Version.getMajor() == 0)
1614 return VersionTuple(2);
1615 return Version;
1616 }
1617 case IOS:
1618 llvm_unreachable("conflicting triple info");
1619 case XROS:
1620 llvm_unreachable("watchOS version isn't relevant for xrOS");
1621 case DriverKit:
1622 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1623 case Firmware:
1624 llvm_unreachable("watchOS version isn't relevant for Firmware");
1625 }
1626}
1627
1629 switch (getOS()) {
1630 default:
1631 llvm_unreachable("unexpected OS for Darwin triple");
1632 case DriverKit:
1634 if (Version.getMajor() == 0)
1635 return Version.withMajorReplaced(19);
1636 return Version;
1637 }
1638}
1639
1641 if (getArch() != spirv || getOS() != Vulkan)
1642 llvm_unreachable("invalid Vulkan SPIR-V triple");
1643
1644 VersionTuple VulkanVersion = getOSVersion();
1645 SubArchType SpirvVersion = getSubArch();
1646
1648 // Vulkan 1.2 -> SPIR-V 1.5.
1650 // Vulkan 1.3 -> SPIR-V 1.6.
1652
1653 // If Vulkan version is unset, default to 1.2.
1654 if (VulkanVersion == VersionTuple(0))
1655 VulkanVersion = VersionTuple(1, 2);
1656
1657 if (ValidVersionMap.contains(VulkanVersion) &&
1658 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1659 SpirvVersion == NoSubArch))
1660 return VulkanVersion;
1661
1662 return VersionTuple(0);
1663}
1664
1666 if (getArch() != dxil || getOS() != ShaderModel)
1667 llvm_unreachable("invalid DXIL triple");
1668 StringRef Arch = getArchName();
1669 if (getSubArch() == NoSubArch)
1671 Arch.consume_front("dxilv");
1672 VersionTuple DXILVersion = parseVersionFromName(Arch);
1673 // FIXME: validate DXIL version against Shader Model version.
1674 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1675 return DXILVersion;
1676}
1677
1678void Triple::setTriple(const Twine &Str) { *this = Triple(Str); }
1679
1681 setArchName(getArchName(Kind, SubArch));
1682}
1683
1687
1689
1691 if (ObjectFormat == getDefaultFormat(*this))
1693
1695 getObjectFormatTypeName(ObjectFormat))
1696 .str());
1697}
1698
1700 if (Environment == UnknownEnvironment)
1702
1703 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1705 .str());
1706}
1707
1709 setTriple(Str + "-" + getVendorName() + "-" + getOSAndEnvironmentName());
1710}
1711
1713 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1714}
1715
1717 if (hasEnvironment())
1718 setTriple(getArchName() + "-" + getVendorName() + "-" + Str + "-" +
1720 else
1721 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1722}
1723
1725 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() + "-" +
1726 Str);
1727}
1728
1730 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1731}
1732
1734 switch (Arch) {
1736 return 0;
1737
1738 case llvm::Triple::avr:
1740 return 16;
1741
1744 case llvm::Triple::arc:
1745 case llvm::Triple::arm:
1747 case llvm::Triple::csky:
1748 case llvm::Triple::dxil:
1754 case llvm::Triple::m68k:
1755 case llvm::Triple::mips:
1758 case llvm::Triple::ppc:
1760 case llvm::Triple::r600:
1767 case llvm::Triple::spir:
1769 case llvm::Triple::tce:
1774 case llvm::Triple::x86:
1777 return 32;
1778
1801 case llvm::Triple::ve:
1804 return 64;
1805 }
1806 llvm_unreachable("Invalid architecture value");
1807}
1808
1810 switch (getArch()) {
1811 default:
1812 break;
1813 case Triple::ppc:
1814 case Triple::ppcle:
1815 if (isOSLinux())
1816 return 40;
1817 break;
1818 case Triple::ppc64:
1819 case Triple::ppc64le:
1820 if (isOSLinux())
1821 return 48;
1822 break;
1823 }
1824 return 32;
1825}
1826
1828 return getArchPointerBitWidth(getArch()) == 64;
1829}
1830
1832 return getArchPointerBitWidth(getArch()) == 32;
1833}
1834
1836 return getArchPointerBitWidth(getArch()) == 16;
1837}
1838
1840 Triple T(*this);
1841 switch (getArch()) {
1843 case Triple::amdgpu:
1844 case Triple::avr:
1845 case Triple::bpfeb:
1846 case Triple::bpfel:
1847 case Triple::msp430:
1848 case Triple::systemz:
1849 case Triple::ve:
1850 T.setArch(UnknownArch);
1851 break;
1852
1853 case Triple::aarch64_32:
1854 case Triple::amdil:
1855 case Triple::arc:
1856 case Triple::arm:
1857 case Triple::armeb:
1858 case Triple::csky:
1859 case Triple::dxil:
1860 case Triple::hexagon:
1861 case Triple::hsail:
1862 case Triple::kalimba:
1863 case Triple::lanai:
1865 case Triple::m68k:
1866 case Triple::mips:
1867 case Triple::mipsel:
1868 case Triple::nvptx:
1869 case Triple::ppc:
1870 case Triple::ppcle:
1871 case Triple::r600:
1873 case Triple::riscv32:
1874 case Triple::riscv32be:
1875 case Triple::shave:
1876 case Triple::sparc:
1877 case Triple::sparcel:
1878 case Triple::spir:
1879 case Triple::spirv32:
1880 case Triple::tce:
1881 case Triple::tcele:
1882 case Triple::thumb:
1883 case Triple::thumbeb:
1884 case Triple::wasm32:
1885 case Triple::x86:
1886 case Triple::xcore:
1887 case Triple::xtensa:
1888 // Already 32-bit.
1889 break;
1890
1891 case Triple::aarch64:
1892 T.setArch(Triple::arm);
1893 break;
1894 case Triple::aarch64_be:
1895 T.setArch(Triple::armeb);
1896 break;
1897 case Triple::amdil64:
1898 T.setArch(Triple::amdil);
1899 break;
1900 case Triple::hsail64:
1901 T.setArch(Triple::hsail);
1902 break;
1904 T.setArch(Triple::loongarch32);
1905 break;
1906 case Triple::mips64:
1907 T.setArch(Triple::mips, getSubArch());
1908 break;
1909 case Triple::mips64el:
1910 T.setArch(Triple::mipsel, getSubArch());
1911 break;
1912 case Triple::nvptx64:
1913 T.setArch(Triple::nvptx);
1914 break;
1915 case Triple::ppc64:
1916 T.setArch(Triple::ppc);
1917 break;
1918 case Triple::ppc64le:
1919 T.setArch(Triple::ppcle);
1920 break;
1922 T.setArch(Triple::renderscript32);
1923 break;
1924 case Triple::riscv64:
1925 T.setArch(Triple::riscv32);
1926 break;
1927 case Triple::riscv64be:
1928 T.setArch(Triple::riscv32be);
1929 break;
1930 case Triple::sparcv9:
1931 T.setArch(Triple::sparc);
1932 break;
1933 case Triple::spir64:
1934 T.setArch(Triple::spir);
1935 break;
1936 case Triple::spirv:
1937 case Triple::spirv64:
1938 T.setArch(Triple::spirv32, getSubArch());
1939 break;
1940 case Triple::tcele64:
1941 T.setArch(Triple::tcele);
1942 break;
1943 case Triple::wasm64:
1944 T.setArch(Triple::wasm32);
1945 break;
1946 case Triple::x86_64:
1947 T.setArch(Triple::x86);
1948 break;
1949 }
1950 return T;
1951}
1952
1954 Triple T(*this);
1955 switch (getArch()) {
1957 case Triple::arc:
1958 case Triple::avr:
1959 case Triple::csky:
1960 case Triple::dxil:
1961 case Triple::hexagon:
1962 case Triple::kalimba:
1963 case Triple::lanai:
1964 case Triple::m68k:
1965 case Triple::msp430:
1966 case Triple::r600:
1967 case Triple::shave:
1968 case Triple::sparcel:
1969 case Triple::tce:
1970 case Triple::xcore:
1971 case Triple::xtensa:
1972 T.setArch(UnknownArch);
1973 break;
1974
1975 case Triple::aarch64:
1976 case Triple::aarch64_be:
1977 case Triple::amdgpu:
1978 case Triple::amdil64:
1979 case Triple::bpfeb:
1980 case Triple::bpfel:
1981 case Triple::hsail64:
1983 case Triple::mips64:
1984 case Triple::mips64el:
1985 case Triple::nvptx64:
1986 case Triple::ppc64:
1987 case Triple::ppc64le:
1989 case Triple::riscv64:
1990 case Triple::riscv64be:
1991 case Triple::sparcv9:
1992 case Triple::spir64:
1993 case Triple::spirv64:
1994 case Triple::systemz:
1995 case Triple::tcele64:
1996 case Triple::ve:
1997 case Triple::wasm64:
1998 case Triple::x86_64:
1999 // Already 64-bit.
2000 break;
2001
2002 case Triple::aarch64_32:
2003 T.setArch(Triple::aarch64);
2004 break;
2005 case Triple::amdil:
2006 T.setArch(Triple::amdil64);
2007 break;
2008 case Triple::arm:
2009 T.setArch(Triple::aarch64);
2010 break;
2011 case Triple::armeb:
2012 T.setArch(Triple::aarch64_be);
2013 break;
2014 case Triple::hsail:
2015 T.setArch(Triple::hsail64);
2016 break;
2018 T.setArch(Triple::loongarch64);
2019 break;
2020 case Triple::mips:
2021 T.setArch(Triple::mips64, getSubArch());
2022 break;
2023 case Triple::mipsel:
2024 T.setArch(Triple::mips64el, getSubArch());
2025 break;
2026 case Triple::nvptx:
2027 T.setArch(Triple::nvptx64);
2028 break;
2029 case Triple::ppc:
2030 T.setArch(Triple::ppc64);
2031 break;
2032 case Triple::ppcle:
2033 T.setArch(Triple::ppc64le);
2034 break;
2036 T.setArch(Triple::renderscript64);
2037 break;
2038 case Triple::riscv32:
2039 T.setArch(Triple::riscv64);
2040 break;
2041 case Triple::riscv32be:
2042 T.setArch(Triple::riscv64be);
2043 break;
2044 case Triple::sparc:
2045 T.setArch(Triple::sparcv9);
2046 break;
2047 case Triple::spir:
2048 T.setArch(Triple::spir64);
2049 break;
2050 case Triple::spirv:
2051 case Triple::spirv32:
2052 T.setArch(Triple::spirv64, getSubArch());
2053 break;
2054 case Triple::tcele:
2055 T.setArch(Triple::tcele64);
2056 break;
2057 case Triple::thumb:
2058 T.setArch(Triple::aarch64);
2059 break;
2060 case Triple::thumbeb:
2061 T.setArch(Triple::aarch64_be);
2062 break;
2063 case Triple::wasm32:
2064 T.setArch(Triple::wasm64);
2065 break;
2066 case Triple::x86:
2067 T.setArch(Triple::x86_64);
2068 break;
2069 }
2070 return T;
2071}
2072
2074 Triple T(*this);
2075 // Already big endian.
2076 if (!isLittleEndian())
2077 return T;
2078 switch (getArch()) {
2080 case Triple::amdgpu:
2081 case Triple::amdil64:
2082 case Triple::amdil:
2083 case Triple::avr:
2084 case Triple::dxil:
2085 case Triple::hexagon:
2086 case Triple::hsail64:
2087 case Triple::hsail:
2088 case Triple::kalimba:
2091 case Triple::msp430:
2092 case Triple::nvptx64:
2093 case Triple::nvptx:
2094 case Triple::r600:
2097 case Triple::shave:
2098 case Triple::spir64:
2099 case Triple::spir:
2100 case Triple::spirv:
2101 case Triple::spirv32:
2102 case Triple::spirv64:
2103 case Triple::tcele64:
2104 case Triple::wasm32:
2105 case Triple::wasm64:
2106 case Triple::x86:
2107 case Triple::x86_64:
2108 case Triple::xcore:
2109 case Triple::ve:
2110 case Triple::csky:
2111 case Triple::xtensa:
2112
2113 // ARM is intentionally unsupported here, changing the architecture would
2114 // drop any arch suffixes.
2115 case Triple::arm:
2116 case Triple::thumb:
2117 T.setArch(UnknownArch);
2118 break;
2119
2120 case Triple::aarch64:
2121 T.setArch(Triple::aarch64_be);
2122 break;
2123 case Triple::bpfel:
2124 T.setArch(Triple::bpfeb);
2125 break;
2126 case Triple::mips64el:
2127 T.setArch(Triple::mips64, getSubArch());
2128 break;
2129 case Triple::mipsel:
2130 T.setArch(Triple::mips, getSubArch());
2131 break;
2132 case Triple::ppcle:
2133 T.setArch(Triple::ppc);
2134 break;
2135 case Triple::ppc64le:
2136 T.setArch(Triple::ppc64);
2137 break;
2138 case Triple::riscv32:
2139 T.setArch(Triple::riscv32be);
2140 break;
2141 case Triple::riscv64:
2142 T.setArch(Triple::riscv64be);
2143 break;
2144 case Triple::sparcel:
2145 T.setArch(Triple::sparc);
2146 break;
2147 case Triple::tcele:
2148 T.setArch(Triple::tce);
2149 break;
2150 default:
2151 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
2152 }
2153 return T;
2154}
2155
2157 Triple T(*this);
2158 if (isLittleEndian())
2159 return T;
2160
2161 switch (getArch()) {
2163 case Triple::lanai:
2164 case Triple::sparcv9:
2165 case Triple::systemz:
2166 case Triple::m68k:
2167
2168 // ARM is intentionally unsupported here, changing the architecture would
2169 // drop any arch suffixes.
2170 case Triple::armeb:
2171 case Triple::thumbeb:
2172 T.setArch(UnknownArch);
2173 break;
2174
2175 case Triple::aarch64_be:
2176 T.setArch(Triple::aarch64);
2177 break;
2178 case Triple::bpfeb:
2179 T.setArch(Triple::bpfel);
2180 break;
2181 case Triple::mips64:
2182 T.setArch(Triple::mips64el, getSubArch());
2183 break;
2184 case Triple::mips:
2185 T.setArch(Triple::mipsel, getSubArch());
2186 break;
2187 case Triple::ppc:
2188 T.setArch(Triple::ppcle);
2189 break;
2190 case Triple::ppc64:
2191 T.setArch(Triple::ppc64le);
2192 break;
2193 case Triple::riscv32be:
2194 T.setArch(Triple::riscv32);
2195 break;
2196 case Triple::riscv64be:
2197 T.setArch(Triple::riscv64);
2198 break;
2199 case Triple::sparc:
2200 T.setArch(Triple::sparcel);
2201 break;
2202 case Triple::tce:
2203 T.setArch(Triple::tcele);
2204 break;
2205 default:
2206 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
2207 }
2208 return T;
2209}
2210
2212 switch (getArch()) {
2213 case Triple::aarch64:
2214 case Triple::aarch64_32:
2215 case Triple::amdgpu:
2216 case Triple::amdil64:
2217 case Triple::amdil:
2218 case Triple::arm:
2219 case Triple::avr:
2220 case Triple::bpfel:
2221 case Triple::csky:
2222 case Triple::dxil:
2223 case Triple::hexagon:
2224 case Triple::hsail64:
2225 case Triple::hsail:
2226 case Triple::kalimba:
2229 case Triple::mips64el:
2230 case Triple::mipsel:
2231 case Triple::msp430:
2232 case Triple::nvptx64:
2233 case Triple::nvptx:
2234 case Triple::ppcle:
2235 case Triple::ppc64le:
2236 case Triple::r600:
2239 case Triple::riscv32:
2240 case Triple::riscv64:
2241 case Triple::shave:
2242 case Triple::sparcel:
2243 case Triple::spir64:
2244 case Triple::spir:
2245 case Triple::spirv:
2246 case Triple::spirv32:
2247 case Triple::spirv64:
2248 case Triple::tcele:
2249 case Triple::tcele64:
2250 case Triple::thumb:
2251 case Triple::ve:
2252 case Triple::wasm32:
2253 case Triple::wasm64:
2254 case Triple::x86:
2255 case Triple::x86_64:
2256 case Triple::xcore:
2257 case Triple::xtensa:
2258 return true;
2259 default:
2260 return false;
2261 }
2262}
2263
2265 if (getArch() == Triple::xcore)
2266 return 1;
2267 if (isOSWindowsOrUEFI() || isPS())
2268 return 2;
2269 if (isOSAIX() && isArch32Bit())
2270 return 2;
2271 return 4;
2272}
2273
2275 // On MinGW, C code is usually built with a "w64" vendor, while Rust
2276 // often uses a "pc" vendor.
2277 bool IgnoreVendor = isWindowsGNUEnvironment();
2278
2279 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
2280 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2281 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2282 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2283 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2284 if (getVendor() == Triple::Apple)
2285 return getSubArch() == Other.getSubArch() &&
2286 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2287 else
2288 return getSubArch() == Other.getSubArch() &&
2289 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2290 getOS() == Other.getOS() &&
2291 getEnvironment() == Other.getEnvironment() &&
2292 getObjectFormat() == Other.getObjectFormat();
2293 }
2294
2295 if (getArch() == Triple::amdgpu && Other.getArch() == Triple::amdgpu) {
2296 if (getOS() != Other.getOS() || getVendor() != Other.getVendor() ||
2297 getEnvironment() != Other.getEnvironment() ||
2298 getObjectFormat() != Other.getObjectFormat())
2299 return false;
2300 return AMDGPU::isSubArchCompatible(*this, Other);
2301 }
2302
2303 // If vendor is apple, ignore the version number (the environment field)
2304 // and the object format.
2305 if (getVendor() == Triple::Apple)
2306 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2307 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2308 getOS() == Other.getOS();
2309
2310 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2311 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2312 getOS() == Other.getOS() &&
2313 getEnvironment() == Other.getEnvironment() &&
2314 getObjectFormat() == Other.getObjectFormat();
2315}
2316
2317std::string Triple::merge(const Triple &Other) const {
2318 // If vendor is apple, pick the triple with the larger version number.
2319 if (getVendor() == Triple::Apple && Other.isOSVersionLT(*this))
2320 return str();
2321
2322 if (isAMDGCN() && Other.isAMDGCN() && getOS() == Other.getOS() &&
2323 getVendor() == Other.getVendor())
2324 return AMDGPU::mergeSubArch(*this, Other);
2325
2326 return Other.str();
2327}
2328
2329bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2330 unsigned Micro) const {
2331 assert(isMacOSX() && "Not an OS X triple!");
2332
2333 // If this is OS X, expect a sane version number.
2334 if (getOS() == Triple::MacOSX)
2335 return isOSVersionLT(Major, Minor, Micro);
2336
2337 // Otherwise, compare to the "Darwin" number.
2338 if (Major == 10)
2339 return isOSVersionLT(Minor + 4, Micro, 0);
2340 assert(Major >= 11 && "Unexpected major version");
2341 if (Major < 25)
2342 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2343 return isOSVersionLT(Major + 1, Minor, Micro);
2344}
2345
2348 return VersionTuple();
2349 switch (getOS()) {
2350 case Triple::MacOSX:
2351 // ARM64 slice is supported starting from macOS 11.0+.
2352 return VersionTuple(11, 0, 0);
2353 case Triple::IOS:
2354 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2355 // ARM64 simulators are supported for iOS 14+.
2357 return VersionTuple(14, 0, 0);
2358 // ARM64e slice is supported starting from iOS 14.
2359 if (isArm64e())
2360 return VersionTuple(14, 0, 0);
2361 break;
2362 case Triple::TvOS:
2363 // ARM64 simulators are supported for tvOS 14+.
2365 return VersionTuple(14, 0, 0);
2366 break;
2367 case Triple::WatchOS:
2368 // ARM64 simulators are supported for watchOS 7+.
2370 return VersionTuple(7, 0, 0);
2371 // ARM64/ARM64e slices are supported starting from watchOS 26.
2372 // ARM64_32 is older though.
2374 return VersionTuple(26, 0, 0);
2375 case Triple::DriverKit:
2376 return VersionTuple(20, 0, 0);
2377 default:
2378 break;
2379 }
2380 return VersionTuple();
2381}
2382
2384 const VersionTuple &Version,
2385 bool IsInValidRange) {
2386 const unsigned MacOSRangeBump = 10;
2387 const unsigned IOSRangeBump = 7;
2388 const unsigned XROSRangeBump = 23;
2389 const unsigned WatchOSRangeBump = 14;
2390 switch (OSKind) {
2391 case MacOSX: {
2392 // macOS 10.16 is canonicalized to macOS 11.
2393 if (Version == VersionTuple(10, 16))
2394 return VersionTuple(11, 0);
2395 // macOS 16 is canonicalized to macOS 26.
2396 if (Version == VersionTuple(16, 0))
2397 return VersionTuple(26, 0);
2398 if (!IsInValidRange)
2399 return Version.withMajorReplaced(Version.getMajor() + MacOSRangeBump);
2400 break;
2401 }
2402 case IOS:
2403 case TvOS: {
2404 // Both iOS & tvOS 19.0 canonicalize to 26.
2405 if (Version == VersionTuple(19, 0))
2406 return VersionTuple(26, 0);
2407 if (!IsInValidRange)
2408 return Version.withMajorReplaced(Version.getMajor() + IOSRangeBump);
2409 break;
2410 }
2411 case XROS: {
2412 // visionOS3 is canonicalized to 26.
2413 if (Version == VersionTuple(3, 0))
2414 return VersionTuple(26, 0);
2415 if (!IsInValidRange)
2416 return Version.withMajorReplaced(Version.getMajor() + XROSRangeBump);
2417 break;
2418 }
2419 case WatchOS: {
2420 // watchOS 12 is canonicalized to 26.
2421 if (Version == VersionTuple(12, 0))
2422 return VersionTuple(26, 0);
2423 if (!IsInValidRange)
2424 return Version.withMajorReplaced(Version.getMajor() + WatchOSRangeBump);
2425 break;
2426 }
2427 case DriverKit: {
2428 // DriverKit26 is canonicalized to 27.
2429 if (Version.getMajor() == 26U)
2430 return Version.withMajorReplaced(27);
2431 break;
2432 }
2433 default:
2434 return Version;
2435 }
2436
2437 return Version;
2438}
2439
2441 /// This constant is used to capture gaps in versioning.
2442 const VersionTuple CommonVersion(26);
2443 auto IsValid = [&](const VersionTuple &StartingVersion) {
2444 return !((Version > StartingVersion) && (Version < CommonVersion));
2445 };
2446 switch (OSKind) {
2447 case WatchOS: {
2448 const VersionTuple StartingWatchOS(12);
2449 return IsValid(StartingWatchOS);
2450 }
2451 case IOS:
2452 case TvOS: {
2453 const VersionTuple StartingIOS(19);
2454 return IsValid(StartingIOS);
2455 }
2456 case MacOSX: {
2457 const VersionTuple StartingMacOS(16);
2458 return IsValid(StartingMacOS);
2459 }
2460 case XROS: {
2461 const VersionTuple StartingXROS(3);
2462 return IsValid(StartingXROS);
2463 }
2464 default:
2465 return true;
2466 }
2467
2468 llvm_unreachable("unexpected or invalid os version");
2469}
2470
2472 if (isOSBinFormatCOFF()) {
2473 if (getArch() == Triple::x86 &&
2477 }
2478
2479 if (isOSBinFormatXCOFF())
2481 if (isOSBinFormatGOFF())
2483
2484 if (isARM() || isThumb()) {
2485 if (isOSBinFormatELF()) {
2488 }
2489
2492 }
2493
2494 if (isAArch64() || isX86() || isPPC() || isMIPS() || isSPARC() || isBPF() ||
2495 isRISCV() || isLoongArch())
2497
2498 switch (getArch()) {
2499 case Triple::arc:
2500 case Triple::csky:
2501 case Triple::hexagon:
2502 case Triple::lanai:
2503 case Triple::m68k:
2504 case Triple::msp430:
2505 case Triple::systemz:
2506 case Triple::xcore:
2507 case Triple::xtensa:
2509 default:
2510 break;
2511 }
2512
2513 // Explicitly none targets.
2514 if (isWasm() || isAMDGPU() || isNVPTX() || isSPIROrSPIRV())
2516
2517 // Default to none.
2519}
2520
2522 Triple::EnvironmentType Env = T.getEnvironment();
2523 bool IsHard =
2524 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
2525 Env == Triple::MuslEABIHF || Env == Triple::EABIHF ||
2526 (T.isOSBinFormatMachO() && T.getSubArch() == Triple::ARMSubArch_v7em) ||
2527 T.isOSWindows() || ARM::computeTargetABI(T, "") == ARM::ARM_ABI_AAPCS16;
2528 return IsHard ? FloatABI::Hard : FloatABI::Soft;
2529}
2530
2532 if (isARM() || isThumb())
2533 return getARMDefaultFloatABI(*this);
2534
2535 // MIPS defaults to hard float, except on FreeBSD which uses soft float.
2536 if (isMIPS())
2538
2539 if (isCSKY() || isAVR() || getArch() == msp430)
2540 return FloatABI::Soft;
2541
2542 // Most targets use hard float unless soft float is explicitly requested.
2543 return FloatABI::Hard;
2544}
2545
2547
2549 switch (getArch()) {
2550 case loongarch64:
2551 case riscv32:
2552 case riscv64:
2553 case riscv32be:
2554 case riscv64be:
2555 case sparc:
2556 case sparcel:
2557 case sparcv9:
2558 case systemz:
2559 case ve:
2560 case wasm32:
2561 case wasm64:
2563 case ppc:
2564 case ppcle:
2565 case ppc64:
2566 case ppc64le:
2567 // PowerPC uses IBM double-double, except on a handful of OSes that use
2568 // plain IEEE double. NetBSD only switches to IEEE double on 32-bit PowerPC.
2569 if (isOSAIX() || isOSFreeBSD() || isOSOpenBSD() || isMusl() ||
2570 (isOSNetBSD() && isPPC32()))
2573 case x86:
2574 case x86_64:
2575 // Android and OHOS use IEEE double on 32-bit and IEEE quad on 64-bit.
2576 if (isAndroid() || isOHOSFamily())
2579 // Windows-MSVC and UEFI use IEEE double. MinGW and Cygwin keep x87.
2583 case aarch64:
2584 case aarch64_be:
2585 case aarch64_32:
2586 // AArch64 uses IEEE quad, except on Windows and Darwin.
2587 if (isOSWindows() || isOSDarwin())
2590 case mips64:
2591 case mips64el:
2593 case avr:
2594 case tce:
2595 case tcele:
2596 // AVR and 32-bit OpenASIP use IEEE single precision.
2598 case tcele64:
2599 // 64-bit OpenASIP uses IEEE double, unlike its 32-bit variants.
2601 default:
2603 }
2604}
2605
2606// HLSL triple environment orders are relied on in the front end
2607static_assert(Triple::Vertex - Triple::Pixel == 1,
2608 "incorrect HLSL stage order");
2609static_assert(Triple::Geometry - Triple::Pixel == 2,
2610 "incorrect HLSL stage order");
2611static_assert(Triple::Hull - Triple::Pixel == 3, "incorrect HLSL stage order");
2612static_assert(Triple::Domain - Triple::Pixel == 4,
2613 "incorrect HLSL stage order");
2614static_assert(Triple::Compute - Triple::Pixel == 5,
2615 "incorrect HLSL stage order");
2616static_assert(Triple::Library - Triple::Pixel == 6,
2617 "incorrect HLSL stage order");
2618static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2619 "incorrect HLSL stage order");
2620static_assert(Triple::Intersection - Triple::Pixel == 8,
2621 "incorrect HLSL stage order");
2622static_assert(Triple::AnyHit - Triple::Pixel == 9,
2623 "incorrect HLSL stage order");
2624static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2625 "incorrect HLSL stage order");
2626static_assert(Triple::Miss - Triple::Pixel == 11, "incorrect HLSL stage order");
2627static_assert(Triple::Callable - Triple::Pixel == 12,
2628 "incorrect HLSL stage order");
2629static_assert(Triple::Mesh - Triple::Pixel == 13, "incorrect HLSL stage order");
2630static_assert(Triple::Amplification - Triple::Pixel == 14,
2631 "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 VersionTuple parseVersionFromName(StringRef Name)
Definition Triple.cpp:1447
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition Triple.cpp:949
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:1143
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition Triple.cpp:442
static FloatABI::ABIType getARMDefaultFloatABI(const Triple &T)
Definition Triple.cpp:2521
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[....
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:278
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition DenseMap.h:242
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:2329
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1480
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1137
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1425
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1600
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1708
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1699
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:1839
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:819
bool isWatchABI() const
Definition Triple.h:698
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:404
@ UnknownEnvironment
Definition Triple.h:356
@ Amplification
Definition Triple.h:411
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:997
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1205
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:2383
CanonicalForm
Canonical form.
Definition Triple.h:489
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:617
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2156
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1242
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:538
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:517
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1197
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1219
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:872
bool isWindowsGNUEnvironment() const
Definition Triple.h:814
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1712
bool isOSNetBSD() const
Definition Triple.h:744
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1729
bool isAndroid() const
Tests whether the target is Android.
Definition Triple.h:910
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:1953
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2211
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1690
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1430
bool isAVR() const
Definition Triple.h:1112
bool isSPIROrSPIRV() const
Definition Triple.h:981
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2471
@ 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:2546
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition Triple.cpp:1678
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:523
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1453
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:1190
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:1143
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:514
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:1809
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:869
bool isCSKY() const
Definition Triple.h:1216
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1436
bool isSimulatorEnvironment() const
Definition Triple.h:730
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1665
const std::string & str() const
Definition Triple.h:579
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:940
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:529
bool isOSOpenBSD() const
Definition Triple.h:746
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1640
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1628
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:774
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:777
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:925
LLVM_ABI LongDoubleFormat getDefaultLongDoubleFormat() const
Returns the default floating-point format for the "long double" type.
Definition Triple.cpp:2548
bool isOSWindowsOrUEFI() const
Tests whether the OS is Windows or UEFI.
Definition Triple.h:783
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:881
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:392
@ UnknownObjectFormat
Definition Triple.h:421
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:1002
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2317
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:830
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:1180
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition Triple.h:992
bool isAMDGPU() const
Definition Triple.h:994
@ UnknownVendor
Definition Triple.h:282
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:987
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:855
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2346
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1827
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1442
@ ARMSubArch_v6t2
Definition Triple.h:154
@ AMDGPUSubArch600
Definition Triple.h:198
@ MipsSubArch_r6
Definition Triple.h:170
@ X86_64SubArch_lfi
Definition Triple.h:164
@ DXILSubArch_v1_2
Definition Triple.h:186
@ ARMSubArch_v7
Definition Triple.h:145
@ ARMSubArch_v8m_mainline
Definition Triple.h:143
@ AMDGPUSubArch1153
Definition Triple.h:259
@ ARMSubArch_v9_6a
Definition Triple.h:124
@ AMDGPUSubArch1012
Definition Triple.h:239
@ ARMSubArch_v8r
Definition Triple.h:141
@ AMDGPUSubArch1150
Definition Triple.h:256
@ ARMSubArch_v9_1a
Definition Triple.h:129
@ AMDGPUSubArch1250S
Definition Triple.h:272
@ DXILSubArch_v1_1
Definition Triple.h:185
@ AMDGPUSubArch703
Definition Triple.h:206
@ AMDGPUSubArch1201
Definition Triple.h:269
@ LatestDXILSubArch
Definition Triple.h:194
@ SPIRVSubArch_v10
Definition Triple.h:175
@ AMDGPUSubArch9
Definition Triple.h:219
@ SPIRVSubArch_v13
Definition Triple.h:178
@ AMDGPUSubArch1172
Definition Triple.h:265
@ AMDGPUSubArch1035
Definition Triple.h:248
@ ARMSubArch_v7k
Definition Triple.h:149
@ AMDGPUSubArch9_4
Definition Triple.h:232
@ AMDGPUSubArch6
Definition Triple.h:197
@ AMDGPUSubArch1033
Definition Triple.h:246
@ AMDGPUSubArch1103
Definition Triple.h:255
@ ARMSubArch_v8_7a
Definition Triple.h:133
@ AMDGPUSubArch1034
Definition Triple.h:247
@ AMDGPUSubArch1154
Definition Triple.h:260
@ ARMSubArch_v8
Definition Triple.h:140
@ SPIRVSubArch_v16
Definition Triple.h:181
@ ARMSubArch_v8_1a
Definition Triple.h:139
@ ARMSubArch_v9_2a
Definition Triple.h:128
@ AMDGPUSubArch1200
Definition Triple.h:268
@ AMDGPUSubArch10_3
Definition Triple.h:242
@ DXILSubArch_v1_3
Definition Triple.h:187
@ SPIRVSubArch_v15
Definition Triple.h:180
@ ARMSubArch_v7m
Definition Triple.h:147
@ AMDGPUSubArch1102
Definition Triple.h:254
@ ARMSubArch_v9_7a
Definition Triple.h:123
@ AMDGPUSubArch1013
Definition Triple.h:240
@ AMDGPUSubArch902
Definition Triple.h:221
@ ARMSubArch_v6k
Definition Triple.h:153
@ AMDGPUSubArch1010
Definition Triple.h:237
@ AMDGPUSubArch90A
Definition Triple.h:230
@ ARMSubArch_v5
Definition Triple.h:155
@ AMDGPUSubArch1170
Definition Triple.h:263
@ AArch64SubArch_arm64e
Definition Triple.h:159
@ AMDGPUSubArch810
Definition Triple.h:217
@ ARMSubArch_v6
Definition Triple.h:151
@ AMDGPUSubArch11
Definition Triple.h:251
@ AMDGPUSubArch1151
Definition Triple.h:257
@ ARMSubArch_v9_5a
Definition Triple.h:125
@ AMDGPUSubArch602
Definition Triple.h:200
@ ARMSubArch_v7ve
Definition Triple.h:150
@ ARMSubArch_v8m_baseline
Definition Triple.h:142
@ ARMSubArch_v8_8a
Definition Triple.h:132
@ AArch64SubArch_arm64e_x1
Definition Triple.h:160
@ AMDGPUSubArch942
Definition Triple.h:233
@ AMDGPUSubArch7
Definition Triple.h:202
@ AMDGPUSubArch702
Definition Triple.h:205
@ AMDGPUSubArch950
Definition Triple.h:234
@ ARMSubArch_v8_2a
Definition Triple.h:138
@ ARMSubArch_v7s
Definition Triple.h:148
@ AMDGPUSubArch1251
Definition Triple.h:274
@ AMDGPUSubArch805
Definition Triple.h:214
@ DXILSubArch_v1_0
Definition Triple.h:184
@ DXILSubArch_v1_7
Definition Triple.h:191
@ AMDGPUSubArch12_5
Definition Triple.h:271
@ KalimbaSubArch_v3
Definition Triple.h:166
@ DXILSubArch_v1_5
Definition Triple.h:189
@ AMDGPUSubArch1250
Definition Triple.h:273
@ AMDGPUSubArch1030
Definition Triple.h:243
@ ARMSubArch_v8_4a
Definition Triple.h:136
@ AMDGPUSubArch803
Definition Triple.h:213
@ AMDGPUSubArch601
Definition Triple.h:199
@ ARMSubArch_v8_9a
Definition Triple.h:131
@ AMDGPUSubArch10_1
Definition Triple.h:236
@ AMDGPUSubArch904
Definition Triple.h:222
@ AMDGPUSubArch11_7
Definition Triple.h:262
@ AMDGPUSubArch705
Definition Triple.h:208
@ AMDGPUSubArch802
Definition Triple.h:212
@ AMDGPUSubArch8
Definition Triple.h:210
@ ARMSubArch_v7em
Definition Triple.h:146
@ SPIRVSubArch_v12
Definition Triple.h:177
@ AMDGPUSubArch90C
Definition Triple.h:225
@ SPIRVSubArch_v14
Definition Triple.h:179
@ AMDGPUSubArch1100
Definition Triple.h:252
@ KalimbaSubArch_v4
Definition Triple.h:167
@ AMDGPUSubArch909
Definition Triple.h:224
@ ARMSubArch_v8_1m_mainline
Definition Triple.h:144
@ AMDGPUSubArch1036
Definition Triple.h:249
@ ARMSubArch_v8_3a
Definition Triple.h:137
@ AArch64SubArch_arm64ec
Definition Triple.h:161
@ ARMSubArch_v8_6a
Definition Triple.h:134
@ ARMSubArch_v5te
Definition Triple.h:156
@ KalimbaSubArch_v5
Definition Triple.h:168
@ AMDGPUSubArch701
Definition Triple.h:204
@ ARMSubArch_v4t
Definition Triple.h:157
@ AMDGPUSubArch1171
Definition Triple.h:264
@ DXILSubArch_v1_6
Definition Triple.h:190
@ AMDGPUSubArch1011
Definition Triple.h:238
@ AMDGPUSubArch906
Definition Triple.h:223
@ AMDGPUSubArch900
Definition Triple.h:220
@ AMDGPUSubArch1152
Definition Triple.h:258
@ DXILSubArch_v1_8
Definition Triple.h:192
@ AMDGPUSubArch801
Definition Triple.h:211
@ ARMSubArch_v9_4a
Definition Triple.h:126
@ ARMSubArch_v8_5a
Definition Triple.h:135
@ AArch64SubArch_lfi
Definition Triple.h:162
@ ARMSubArch_v6m
Definition Triple.h:152
@ ARMSubArch_v9_3a
Definition Triple.h:127
@ DXILSubArch_v1_9
Definition Triple.h:193
@ AMDGPUSubArch704
Definition Triple.h:207
@ AMDGPUSubArch1031
Definition Triple.h:244
@ AMDGPUSubArch1101
Definition Triple.h:253
@ ARMSubArch_v9
Definition Triple.h:130
@ AMDGPUSubArch13
Definition Triple.h:276
@ AMDGPUSubArch12
Definition Triple.h:267
@ DXILSubArch_v1_4
Definition Triple.h:188
@ AMDGPUSubArch700
Definition Triple.h:203
@ SPIRVSubArch_v11
Definition Triple.h:176
@ PPCSubArch_spe
Definition Triple.h:172
@ AMDGPUSubArch1032
Definition Triple.h:245
@ AMDGPUSubArch1310
Definition Triple.h:277
@ AMDGPUSubArch908
Definition Triple.h:229
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:1494
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:2440
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:681
bool isOSFreeBSD() const
Definition Triple.h:748
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1724
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1688
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1716
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:520
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1191
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:723
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:645
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:584
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1134
LLVM_ABI FloatABI::ABIType getDefaultFloatABI() const
Returns the default floating-point ABI for this target triple, i.e.
Definition Triple.cpp:2531
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:907
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1211
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1421
bool isMacCatalystEnvironment() const
Definition Triple.h:734
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1095
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:1835
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2073
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1548
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:1457
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:1831
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2274
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:866
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:791
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:526
LLVM_ABI unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2264
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:1680
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1684
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1121
bool isWindowsItaniumEnvironment() const
Definition Triple.h:806
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:67
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:141
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
ExceptionHandling
Definition CodeGen.h:54
@ SjLj
setjmp/longjmp based exceptions
Definition CodeGen.h:57
@ ZOS
z/OS MVS Exception Handling.
Definition CodeGen.h:62
@ None
No exception support.
Definition CodeGen.h:55
@ AIX
AIX Exception Handling.
Definition CodeGen.h:61
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:56
@ WinEH
Windows Exception Handling.
Definition CodeGen.h:59
@ Default
The result value is uniform if and only if all operands are uniform.
Definition Uniformity.h:20
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:880