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