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)
848 }
849
850 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
851
852 // For now, this is the small part. Early return.
853 if (ARMSubArch.empty())
854 return StringSwitch<Triple::SubArchType>(SubArchName)
859
860 // ARM sub arch.
861 switch (ARM::parseArch(ARMSubArch)) {
862 case ARM::ArchKind::ARMV4:
863 return Triple::NoSubArch;
864 case ARM::ArchKind::ARMV4T:
866 case ARM::ArchKind::ARMV5T:
868 case ARM::ArchKind::ARMV5TE:
869 case ARM::ArchKind::IWMMXT:
870 case ARM::ArchKind::IWMMXT2:
871 case ARM::ArchKind::XSCALE:
872 case ARM::ArchKind::ARMV5TEJ:
874 case ARM::ArchKind::ARMV6:
876 case ARM::ArchKind::ARMV6K:
877 case ARM::ArchKind::ARMV6KZ:
879 case ARM::ArchKind::ARMV6T2:
881 case ARM::ArchKind::ARMV6M:
883 case ARM::ArchKind::ARMV7A:
884 case ARM::ArchKind::ARMV7R:
886 case ARM::ArchKind::ARMV7VE:
888 case ARM::ArchKind::ARMV7K:
890 case ARM::ArchKind::ARMV7M:
892 case ARM::ArchKind::ARMV7S:
894 case ARM::ArchKind::ARMV7EM:
896 case ARM::ArchKind::ARMV8A:
898 case ARM::ArchKind::ARMV8_1A:
900 case ARM::ArchKind::ARMV8_2A:
902 case ARM::ArchKind::ARMV8_3A:
904 case ARM::ArchKind::ARMV8_4A:
906 case ARM::ArchKind::ARMV8_5A:
908 case ARM::ArchKind::ARMV8_6A:
910 case ARM::ArchKind::ARMV8_7A:
912 case ARM::ArchKind::ARMV8_8A:
914 case ARM::ArchKind::ARMV8_9A:
916 case ARM::ArchKind::ARMV9A:
918 case ARM::ArchKind::ARMV9_1A:
920 case ARM::ArchKind::ARMV9_2A:
922 case ARM::ArchKind::ARMV9_3A:
924 case ARM::ArchKind::ARMV9_4A:
926 case ARM::ArchKind::ARMV9_5A:
928 case ARM::ArchKind::ARMV9_6A:
930 case ARM::ArchKind::ARMV9_7A:
932 case ARM::ArchKind::ARMV8R:
934 case ARM::ArchKind::ARMV8MBaseline:
936 case ARM::ArchKind::ARMV8MMainline:
938 case ARM::ArchKind::ARMV8_1MMainline:
940 default:
941 return Triple::NoSubArch;
942 }
943}
944
946 switch (T.getArch()) {
948 case Triple::aarch64:
950 case Triple::arm:
951 case Triple::thumb:
952 case Triple::x86:
953 case Triple::x86_64:
954 switch (T.getOS()) {
955 case Triple::Win32:
956 case Triple::UEFI:
957 return Triple::COFF;
958 default:
959 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
960 }
962 case Triple::amdgpu:
963 case Triple::amdil64:
964 case Triple::amdil:
965 case Triple::arc:
966 case Triple::armeb:
967 case Triple::avr:
968 case Triple::bpfeb:
969 case Triple::bpfel:
970 case Triple::csky:
971 case Triple::hexagon:
972 case Triple::hsail64:
973 case Triple::hsail:
974 case Triple::kalimba:
975 case Triple::lanai:
978 case Triple::m68k:
979 case Triple::mips64:
980 case Triple::mips64el:
981 case Triple::mips:
982 case Triple::msp430:
983 case Triple::nvptx64:
984 case Triple::nvptx:
985 case Triple::ppc64le:
986 case Triple::ppcle:
987 case Triple::r600:
990 case Triple::riscv32:
991 case Triple::riscv64:
994 case Triple::shave:
995 case Triple::sparc:
996 case Triple::sparcel:
997 case Triple::sparcv9:
998 case Triple::spir64:
999 case Triple::spir:
1000 case Triple::tce:
1001 case Triple::tcele:
1002 case Triple::tcele64:
1003 case Triple::thumbeb:
1004 case Triple::ve:
1005 case Triple::xcore:
1006 case Triple::xtensa:
1007 return Triple::ELF;
1008
1009 case Triple::mipsel:
1010 if (T.isOSWindows())
1011 return Triple::COFF;
1012 return Triple::ELF;
1013
1014 case Triple::ppc64:
1015 case Triple::ppc:
1016 if (T.isOSAIX())
1017 return Triple::XCOFF;
1018 if (T.isOSDarwin())
1019 return Triple::MachO;
1020 return Triple::ELF;
1021
1022 case Triple::systemz:
1023 if (T.isOSzOS())
1024 return Triple::GOFF;
1025 return Triple::ELF;
1026
1027 case Triple::wasm32:
1028 case Triple::wasm64:
1029 return Triple::Wasm;
1030
1031 case Triple::spirv:
1032 case Triple::spirv32:
1033 case Triple::spirv64:
1034 return Triple::SPIRV;
1035
1036 case Triple::dxil:
1037 return Triple::DXContainer;
1038 }
1039 llvm_unreachable("unknown architecture");
1040}
1041
1042/// Construct a triple from the string representation provided.
1043///
1044/// This stores the string representation and parses the various pieces into
1045/// enum members.
1046Triple::Triple(std::string &&Str) : Data(std::move(Str)) {
1047 // Do minimal parsing by hand here.
1048 SmallVector<StringRef, 4> Components;
1049 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
1050 if (Components.size() > 0) {
1051 Arch = parseArch(Components[0]);
1052 SubArch = parseSubArch(Components[0]);
1053 if (Components.size() > 1) {
1054 Vendor = parseVendor(Components[1]);
1055 if (Components.size() > 2) {
1056 OS = parseOS(Components[2]);
1057 if (Components.size() > 3) {
1058 Environment = parseEnvironment(Components[3]);
1059 ObjectFormat = parseFormat(Components[3]);
1060 }
1061 }
1062 } else {
1063 Environment =
1065 .StartsWith("mipsn32", Triple::GNUABIN32)
1066 .StartsWith("mips64", Triple::GNUABI64)
1067 .StartsWith("mipsisa64", Triple::GNUABI64)
1068 .StartsWith("mipsisa32", Triple::GNU)
1069 .Cases({"mips", "mipsel", "mipsr6", "mipsr6el"}, Triple::GNU)
1071 }
1072 }
1073 if (ObjectFormat == UnknownObjectFormat)
1074 ObjectFormat = getDefaultFormat(*this);
1075}
1076
1077Triple::Triple(const Twine &Str) : Triple(Str.str()) {}
1078
1079/// Construct a triple from string representations of the architecture,
1080/// vendor, and OS.
1081///
1082/// This joins each argument into a canonical string representation and parses
1083/// them into enum members. It leaves the environment unknown and omits it from
1084/// the string representation.
1085Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1086 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1087 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1088 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1089 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1090 ObjectFormat = getDefaultFormat(*this);
1091}
1092
1093/// Construct a triple from string representations of the architecture,
1094/// vendor, OS, and environment.
1095///
1096/// This joins each argument into a canonical string representation and parses
1097/// them into enum members.
1098Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1099 const Twine &EnvironmentStr)
1100 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1101 EnvironmentStr)
1102 .str()),
1103 Arch(parseArch(ArchStr.str())), SubArch(parseSubArch(ArchStr.str())),
1104 Vendor(parseVendor(VendorStr.str())), OS(parseOS(OSStr.str())),
1105 Environment(parseEnvironment(EnvironmentStr.str())),
1106 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1107 if (ObjectFormat == Triple::UnknownObjectFormat)
1108 ObjectFormat = getDefaultFormat(*this);
1109}
1110
1112 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1113 Twine('-') + getOSTypeName(OS))
1114 .str()),
1115 Arch(A), SubArch(SA), Vendor(V), OS(OS),
1116 ObjectFormat(getDefaultFormat(*this)) {}
1117
1120 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1121 Twine('-') + getOSTypeName(OS) + Twine('-') +
1123 .str()),
1124 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1125 ObjectFormat(getDefaultFormat(*this)) {}
1126
1129 : Data((getArchName(A, SA) + Twine('-') + getVendorTypeName(V) +
1130 Twine('-') + getOSTypeName(OS) + Twine('-') +
1131 getEnvironmentTypeName(E) + Twine('-') +
1133 .str()),
1134 Arch(A), SubArch(SA), Vendor(V), OS(OS), Environment(E),
1135 ObjectFormat(OF) {}
1136
1138
1140 VersionTuple Ver =
1141 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1142 // Default DXIL minor version when Shader Model version is anything other
1143 // than 6.[0...9] or 6.x (which translates to latest current SM version)
1144 const unsigned SMMajor = 6;
1145 if (!Ver.empty()) {
1146 if (Ver.getMajor() == SMMajor) {
1147 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1148 switch (*SMMinor) {
1149 case 0:
1151 case 1:
1153 case 2:
1155 case 3:
1157 case 4:
1159 case 5:
1161 case 6:
1163 case 7:
1165 case 8:
1167 case 9:
1169 default:
1170 report_fatal_error("Unsupported Shader Model version", false);
1171 }
1172 }
1173 }
1174 } else {
1175 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1176 // shadermodel6.x is
1177 if (ShaderModelStr == "shadermodel6.x") {
1179 }
1180 }
1181 // DXIL version corresponding to Shader Model version other than 6.Minor
1182 // is 1.0
1184}
1185
1187 bool IsMinGW32 = false;
1188 bool IsCygwin = false;
1189
1190 // Parse into components.
1191 SmallVector<StringRef, 4> Components;
1192 Str.split(Components, '-');
1193
1194 // If the first component corresponds to a known architecture, preferentially
1195 // use it for the architecture. If the second component corresponds to a
1196 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1197 // component movement when a component parses as (eg) both a valid arch and a
1198 // valid os.
1199 ArchType Arch = UnknownArch;
1200 if (Components.size() > 0)
1201 Arch = parseArch(Components[0]);
1202 VendorType Vendor = UnknownVendor;
1203 if (Components.size() > 1)
1204 Vendor = parseVendor(Components[1]);
1205 OSType OS = UnknownOS;
1206 if (Components.size() > 2) {
1207 OS = parseOS(Components[2]);
1208 IsCygwin = Components[2].starts_with("cygwin") ||
1209 Components[2].starts_with("msys");
1210 IsMinGW32 = Components[2].starts_with("mingw");
1211 }
1212 EnvironmentType Environment = UnknownEnvironment;
1213 if (Components.size() > 3)
1214 Environment = parseEnvironment(Components[3]);
1216 if (Components.size() > 4)
1217 ObjectFormat = parseFormat(Components[4]);
1218
1219 // Note which components are already in their final position. These will not
1220 // be moved.
1221 bool Found[4];
1222 Found[0] = Arch != UnknownArch;
1223 Found[1] = Vendor != UnknownVendor;
1224 Found[2] = OS != UnknownOS;
1225 Found[3] = Environment != UnknownEnvironment;
1226
1227 // If they are not there already, permute the components into their canonical
1228 // positions by seeing if they parse as a valid architecture, and if so moving
1229 // the component to the architecture position etc.
1230 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1231 if (Found[Pos])
1232 continue; // Already in the canonical position.
1233
1234 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1235 // Do not reparse any components that already matched.
1236 if (Idx < std::size(Found) && Found[Idx])
1237 continue;
1238
1239 // Does this component parse as valid for the target position?
1240 bool Valid = false;
1241 StringRef Comp = Components[Idx];
1242 switch (Pos) {
1243 default:
1244 llvm_unreachable("unexpected component type!");
1245 case 0:
1246 Arch = parseArch(Comp);
1247 Valid = Arch != UnknownArch;
1248 break;
1249 case 1:
1250 Vendor = parseVendor(Comp);
1251 Valid = Vendor != UnknownVendor;
1252 break;
1253 case 2:
1254 OS = parseOS(Comp);
1255 IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
1256 IsMinGW32 = Comp.starts_with("mingw");
1257 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1258 break;
1259 case 3:
1260 Environment = parseEnvironment(Comp);
1261 Valid = Environment != UnknownEnvironment;
1262 if (!Valid) {
1263 ObjectFormat = parseFormat(Comp);
1264 Valid = ObjectFormat != UnknownObjectFormat;
1265 }
1266 break;
1267 }
1268 if (!Valid)
1269 continue; // Nope, try the next component.
1270
1271 // Move the component to the target position, pushing any non-fixed
1272 // components that are in the way to the right. This tends to give
1273 // good results in the common cases of a forgotten vendor component
1274 // or a wrongly positioned environment.
1275 if (Pos < Idx) {
1276 // Insert left, pushing the existing components to the right. For
1277 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1278 StringRef CurrentComponent(""); // The empty component.
1279 // Replace the component we are moving with an empty component.
1280 std::swap(CurrentComponent, Components[Idx]);
1281 // Insert the component being moved at Pos, displacing any existing
1282 // components to the right.
1283 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1284 // Skip over any fixed components.
1285 while (i < std::size(Found) && Found[i])
1286 ++i;
1287 // Place the component at the new position, getting the component
1288 // that was at this position - it will be moved right.
1289 std::swap(CurrentComponent, Components[i]);
1290 }
1291 } else if (Pos > Idx) {
1292 // Push right by inserting empty components until the component at Idx
1293 // reaches the target position Pos. For example, pc-a -> -pc-a when
1294 // moving pc to the second position.
1295 do {
1296 // Insert one empty component at Idx.
1297 StringRef CurrentComponent(""); // The empty component.
1298 for (unsigned i = Idx; i < Components.size();) {
1299 // Place the component at the new position, getting the component
1300 // that was at this position - it will be moved right.
1301 std::swap(CurrentComponent, Components[i]);
1302 // If it was placed on top of an empty component then we are done.
1303 if (CurrentComponent.empty())
1304 break;
1305 // Advance to the next component, skipping any fixed components.
1306 while (++i < std::size(Found) && Found[i])
1307 ;
1308 }
1309 // The last component was pushed off the end - append it.
1310 if (!CurrentComponent.empty())
1311 Components.push_back(CurrentComponent);
1312
1313 // Advance Idx to the component's new position.
1314 while (++Idx < std::size(Found) && Found[Idx])
1315 ;
1316 } while (Idx < Pos); // Add more until the final position is reached.
1317 }
1318 assert(Pos < Components.size() && Components[Pos] == Comp &&
1319 "Component moved wrong!");
1320 Found[Pos] = true;
1321 break;
1322 }
1323 }
1324
1325 // If "none" is in the middle component in a three-component triple, treat it
1326 // as the OS (Components[2]) instead of the vendor (Components[1]).
1327 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1328 Components[1] == "none" && Components[2].empty())
1329 std::swap(Components[1], Components[2]);
1330
1331 // Replace empty components with "unknown" value.
1332 for (StringRef &C : Components)
1333 if (C.empty())
1334 C = "unknown";
1335
1336 // Special case logic goes here. At this point Arch, Vendor and OS have the
1337 // correct values for the computed components.
1338 std::string NormalizedEnvironment;
1339 if (Environment == Triple::Android &&
1340 Components[3].starts_with("androideabi")) {
1341 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1342 if (AndroidVersion.empty()) {
1343 Components[3] = "android";
1344 } else {
1345 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1346 Components[3] = NormalizedEnvironment;
1347 }
1348 }
1349
1350 // SUSE uses "gnueabi" to mean "gnueabihf"
1351 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1352 Components[3] = "gnueabihf";
1353
1354 if (OS == Triple::Win32) {
1355 Components.resize(4);
1356 Components[2] = "windows";
1357 if (Environment == UnknownEnvironment) {
1358 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1359 Components[3] = "msvc";
1360 else
1361 Components[3] = getObjectFormatTypeName(ObjectFormat);
1362 }
1363 } else if (IsMinGW32) {
1364 Components.resize(4);
1365 Components[2] = "windows";
1366 Components[3] = "gnu";
1367 } else if (IsCygwin) {
1368 Components.resize(4);
1369 Components[2] = "windows";
1370 Components[3] = "cygnus";
1371 }
1372 if (IsMinGW32 || IsCygwin ||
1373 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1374 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1375 Components.resize(5);
1376 Components[4] = getObjectFormatTypeName(ObjectFormat);
1377 }
1378 }
1379
1380 // Normalize DXIL triple if it does not include DXIL version number.
1381 // Determine DXIL version number using the minor version number of Shader
1382 // Model version specified in target triple, if any. Prior to decoupling DXIL
1383 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1384 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1385 if (Components[0] == "dxil") {
1386 if (Components.size() > 4) {
1387 Components.resize(4);
1388 }
1389 // Add DXIL version only if shadermodel is specified in the triple
1390 if (OS == Triple::ShaderModel) {
1391 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1392 }
1393 }
1394
1395 // Currently the firmware OS is an Apple specific concept.
1396 if ((Components.size() > 2) && (Components[2] == "firmware") &&
1397 (Components[1] != "apple"))
1399 "the firmware target os is only supported for the apple vendor");
1400
1401 // Canonicalize the components if necessary.
1402 switch (Form) {
1403 case CanonicalForm::ANY:
1404 break;
1408 Components.resize(static_cast<unsigned>(Form), "unknown");
1409 break;
1410 }
1411 }
1412
1413 // Stick the corrected components back together to form the normalized string.
1414 return join(Components, "-");
1415}
1416
1418 return StringRef(Data).split('-').first; // Isolate first component
1419}
1420
1422 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1423 return Tmp.split('-').first; // Isolate second component
1424}
1425
1427 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1428 Tmp = Tmp.split('-').second; // Strip second component
1429 return Tmp.split('-').first; // Isolate third component
1430}
1431
1433 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1434 Tmp = Tmp.split('-').second; // Strip second component
1435 return Tmp.split('-').second; // Strip third component
1436}
1437
1439 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1440 return Tmp.split('-').second; // Strip second component
1441}
1442
1444 VersionTuple Version;
1445 Version.tryParse(Name);
1446 return Version.withoutBuild();
1447}
1448
1452
1454 StringRef EnvironmentName = getEnvironmentName();
1455
1456 // none is a valid environment type - it basically amounts to a freestanding
1457 // environment.
1458 if (EnvironmentName == "none")
1459 return "";
1460
1461 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1462 EnvironmentName.consume_front(EnvironmentTypeName);
1463
1464 if (EnvironmentName.contains("-")) {
1465 // -obj is the suffix
1467 StringRef ObjectFormatTypeName =
1469 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1470 EnvironmentName.consume_back(tmp);
1471 }
1472 }
1473 return EnvironmentName;
1474}
1475
1477 StringRef OSName = getOSName();
1478 // Assume that the OS portion of the triple starts with the canonical name.
1479 StringRef OSTypeName = getOSTypeName(getOS());
1480 if (OSName.starts_with(OSTypeName))
1481 OSName = OSName.substr(OSTypeName.size());
1482 else if (getOS() == MacOSX)
1483 OSName.consume_front("macos");
1484 else if (OSName.starts_with("visionos"))
1485 OSName.consume_front("visionos");
1486
1487 return parseVersionFromName(OSName);
1488}
1489
1492
1493 switch (getOS()) {
1494 default:
1495 llvm_unreachable("unexpected OS for Darwin triple");
1496 case Darwin:
1497 // Default to darwin8, i.e., MacOSX 10.4.
1498 if (Version.getMajor() == 0)
1499 Version = VersionTuple(8);
1500 // Darwin version numbers are skewed from OS X versions.
1501 if (Version.getMajor() < 4) {
1502 return false;
1503 }
1504 if (Version.getMajor() <= 19) {
1505 Version = VersionTuple(10, Version.getMajor() - 4);
1506 } else if (Version.getMajor() < 25) {
1507 // darwin20-24 corresponds to macOS 11-15.
1508 Version = VersionTuple(11 + Version.getMajor() - 20);
1509 } else if ((Version.getMajor() == 25) || (Version.getMajor() == 26)) {
1510 // darwin25-26 corresponds to macOS 26-27.
1511 Version = VersionTuple(Version.getMajor() + 1);
1512 } else {
1513 // Starting with darwin27, it naturally corresponds to the same macOS
1514 // version.
1515 }
1516 break;
1517 case MacOSX:
1518 // Default to 10.4.
1519 if (Version.getMajor() == 0) {
1520 Version = VersionTuple(10, 4);
1521 } else if (Version.getMajor() < 10) {
1522 return false;
1523 }
1524 break;
1525 case IOS:
1526 case TvOS:
1527 case WatchOS:
1528 // Ignore the version from the triple. This is only handled because the
1529 // the clang driver combines OS X and IOS support into a common Darwin
1530 // toolchain that wants to know the OS X version number even when targeting
1531 // IOS.
1532 Version = VersionTuple(10, 4);
1533 break;
1534 case XROS:
1535 llvm_unreachable("OSX version isn't relevant for xrOS");
1536 case DriverKit:
1537 llvm_unreachable("OSX version isn't relevant for DriverKit");
1538 case Firmware:
1539 llvm_unreachable("OSX version isn't relevant for Firmware");
1540 }
1541 return true;
1542}
1543
1545 switch (getOS()) {
1546 default:
1547 llvm_unreachable("unexpected OS for Darwin triple");
1548 case Darwin:
1549 case MacOSX:
1550 // Ignore the version from the triple. This is only handled because the
1551 // the clang driver combines OS X and IOS support into a common Darwin
1552 // toolchain that wants to know the iOS version number even when targeting
1553 // OS X.
1554 return VersionTuple(5);
1555 case IOS:
1556 case TvOS: {
1558 // Default to 5.0 (or 7.0 for arm64).
1559 if (Version.getMajor() == 0)
1560 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1561 if (Version.getMajor() == 19)
1562 // tvOS 19 corresponds to ios26.
1563 return VersionTuple(26);
1566 }
1567 case XROS: {
1569 // xrOS 1 is aligned with iOS 17.
1570 if (Version.getMajor() < 3)
1571 return Version.withMajorReplaced(Version.getMajor() + 16);
1572 // visionOS 3 corresponds to ios 26+.
1573 if (Version.getMajor() == 3)
1574 return VersionTuple(26);
1577 }
1578 case WatchOS: {
1580 // watchOS 12 corresponds to ios 26.
1581 if (Version.getMajor() == 12)
1582 return VersionTuple(26);
1586 }
1587 case BridgeOS:
1588 llvm_unreachable("conflicting triple info");
1589 case DriverKit:
1590 llvm_unreachable("DriverKit doesn't have an iOS version");
1591 case Firmware:
1592 llvm_unreachable("iOS version isn't relevant for Firmware");
1593 }
1594}
1595
1597 switch (getOS()) {
1598 default:
1599 llvm_unreachable("unexpected OS for Darwin triple");
1600 case Darwin:
1601 case MacOSX:
1602 // Ignore the version from the triple. This is only handled because the
1603 // the clang driver combines OS X and IOS support into a common Darwin
1604 // toolchain that wants to know the iOS version number even when targeting
1605 // OS X.
1606 return VersionTuple(2);
1607 case WatchOS: {
1609 if (Version.getMajor() == 0)
1610 return VersionTuple(2);
1611 return Version;
1612 }
1613 case IOS:
1614 llvm_unreachable("conflicting triple info");
1615 case XROS:
1616 llvm_unreachable("watchOS version isn't relevant for xrOS");
1617 case DriverKit:
1618 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1619 case Firmware:
1620 llvm_unreachable("watchOS version isn't relevant for Firmware");
1621 }
1622}
1623
1625 switch (getOS()) {
1626 default:
1627 llvm_unreachable("unexpected OS for Darwin triple");
1628 case DriverKit:
1630 if (Version.getMajor() == 0)
1631 return Version.withMajorReplaced(19);
1632 return Version;
1633 }
1634}
1635
1637 if (getArch() != spirv || getOS() != Vulkan)
1638 llvm_unreachable("invalid Vulkan SPIR-V triple");
1639
1640 VersionTuple VulkanVersion = getOSVersion();
1641 SubArchType SpirvVersion = getSubArch();
1642
1644 // Vulkan 1.2 -> SPIR-V 1.5.
1646 // Vulkan 1.3 -> SPIR-V 1.6.
1648
1649 // If Vulkan version is unset, default to 1.2.
1650 if (VulkanVersion == VersionTuple(0))
1651 VulkanVersion = VersionTuple(1, 2);
1652
1653 if (ValidVersionMap.contains(VulkanVersion) &&
1654 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1655 SpirvVersion == NoSubArch))
1656 return VulkanVersion;
1657
1658 return VersionTuple(0);
1659}
1660
1662 if (getArch() != dxil || getOS() != ShaderModel)
1663 llvm_unreachable("invalid DXIL triple");
1664 StringRef Arch = getArchName();
1665 if (getSubArch() == NoSubArch)
1667 Arch.consume_front("dxilv");
1668 VersionTuple DXILVersion = parseVersionFromName(Arch);
1669 // FIXME: validate DXIL version against Shader Model version.
1670 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1671 return DXILVersion;
1672}
1673
1674void Triple::setTriple(const Twine &Str) { *this = Triple(Str); }
1675
1677 setArchName(getArchName(Kind, SubArch));
1678}
1679
1683
1685
1687 if (ObjectFormat == getDefaultFormat(*this))
1689
1691 getObjectFormatTypeName(ObjectFormat))
1692 .str());
1693}
1694
1696 if (Environment == UnknownEnvironment)
1698
1699 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1701 .str());
1702}
1703
1705 setTriple(Str + "-" + getVendorName() + "-" + getOSAndEnvironmentName());
1706}
1707
1709 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1710}
1711
1713 if (hasEnvironment())
1714 setTriple(getArchName() + "-" + getVendorName() + "-" + Str + "-" +
1716 else
1717 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1718}
1719
1721 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() + "-" +
1722 Str);
1723}
1724
1726 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1727}
1728
1730 switch (Arch) {
1732 return 0;
1733
1734 case llvm::Triple::avr:
1736 return 16;
1737
1740 case llvm::Triple::arc:
1741 case llvm::Triple::arm:
1743 case llvm::Triple::csky:
1744 case llvm::Triple::dxil:
1750 case llvm::Triple::m68k:
1751 case llvm::Triple::mips:
1754 case llvm::Triple::ppc:
1756 case llvm::Triple::r600:
1763 case llvm::Triple::spir:
1765 case llvm::Triple::tce:
1770 case llvm::Triple::x86:
1773 return 32;
1774
1797 case llvm::Triple::ve:
1800 return 64;
1801 }
1802 llvm_unreachable("Invalid architecture value");
1803}
1804
1806 switch (getArch()) {
1807 default:
1808 break;
1809 case Triple::ppc:
1810 case Triple::ppcle:
1811 if (isOSLinux())
1812 return 40;
1813 break;
1814 case Triple::ppc64:
1815 case Triple::ppc64le:
1816 if (isOSLinux())
1817 return 48;
1818 break;
1819 }
1820 return 32;
1821}
1822
1824 return getArchPointerBitWidth(getArch()) == 64;
1825}
1826
1828 return getArchPointerBitWidth(getArch()) == 32;
1829}
1830
1832 return getArchPointerBitWidth(getArch()) == 16;
1833}
1834
1836 Triple T(*this);
1837 switch (getArch()) {
1839 case Triple::amdgpu:
1840 case Triple::avr:
1841 case Triple::bpfeb:
1842 case Triple::bpfel:
1843 case Triple::msp430:
1844 case Triple::systemz:
1845 case Triple::ve:
1846 T.setArch(UnknownArch);
1847 break;
1848
1849 case Triple::aarch64_32:
1850 case Triple::amdil:
1851 case Triple::arc:
1852 case Triple::arm:
1853 case Triple::armeb:
1854 case Triple::csky:
1855 case Triple::dxil:
1856 case Triple::hexagon:
1857 case Triple::hsail:
1858 case Triple::kalimba:
1859 case Triple::lanai:
1861 case Triple::m68k:
1862 case Triple::mips:
1863 case Triple::mipsel:
1864 case Triple::nvptx:
1865 case Triple::ppc:
1866 case Triple::ppcle:
1867 case Triple::r600:
1869 case Triple::riscv32:
1870 case Triple::riscv32be:
1871 case Triple::shave:
1872 case Triple::sparc:
1873 case Triple::sparcel:
1874 case Triple::spir:
1875 case Triple::spirv32:
1876 case Triple::tce:
1877 case Triple::tcele:
1878 case Triple::thumb:
1879 case Triple::thumbeb:
1880 case Triple::wasm32:
1881 case Triple::x86:
1882 case Triple::xcore:
1883 case Triple::xtensa:
1884 // Already 32-bit.
1885 break;
1886
1887 case Triple::aarch64:
1888 T.setArch(Triple::arm);
1889 break;
1890 case Triple::aarch64_be:
1891 T.setArch(Triple::armeb);
1892 break;
1893 case Triple::amdil64:
1894 T.setArch(Triple::amdil);
1895 break;
1896 case Triple::hsail64:
1897 T.setArch(Triple::hsail);
1898 break;
1900 T.setArch(Triple::loongarch32);
1901 break;
1902 case Triple::mips64:
1903 T.setArch(Triple::mips, getSubArch());
1904 break;
1905 case Triple::mips64el:
1906 T.setArch(Triple::mipsel, getSubArch());
1907 break;
1908 case Triple::nvptx64:
1909 T.setArch(Triple::nvptx);
1910 break;
1911 case Triple::ppc64:
1912 T.setArch(Triple::ppc);
1913 break;
1914 case Triple::ppc64le:
1915 T.setArch(Triple::ppcle);
1916 break;
1918 T.setArch(Triple::renderscript32);
1919 break;
1920 case Triple::riscv64:
1921 T.setArch(Triple::riscv32);
1922 break;
1923 case Triple::riscv64be:
1924 T.setArch(Triple::riscv32be);
1925 break;
1926 case Triple::sparcv9:
1927 T.setArch(Triple::sparc);
1928 break;
1929 case Triple::spir64:
1930 T.setArch(Triple::spir);
1931 break;
1932 case Triple::spirv:
1933 case Triple::spirv64:
1934 T.setArch(Triple::spirv32, getSubArch());
1935 break;
1936 case Triple::tcele64:
1937 T.setArch(Triple::tcele);
1938 break;
1939 case Triple::wasm64:
1940 T.setArch(Triple::wasm32);
1941 break;
1942 case Triple::x86_64:
1943 T.setArch(Triple::x86);
1944 break;
1945 }
1946 return T;
1947}
1948
1950 Triple T(*this);
1951 switch (getArch()) {
1953 case Triple::arc:
1954 case Triple::avr:
1955 case Triple::csky:
1956 case Triple::dxil:
1957 case Triple::hexagon:
1958 case Triple::kalimba:
1959 case Triple::lanai:
1960 case Triple::m68k:
1961 case Triple::msp430:
1962 case Triple::r600:
1963 case Triple::shave:
1964 case Triple::sparcel:
1965 case Triple::tce:
1966 case Triple::xcore:
1967 case Triple::xtensa:
1968 T.setArch(UnknownArch);
1969 break;
1970
1971 case Triple::aarch64:
1972 case Triple::aarch64_be:
1973 case Triple::amdgpu:
1974 case Triple::amdil64:
1975 case Triple::bpfeb:
1976 case Triple::bpfel:
1977 case Triple::hsail64:
1979 case Triple::mips64:
1980 case Triple::mips64el:
1981 case Triple::nvptx64:
1982 case Triple::ppc64:
1983 case Triple::ppc64le:
1985 case Triple::riscv64:
1986 case Triple::riscv64be:
1987 case Triple::sparcv9:
1988 case Triple::spir64:
1989 case Triple::spirv64:
1990 case Triple::systemz:
1991 case Triple::tcele64:
1992 case Triple::ve:
1993 case Triple::wasm64:
1994 case Triple::x86_64:
1995 // Already 64-bit.
1996 break;
1997
1998 case Triple::aarch64_32:
1999 T.setArch(Triple::aarch64);
2000 break;
2001 case Triple::amdil:
2002 T.setArch(Triple::amdil64);
2003 break;
2004 case Triple::arm:
2005 T.setArch(Triple::aarch64);
2006 break;
2007 case Triple::armeb:
2008 T.setArch(Triple::aarch64_be);
2009 break;
2010 case Triple::hsail:
2011 T.setArch(Triple::hsail64);
2012 break;
2014 T.setArch(Triple::loongarch64);
2015 break;
2016 case Triple::mips:
2017 T.setArch(Triple::mips64, getSubArch());
2018 break;
2019 case Triple::mipsel:
2020 T.setArch(Triple::mips64el, getSubArch());
2021 break;
2022 case Triple::nvptx:
2023 T.setArch(Triple::nvptx64);
2024 break;
2025 case Triple::ppc:
2026 T.setArch(Triple::ppc64);
2027 break;
2028 case Triple::ppcle:
2029 T.setArch(Triple::ppc64le);
2030 break;
2032 T.setArch(Triple::renderscript64);
2033 break;
2034 case Triple::riscv32:
2035 T.setArch(Triple::riscv64);
2036 break;
2037 case Triple::riscv32be:
2038 T.setArch(Triple::riscv64be);
2039 break;
2040 case Triple::sparc:
2041 T.setArch(Triple::sparcv9);
2042 break;
2043 case Triple::spir:
2044 T.setArch(Triple::spir64);
2045 break;
2046 case Triple::spirv:
2047 case Triple::spirv32:
2048 T.setArch(Triple::spirv64, getSubArch());
2049 break;
2050 case Triple::tcele:
2051 T.setArch(Triple::tcele64);
2052 break;
2053 case Triple::thumb:
2054 T.setArch(Triple::aarch64);
2055 break;
2056 case Triple::thumbeb:
2057 T.setArch(Triple::aarch64_be);
2058 break;
2059 case Triple::wasm32:
2060 T.setArch(Triple::wasm64);
2061 break;
2062 case Triple::x86:
2063 T.setArch(Triple::x86_64);
2064 break;
2065 }
2066 return T;
2067}
2068
2070 Triple T(*this);
2071 // Already big endian.
2072 if (!isLittleEndian())
2073 return T;
2074 switch (getArch()) {
2076 case Triple::amdgpu:
2077 case Triple::amdil64:
2078 case Triple::amdil:
2079 case Triple::avr:
2080 case Triple::dxil:
2081 case Triple::hexagon:
2082 case Triple::hsail64:
2083 case Triple::hsail:
2084 case Triple::kalimba:
2087 case Triple::msp430:
2088 case Triple::nvptx64:
2089 case Triple::nvptx:
2090 case Triple::r600:
2093 case Triple::shave:
2094 case Triple::spir64:
2095 case Triple::spir:
2096 case Triple::spirv:
2097 case Triple::spirv32:
2098 case Triple::spirv64:
2099 case Triple::tcele64:
2100 case Triple::wasm32:
2101 case Triple::wasm64:
2102 case Triple::x86:
2103 case Triple::x86_64:
2104 case Triple::xcore:
2105 case Triple::ve:
2106 case Triple::csky:
2107 case Triple::xtensa:
2108
2109 // ARM is intentionally unsupported here, changing the architecture would
2110 // drop any arch suffixes.
2111 case Triple::arm:
2112 case Triple::thumb:
2113 T.setArch(UnknownArch);
2114 break;
2115
2116 case Triple::aarch64:
2117 T.setArch(Triple::aarch64_be);
2118 break;
2119 case Triple::bpfel:
2120 T.setArch(Triple::bpfeb);
2121 break;
2122 case Triple::mips64el:
2123 T.setArch(Triple::mips64, getSubArch());
2124 break;
2125 case Triple::mipsel:
2126 T.setArch(Triple::mips, getSubArch());
2127 break;
2128 case Triple::ppcle:
2129 T.setArch(Triple::ppc);
2130 break;
2131 case Triple::ppc64le:
2132 T.setArch(Triple::ppc64);
2133 break;
2134 case Triple::riscv32:
2135 T.setArch(Triple::riscv32be);
2136 break;
2137 case Triple::riscv64:
2138 T.setArch(Triple::riscv64be);
2139 break;
2140 case Triple::sparcel:
2141 T.setArch(Triple::sparc);
2142 break;
2143 case Triple::tcele:
2144 T.setArch(Triple::tce);
2145 break;
2146 default:
2147 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
2148 }
2149 return T;
2150}
2151
2153 Triple T(*this);
2154 if (isLittleEndian())
2155 return T;
2156
2157 switch (getArch()) {
2159 case Triple::lanai:
2160 case Triple::sparcv9:
2161 case Triple::systemz:
2162 case Triple::m68k:
2163
2164 // ARM is intentionally unsupported here, changing the architecture would
2165 // drop any arch suffixes.
2166 case Triple::armeb:
2167 case Triple::thumbeb:
2168 T.setArch(UnknownArch);
2169 break;
2170
2171 case Triple::aarch64_be:
2172 T.setArch(Triple::aarch64);
2173 break;
2174 case Triple::bpfeb:
2175 T.setArch(Triple::bpfel);
2176 break;
2177 case Triple::mips64:
2178 T.setArch(Triple::mips64el, getSubArch());
2179 break;
2180 case Triple::mips:
2181 T.setArch(Triple::mipsel, getSubArch());
2182 break;
2183 case Triple::ppc:
2184 T.setArch(Triple::ppcle);
2185 break;
2186 case Triple::ppc64:
2187 T.setArch(Triple::ppc64le);
2188 break;
2189 case Triple::riscv32be:
2190 T.setArch(Triple::riscv32);
2191 break;
2192 case Triple::riscv64be:
2193 T.setArch(Triple::riscv64);
2194 break;
2195 case Triple::sparc:
2196 T.setArch(Triple::sparcel);
2197 break;
2198 case Triple::tce:
2199 T.setArch(Triple::tcele);
2200 break;
2201 default:
2202 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
2203 }
2204 return T;
2205}
2206
2208 switch (getArch()) {
2209 case Triple::aarch64:
2210 case Triple::aarch64_32:
2211 case Triple::amdgpu:
2212 case Triple::amdil64:
2213 case Triple::amdil:
2214 case Triple::arm:
2215 case Triple::avr:
2216 case Triple::bpfel:
2217 case Triple::csky:
2218 case Triple::dxil:
2219 case Triple::hexagon:
2220 case Triple::hsail64:
2221 case Triple::hsail:
2222 case Triple::kalimba:
2225 case Triple::mips64el:
2226 case Triple::mipsel:
2227 case Triple::msp430:
2228 case Triple::nvptx64:
2229 case Triple::nvptx:
2230 case Triple::ppcle:
2231 case Triple::ppc64le:
2232 case Triple::r600:
2235 case Triple::riscv32:
2236 case Triple::riscv64:
2237 case Triple::shave:
2238 case Triple::sparcel:
2239 case Triple::spir64:
2240 case Triple::spir:
2241 case Triple::spirv:
2242 case Triple::spirv32:
2243 case Triple::spirv64:
2244 case Triple::tcele:
2245 case Triple::tcele64:
2246 case Triple::thumb:
2247 case Triple::ve:
2248 case Triple::wasm32:
2249 case Triple::wasm64:
2250 case Triple::x86:
2251 case Triple::x86_64:
2252 case Triple::xcore:
2253 case Triple::xtensa:
2254 return true;
2255 default:
2256 return false;
2257 }
2258}
2259
2261 if (getArch() == Triple::xcore)
2262 return 1;
2263 if (isOSWindowsOrUEFI() || isPS())
2264 return 2;
2265 if (isOSAIX() && isArch32Bit())
2266 return 2;
2267 return 4;
2268}
2269
2271 // On MinGW, C code is usually built with a "w64" vendor, while Rust
2272 // often uses a "pc" vendor.
2273 bool IgnoreVendor = isWindowsGNUEnvironment();
2274
2275 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
2276 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2277 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2278 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2279 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2280 if (getVendor() == Triple::Apple)
2281 return getSubArch() == Other.getSubArch() &&
2282 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2283 else
2284 return getSubArch() == Other.getSubArch() &&
2285 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2286 getOS() == Other.getOS() &&
2287 getEnvironment() == Other.getEnvironment() &&
2288 getObjectFormat() == Other.getObjectFormat();
2289 }
2290
2291 if (getArch() == Triple::amdgpu && Other.getArch() == Triple::amdgpu) {
2292 if (getOS() != Other.getOS() || getVendor() != Other.getVendor() ||
2293 getEnvironment() != Other.getEnvironment() ||
2294 getObjectFormat() != Other.getObjectFormat())
2295 return false;
2296 return AMDGPU::isSubArchCompatible(*this, Other);
2297 }
2298
2299 // If vendor is apple, ignore the version number (the environment field)
2300 // and the object format.
2301 if (getVendor() == Triple::Apple)
2302 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2303 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2304 getOS() == Other.getOS();
2305
2306 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2307 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2308 getOS() == Other.getOS() &&
2309 getEnvironment() == Other.getEnvironment() &&
2310 getObjectFormat() == Other.getObjectFormat();
2311}
2312
2313std::string Triple::merge(const Triple &Other) const {
2314 // If vendor is apple, pick the triple with the larger version number.
2315 if (getVendor() == Triple::Apple && Other.isOSVersionLT(*this))
2316 return str();
2317
2318 if (isAMDGCN() && Other.isAMDGCN() && getOS() == Other.getOS() &&
2319 getVendor() == Other.getVendor())
2320 return AMDGPU::mergeSubArch(*this, Other);
2321
2322 return Other.str();
2323}
2324
2325bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2326 unsigned Micro) const {
2327 assert(isMacOSX() && "Not an OS X triple!");
2328
2329 // If this is OS X, expect a sane version number.
2330 if (getOS() == Triple::MacOSX)
2331 return isOSVersionLT(Major, Minor, Micro);
2332
2333 // Otherwise, compare to the "Darwin" number.
2334 if (Major == 10)
2335 return isOSVersionLT(Minor + 4, Micro, 0);
2336 assert(Major >= 11 && "Unexpected major version");
2337 if (Major < 25)
2338 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2339 return isOSVersionLT(Major + 1, Minor, Micro);
2340}
2341
2344 return VersionTuple();
2345 switch (getOS()) {
2346 case Triple::MacOSX:
2347 // ARM64 slice is supported starting from macOS 11.0+.
2348 return VersionTuple(11, 0, 0);
2349 case Triple::IOS:
2350 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2351 // ARM64 simulators are supported for iOS 14+.
2353 return VersionTuple(14, 0, 0);
2354 // ARM64e slice is supported starting from iOS 14.
2355 if (isArm64e())
2356 return VersionTuple(14, 0, 0);
2357 break;
2358 case Triple::TvOS:
2359 // ARM64 simulators are supported for tvOS 14+.
2361 return VersionTuple(14, 0, 0);
2362 break;
2363 case Triple::WatchOS:
2364 // ARM64 simulators are supported for watchOS 7+.
2366 return VersionTuple(7, 0, 0);
2367 // ARM64/ARM64e slices are supported starting from watchOS 26.
2368 // ARM64_32 is older though.
2370 return VersionTuple(26, 0, 0);
2371 case Triple::DriverKit:
2372 return VersionTuple(20, 0, 0);
2373 default:
2374 break;
2375 }
2376 return VersionTuple();
2377}
2378
2380 const VersionTuple &Version,
2381 bool IsInValidRange) {
2382 const unsigned MacOSRangeBump = 10;
2383 const unsigned IOSRangeBump = 7;
2384 const unsigned XROSRangeBump = 23;
2385 const unsigned WatchOSRangeBump = 14;
2386 switch (OSKind) {
2387 case MacOSX: {
2388 // macOS 10.16 is canonicalized to macOS 11.
2389 if (Version == VersionTuple(10, 16))
2390 return VersionTuple(11, 0);
2391 // macOS 16 is canonicalized to macOS 26.
2392 if (Version == VersionTuple(16, 0))
2393 return VersionTuple(26, 0);
2394 if (!IsInValidRange)
2395 return Version.withMajorReplaced(Version.getMajor() + MacOSRangeBump);
2396 break;
2397 }
2398 case IOS:
2399 case TvOS: {
2400 // Both iOS & tvOS 19.0 canonicalize to 26.
2401 if (Version == VersionTuple(19, 0))
2402 return VersionTuple(26, 0);
2403 if (!IsInValidRange)
2404 return Version.withMajorReplaced(Version.getMajor() + IOSRangeBump);
2405 break;
2406 }
2407 case XROS: {
2408 // visionOS3 is canonicalized to 26.
2409 if (Version == VersionTuple(3, 0))
2410 return VersionTuple(26, 0);
2411 if (!IsInValidRange)
2412 return Version.withMajorReplaced(Version.getMajor() + XROSRangeBump);
2413 break;
2414 }
2415 case WatchOS: {
2416 // watchOS 12 is canonicalized to 26.
2417 if (Version == VersionTuple(12, 0))
2418 return VersionTuple(26, 0);
2419 if (!IsInValidRange)
2420 return Version.withMajorReplaced(Version.getMajor() + WatchOSRangeBump);
2421 break;
2422 }
2423 case DriverKit: {
2424 // DriverKit26 is canonicalized to 27.
2425 if (Version.getMajor() == 26U)
2426 return Version.withMajorReplaced(27);
2427 break;
2428 }
2429 default:
2430 return Version;
2431 }
2432
2433 return Version;
2434}
2435
2437 /// This constant is used to capture gaps in versioning.
2438 const VersionTuple CommonVersion(26);
2439 auto IsValid = [&](const VersionTuple &StartingVersion) {
2440 return !((Version > StartingVersion) && (Version < CommonVersion));
2441 };
2442 switch (OSKind) {
2443 case WatchOS: {
2444 const VersionTuple StartingWatchOS(12);
2445 return IsValid(StartingWatchOS);
2446 }
2447 case IOS:
2448 case TvOS: {
2449 const VersionTuple StartingIOS(19);
2450 return IsValid(StartingIOS);
2451 }
2452 case MacOSX: {
2453 const VersionTuple StartingMacOS(16);
2454 return IsValid(StartingMacOS);
2455 }
2456 case XROS: {
2457 const VersionTuple StartingXROS(3);
2458 return IsValid(StartingXROS);
2459 }
2460 default:
2461 return true;
2462 }
2463
2464 llvm_unreachable("unexpected or invalid os version");
2465}
2466
2468 if (isOSBinFormatCOFF()) {
2469 if (getArch() == Triple::x86 &&
2473 }
2474
2475 if (isOSBinFormatXCOFF())
2477 if (isOSBinFormatGOFF())
2479
2480 if (isARM() || isThumb()) {
2481 if (isOSBinFormatELF()) {
2484 }
2485
2488 }
2489
2490 if (isAArch64() || isX86() || isPPC() || isMIPS() || isSPARC() || isBPF() ||
2491 isRISCV() || isLoongArch())
2493
2494 switch (getArch()) {
2495 case Triple::arc:
2496 case Triple::csky:
2497 case Triple::hexagon:
2498 case Triple::lanai:
2499 case Triple::m68k:
2500 case Triple::msp430:
2501 case Triple::systemz:
2502 case Triple::xcore:
2503 case Triple::xtensa:
2505 default:
2506 break;
2507 }
2508
2509 // Explicitly none targets.
2510 if (isWasm() || isAMDGPU() || isNVPTX() || isSPIROrSPIRV())
2512
2513 // Default to none.
2515}
2516
2518 Triple::EnvironmentType Env = T.getEnvironment();
2519 bool IsHard =
2520 Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
2521 Env == Triple::MuslEABIHF || Env == Triple::EABIHF ||
2522 (T.isOSBinFormatMachO() && T.getSubArch() == Triple::ARMSubArch_v7em) ||
2523 T.isOSWindows() || ARM::computeTargetABI(T, "") == ARM::ARM_ABI_AAPCS16;
2524 return IsHard ? FloatABI::Hard : FloatABI::Soft;
2525}
2526
2528 if (isARM() || isThumb())
2529 return getARMDefaultFloatABI(*this);
2530
2531 // MIPS defaults to hard float, except on FreeBSD which uses soft float.
2532 if (isMIPS())
2534
2535 if (isCSKY() || isAVR() || getArch() == msp430)
2536 return FloatABI::Soft;
2537
2538 // Most targets use hard float unless soft float is explicitly requested.
2539 return FloatABI::Hard;
2540}
2541
2543 switch (getArch()) {
2544 case loongarch64:
2545 case riscv32:
2546 case riscv64:
2547 case riscv32be:
2548 case riscv64be:
2549 case sparc:
2550 case sparcel:
2551 case sparcv9:
2552 case systemz:
2553 case ve:
2554 case wasm32:
2555 case wasm64:
2557 case ppc:
2558 case ppcle:
2559 case ppc64:
2560 case ppc64le:
2561 // PowerPC uses IBM double-double, except on a handful of OSes that use
2562 // plain IEEE double. NetBSD only switches to IEEE double on 32-bit PowerPC.
2563 if (isOSAIX() || isOSFreeBSD() || isOSOpenBSD() || isMusl() ||
2564 (isOSNetBSD() && isPPC32()))
2567 case x86:
2568 case x86_64:
2569 // Android and OHOS use IEEE double on 32-bit and IEEE quad on 64-bit.
2570 if (isAndroid() || isOHOSFamily())
2573 // Windows-MSVC and UEFI use IEEE double. MinGW and Cygwin keep x87.
2577 case aarch64:
2578 case aarch64_be:
2579 case aarch64_32:
2580 // AArch64 uses IEEE quad, except on Windows and Darwin.
2581 if (isOSWindows() || isOSDarwin())
2584 case mips64:
2585 case mips64el:
2587 case avr:
2588 case tce:
2589 case tcele:
2590 // AVR and 32-bit OpenASIP use IEEE single precision.
2592 case tcele64:
2593 // 64-bit OpenASIP uses IEEE double, unlike its 32-bit variants.
2595 default:
2597 }
2598}
2599
2600// HLSL triple environment orders are relied on in the front end
2601static_assert(Triple::Vertex - Triple::Pixel == 1,
2602 "incorrect HLSL stage order");
2603static_assert(Triple::Geometry - Triple::Pixel == 2,
2604 "incorrect HLSL stage order");
2605static_assert(Triple::Hull - Triple::Pixel == 3, "incorrect HLSL stage order");
2606static_assert(Triple::Domain - Triple::Pixel == 4,
2607 "incorrect HLSL stage order");
2608static_assert(Triple::Compute - Triple::Pixel == 5,
2609 "incorrect HLSL stage order");
2610static_assert(Triple::Library - Triple::Pixel == 6,
2611 "incorrect HLSL stage order");
2612static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2613 "incorrect HLSL stage order");
2614static_assert(Triple::Intersection - Triple::Pixel == 8,
2615 "incorrect HLSL stage order");
2616static_assert(Triple::AnyHit - Triple::Pixel == 9,
2617 "incorrect HLSL stage order");
2618static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2619 "incorrect HLSL stage order");
2620static_assert(Triple::Miss - Triple::Pixel == 11, "incorrect HLSL stage order");
2621static_assert(Triple::Callable - Triple::Pixel == 12,
2622 "incorrect HLSL stage order");
2623static_assert(Triple::Mesh - Triple::Pixel == 13, "incorrect HLSL stage order");
2624static_assert(Triple::Amplification - Triple::Pixel == 14,
2625 "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:1443
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition Triple.cpp:945
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:1139
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition Triple.cpp:441
static FloatABI::ABIType getARMDefaultFloatABI(const Triple &T)
Definition Triple.cpp:2517
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:2325
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1476
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition Triple.h:1136
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition Triple.cpp:1421
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1596
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition Triple.cpp:1704
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition Triple.cpp:1695
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition Triple.cpp:1835
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition Triple.h:818
bool isWatchABI() const
Definition Triple.h:697
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition Triple.h:403
@ UnknownEnvironment
Definition Triple.h:355
@ Amplification
Definition Triple.h:410
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition Triple.h:996
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1204
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:2379
CanonicalForm
Canonical form.
Definition Triple.h:488
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:616
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition Triple.cpp:2152
bool isBPF() const
Tests whether the target is eBPF.
Definition Triple.h:1236
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:537
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition Triple.h:516
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition Triple.h:1196
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition Triple.h:1218
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition Triple.h:871
bool isWindowsGNUEnvironment() const
Definition Triple.h:813
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition Triple.cpp:1708
bool isOSNetBSD() const
Definition Triple.h:743
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition Triple.cpp:1725
bool isAndroid() const
Tests whether the target is Android.
Definition Triple.h:909
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition Triple.cpp:1949
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition Triple.cpp:2207
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition Triple.cpp:1686
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition Triple.cpp:1426
bool isAVR() const
Definition Triple.h:1111
bool isSPIROrSPIRV() const
Definition Triple.h:980
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition Triple.cpp:2467
@ 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:1674
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:522
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition Triple.cpp:1449
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:1186
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:1142
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:513
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:1805
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:868
bool isCSKY() const
Definition Triple.h:1215
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition Triple.cpp:1432
bool isSimulatorEnvironment() const
Definition Triple.h:729
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition Triple.cpp:1661
const std::string & str() const
Definition Triple.h:578
bool isOHOSFamily() const
Tests whether the target is OHOS LiteOS default enviroment is also OHOS, but omited on triple.
Definition Triple.h:939
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition Triple.h:528
bool isOSOpenBSD() const
Definition Triple.h:745
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition Triple.cpp:1636
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1624
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:773
bool isOSWindows() const
Tests whether the OS is Windows.
Definition Triple.h:776
bool isMusl() const
Tests whether the environment is musl-libc.
Definition Triple.h:924
LLVM_ABI LongDoubleFormat getDefaultLongDoubleFormat() const
Returns the default floating-point format for the "long double" type.
Definition Triple.cpp:2542
bool isOSWindowsOrUEFI() const
Tests whether the OS is Windows or UEFI.
Definition Triple.h:782
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:880
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition Triple.cpp:391
@ UnknownObjectFormat
Definition Triple.h:420
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition Triple.h:1001
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition Triple.cpp:2313
bool isOSLinux() const
Tests whether the OS is Linux.
Definition Triple.h:829
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:1179
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Definition Triple.h:991
bool isAMDGPU() const
Definition Triple.h:993
@ UnknownVendor
Definition Triple.h:281
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:986
bool isOSAIX() const
Tests whether the OS is AIX.
Definition Triple.h:854
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition Triple.cpp:2342
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1823
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition Triple.cpp:1438
@ 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
@ AMDGPUSubArch1250S
Definition Triple.h:271
@ 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:273
@ 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:272
@ 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:275
@ 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:276
@ 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:1490
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:2436
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:680
bool isOSFreeBSD() const
Definition Triple.h:747
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition Triple.cpp:1720
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition Triple.cpp:1684
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition Triple.cpp:1712
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:519
bool isSPARC() const
Tests whether the target is SPARC.
Definition Triple.h:1190
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:722
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:644
bool empty() const
Whether the triple is empty / default constructed.
Definition Triple.h:583
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition Triple.h:1133
LLVM_ABI FloatABI::ABIType getDefaultFloatABI() const
Returns the default floating-point ABI for this target triple, i.e.
Definition Triple.cpp:2527
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
Definition Triple.h:906
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition Triple.h:1210
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1417
bool isMacCatalystEnvironment() const
Definition Triple.h:733
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition Triple.h:1094
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:1831
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition Triple.cpp:2069
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition Triple.cpp:1544
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:1453
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition Triple.cpp:1827
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition Triple.cpp:2270
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:865
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition Triple.h:790
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition Triple.h:525
LLVM_ABI unsigned getDefaultWCharSize() const
Returns the default wchar_t size (in bytes) for this target triple.
Definition Triple.cpp:2260
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:1676
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition Triple.cpp:1680
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition Triple.h:1120
bool isWindowsItaniumEnvironment() const
Definition Triple.h:805
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.
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