LLVM 22.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"
20#include <cassert>
21#include <cstring>
22using namespace llvm;
23
25 switch (Kind) {
26 case UnknownArch: return "unknown";
27
28 case aarch64: return "aarch64";
29 case aarch64_32: return "aarch64_32";
30 case aarch64_be: return "aarch64_be";
31 case amdgcn: return "amdgcn";
32 case amdil64: return "amdil64";
33 case amdil: return "amdil";
34 case arc: return "arc";
35 case arm: return "arm";
36 case armeb: return "armeb";
37 case avr: return "avr";
38 case bpfeb: return "bpfeb";
39 case bpfel: return "bpfel";
40 case csky: return "csky";
41 case dxil: return "dxil";
42 case hexagon: return "hexagon";
43 case hsail64: return "hsail64";
44 case hsail: return "hsail";
45 case kalimba: return "kalimba";
46 case lanai: return "lanai";
47 case loongarch32: return "loongarch32";
48 case loongarch64: return "loongarch64";
49 case m68k: return "m68k";
50 case mips64: return "mips64";
51 case mips64el: return "mips64el";
52 case mips: return "mips";
53 case mipsel: return "mipsel";
54 case msp430: return "msp430";
55 case nvptx64: return "nvptx64";
56 case nvptx: return "nvptx";
57 case ppc64: return "powerpc64";
58 case ppc64le: return "powerpc64le";
59 case ppc: return "powerpc";
60 case ppcle: return "powerpcle";
61 case r600: return "r600";
62 case renderscript32: return "renderscript32";
63 case renderscript64: return "renderscript64";
64 case riscv32: return "riscv32";
65 case riscv64: return "riscv64";
66 case riscv32be:
67 return "riscv32be";
68 case riscv64be:
69 return "riscv64be";
70 case shave: return "shave";
71 case sparc: return "sparc";
72 case sparcel: return "sparcel";
73 case sparcv9: return "sparcv9";
74 case spir64: return "spir64";
75 case spir: return "spir";
76 case spirv: return "spirv";
77 case spirv32: return "spirv32";
78 case spirv64: return "spirv64";
79 case systemz: return "s390x";
80 case tce: return "tce";
81 case tcele: return "tcele";
82 case thumb: return "thumb";
83 case thumbeb: return "thumbeb";
84 case ve: return "ve";
85 case wasm32: return "wasm32";
86 case wasm64: return "wasm64";
87 case x86: return "i386";
88 case x86_64: return "x86_64";
89 case xcore: return "xcore";
90 case xtensa: return "xtensa";
91 }
92
93 llvm_unreachable("Invalid ArchType!");
94}
95
97 switch (Kind) {
98 case Triple::mips:
99 if (SubArch == MipsSubArch_r6)
100 return "mipsisa32r6";
101 break;
102 case Triple::mipsel:
103 if (SubArch == MipsSubArch_r6)
104 return "mipsisa32r6el";
105 break;
106 case Triple::mips64:
107 if (SubArch == MipsSubArch_r6)
108 return "mipsisa64r6";
109 break;
110 case Triple::mips64el:
111 if (SubArch == MipsSubArch_r6)
112 return "mipsisa64r6el";
113 break;
114 case Triple::aarch64:
115 if (SubArch == AArch64SubArch_arm64ec)
116 return "arm64ec";
117 if (SubArch == AArch64SubArch_arm64e)
118 return "arm64e";
119 break;
120 case Triple::spirv:
121 switch (SubArch) {
123 return "spirv1.0";
125 return "spirv1.1";
127 return "spirv1.2";
129 return "spirv1.3";
131 return "spirv1.4";
133 return "spirv1.5";
135 return "spirv1.6";
136 default:
137 break;
138 }
139 break;
140 case Triple::dxil:
141 switch (SubArch) {
144 return "dxilv1.0";
146 return "dxilv1.1";
148 return "dxilv1.2";
150 return "dxilv1.3";
152 return "dxilv1.4";
154 return "dxilv1.5";
156 return "dxilv1.6";
158 return "dxilv1.7";
160 return "dxilv1.8";
161 default:
162 break;
163 }
164 break;
165 default:
166 break;
167 }
168 return getArchTypeName(Kind);
169}
170
172 switch (Kind) {
173 default:
174 return StringRef();
175
176 case aarch64:
177 case aarch64_be:
178 case aarch64_32: return "aarch64";
179
180 case arc: return "arc";
181
182 case arm:
183 case armeb:
184 case thumb:
185 case thumbeb: return "arm";
186
187 case avr: return "avr";
188
189 case ppc64:
190 case ppc64le:
191 case ppc:
192 case ppcle: return "ppc";
193
194 case m68k: return "m68k";
195
196 case mips:
197 case mipsel:
198 case mips64:
199 case mips64el: return "mips";
200
201 case hexagon: return "hexagon";
202
203 case amdgcn: return "amdgcn";
204 case r600: return "r600";
205
206 case bpfel:
207 case bpfeb: return "bpf";
208
209 case sparcv9:
210 case sparcel:
211 case sparc: return "sparc";
212
213 case systemz: return "s390";
214
215 case x86:
216 case x86_64: return "x86";
217
218 case xcore: return "xcore";
219
220 // NVPTX intrinsics are namespaced under nvvm.
221 case nvptx: return "nvvm";
222 case nvptx64: return "nvvm";
223
224 case amdil:
225 case amdil64: return "amdil";
226
227 case hsail:
228 case hsail64: return "hsail";
229
230 case spir:
231 case spir64: return "spir";
232
233 case spirv:
234 case spirv32:
235 case spirv64: return "spv";
236
237 case kalimba: return "kalimba";
238 case lanai: return "lanai";
239 case shave: return "shave";
240 case wasm32:
241 case wasm64: return "wasm";
242
243 case riscv32:
244 case riscv64:
245 case riscv32be:
246 case riscv64be:
247 return "riscv";
248
249 case ve: return "ve";
250 case csky: return "csky";
251
252 case loongarch32:
253 case loongarch64: return "loongarch";
254
255 case dxil: return "dx";
256
257 case xtensa: return "xtensa";
258 }
259}
260
262 switch (Kind) {
263 case UnknownVendor: return "unknown";
264
265 case AMD: return "amd";
266 case Apple: return "apple";
267 case CSR: return "csr";
268 case Freescale: return "fsl";
269 case IBM: return "ibm";
270 case ImaginationTechnologies: return "img";
271 case Intel:
272 return "intel";
273 case Mesa: return "mesa";
274 case MipsTechnologies: return "mti";
275 case NVIDIA: return "nvidia";
276 case OpenEmbedded: return "oe";
277 case PC: return "pc";
278 case SCEI: return "scei";
279 case SUSE: return "suse";
280 case Meta:
281 return "meta";
282 }
283
284 llvm_unreachable("Invalid VendorType!");
285}
286
288 switch (Kind) {
289 case UnknownOS: return "unknown";
290
291 case AIX: return "aix";
292 case AMDHSA: return "amdhsa";
293 case AMDPAL: return "amdpal";
294 case BridgeOS: return "bridgeos";
295 case CUDA: return "cuda";
296 case Darwin: return "darwin";
297 case DragonFly: return "dragonfly";
298 case DriverKit: return "driverkit";
299 case ELFIAMCU: return "elfiamcu";
300 case Emscripten: return "emscripten";
301 case FreeBSD: return "freebsd";
302 case Fuchsia: return "fuchsia";
303 case Haiku: return "haiku";
304 case HermitCore: return "hermit";
305 case Hurd: return "hurd";
306 case IOS: return "ios";
307 case KFreeBSD: return "kfreebsd";
308 case Linux: return "linux";
309 case Lv2: return "lv2";
310 case MacOSX: return "macosx";
311 case Managarm:
312 return "managarm";
313 case Mesa3D: return "mesa3d";
314 case NVCL: return "nvcl";
315 case NetBSD: return "netbsd";
316 case OpenBSD: return "openbsd";
317 case PS4: return "ps4";
318 case PS5: return "ps5";
319 case RTEMS: return "rtems";
320 case Solaris: return "solaris";
321 case Serenity: return "serenity";
322 case TvOS: return "tvos";
323 case UEFI: return "uefi";
324 case WASI: return "wasi";
325 case WatchOS: return "watchos";
326 case Win32: return "windows";
327 case ZOS: return "zos";
328 case ShaderModel: return "shadermodel";
329 case LiteOS: return "liteos";
330 case XROS: return "xros";
331 case Vulkan: return "vulkan";
332 }
333
334 llvm_unreachable("Invalid OSType");
335}
336
338 switch (Kind) {
339 case UnknownEnvironment: return "unknown";
340 case Android: return "android";
341 case CODE16: return "code16";
342 case CoreCLR: return "coreclr";
343 case Cygnus: return "cygnus";
344 case EABI: return "eabi";
345 case EABIHF: return "eabihf";
346 case GNU: return "gnu";
347 case GNUT64: return "gnut64";
348 case GNUABI64: return "gnuabi64";
349 case GNUABIN32: return "gnuabin32";
350 case GNUEABI: return "gnueabi";
351 case GNUEABIT64: return "gnueabit64";
352 case GNUEABIHF: return "gnueabihf";
353 case GNUEABIHFT64: return "gnueabihft64";
354 case GNUF32: return "gnuf32";
355 case GNUF64: return "gnuf64";
356 case GNUSF: return "gnusf";
357 case GNUX32: return "gnux32";
358 case GNUILP32: return "gnu_ilp32";
359 case Itanium: return "itanium";
360 case MSVC: return "msvc";
361 case MacABI: return "macabi";
362 case Musl: return "musl";
363 case MuslABIN32:
364 return "muslabin32";
365 case MuslABI64:
366 return "muslabi64";
367 case MuslEABI: return "musleabi";
368 case MuslEABIHF: return "musleabihf";
369 case MuslF32:
370 return "muslf32";
371 case MuslSF:
372 return "muslsf";
373 case MuslX32: return "muslx32";
374 case Simulator: return "simulator";
375 case Pixel: return "pixel";
376 case Vertex: return "vertex";
377 case Geometry: return "geometry";
378 case Hull: return "hull";
379 case Domain: return "domain";
380 case Compute: return "compute";
381 case Library: return "library";
382 case RayGeneration: return "raygeneration";
383 case Intersection: return "intersection";
384 case AnyHit: return "anyhit";
385 case ClosestHit: return "closesthit";
386 case Miss: return "miss";
387 case Callable: return "callable";
388 case Mesh: return "mesh";
389 case Amplification: return "amplification";
390 case OpenCL:
391 return "opencl";
392 case OpenHOS: return "ohos";
393 case PAuthTest:
394 return "pauthtest";
395 case MTIA:
396 return "mtia";
397 case LLVM:
398 return "llvm";
399 case Mlibc:
400 return "mlibc";
401 }
402
403 llvm_unreachable("Invalid EnvironmentType!");
404}
405
407 switch (Kind) {
408 case UnknownObjectFormat: return "";
409 case COFF: return "coff";
410 case ELF: return "elf";
411 case GOFF: return "goff";
412 case MachO: return "macho";
413 case Wasm: return "wasm";
414 case XCOFF: return "xcoff";
415 case DXContainer: return "dxcontainer";
416 case SPIRV: return "spirv";
417 }
418 llvm_unreachable("unknown object format type");
419}
420
422 if (ArchName == "bpf") {
424 return Triple::bpfel;
425 else
426 return Triple::bpfeb;
427 } else if (ArchName == "bpf_be" || ArchName == "bpfeb") {
428 return Triple::bpfeb;
429 } else if (ArchName == "bpf_le" || ArchName == "bpfel") {
430 return Triple::bpfel;
431 } else {
432 return Triple::UnknownArch;
433 }
434}
435
439 .Case("aarch64", aarch64)
440 .Case("aarch64_be", aarch64_be)
441 .Case("aarch64_32", aarch64_32)
442 .Case("arc", arc)
443 .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
444 .Case("arm64_32", aarch64_32)
445 .Case("arm", arm)
446 .Case("armeb", armeb)
447 .Case("avr", avr)
448 .StartsWith("bpf", BPFArch)
449 .Case("m68k", m68k)
450 .Case("mips", mips)
451 .Case("mipsel", mipsel)
452 .Case("mips64", mips64)
453 .Case("mips64el", mips64el)
454 .Case("msp430", msp430)
455 .Case("ppc64", ppc64)
456 .Case("ppc32", ppc)
457 .Case("ppc", ppc)
458 .Case("ppc32le", ppcle)
459 .Case("ppcle", ppcle)
460 .Case("ppc64le", ppc64le)
461 .Case("r600", r600)
462 .Case("amdgcn", amdgcn)
463 .Case("riscv32", riscv32)
464 .Case("riscv64", riscv64)
465 .Case("riscv32be", riscv32be)
466 .Case("riscv64be", riscv64be)
467 .Case("hexagon", hexagon)
468 .Case("sparc", sparc)
469 .Case("sparcel", sparcel)
470 .Case("sparcv9", sparcv9)
471 .Case("s390x", systemz)
472 .Case("systemz", systemz)
473 .Case("tce", tce)
474 .Case("tcele", tcele)
475 .Case("thumb", thumb)
476 .Case("thumbeb", thumbeb)
477 .Case("x86", x86)
478 .Case("i386", x86)
479 .Case("x86-64", x86_64)
480 .Case("xcore", xcore)
481 .Case("nvptx", nvptx)
482 .Case("nvptx64", nvptx64)
483 .Case("amdil", amdil)
484 .Case("amdil64", amdil64)
485 .Case("hsail", hsail)
486 .Case("hsail64", hsail64)
487 .Case("spir", spir)
488 .Case("spir64", spir64)
489 .Case("spirv", spirv)
490 .Case("spirv32", spirv32)
491 .Case("spirv64", spirv64)
492 .Case("kalimba", kalimba)
493 .Case("lanai", lanai)
494 .Case("shave", shave)
495 .Case("wasm32", wasm32)
496 .Case("wasm64", wasm64)
497 .Case("renderscript32", renderscript32)
498 .Case("renderscript64", renderscript64)
499 .Case("ve", ve)
500 .Case("csky", csky)
501 .Case("loongarch32", loongarch32)
502 .Case("loongarch64", loongarch64)
503 .Case("dxil", dxil)
504 .Case("xtensa", xtensa)
506}
507
509 ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
510 ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
511
513 switch (ENDIAN) {
515 switch (ISA) {
517 arch = Triple::arm;
518 break;
520 arch = Triple::thumb;
521 break;
523 arch = Triple::aarch64;
524 break;
526 break;
527 }
528 break;
529 }
531 switch (ISA) {
533 arch = Triple::armeb;
534 break;
536 arch = Triple::thumbeb;
537 break;
539 arch = Triple::aarch64_be;
540 break;
542 break;
543 }
544 break;
545 }
547 break;
548 }
549 }
550
551 ArchName = ARM::getCanonicalArchName(ArchName);
552 if (ArchName.empty())
553 return Triple::UnknownArch;
554
555 // Thumb only exists in v4+
556 if (ISA == ARM::ISAKind::THUMB &&
557 (ArchName.starts_with("v2") || ArchName.starts_with("v3")))
558 return Triple::UnknownArch;
559
560 // Thumb only for v6m
562 unsigned Version = ARM::parseArchVersion(ArchName);
563 if (Profile == ARM::ProfileKind::M && Version == 6) {
564 if (ENDIAN == ARM::EndianKind::BIG)
565 return Triple::thumbeb;
566 else
567 return Triple::thumb;
568 }
569
570 return arch;
571}
572
574 auto AT = StringSwitch<Triple::ArchType>(ArchName)
575 .Cases("i386", "i486", "i586", "i686", Triple::x86)
576 // FIXME: Do we need to support these?
577 .Cases("i786", "i886", "i986", Triple::x86)
578 .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
579 .Cases("powerpc", "powerpcspe", "ppc", "ppc32", Triple::ppc)
580 .Cases("powerpcle", "ppcle", "ppc32le", Triple::ppcle)
581 .Cases("powerpc64", "ppu", "ppc64", Triple::ppc64)
582 .Cases("powerpc64le", "ppc64le", Triple::ppc64le)
583 .Case("xscale", Triple::arm)
584 .Case("xscaleeb", Triple::armeb)
585 .Case("aarch64", Triple::aarch64)
586 .Case("aarch64_be", Triple::aarch64_be)
587 .Case("aarch64_32", Triple::aarch64_32)
588 .Case("arc", Triple::arc)
589 .Case("arm64", Triple::aarch64)
590 .Case("arm64_32", Triple::aarch64_32)
591 .Case("arm64e", Triple::aarch64)
592 .Case("arm64ec", Triple::aarch64)
593 .Case("arm", Triple::arm)
594 .Case("armeb", Triple::armeb)
595 .Case("thumb", Triple::thumb)
596 .Case("thumbeb", Triple::thumbeb)
597 .Case("avr", Triple::avr)
598 .Case("m68k", Triple::m68k)
599 .Case("msp430", Triple::msp430)
600 .Cases("mips", "mipseb", "mipsallegrex", "mipsisa32r6",
601 "mipsr6", Triple::mips)
602 .Cases("mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el",
604 .Cases("mips64", "mips64eb", "mipsn32", "mipsisa64r6",
605 "mips64r6", "mipsn32r6", Triple::mips64)
606 .Cases("mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
607 "mipsn32r6el", Triple::mips64el)
608 .Case("r600", Triple::r600)
609 .Case("amdgcn", Triple::amdgcn)
610 .Case("riscv32", Triple::riscv32)
611 .Case("riscv64", Triple::riscv64)
612 .Case("riscv32be", Triple::riscv32be)
613 .Case("riscv64be", Triple::riscv64be)
614 .Case("hexagon", Triple::hexagon)
615 .Cases("s390x", "systemz", Triple::systemz)
616 .Case("sparc", Triple::sparc)
617 .Case("sparcel", Triple::sparcel)
618 .Cases("sparcv9", "sparc64", Triple::sparcv9)
619 .Case("tce", Triple::tce)
620 .Case("tcele", Triple::tcele)
621 .Case("xcore", Triple::xcore)
622 .Case("nvptx", Triple::nvptx)
623 .Case("nvptx64", Triple::nvptx64)
624 .Case("amdil", Triple::amdil)
625 .Case("amdil64", Triple::amdil64)
626 .Case("hsail", Triple::hsail)
627 .Case("hsail64", Triple::hsail64)
628 .Case("spir", Triple::spir)
629 .Case("spir64", Triple::spir64)
630 .Cases("spirv", "spirv1.5", "spirv1.6", Triple::spirv)
631 .Cases("spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
632 "spirv32v1.3", "spirv32v1.4", "spirv32v1.5",
633 "spirv32v1.6", Triple::spirv32)
634 .Cases("spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
635 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5",
636 "spirv64v1.6", Triple::spirv64)
637 .StartsWith("kalimba", Triple::kalimba)
638 .Case("lanai", Triple::lanai)
639 .Case("renderscript32", Triple::renderscript32)
640 .Case("renderscript64", Triple::renderscript64)
641 .Case("shave", Triple::shave)
642 .Case("ve", Triple::ve)
643 .Case("wasm32", Triple::wasm32)
644 .Case("wasm64", Triple::wasm64)
645 .Case("csky", Triple::csky)
646 .Case("loongarch32", Triple::loongarch32)
647 .Case("loongarch64", Triple::loongarch64)
648 .Cases("dxil", "dxilv1.0", "dxilv1.1", "dxilv1.2", "dxilv1.3",
649 "dxilv1.4", "dxilv1.5", "dxilv1.6", "dxilv1.7",
650 "dxilv1.8", Triple::dxil)
651 .Case("xtensa", Triple::xtensa)
653
654 // Some architectures require special parsing logic just to compute the
655 // ArchType result.
656 if (AT == Triple::UnknownArch) {
657 if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
658 ArchName.starts_with("aarch64"))
659 return parseARMArch(ArchName);
660 if (ArchName.starts_with("bpf"))
661 return parseBPFArch(ArchName);
662 }
663
664 return AT;
665}
666
668 return StringSwitch<Triple::VendorType>(VendorName)
669 .Case("apple", Triple::Apple)
670 .Case("pc", Triple::PC)
671 .Case("scei", Triple::SCEI)
672 .Case("sie", Triple::SCEI)
673 .Case("fsl", Triple::Freescale)
674 .Case("ibm", Triple::IBM)
677 .Case("nvidia", Triple::NVIDIA)
678 .Case("csr", Triple::CSR)
679 .Case("amd", Triple::AMD)
680 .Case("mesa", Triple::Mesa)
681 .Case("suse", Triple::SUSE)
683 .Case("intel", Triple::Intel)
684 .Case("meta", Triple::Meta)
686}
687
689 return StringSwitch<Triple::OSType>(OSName)
690 .StartsWith("darwin", Triple::Darwin)
691 .StartsWith("dragonfly", Triple::DragonFly)
692 .StartsWith("freebsd", Triple::FreeBSD)
693 .StartsWith("fuchsia", Triple::Fuchsia)
694 .StartsWith("ios", Triple::IOS)
695 .StartsWith("kfreebsd", Triple::KFreeBSD)
696 .StartsWith("linux", Triple::Linux)
697 .StartsWith("lv2", Triple::Lv2)
698 .StartsWith("macos", Triple::MacOSX)
699 .StartsWith("managarm", Triple::Managarm)
700 .StartsWith("netbsd", Triple::NetBSD)
701 .StartsWith("openbsd", Triple::OpenBSD)
702 .StartsWith("solaris", Triple::Solaris)
703 .StartsWith("uefi", Triple::UEFI)
704 .StartsWith("win32", Triple::Win32)
705 .StartsWith("windows", Triple::Win32)
706 .StartsWith("zos", Triple::ZOS)
707 .StartsWith("haiku", Triple::Haiku)
708 .StartsWith("rtems", Triple::RTEMS)
709 .StartsWith("aix", Triple::AIX)
710 .StartsWith("cuda", Triple::CUDA)
711 .StartsWith("nvcl", Triple::NVCL)
712 .StartsWith("amdhsa", Triple::AMDHSA)
713 .StartsWith("ps4", Triple::PS4)
714 .StartsWith("ps5", Triple::PS5)
715 .StartsWith("elfiamcu", Triple::ELFIAMCU)
716 .StartsWith("tvos", Triple::TvOS)
717 .StartsWith("watchos", Triple::WatchOS)
718 .StartsWith("bridgeos", Triple::BridgeOS)
719 .StartsWith("driverkit", Triple::DriverKit)
720 .StartsWith("xros", Triple::XROS)
721 .StartsWith("visionos", Triple::XROS)
722 .StartsWith("mesa3d", Triple::Mesa3D)
723 .StartsWith("amdpal", Triple::AMDPAL)
725 .StartsWith("hurd", Triple::Hurd)
726 .StartsWith("wasi", Triple::WASI)
727 .StartsWith("emscripten", Triple::Emscripten)
728 .StartsWith("shadermodel", Triple::ShaderModel)
729 .StartsWith("liteos", Triple::LiteOS)
730 .StartsWith("serenity", Triple::Serenity)
731 .StartsWith("vulkan", Triple::Vulkan)
733}
734
736 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
737 .StartsWith("eabihf", Triple::EABIHF)
738 .StartsWith("eabi", Triple::EABI)
739 .StartsWith("gnuabin32", Triple::GNUABIN32)
740 .StartsWith("gnuabi64", Triple::GNUABI64)
741 .StartsWith("gnueabihft64", Triple::GNUEABIHFT64)
742 .StartsWith("gnueabihf", Triple::GNUEABIHF)
743 .StartsWith("gnueabit64", Triple::GNUEABIT64)
744 .StartsWith("gnueabi", Triple::GNUEABI)
745 .StartsWith("gnuf32", Triple::GNUF32)
746 .StartsWith("gnuf64", Triple::GNUF64)
747 .StartsWith("gnusf", Triple::GNUSF)
748 .StartsWith("gnux32", Triple::GNUX32)
749 .StartsWith("gnu_ilp32", Triple::GNUILP32)
750 .StartsWith("code16", Triple::CODE16)
751 .StartsWith("gnut64", Triple::GNUT64)
752 .StartsWith("gnu", Triple::GNU)
753 .StartsWith("android", Triple::Android)
754 .StartsWith("muslabin32", Triple::MuslABIN32)
755 .StartsWith("muslabi64", Triple::MuslABI64)
756 .StartsWith("musleabihf", Triple::MuslEABIHF)
757 .StartsWith("musleabi", Triple::MuslEABI)
758 .StartsWith("muslf32", Triple::MuslF32)
759 .StartsWith("muslsf", Triple::MuslSF)
760 .StartsWith("muslx32", Triple::MuslX32)
761 .StartsWith("musl", Triple::Musl)
762 .StartsWith("msvc", Triple::MSVC)
763 .StartsWith("itanium", Triple::Itanium)
764 .StartsWith("cygnus", Triple::Cygnus)
765 .StartsWith("coreclr", Triple::CoreCLR)
766 .StartsWith("simulator", Triple::Simulator)
767 .StartsWith("macabi", Triple::MacABI)
768 .StartsWith("pixel", Triple::Pixel)
769 .StartsWith("vertex", Triple::Vertex)
770 .StartsWith("geometry", Triple::Geometry)
771 .StartsWith("hull", Triple::Hull)
772 .StartsWith("domain", Triple::Domain)
773 .StartsWith("compute", Triple::Compute)
774 .StartsWith("library", Triple::Library)
775 .StartsWith("raygeneration", Triple::RayGeneration)
776 .StartsWith("intersection", Triple::Intersection)
777 .StartsWith("anyhit", Triple::AnyHit)
778 .StartsWith("closesthit", Triple::ClosestHit)
779 .StartsWith("miss", Triple::Miss)
780 .StartsWith("callable", Triple::Callable)
781 .StartsWith("mesh", Triple::Mesh)
782 .StartsWith("amplification", Triple::Amplification)
783 .StartsWith("opencl", Triple::OpenCL)
785 .StartsWith("pauthtest", Triple::PAuthTest)
786 .StartsWith("llvm", Triple::LLVM)
787 .StartsWith("mlibc", Triple::Mlibc)
788 .StartsWith("mtia", Triple::MTIA)
790}
791
793 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
794 // "xcoff" must come before "coff" because of the order-dependendent
795 // pattern matching.
796 .EndsWith("xcoff", Triple::XCOFF)
797 .EndsWith("coff", Triple::COFF)
798 .EndsWith("elf", Triple::ELF)
799 .EndsWith("goff", Triple::GOFF)
800 .EndsWith("macho", Triple::MachO)
801 .EndsWith("wasm", Triple::Wasm)
802 .EndsWith("spirv", Triple::SPIRV)
804}
805
807 if (SubArchName.starts_with("mips") &&
808 (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
810
811 if (SubArchName == "powerpcspe")
813
814 if (SubArchName == "arm64e")
816
817 if (SubArchName == "arm64ec")
819
820 if (SubArchName.starts_with("spirv"))
821 return StringSwitch<Triple::SubArchType>(SubArchName)
830
831 if (SubArchName.starts_with("dxil"))
832 return StringSwitch<Triple::SubArchType>(SubArchName)
843
844 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
845
846 // For now, this is the small part. Early return.
847 if (ARMSubArch.empty())
848 return StringSwitch<Triple::SubArchType>(SubArchName)
853
854 // ARM sub arch.
855 switch(ARM::parseArch(ARMSubArch)) {
856 case ARM::ArchKind::ARMV4:
857 return Triple::NoSubArch;
858 case ARM::ArchKind::ARMV4T:
860 case ARM::ArchKind::ARMV5T:
862 case ARM::ArchKind::ARMV5TE:
863 case ARM::ArchKind::IWMMXT:
864 case ARM::ArchKind::IWMMXT2:
865 case ARM::ArchKind::XSCALE:
866 case ARM::ArchKind::ARMV5TEJ:
868 case ARM::ArchKind::ARMV6:
870 case ARM::ArchKind::ARMV6K:
871 case ARM::ArchKind::ARMV6KZ:
873 case ARM::ArchKind::ARMV6T2:
875 case ARM::ArchKind::ARMV6M:
877 case ARM::ArchKind::ARMV7A:
878 case ARM::ArchKind::ARMV7R:
880 case ARM::ArchKind::ARMV7VE:
882 case ARM::ArchKind::ARMV7K:
884 case ARM::ArchKind::ARMV7M:
886 case ARM::ArchKind::ARMV7S:
888 case ARM::ArchKind::ARMV7EM:
890 case ARM::ArchKind::ARMV8A:
892 case ARM::ArchKind::ARMV8_1A:
894 case ARM::ArchKind::ARMV8_2A:
896 case ARM::ArchKind::ARMV8_3A:
898 case ARM::ArchKind::ARMV8_4A:
900 case ARM::ArchKind::ARMV8_5A:
902 case ARM::ArchKind::ARMV8_6A:
904 case ARM::ArchKind::ARMV8_7A:
906 case ARM::ArchKind::ARMV8_8A:
908 case ARM::ArchKind::ARMV8_9A:
910 case ARM::ArchKind::ARMV9A:
912 case ARM::ArchKind::ARMV9_1A:
914 case ARM::ArchKind::ARMV9_2A:
916 case ARM::ArchKind::ARMV9_3A:
918 case ARM::ArchKind::ARMV9_4A:
920 case ARM::ArchKind::ARMV9_5A:
922 case ARM::ArchKind::ARMV9_6A:
924 case ARM::ArchKind::ARMV8R:
926 case ARM::ArchKind::ARMV8MBaseline:
928 case ARM::ArchKind::ARMV8MMainline:
930 case ARM::ArchKind::ARMV8_1MMainline:
932 default:
933 return Triple::NoSubArch;
934 }
935}
936
938 switch (T.getArch()) {
940 case Triple::aarch64:
942 case Triple::arm:
943 case Triple::thumb:
944 case Triple::x86:
945 case Triple::x86_64:
946 switch (T.getOS()) {
947 case Triple::Win32:
948 case Triple::UEFI:
949 return Triple::COFF;
950 default:
951 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
952 }
954 case Triple::amdgcn:
955 case Triple::amdil64:
956 case Triple::amdil:
957 case Triple::arc:
958 case Triple::armeb:
959 case Triple::avr:
960 case Triple::bpfeb:
961 case Triple::bpfel:
962 case Triple::csky:
963 case Triple::hexagon:
964 case Triple::hsail64:
965 case Triple::hsail:
966 case Triple::kalimba:
967 case Triple::lanai:
970 case Triple::m68k:
971 case Triple::mips64:
972 case Triple::mips64el:
973 case Triple::mips:
974 case Triple::msp430:
975 case Triple::nvptx64:
976 case Triple::nvptx:
977 case Triple::ppc64le:
978 case Triple::ppcle:
979 case Triple::r600:
982 case Triple::riscv32:
983 case Triple::riscv64:
986 case Triple::shave:
987 case Triple::sparc:
988 case Triple::sparcel:
989 case Triple::sparcv9:
990 case Triple::spir64:
991 case Triple::spir:
992 case Triple::tce:
993 case Triple::tcele:
994 case Triple::thumbeb:
995 case Triple::ve:
996 case Triple::xcore:
997 case Triple::xtensa:
998 return Triple::ELF;
999
1000 case Triple::mipsel:
1001 if (T.isOSWindows())
1002 return Triple::COFF;
1003 return Triple::ELF;
1004
1005 case Triple::ppc64:
1006 case Triple::ppc:
1007 if (T.isOSAIX())
1008 return Triple::XCOFF;
1009 if (T.isOSDarwin())
1010 return Triple::MachO;
1011 return Triple::ELF;
1012
1013 case Triple::systemz:
1014 if (T.isOSzOS())
1015 return Triple::GOFF;
1016 return Triple::ELF;
1017
1018 case Triple::wasm32:
1019 case Triple::wasm64:
1020 return Triple::Wasm;
1021
1022 case Triple::spirv:
1023 case Triple::spirv32:
1024 case Triple::spirv64:
1025 return Triple::SPIRV;
1026
1027 case Triple::dxil:
1028 return Triple::DXContainer;
1029 }
1030 llvm_unreachable("unknown architecture");
1031}
1032
1033/// Construct a triple from the string representation provided.
1034///
1035/// This stores the string representation and parses the various pieces into
1036/// enum members.
1037Triple::Triple(std::string &&Str) : Data(std::move(Str)) {
1038 // Do minimal parsing by hand here.
1039 SmallVector<StringRef, 4> Components;
1040 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
1041 if (Components.size() > 0) {
1042 Arch = parseArch(Components[0]);
1043 SubArch = parseSubArch(Components[0]);
1044 if (Components.size() > 1) {
1045 Vendor = parseVendor(Components[1]);
1046 if (Components.size() > 2) {
1047 OS = parseOS(Components[2]);
1048 if (Components.size() > 3) {
1049 Environment = parseEnvironment(Components[3]);
1050 ObjectFormat = parseFormat(Components[3]);
1051 }
1052 }
1053 } else {
1054 Environment =
1056 .StartsWith("mipsn32", Triple::GNUABIN32)
1057 .StartsWith("mips64", Triple::GNUABI64)
1058 .StartsWith("mipsisa64", Triple::GNUABI64)
1059 .StartsWith("mipsisa32", Triple::GNU)
1060 .Cases("mips", "mipsel", "mipsr6", "mipsr6el", Triple::GNU)
1062 }
1063 }
1064 if (ObjectFormat == UnknownObjectFormat)
1065 ObjectFormat = getDefaultFormat(*this);
1066}
1067
1068Triple::Triple(const Twine &Str) : Triple(Str.str()) {}
1069
1070/// Construct a triple from string representations of the architecture,
1071/// vendor, and OS.
1072///
1073/// This joins each argument into a canonical string representation and parses
1074/// them into enum members. It leaves the environment unknown and omits it from
1075/// the string representation.
1076Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1077 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1078 Arch(parseArch(ArchStr.str())),
1079 SubArch(parseSubArch(ArchStr.str())),
1080 Vendor(parseVendor(VendorStr.str())),
1081 OS(parseOS(OSStr.str())),
1082 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1083 ObjectFormat = getDefaultFormat(*this);
1084}
1085
1086/// Construct a triple from string representations of the architecture,
1087/// vendor, OS, and environment.
1088///
1089/// This joins each argument into a canonical string representation and parses
1090/// them into enum members.
1091Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1092 const Twine &EnvironmentStr)
1093 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1094 EnvironmentStr).str()),
1095 Arch(parseArch(ArchStr.str())),
1096 SubArch(parseSubArch(ArchStr.str())),
1097 Vendor(parseVendor(VendorStr.str())),
1098 OS(parseOS(OSStr.str())),
1099 Environment(parseEnvironment(EnvironmentStr.str())),
1100 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1101 if (ObjectFormat == Triple::UnknownObjectFormat)
1102 ObjectFormat = getDefaultFormat(*this);
1103}
1104
1106
1108 VersionTuple Ver =
1109 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1110 // Default DXIL minor version when Shader Model version is anything other
1111 // than 6.[0...8] or 6.x (which translates to latest current SM version)
1112 const unsigned SMMajor = 6;
1113 if (!Ver.empty()) {
1114 if (Ver.getMajor() == SMMajor) {
1115 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1116 switch (*SMMinor) {
1117 case 0:
1119 case 1:
1121 case 2:
1123 case 3:
1125 case 4:
1127 case 5:
1129 case 6:
1131 case 7:
1133 case 8:
1135 default:
1136 report_fatal_error("Unsupported Shader Model version", false);
1137 }
1138 }
1139 }
1140 } else {
1141 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1142 // shadermodel6.x is
1143 if (ShaderModelStr == "shadermodel6.x") {
1145 }
1146 }
1147 // DXIL version corresponding to Shader Model version other than 6.Minor
1148 // is 1.0
1150}
1151
1153 bool IsMinGW32 = false;
1154 bool IsCygwin = false;
1155
1156 // Parse into components.
1157 SmallVector<StringRef, 4> Components;
1158 Str.split(Components, '-');
1159
1160 // If the first component corresponds to a known architecture, preferentially
1161 // use it for the architecture. If the second component corresponds to a
1162 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1163 // component movement when a component parses as (eg) both a valid arch and a
1164 // valid os.
1165 ArchType Arch = UnknownArch;
1166 if (Components.size() > 0)
1167 Arch = parseArch(Components[0]);
1168 VendorType Vendor = UnknownVendor;
1169 if (Components.size() > 1)
1170 Vendor = parseVendor(Components[1]);
1171 OSType OS = UnknownOS;
1172 if (Components.size() > 2) {
1173 OS = parseOS(Components[2]);
1174 IsCygwin = Components[2].starts_with("cygwin") ||
1175 Components[2].starts_with("msys");
1176 IsMinGW32 = Components[2].starts_with("mingw");
1177 }
1178 EnvironmentType Environment = UnknownEnvironment;
1179 if (Components.size() > 3)
1180 Environment = parseEnvironment(Components[3]);
1182 if (Components.size() > 4)
1183 ObjectFormat = parseFormat(Components[4]);
1184
1185 // Note which components are already in their final position. These will not
1186 // be moved.
1187 bool Found[4];
1188 Found[0] = Arch != UnknownArch;
1189 Found[1] = Vendor != UnknownVendor;
1190 Found[2] = OS != UnknownOS;
1191 Found[3] = Environment != UnknownEnvironment;
1192
1193 // If they are not there already, permute the components into their canonical
1194 // positions by seeing if they parse as a valid architecture, and if so moving
1195 // the component to the architecture position etc.
1196 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1197 if (Found[Pos])
1198 continue; // Already in the canonical position.
1199
1200 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1201 // Do not reparse any components that already matched.
1202 if (Idx < std::size(Found) && Found[Idx])
1203 continue;
1204
1205 // Does this component parse as valid for the target position?
1206 bool Valid = false;
1207 StringRef Comp = Components[Idx];
1208 switch (Pos) {
1209 default: llvm_unreachable("unexpected component type!");
1210 case 0:
1211 Arch = parseArch(Comp);
1212 Valid = Arch != UnknownArch;
1213 break;
1214 case 1:
1215 Vendor = parseVendor(Comp);
1216 Valid = Vendor != UnknownVendor;
1217 break;
1218 case 2:
1219 OS = parseOS(Comp);
1220 IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
1221 IsMinGW32 = Comp.starts_with("mingw");
1222 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1223 break;
1224 case 3:
1225 Environment = parseEnvironment(Comp);
1226 Valid = Environment != UnknownEnvironment;
1227 if (!Valid) {
1228 ObjectFormat = parseFormat(Comp);
1229 Valid = ObjectFormat != UnknownObjectFormat;
1230 }
1231 break;
1232 }
1233 if (!Valid)
1234 continue; // Nope, try the next component.
1235
1236 // Move the component to the target position, pushing any non-fixed
1237 // components that are in the way to the right. This tends to give
1238 // good results in the common cases of a forgotten vendor component
1239 // or a wrongly positioned environment.
1240 if (Pos < Idx) {
1241 // Insert left, pushing the existing components to the right. For
1242 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1243 StringRef CurrentComponent(""); // The empty component.
1244 // Replace the component we are moving with an empty component.
1245 std::swap(CurrentComponent, Components[Idx]);
1246 // Insert the component being moved at Pos, displacing any existing
1247 // components to the right.
1248 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1249 // Skip over any fixed components.
1250 while (i < std::size(Found) && Found[i])
1251 ++i;
1252 // Place the component at the new position, getting the component
1253 // that was at this position - it will be moved right.
1254 std::swap(CurrentComponent, Components[i]);
1255 }
1256 } else if (Pos > Idx) {
1257 // Push right by inserting empty components until the component at Idx
1258 // reaches the target position Pos. For example, pc-a -> -pc-a when
1259 // moving pc to the second position.
1260 do {
1261 // Insert one empty component at Idx.
1262 StringRef CurrentComponent(""); // The empty component.
1263 for (unsigned i = Idx; i < Components.size();) {
1264 // Place the component at the new position, getting the component
1265 // that was at this position - it will be moved right.
1266 std::swap(CurrentComponent, Components[i]);
1267 // If it was placed on top of an empty component then we are done.
1268 if (CurrentComponent.empty())
1269 break;
1270 // Advance to the next component, skipping any fixed components.
1271 while (++i < std::size(Found) && Found[i])
1272 ;
1273 }
1274 // The last component was pushed off the end - append it.
1275 if (!CurrentComponent.empty())
1276 Components.push_back(CurrentComponent);
1277
1278 // Advance Idx to the component's new position.
1279 while (++Idx < std::size(Found) && Found[Idx])
1280 ;
1281 } while (Idx < Pos); // Add more until the final position is reached.
1282 }
1283 assert(Pos < Components.size() && Components[Pos] == Comp &&
1284 "Component moved wrong!");
1285 Found[Pos] = true;
1286 break;
1287 }
1288 }
1289
1290 // If "none" is in the middle component in a three-component triple, treat it
1291 // as the OS (Components[2]) instead of the vendor (Components[1]).
1292 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1293 Components[1] == "none" && Components[2].empty())
1294 std::swap(Components[1], Components[2]);
1295
1296 // Replace empty components with "unknown" value.
1297 for (StringRef &C : Components)
1298 if (C.empty())
1299 C = "unknown";
1300
1301 // Special case logic goes here. At this point Arch, Vendor and OS have the
1302 // correct values for the computed components.
1303 std::string NormalizedEnvironment;
1304 if (Environment == Triple::Android &&
1305 Components[3].starts_with("androideabi")) {
1306 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1307 if (AndroidVersion.empty()) {
1308 Components[3] = "android";
1309 } else {
1310 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1311 Components[3] = NormalizedEnvironment;
1312 }
1313 }
1314
1315 // SUSE uses "gnueabi" to mean "gnueabihf"
1316 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1317 Components[3] = "gnueabihf";
1318
1319 if (OS == Triple::Win32) {
1320 Components.resize(4);
1321 Components[2] = "windows";
1322 if (Environment == UnknownEnvironment) {
1323 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1324 Components[3] = "msvc";
1325 else
1326 Components[3] = getObjectFormatTypeName(ObjectFormat);
1327 }
1328 } else if (IsMinGW32) {
1329 Components.resize(4);
1330 Components[2] = "windows";
1331 Components[3] = "gnu";
1332 } else if (IsCygwin) {
1333 Components.resize(4);
1334 Components[2] = "windows";
1335 Components[3] = "cygnus";
1336 }
1337 if (IsMinGW32 || IsCygwin ||
1338 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1339 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1340 Components.resize(5);
1341 Components[4] = getObjectFormatTypeName(ObjectFormat);
1342 }
1343 }
1344
1345 // Normalize DXIL triple if it does not include DXIL version number.
1346 // Determine DXIL version number using the minor version number of Shader
1347 // Model version specified in target triple, if any. Prior to decoupling DXIL
1348 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1349 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1350 if (Components[0] == "dxil") {
1351 if (Components.size() > 4) {
1352 Components.resize(4);
1353 }
1354 // Add DXIL version only if shadermodel is specified in the triple
1355 if (OS == Triple::ShaderModel) {
1356 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1357 }
1358 }
1359
1360 // Canonicalize the components if necessary.
1361 switch (Form) {
1362 case CanonicalForm::ANY:
1363 break;
1367 Components.resize(static_cast<unsigned>(Form), "unknown");
1368 break;
1369 }
1370 }
1371
1372 // Stick the corrected components back together to form the normalized string.
1373 return join(Components, "-");
1374}
1375
1377 return StringRef(Data).split('-').first; // Isolate first component
1378}
1379
1381 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1382 return Tmp.split('-').first; // Isolate second component
1383}
1384
1386 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1387 Tmp = Tmp.split('-').second; // Strip second component
1388 return Tmp.split('-').first; // Isolate third component
1389}
1390
1392 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1393 Tmp = Tmp.split('-').second; // Strip second component
1394 return Tmp.split('-').second; // Strip third component
1395}
1396
1398 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1399 return Tmp.split('-').second; // Strip second component
1400}
1401
1404 Version.tryParse(Name);
1405 return Version.withoutBuild();
1406}
1407
1410}
1411
1413 StringRef EnvironmentName = getEnvironmentName();
1414
1415 // none is a valid environment type - it basically amounts to a freestanding
1416 // environment.
1417 if (EnvironmentName == "none")
1418 return "";
1419
1420 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1421 EnvironmentName.consume_front(EnvironmentTypeName);
1422
1423 if (EnvironmentName.contains("-")) {
1424 // -obj is the suffix
1426 StringRef ObjectFormatTypeName =
1428 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1429 EnvironmentName.consume_back(tmp);
1430 }
1431 }
1432 return EnvironmentName;
1433}
1434
1436 StringRef OSName = getOSName();
1437 // Assume that the OS portion of the triple starts with the canonical name.
1438 StringRef OSTypeName = getOSTypeName(getOS());
1439 if (OSName.starts_with(OSTypeName))
1440 OSName = OSName.substr(OSTypeName.size());
1441 else if (getOS() == MacOSX)
1442 OSName.consume_front("macos");
1443 else if (OSName.starts_with("visionos"))
1444 OSName.consume_front("visionos");
1445
1446 return parseVersionFromName(OSName);
1447}
1448
1451
1452 switch (getOS()) {
1453 default: llvm_unreachable("unexpected OS for Darwin triple");
1454 case Darwin:
1455 // Default to darwin8, i.e., MacOSX 10.4.
1456 if (Version.getMajor() == 0)
1457 Version = VersionTuple(8);
1458 // Darwin version numbers are skewed from OS X versions.
1459 if (Version.getMajor() < 4) {
1460 return false;
1461 }
1462 if (Version.getMajor() <= 19) {
1463 Version = VersionTuple(10, Version.getMajor() - 4);
1464 } else if (Version.getMajor() < 25) {
1465 // darwin20-24 corresponds to macOS 11-15.
1466 Version = VersionTuple(11 + Version.getMajor() - 20);
1467 } else {
1468 // darwin25 corresponds with macOS26+.
1469 Version = VersionTuple(Version.getMajor() + 1);
1470 }
1471 break;
1472 case MacOSX:
1473 // Default to 10.4.
1474 if (Version.getMajor() == 0) {
1475 Version = VersionTuple(10, 4);
1476 } else if (Version.getMajor() < 10) {
1477 return false;
1478 }
1479 break;
1480 case IOS:
1481 case TvOS:
1482 case WatchOS:
1483 // Ignore the version from the triple. This is only handled because the
1484 // the clang driver combines OS X and IOS support into a common Darwin
1485 // toolchain that wants to know the OS X version number even when targeting
1486 // IOS.
1487 Version = VersionTuple(10, 4);
1488 break;
1489 case XROS:
1490 llvm_unreachable("OSX version isn't relevant for xrOS");
1491 case DriverKit:
1492 llvm_unreachable("OSX version isn't relevant for DriverKit");
1493 }
1494 return true;
1495}
1496
1498 switch (getOS()) {
1499 default: llvm_unreachable("unexpected OS for Darwin triple");
1500 case Darwin:
1501 case MacOSX:
1502 // Ignore the version from the triple. This is only handled because the
1503 // the clang driver combines OS X and IOS support into a common Darwin
1504 // toolchain that wants to know the iOS version number even when targeting
1505 // OS X.
1506 return VersionTuple(5);
1507 case IOS:
1508 case TvOS: {
1510 // Default to 5.0 (or 7.0 for arm64).
1511 if (Version.getMajor() == 0)
1512 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1513 if (Version.getMajor() == 19)
1514 // tvOS 19 corresponds to ios26.
1515 return VersionTuple(26);
1518 }
1519 case XROS: {
1521 // xrOS 1 is aligned with iOS 17.
1522 if (Version.getMajor() < 3)
1523 return Version.withMajorReplaced(Version.getMajor() + 16);
1524 // visionOS 3 corresponds to ios 26+.
1525 if (Version.getMajor() == 3)
1526 return VersionTuple(26);
1529 }
1530 case WatchOS: {
1532 // watchOS 12 corresponds to ios 26.
1533 if (Version.getMajor() == 12)
1534 return VersionTuple(26);
1538 }
1539 case BridgeOS:
1540 llvm_unreachable("conflicting triple info");
1541 case DriverKit:
1542 llvm_unreachable("DriverKit doesn't have an iOS version");
1543 }
1544}
1545
1547 switch (getOS()) {
1548 default: llvm_unreachable("unexpected OS for Darwin triple");
1549 case Darwin:
1550 case MacOSX:
1551 // Ignore the version from the triple. This is only handled because the
1552 // the clang driver combines OS X and IOS support into a common Darwin
1553 // toolchain that wants to know the iOS version number even when targeting
1554 // OS X.
1555 return VersionTuple(2);
1556 case WatchOS: {
1558 if (Version.getMajor() == 0)
1559 return VersionTuple(2);
1560 return Version;
1561 }
1562 case IOS:
1563 llvm_unreachable("conflicting triple info");
1564 case XROS:
1565 llvm_unreachable("watchOS version isn't relevant for xrOS");
1566 case DriverKit:
1567 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1568 }
1569}
1570
1572 switch (getOS()) {
1573 default:
1574 llvm_unreachable("unexpected OS for Darwin triple");
1575 case DriverKit:
1577 if (Version.getMajor() == 0)
1578 return Version.withMajorReplaced(19);
1579 return Version;
1580 }
1581}
1582
1584 if (getArch() != spirv || getOS() != Vulkan)
1585 llvm_unreachable("invalid Vulkan SPIR-V triple");
1586
1587 VersionTuple VulkanVersion = getOSVersion();
1588 SubArchType SpirvVersion = getSubArch();
1589
1591 // Vulkan 1.2 -> SPIR-V 1.5.
1593 // Vulkan 1.3 -> SPIR-V 1.6.
1595
1596 // If Vulkan version is unset, default to 1.2.
1597 if (VulkanVersion == VersionTuple(0))
1598 VulkanVersion = VersionTuple(1, 2);
1599
1600 if (ValidVersionMap.contains(VulkanVersion) &&
1601 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1602 SpirvVersion == NoSubArch))
1603 return VulkanVersion;
1604
1605 return VersionTuple(0);
1606}
1607
1609 if (getArch() != dxil || getOS() != ShaderModel)
1610 llvm_unreachable("invalid DXIL triple");
1611 StringRef Arch = getArchName();
1612 if (getSubArch() == NoSubArch)
1614 Arch.consume_front("dxilv");
1615 VersionTuple DXILVersion = parseVersionFromName(Arch);
1616 // FIXME: validate DXIL version against Shader Model version.
1617 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1618 return DXILVersion;
1619}
1620
1621void Triple::setTriple(const Twine &Str) {
1622 *this = Triple(Str);
1623}
1624
1626 setArchName(getArchName(Kind, SubArch));
1627}
1628
1631}
1632
1634 setOSName(getOSTypeName(Kind));
1635}
1636
1638 if (ObjectFormat == getDefaultFormat(*this))
1640
1642 getObjectFormatTypeName(ObjectFormat)).str());
1643}
1644
1646 if (Environment == UnknownEnvironment)
1648
1649 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1650 getObjectFormatTypeName(Kind)).str());
1651}
1652
1654 setTriple(Str + "-" + getVendorName() + "-" + getOSAndEnvironmentName());
1655}
1656
1658 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1659}
1660
1662 if (hasEnvironment())
1663 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1664 "-" + getEnvironmentName());
1665 else
1666 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1667}
1668
1670 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1671 "-" + Str);
1672}
1673
1675 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1676}
1677
1679 switch (Arch) {
1681 return 0;
1682
1683 case llvm::Triple::avr:
1685 return 16;
1686
1689 case llvm::Triple::arc:
1690 case llvm::Triple::arm:
1692 case llvm::Triple::csky:
1693 case llvm::Triple::dxil:
1699 case llvm::Triple::m68k:
1700 case llvm::Triple::mips:
1703 case llvm::Triple::ppc:
1705 case llvm::Triple::r600:
1712 case llvm::Triple::spir:
1714 case llvm::Triple::tce:
1719 case llvm::Triple::x86:
1722 return 32;
1723
1745 case llvm::Triple::ve:
1748 return 64;
1749 }
1750 llvm_unreachable("Invalid architecture value");
1751}
1752
1754 switch (getArch()) {
1755 default:
1756 break;
1757 case Triple::ppc:
1758 case Triple::ppcle:
1759 if (isOSLinux())
1760 return 40;
1761 break;
1762 case Triple::ppc64:
1763 case Triple::ppc64le:
1764 if (isOSLinux())
1765 return 48;
1766 break;
1767 }
1768 return 32;
1769}
1770
1772 return getArchPointerBitWidth(getArch()) == 64;
1773}
1774
1776 return getArchPointerBitWidth(getArch()) == 32;
1777}
1778
1780 return getArchPointerBitWidth(getArch()) == 16;
1781}
1782
1784 Triple T(*this);
1785 switch (getArch()) {
1787 case Triple::amdgcn:
1788 case Triple::avr:
1789 case Triple::bpfeb:
1790 case Triple::bpfel:
1791 case Triple::msp430:
1792 case Triple::systemz:
1793 case Triple::ve:
1794 T.setArch(UnknownArch);
1795 break;
1796
1797 case Triple::aarch64_32:
1798 case Triple::amdil:
1799 case Triple::arc:
1800 case Triple::arm:
1801 case Triple::armeb:
1802 case Triple::csky:
1803 case Triple::dxil:
1804 case Triple::hexagon:
1805 case Triple::hsail:
1806 case Triple::kalimba:
1807 case Triple::lanai:
1809 case Triple::m68k:
1810 case Triple::mips:
1811 case Triple::mipsel:
1812 case Triple::nvptx:
1813 case Triple::ppc:
1814 case Triple::ppcle:
1815 case Triple::r600:
1817 case Triple::riscv32:
1818 case Triple::riscv32be:
1819 case Triple::shave:
1820 case Triple::sparc:
1821 case Triple::sparcel:
1822 case Triple::spir:
1823 case Triple::spirv32:
1824 case Triple::tce:
1825 case Triple::tcele:
1826 case Triple::thumb:
1827 case Triple::thumbeb:
1828 case Triple::wasm32:
1829 case Triple::x86:
1830 case Triple::xcore:
1831 case Triple::xtensa:
1832 // Already 32-bit.
1833 break;
1834
1835 case Triple::aarch64: T.setArch(Triple::arm); break;
1836 case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1837 case Triple::amdil64: T.setArch(Triple::amdil); break;
1838 case Triple::hsail64: T.setArch(Triple::hsail); break;
1839 case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
1840 case Triple::mips64:
1841 T.setArch(Triple::mips, getSubArch());
1842 break;
1843 case Triple::mips64el:
1844 T.setArch(Triple::mipsel, getSubArch());
1845 break;
1846 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1847 case Triple::ppc64: T.setArch(Triple::ppc); break;
1848 case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1849 case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1850 case Triple::riscv64: T.setArch(Triple::riscv32); break;
1851 case Triple::riscv64be:
1852 T.setArch(Triple::riscv32be);
1853 break;
1854 case Triple::sparcv9: T.setArch(Triple::sparc); break;
1855 case Triple::spir64: T.setArch(Triple::spir); break;
1856 case Triple::spirv:
1857 case Triple::spirv64:
1858 T.setArch(Triple::spirv32, getSubArch());
1859 break;
1860 case Triple::wasm64: T.setArch(Triple::wasm32); break;
1861 case Triple::x86_64: T.setArch(Triple::x86); break;
1862 }
1863 return T;
1864}
1865
1867 Triple T(*this);
1868 switch (getArch()) {
1870 case Triple::arc:
1871 case Triple::avr:
1872 case Triple::csky:
1873 case Triple::dxil:
1874 case Triple::hexagon:
1875 case Triple::kalimba:
1876 case Triple::lanai:
1877 case Triple::m68k:
1878 case Triple::msp430:
1879 case Triple::r600:
1880 case Triple::shave:
1881 case Triple::sparcel:
1882 case Triple::tce:
1883 case Triple::tcele:
1884 case Triple::xcore:
1885 case Triple::xtensa:
1886 T.setArch(UnknownArch);
1887 break;
1888
1889 case Triple::aarch64:
1890 case Triple::aarch64_be:
1891 case Triple::amdgcn:
1892 case Triple::amdil64:
1893 case Triple::bpfeb:
1894 case Triple::bpfel:
1895 case Triple::hsail64:
1897 case Triple::mips64:
1898 case Triple::mips64el:
1899 case Triple::nvptx64:
1900 case Triple::ppc64:
1901 case Triple::ppc64le:
1903 case Triple::riscv64:
1904 case Triple::riscv64be:
1905 case Triple::sparcv9:
1906 case Triple::spir64:
1907 case Triple::spirv64:
1908 case Triple::systemz:
1909 case Triple::ve:
1910 case Triple::wasm64:
1911 case Triple::x86_64:
1912 // Already 64-bit.
1913 break;
1914
1915 case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1916 case Triple::amdil: T.setArch(Triple::amdil64); break;
1917 case Triple::arm: T.setArch(Triple::aarch64); break;
1918 case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1919 case Triple::hsail: T.setArch(Triple::hsail64); break;
1920 case Triple::loongarch32: T.setArch(Triple::loongarch64); break;
1921 case Triple::mips:
1922 T.setArch(Triple::mips64, getSubArch());
1923 break;
1924 case Triple::mipsel:
1925 T.setArch(Triple::mips64el, getSubArch());
1926 break;
1927 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1928 case Triple::ppc: T.setArch(Triple::ppc64); break;
1929 case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1930 case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1931 case Triple::riscv32: T.setArch(Triple::riscv64); break;
1932 case Triple::riscv32be:
1933 T.setArch(Triple::riscv64be);
1934 break;
1935 case Triple::sparc: T.setArch(Triple::sparcv9); break;
1936 case Triple::spir: T.setArch(Triple::spir64); break;
1937 case Triple::spirv:
1938 case Triple::spirv32:
1939 T.setArch(Triple::spirv64, getSubArch());
1940 break;
1941 case Triple::thumb: T.setArch(Triple::aarch64); break;
1942 case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1943 case Triple::wasm32: T.setArch(Triple::wasm64); break;
1944 case Triple::x86: T.setArch(Triple::x86_64); break;
1945 }
1946 return T;
1947}
1948
1950 Triple T(*this);
1951 // Already big endian.
1952 if (!isLittleEndian())
1953 return T;
1954 switch (getArch()) {
1956 case Triple::amdgcn:
1957 case Triple::amdil64:
1958 case Triple::amdil:
1959 case Triple::avr:
1960 case Triple::dxil:
1961 case Triple::hexagon:
1962 case Triple::hsail64:
1963 case Triple::hsail:
1964 case Triple::kalimba:
1967 case Triple::msp430:
1968 case Triple::nvptx64:
1969 case Triple::nvptx:
1970 case Triple::r600:
1973 case Triple::shave:
1974 case Triple::spir64:
1975 case Triple::spir:
1976 case Triple::spirv:
1977 case Triple::spirv32:
1978 case Triple::spirv64:
1979 case Triple::wasm32:
1980 case Triple::wasm64:
1981 case Triple::x86:
1982 case Triple::x86_64:
1983 case Triple::xcore:
1984 case Triple::ve:
1985 case Triple::csky:
1986 case Triple::xtensa:
1987
1988 // ARM is intentionally unsupported here, changing the architecture would
1989 // drop any arch suffixes.
1990 case Triple::arm:
1991 case Triple::thumb:
1992 T.setArch(UnknownArch);
1993 break;
1994
1995 case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1996 case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1997 case Triple::mips64el:
1998 T.setArch(Triple::mips64, getSubArch());
1999 break;
2000 case Triple::mipsel:
2001 T.setArch(Triple::mips, getSubArch());
2002 break;
2003 case Triple::ppcle: T.setArch(Triple::ppc); break;
2004 case Triple::ppc64le: T.setArch(Triple::ppc64); break;
2005 case Triple::riscv32:
2006 T.setArch(Triple::riscv32be);
2007 break;
2008 case Triple::riscv64:
2009 T.setArch(Triple::riscv64be);
2010 break;
2011 case Triple::sparcel: T.setArch(Triple::sparc); break;
2012 case Triple::tcele: T.setArch(Triple::tce); break;
2013 default:
2014 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
2015 }
2016 return T;
2017}
2018
2020 Triple T(*this);
2021 if (isLittleEndian())
2022 return T;
2023
2024 switch (getArch()) {
2026 case Triple::lanai:
2027 case Triple::sparcv9:
2028 case Triple::systemz:
2029 case Triple::m68k:
2030
2031 // ARM is intentionally unsupported here, changing the architecture would
2032 // drop any arch suffixes.
2033 case Triple::armeb:
2034 case Triple::thumbeb:
2035 T.setArch(UnknownArch);
2036 break;
2037
2038 case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
2039 case Triple::bpfeb: T.setArch(Triple::bpfel); break;
2040 case Triple::mips64:
2041 T.setArch(Triple::mips64el, getSubArch());
2042 break;
2043 case Triple::mips:
2044 T.setArch(Triple::mipsel, getSubArch());
2045 break;
2046 case Triple::ppc: T.setArch(Triple::ppcle); break;
2047 case Triple::ppc64: T.setArch(Triple::ppc64le); break;
2048 case Triple::riscv32be:
2049 T.setArch(Triple::riscv32);
2050 break;
2051 case Triple::riscv64be:
2052 T.setArch(Triple::riscv64);
2053 break;
2054 case Triple::sparc: T.setArch(Triple::sparcel); break;
2055 case Triple::tce: T.setArch(Triple::tcele); break;
2056 default:
2057 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
2058 }
2059 return T;
2060}
2061
2063 switch (getArch()) {
2064 case Triple::aarch64:
2065 case Triple::aarch64_32:
2066 case Triple::amdgcn:
2067 case Triple::amdil64:
2068 case Triple::amdil:
2069 case Triple::arm:
2070 case Triple::avr:
2071 case Triple::bpfel:
2072 case Triple::csky:
2073 case Triple::dxil:
2074 case Triple::hexagon:
2075 case Triple::hsail64:
2076 case Triple::hsail:
2077 case Triple::kalimba:
2080 case Triple::mips64el:
2081 case Triple::mipsel:
2082 case Triple::msp430:
2083 case Triple::nvptx64:
2084 case Triple::nvptx:
2085 case Triple::ppcle:
2086 case Triple::ppc64le:
2087 case Triple::r600:
2090 case Triple::riscv32:
2091 case Triple::riscv64:
2092 case Triple::shave:
2093 case Triple::sparcel:
2094 case Triple::spir64:
2095 case Triple::spir:
2096 case Triple::spirv:
2097 case Triple::spirv32:
2098 case Triple::spirv64:
2099 case Triple::tcele:
2100 case Triple::thumb:
2101 case Triple::ve:
2102 case Triple::wasm32:
2103 case Triple::wasm64:
2104 case Triple::x86:
2105 case Triple::x86_64:
2106 case Triple::xcore:
2107 case Triple::xtensa:
2108 return true;
2109 default:
2110 return false;
2111 }
2112}
2113
2115 // On MinGW, C code is usually built with a "w64" vendor, while Rust
2116 // often uses a "pc" vendor.
2117 bool IgnoreVendor = isWindowsGNUEnvironment();
2118
2119 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
2120 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2121 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2122 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2123 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2124 if (getVendor() == Triple::Apple)
2125 return getSubArch() == Other.getSubArch() &&
2126 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2127 else
2128 return getSubArch() == Other.getSubArch() &&
2129 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2130 getOS() == Other.getOS() &&
2131 getEnvironment() == Other.getEnvironment() &&
2132 getObjectFormat() == Other.getObjectFormat();
2133 }
2134
2135 // If vendor is apple, ignore the version number (the environment field)
2136 // and the object format.
2137 if (getVendor() == Triple::Apple)
2138 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2139 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2140 getOS() == Other.getOS();
2141
2142 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2143 (getVendor() == Other.getVendor() || IgnoreVendor) &&
2144 getOS() == Other.getOS() &&
2145 getEnvironment() == Other.getEnvironment() &&
2146 getObjectFormat() == Other.getObjectFormat();
2147}
2148
2149std::string Triple::merge(const Triple &Other) const {
2150 // If vendor is apple, pick the triple with the larger version number.
2151 if (getVendor() == Triple::Apple)
2152 if (Other.isOSVersionLT(*this))
2153 return str();
2154
2155 return Other.str();
2156}
2157
2158bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2159 unsigned Micro) const {
2160 assert(isMacOSX() && "Not an OS X triple!");
2161
2162 // If this is OS X, expect a sane version number.
2163 if (getOS() == Triple::MacOSX)
2164 return isOSVersionLT(Major, Minor, Micro);
2165
2166 // Otherwise, compare to the "Darwin" number.
2167 if (Major == 10)
2168 return isOSVersionLT(Minor + 4, Micro, 0);
2169 assert(Major >= 11 && "Unexpected major version");
2170 if (Major < 25)
2171 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2172 return isOSVersionLT(Major + 1, Minor, Micro);
2173}
2174
2177 return VersionTuple();
2178 switch (getOS()) {
2179 case Triple::MacOSX:
2180 // ARM64 slice is supported starting from macOS 11.0+.
2181 return VersionTuple(11, 0, 0);
2182 case Triple::IOS:
2183 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2184 // ARM64 simulators are supported for iOS 14+.
2186 return VersionTuple(14, 0, 0);
2187 // ARM64e slice is supported starting from iOS 14.
2188 if (isArm64e())
2189 return VersionTuple(14, 0, 0);
2190 break;
2191 case Triple::TvOS:
2192 // ARM64 simulators are supported for tvOS 14+.
2194 return VersionTuple(14, 0, 0);
2195 break;
2196 case Triple::WatchOS:
2197 // ARM64 simulators are supported for watchOS 7+.
2199 return VersionTuple(7, 0, 0);
2200 // ARM64/ARM64e slices are supported starting from watchOS 26.
2201 // ARM64_32 is older though.
2203 return VersionTuple(26, 0, 0);
2204 case Triple::DriverKit:
2205 return VersionTuple(20, 0, 0);
2206 default:
2207 break;
2208 }
2209 return VersionTuple();
2210}
2211
2213 const VersionTuple &Version,
2214 bool IsInValidRange) {
2215 const unsigned MacOSRangeBump = 10;
2216 const unsigned IOSRangeBump = 7;
2217 const unsigned XROSRangeBump = 23;
2218 const unsigned WatchOSRangeBump = 14;
2219 switch (OSKind) {
2220 case MacOSX: {
2221 // macOS 10.16 is canonicalized to macOS 11.
2222 if (Version == VersionTuple(10, 16))
2223 return VersionTuple(11, 0);
2224 // macOS 16 is canonicalized to macOS 26.
2225 if (Version == VersionTuple(16, 0))
2226 return VersionTuple(26, 0);
2227 if (!IsInValidRange)
2228 return Version.withMajorReplaced(Version.getMajor() + MacOSRangeBump);
2229 break;
2230 }
2231 case IOS:
2232 case TvOS: {
2233 // Both iOS & tvOS 19.0 canonicalize to 26.
2234 if (Version == VersionTuple(19, 0))
2235 return VersionTuple(26, 0);
2236 if (!IsInValidRange)
2237 return Version.withMajorReplaced(Version.getMajor() + IOSRangeBump);
2238 break;
2239 }
2240 case XROS: {
2241 // visionOS3 is canonicalized to 26.
2242 if (Version == VersionTuple(3, 0))
2243 return VersionTuple(26, 0);
2244 if (!IsInValidRange)
2245 return Version.withMajorReplaced(Version.getMajor() + XROSRangeBump);
2246 break;
2247 }
2248 case WatchOS: {
2249 // watchOS 12 is canonicalized to 26.
2250 if (Version == VersionTuple(12, 0))
2251 return VersionTuple(26, 0);
2252 if (!IsInValidRange)
2253 return Version.withMajorReplaced(Version.getMajor() + WatchOSRangeBump);
2254 break;
2255 }
2256 default:
2257 return Version;
2258 }
2259
2260 return Version;
2261}
2262
2264 /// This constant is used to capture gaps in versioning.
2265 const VersionTuple CommonVersion(26);
2266 auto IsValid = [&](const VersionTuple &StartingVersion) {
2267 return !((Version > StartingVersion) && (Version < CommonVersion));
2268 };
2269 switch (OSKind) {
2270 case WatchOS: {
2271 const VersionTuple StartingWatchOS(12);
2272 return IsValid(StartingWatchOS);
2273 }
2274 case IOS:
2275 case TvOS: {
2276 const VersionTuple StartingIOS(19);
2277 return IsValid(StartingIOS);
2278 }
2279 case MacOSX: {
2280 const VersionTuple StartingMacOS(16);
2281 return IsValid(StartingMacOS);
2282 }
2283 case XROS: {
2284 const VersionTuple StartingXROS(3);
2285 return IsValid(StartingXROS);
2286 }
2287 default:
2288 return true;
2289 }
2290
2291 llvm_unreachable("unexpected or invalid os version");
2292}
2293
2295 if (isOSBinFormatCOFF()) {
2296 if (getArch() == Triple::x86 &&
2300 }
2301
2302 if (isOSBinFormatXCOFF())
2304 if (isOSBinFormatGOFF())
2306
2307 if (isARM() || isThumb()) {
2308 if (isOSBinFormatELF()) {
2311 }
2312
2315 }
2316
2317 if (isAArch64() || isX86() || isPPC() || isMIPS() || isSPARC() || isBPF() ||
2318 isRISCV() || isLoongArch())
2320
2321 switch (getArch()) {
2322 case Triple::arc:
2323 case Triple::csky:
2324 case Triple::hexagon:
2325 case Triple::lanai:
2326 case Triple::m68k:
2327 case Triple::msp430:
2328 case Triple::systemz:
2329 case Triple::xcore:
2330 case Triple::xtensa:
2332 default:
2333 break;
2334 }
2335
2336 // Explicitly none targets.
2337 if (isWasm() || isAMDGPU() || isNVPTX() || isSPIROrSPIRV())
2339
2340 // Default to none.
2342}
2343
2344// HLSL triple environment orders are relied on in the front end
2345static_assert(Triple::Vertex - Triple::Pixel == 1,
2346 "incorrect HLSL stage order");
2347static_assert(Triple::Geometry - Triple::Pixel == 2,
2348 "incorrect HLSL stage order");
2349static_assert(Triple::Hull - Triple::Pixel == 3,
2350 "incorrect HLSL stage order");
2351static_assert(Triple::Domain - Triple::Pixel == 4,
2352 "incorrect HLSL stage order");
2353static_assert(Triple::Compute - Triple::Pixel == 5,
2354 "incorrect HLSL stage order");
2355static_assert(Triple::Library - Triple::Pixel == 6,
2356 "incorrect HLSL stage order");
2357static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2358 "incorrect HLSL stage order");
2359static_assert(Triple::Intersection - Triple::Pixel == 8,
2360 "incorrect HLSL stage order");
2361static_assert(Triple::AnyHit - Triple::Pixel == 9,
2362 "incorrect HLSL stage order");
2363static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2364 "incorrect HLSL stage order");
2365static_assert(Triple::Miss - Triple::Pixel == 11,
2366 "incorrect HLSL stage order");
2367static_assert(Triple::Callable - Triple::Pixel == 12,
2368 "incorrect HLSL stage order");
2369static_assert(Triple::Mesh - Triple::Pixel == 13,
2370 "incorrect HLSL stage order");
2371static_assert(Triple::Amplification - Triple::Pixel == 14,
2372 "incorrect HLSL stage order");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
std::string Name
Load MIR Sample Profile
raw_pwrite_stream & OS
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:735
static VersionTuple parseVersionFromName(StringRef Name)
Definition: Triple.cpp:1402
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition: Triple.cpp:937
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition: Triple.cpp:508
static Triple::OSType parseOS(StringRef OSName)
Definition: Triple.cpp:688
static StringRef getDXILArchNameFromShaderModel(StringRef ShaderModelStr)
Definition: Triple.cpp:1107
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition: Triple.cpp:421
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition: Triple.cpp:806
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition: Triple.cpp:792
static Triple::ArchType parseArch(StringRef ArchName)
Definition: Triple.cpp:573
static Triple::VendorType parseVendor(StringRef VendorName)
Definition: Triple.cpp:667
Defines the llvm::VersionTuple class, which represents a version in the form major[....
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:203
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition: DenseMap.h:168
size_t size() const
Definition: SmallVector.h:79
void resize(size_type N)
Definition: SmallVector.h:639
void push_back(const T &Elt)
Definition: SmallVector.h:414
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:710
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition: StringRef.h:665
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:581
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:269
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:151
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition: StringRef.h:619
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:154
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:434
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:645
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:281
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:43
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:68
R Default(T Value)
Definition: StringSwitch.h:177
StringSwitch & StartsWith(StringLiteral S, T Value)
Definition: StringSwitch.h:80
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
Definition: StringSwitch.h:87
StringSwitch & EndsWith(StringLiteral S, T Value)
Definition: StringSwitch.h:73
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:47
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:2158
LLVM_ABI VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1435
bool isPPC() const
Tests whether the target is PowerPC (32- or 64-bit LE or BE).
Definition: Triple.h:1037
LLVM_ABI StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition: Triple.cpp:1380
LLVM_ABI VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1546
LLVM_ABI void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1653
LLVM_ABI void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition: Triple.cpp:1645
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1783
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition: Triple.h:714
bool isWatchABI() const
Definition: Triple.h:586
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ MuslABIN32
Definition: Triple.h:271
@ RayGeneration
Definition: Triple.h:298
@ GNUEABIT64
Definition: Triple.h:258
@ UnknownEnvironment
Definition: Triple.h:251
@ ClosestHit
Definition: Triple.h:301
@ MuslEABIHF
Definition: Triple.h:274
@ Amplification
Definition: Triple.h:305
@ Intersection
Definition: Triple.h:299
@ GNUEABIHFT64
Definition: Triple.h:260
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition: Triple.h:906
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:2212
CanonicalForm
Canonical form.
Definition: Triple.h:383
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition: Triple.h:513
LLVM_ABI llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:2019
bool isBPF() const
Tests whether the target is eBPF.
Definition: Triple.h:1137
static LLVM_ABI StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition: Triple.cpp:261
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition: Triple.h:434
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition: Triple.h:411
bool isX86() const
Tests whether the target is x86 (32- or 64-bit).
Definition: Triple.h:1099
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition: Triple.h:1119
bool isOSBinFormatGOFF() const
Tests whether the OS uses the GOFF binary format.
Definition: Triple.h:776
bool isWindowsGNUEnvironment() const
Definition: Triple.h:709
LLVM_ABI void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1657
@ HermitCore
Definition: Triple.h:240
@ ShaderModel
Definition: Triple.h:244
@ Emscripten
Definition: Triple.h:243
LLVM_ABI void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition: Triple.cpp:1674
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1866
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:2062
LLVM_ABI void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1637
LLVM_ABI StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition: Triple.cpp:1385
bool isSPIROrSPIRV() const
Definition: Triple.h:888
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition: Triple.cpp:2294
@ loongarch32
Definition: Triple.h:64
@ renderscript64
Definition: Triple.h:111
@ UnknownArch
Definition: Triple.h:50
@ aarch64_be
Definition: Triple.h:55
@ loongarch64
Definition: Triple.h:65
@ renderscript32
Definition: Triple.h:110
@ riscv32be
Definition: Triple.h:80
@ riscv64be
Definition: Triple.h:81
@ mips64el
Definition: Triple.h:70
@ aarch64_32
Definition: Triple.h:56
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition: Triple.cpp:1621
OSType getOS() const
Get the parsed operating system type of this triple.
Definition: Triple.h:417
LLVM_ABI VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1408
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:1152
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:436
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition: Triple.h:408
LLVM_ABI unsigned getTrampolineSize() const
Returns the trampoline size in bytes for this configuration.
Definition: Triple.cpp:1753
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:771
LLVM_ABI StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:1391
bool isSimulatorEnvironment() const
Definition: Triple.h:613
LLVM_ABI VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition: Triple.cpp:1608
const std::string & str() const
Definition: Triple.h:475
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition: Triple.h:425
LLVM_ABI VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition: Triple.cpp:1583
LLVM_ABI VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1571
static LLVM_ABI StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition: Triple.cpp:24
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition: Triple.h:789
static LLVM_ABI StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition: Triple.cpp:287
ObjectFormatType
Definition: Triple.h:314
@ DXContainer
Definition: Triple.h:318
@ UnknownObjectFormat
Definition: Triple.h:315
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition: Triple.h:911
LLVM_ABI std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:2149
bool isOSLinux() const
Tests whether the OS is Linux.
Definition: Triple.h:725
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition: Triple.h:1080
bool isAMDGPU() const
Definition: Triple.h:903
@ UnknownVendor
Definition: Triple.h:186
@ OpenEmbedded
Definition: Triple.h:200
@ ImaginationTechnologies
Definition: Triple.h:193
@ MipsTechnologies
Definition: Triple.h:194
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition: Triple.h:896
LLVM_ABI VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition: Triple.cpp:2175
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1771
LLVM_ABI StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition: Triple.cpp:1397
@ ARMSubArch_v6t2
Definition: Triple.h:148
@ MipsSubArch_r6
Definition: Triple.h:160
@ DXILSubArch_v1_2
Definition: Triple.h:176
@ ARMSubArch_v7
Definition: Triple.h:139
@ ARMSubArch_v8m_mainline
Definition: Triple.h:137
@ ARMSubArch_v9_6a
Definition: Triple.h:118
@ ARMSubArch_v8r
Definition: Triple.h:135
@ ARMSubArch_v9_1a
Definition: Triple.h:123
@ DXILSubArch_v1_1
Definition: Triple.h:175
@ LatestDXILSubArch
Definition: Triple.h:183
@ SPIRVSubArch_v10
Definition: Triple.h:165
@ SPIRVSubArch_v13
Definition: Triple.h:168
@ ARMSubArch_v7k
Definition: Triple.h:143
@ ARMSubArch_v8_7a
Definition: Triple.h:127
@ ARMSubArch_v8
Definition: Triple.h:134
@ SPIRVSubArch_v16
Definition: Triple.h:171
@ ARMSubArch_v8_1a
Definition: Triple.h:133
@ ARMSubArch_v9_2a
Definition: Triple.h:122
@ DXILSubArch_v1_3
Definition: Triple.h:177
@ SPIRVSubArch_v15
Definition: Triple.h:170
@ ARMSubArch_v7m
Definition: Triple.h:141
@ ARMSubArch_v6k
Definition: Triple.h:147
@ ARMSubArch_v5
Definition: Triple.h:149
@ AArch64SubArch_arm64e
Definition: Triple.h:153
@ ARMSubArch_v6
Definition: Triple.h:145
@ ARMSubArch_v9_5a
Definition: Triple.h:119
@ ARMSubArch_v7ve
Definition: Triple.h:144
@ ARMSubArch_v8m_baseline
Definition: Triple.h:136
@ ARMSubArch_v8_8a
Definition: Triple.h:126
@ ARMSubArch_v8_2a
Definition: Triple.h:132
@ ARMSubArch_v7s
Definition: Triple.h:142
@ DXILSubArch_v1_0
Definition: Triple.h:174
@ DXILSubArch_v1_7
Definition: Triple.h:181
@ KalimbaSubArch_v3
Definition: Triple.h:156
@ DXILSubArch_v1_5
Definition: Triple.h:179
@ ARMSubArch_v8_4a
Definition: Triple.h:130
@ ARMSubArch_v8_9a
Definition: Triple.h:125
@ ARMSubArch_v7em
Definition: Triple.h:140
@ SPIRVSubArch_v12
Definition: Triple.h:167
@ SPIRVSubArch_v14
Definition: Triple.h:169
@ KalimbaSubArch_v4
Definition: Triple.h:157
@ ARMSubArch_v8_1m_mainline
Definition: Triple.h:138
@ ARMSubArch_v8_3a
Definition: Triple.h:131
@ AArch64SubArch_arm64ec
Definition: Triple.h:154
@ ARMSubArch_v8_6a
Definition: Triple.h:128
@ ARMSubArch_v5te
Definition: Triple.h:150
@ KalimbaSubArch_v5
Definition: Triple.h:158
@ ARMSubArch_v4t
Definition: Triple.h:151
@ DXILSubArch_v1_6
Definition: Triple.h:180
@ DXILSubArch_v1_8
Definition: Triple.h:182
@ ARMSubArch_v9_4a
Definition: Triple.h:120
@ ARMSubArch_v8_5a
Definition: Triple.h:129
@ ARMSubArch_v6m
Definition: Triple.h:146
@ ARMSubArch_v9_3a
Definition: Triple.h:121
@ ARMSubArch_v9
Definition: Triple.h:124
@ DXILSubArch_v1_4
Definition: Triple.h:178
@ SPIRVSubArch_v11
Definition: Triple.h:166
@ PPCSubArch_spe
Definition: Triple.h:162
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:1449
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:2263
bool isMacOSX() const
Is this a Mac OS X triple.
Definition: Triple.h:563
LLVM_ABI void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition: Triple.cpp:1669
LLVM_ABI void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1633
LLVM_ABI void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1661
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition: Triple.h:414
bool isSPARC() const
Tests whether the target is SPARC.
Definition: Triple.h:1091
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition: Triple.h:608
static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition: Triple.cpp:337
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:541
bool empty() const
Whether the triple is empty / default constructed.
Definition: Triple.h:480
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition: Triple.h:1032
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition: Triple.h:1109
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1376
bool isMacCatalystEnvironment() const
Definition: Triple.h:617
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition: Triple.h:995
static LLVM_ABI StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition: Triple.cpp:406
LLVM_ABI bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1779
LLVM_ABI llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1949
LLVM_ABI VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1497
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:1412
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1775
LLVM_ABI bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:2114
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:766
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition: Triple.h:420
static LLVM_ABI StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:171
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1625
LLVM_ABI void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1629
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
Definition: Triple.h:1019
bool isWindowsItaniumEnvironment() const
Definition: Triple.h:701
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]]].
Definition: VersionTuple.h:30
unsigned getMajor() const
Retrieve the major version number.
Definition: VersionTuple.h:72
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
Definition: VersionTuple.h:67
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
Definition: VersionTuple.h:75
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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 ArchKind parseArch(StringRef Arch)
LLVM_ABI ProfileKind parseArchProfile(StringRef Arch)
LLVM_ABI unsigned parseArchVersion(StringRef Arch)
LLVM_ABI EndianKind parseArchEndian(StringRef Arch)
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
constexpr bool IsLittleEndianHost
Definition: SwapByteOrder.h:29
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ExceptionHandling
Definition: CodeGen.h:53
@ SjLj
setjmp/longjmp based exceptions
@ ZOS
z/OS MVS Exception Handling.
@ None
No exception support.
@ AIX
AIX Exception Handling.
@ DwarfCFI
DWARF-like instruction based exceptions.
@ WinEH
Windows Exception Handling.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition: Error.cpp:167
@ Other
Any other memory.
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:1886
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:858