LLVM 20.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 le32: return "le32";
48 case le64: return "le64";
49 case loongarch32: return "loongarch32";
50 case loongarch64: return "loongarch64";
51 case m68k: return "m68k";
52 case mips64: return "mips64";
53 case mips64el: return "mips64el";
54 case mips: return "mips";
55 case mipsel: return "mipsel";
56 case msp430: return "msp430";
57 case nvptx64: return "nvptx64";
58 case nvptx: return "nvptx";
59 case ppc64: return "powerpc64";
60 case ppc64le: return "powerpc64le";
61 case ppc: return "powerpc";
62 case ppcle: return "powerpcle";
63 case r600: return "r600";
64 case renderscript32: return "renderscript32";
65 case renderscript64: return "renderscript64";
66 case riscv32: return "riscv32";
67 case riscv64: return "riscv64";
68 case shave: return "shave";
69 case sparc: return "sparc";
70 case sparcel: return "sparcel";
71 case sparcv9: return "sparcv9";
72 case spir64: return "spir64";
73 case spir: return "spir";
74 case spirv: return "spirv";
75 case spirv32: return "spirv32";
76 case spirv64: return "spirv64";
77 case systemz: return "s390x";
78 case tce: return "tce";
79 case tcele: return "tcele";
80 case thumb: return "thumb";
81 case thumbeb: return "thumbeb";
82 case ve: return "ve";
83 case wasm32: return "wasm32";
84 case wasm64: return "wasm64";
85 case x86: return "i386";
86 case x86_64: return "x86_64";
87 case xcore: return "xcore";
88 case xtensa: return "xtensa";
89 }
90
91 llvm_unreachable("Invalid ArchType!");
92}
93
95 switch (Kind) {
96 case Triple::mips:
97 if (SubArch == MipsSubArch_r6)
98 return "mipsisa32r6";
99 break;
100 case Triple::mipsel:
101 if (SubArch == MipsSubArch_r6)
102 return "mipsisa32r6el";
103 break;
104 case Triple::mips64:
105 if (SubArch == MipsSubArch_r6)
106 return "mipsisa64r6";
107 break;
108 case Triple::mips64el:
109 if (SubArch == MipsSubArch_r6)
110 return "mipsisa64r6el";
111 break;
112 case Triple::aarch64:
113 if (SubArch == AArch64SubArch_arm64ec)
114 return "arm64ec";
115 if (SubArch == AArch64SubArch_arm64e)
116 return "arm64e";
117 break;
118 case Triple::dxil:
119 switch (SubArch) {
122 return "dxilv1.0";
124 return "dxilv1.1";
126 return "dxilv1.2";
128 return "dxilv1.3";
130 return "dxilv1.4";
132 return "dxilv1.5";
134 return "dxilv1.6";
136 return "dxilv1.7";
138 return "dxilv1.8";
139 default:
140 break;
141 }
142 break;
143 default:
144 break;
145 }
146 return getArchTypeName(Kind);
147}
148
150 switch (Kind) {
151 default:
152 return StringRef();
153
154 case aarch64:
155 case aarch64_be:
156 case aarch64_32: return "aarch64";
157
158 case arc: return "arc";
159
160 case arm:
161 case armeb:
162 case thumb:
163 case thumbeb: return "arm";
164
165 case avr: return "avr";
166
167 case ppc64:
168 case ppc64le:
169 case ppc:
170 case ppcle: return "ppc";
171
172 case m68k: return "m68k";
173
174 case mips:
175 case mipsel:
176 case mips64:
177 case mips64el: return "mips";
178
179 case hexagon: return "hexagon";
180
181 case amdgcn: return "amdgcn";
182 case r600: return "r600";
183
184 case bpfel:
185 case bpfeb: return "bpf";
186
187 case sparcv9:
188 case sparcel:
189 case sparc: return "sparc";
190
191 case systemz: return "s390";
192
193 case x86:
194 case x86_64: return "x86";
195
196 case xcore: return "xcore";
197
198 // NVPTX intrinsics are namespaced under nvvm.
199 case nvptx: return "nvvm";
200 case nvptx64: return "nvvm";
201
202 case le32: return "le32";
203 case le64: return "le64";
204
205 case amdil:
206 case amdil64: return "amdil";
207
208 case hsail:
209 case hsail64: return "hsail";
210
211 case spir:
212 case spir64: return "spir";
213
214 case spirv:
215 case spirv32:
216 case spirv64: return "spv";
217
218 case kalimba: return "kalimba";
219 case lanai: return "lanai";
220 case shave: return "shave";
221 case wasm32:
222 case wasm64: return "wasm";
223
224 case riscv32:
225 case riscv64: return "riscv";
226
227 case ve: return "ve";
228 case csky: return "csky";
229
230 case loongarch32:
231 case loongarch64: return "loongarch";
232
233 case dxil: return "dx";
234
235 case xtensa: return "xtensa";
236 }
237}
238
240 switch (Kind) {
241 case UnknownVendor: return "unknown";
242
243 case AMD: return "amd";
244 case Apple: return "apple";
245 case CSR: return "csr";
246 case Freescale: return "fsl";
247 case IBM: return "ibm";
248 case ImaginationTechnologies: return "img";
249 case Mesa: return "mesa";
250 case MipsTechnologies: return "mti";
251 case NVIDIA: return "nvidia";
252 case OpenEmbedded: return "oe";
253 case PC: return "pc";
254 case SCEI: return "scei";
255 case SUSE: return "suse";
256 }
257
258 llvm_unreachable("Invalid VendorType!");
259}
260
262 switch (Kind) {
263 case UnknownOS: return "unknown";
264
265 case AIX: return "aix";
266 case AMDHSA: return "amdhsa";
267 case AMDPAL: return "amdpal";
268 case BridgeOS: return "bridgeos";
269 case CUDA: return "cuda";
270 case Darwin: return "darwin";
271 case DragonFly: return "dragonfly";
272 case DriverKit: return "driverkit";
273 case ELFIAMCU: return "elfiamcu";
274 case Emscripten: return "emscripten";
275 case FreeBSD: return "freebsd";
276 case Fuchsia: return "fuchsia";
277 case Haiku: return "haiku";
278 case HermitCore: return "hermit";
279 case Hurd: return "hurd";
280 case IOS: return "ios";
281 case KFreeBSD: return "kfreebsd";
282 case Linux: return "linux";
283 case Lv2: return "lv2";
284 case MacOSX: return "macosx";
285 case Mesa3D: return "mesa3d";
286 case NVCL: return "nvcl";
287 case NaCl: return "nacl";
288 case NetBSD: return "netbsd";
289 case OpenBSD: return "openbsd";
290 case PS4: return "ps4";
291 case PS5: return "ps5";
292 case RTEMS: return "rtems";
293 case Solaris: return "solaris";
294 case Serenity: return "serenity";
295 case TvOS: return "tvos";
296 case UEFI: return "uefi";
297 case WASI: return "wasi";
298 case WatchOS: return "watchos";
299 case Win32: return "windows";
300 case ZOS: return "zos";
301 case ShaderModel: return "shadermodel";
302 case LiteOS: return "liteos";
303 case XROS: return "xros";
304 case Vulkan: return "vulkan";
305 }
306
307 llvm_unreachable("Invalid OSType");
308}
309
311 switch (Kind) {
312 case UnknownEnvironment: return "unknown";
313 case Android: return "android";
314 case CODE16: return "code16";
315 case CoreCLR: return "coreclr";
316 case Cygnus: return "cygnus";
317 case EABI: return "eabi";
318 case EABIHF: return "eabihf";
319 case GNU: return "gnu";
320 case GNUABI64: return "gnuabi64";
321 case GNUABIN32: return "gnuabin32";
322 case GNUEABI: return "gnueabi";
323 case GNUEABIHF: return "gnueabihf";
324 case GNUF32: return "gnuf32";
325 case GNUF64: return "gnuf64";
326 case GNUSF: return "gnusf";
327 case GNUX32: return "gnux32";
328 case GNUILP32: return "gnu_ilp32";
329 case Itanium: return "itanium";
330 case MSVC: return "msvc";
331 case MacABI: return "macabi";
332 case Musl: return "musl";
333 case MuslEABI: return "musleabi";
334 case MuslEABIHF: return "musleabihf";
335 case MuslX32: return "muslx32";
336 case Simulator: return "simulator";
337 case Pixel: return "pixel";
338 case Vertex: return "vertex";
339 case Geometry: return "geometry";
340 case Hull: return "hull";
341 case Domain: return "domain";
342 case Compute: return "compute";
343 case Library: return "library";
344 case RayGeneration: return "raygeneration";
345 case Intersection: return "intersection";
346 case AnyHit: return "anyhit";
347 case ClosestHit: return "closesthit";
348 case Miss: return "miss";
349 case Callable: return "callable";
350 case Mesh: return "mesh";
351 case Amplification: return "amplification";
352 case OpenCL:
353 return "opencl";
354 case OpenHOS: return "ohos";
355 case PAuthTest:
356 return "pauthtest";
357 }
358
359 llvm_unreachable("Invalid EnvironmentType!");
360}
361
363 switch (Kind) {
364 case UnknownObjectFormat: return "";
365 case COFF: return "coff";
366 case ELF: return "elf";
367 case GOFF: return "goff";
368 case MachO: return "macho";
369 case Wasm: return "wasm";
370 case XCOFF: return "xcoff";
371 case DXContainer: return "dxcontainer";
372 case SPIRV: return "spirv";
373 }
374 llvm_unreachable("unknown object format type");
375}
376
378 if (ArchName == "bpf") {
380 return Triple::bpfel;
381 else
382 return Triple::bpfeb;
383 } else if (ArchName == "bpf_be" || ArchName == "bpfeb") {
384 return Triple::bpfeb;
385 } else if (ArchName == "bpf_le" || ArchName == "bpfel") {
386 return Triple::bpfel;
387 } else {
388 return Triple::UnknownArch;
389 }
390}
391
395 .Case("aarch64", aarch64)
396 .Case("aarch64_be", aarch64_be)
397 .Case("aarch64_32", aarch64_32)
398 .Case("arc", arc)
399 .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
400 .Case("arm64_32", aarch64_32)
401 .Case("arm", arm)
402 .Case("armeb", armeb)
403 .Case("avr", avr)
404 .StartsWith("bpf", BPFArch)
405 .Case("m68k", m68k)
406 .Case("mips", mips)
407 .Case("mipsel", mipsel)
408 .Case("mips64", mips64)
409 .Case("mips64el", mips64el)
410 .Case("msp430", msp430)
411 .Case("ppc64", ppc64)
412 .Case("ppc32", ppc)
413 .Case("ppc", ppc)
414 .Case("ppc32le", ppcle)
415 .Case("ppcle", ppcle)
416 .Case("ppc64le", ppc64le)
417 .Case("r600", r600)
418 .Case("amdgcn", amdgcn)
419 .Case("riscv32", riscv32)
420 .Case("riscv64", riscv64)
421 .Case("hexagon", hexagon)
422 .Case("sparc", sparc)
423 .Case("sparcel", sparcel)
424 .Case("sparcv9", sparcv9)
425 .Case("s390x", systemz)
426 .Case("systemz", systemz)
427 .Case("tce", tce)
428 .Case("tcele", tcele)
429 .Case("thumb", thumb)
430 .Case("thumbeb", thumbeb)
431 .Case("x86", x86)
432 .Case("i386", x86)
433 .Case("x86-64", x86_64)
434 .Case("xcore", xcore)
435 .Case("nvptx", nvptx)
436 .Case("nvptx64", nvptx64)
437 .Case("le32", le32)
438 .Case("le64", le64)
439 .Case("amdil", amdil)
440 .Case("amdil64", amdil64)
441 .Case("hsail", hsail)
442 .Case("hsail64", hsail64)
443 .Case("spir", spir)
444 .Case("spir64", spir64)
445 .Case("spirv", spirv)
446 .Case("spirv32", spirv32)
447 .Case("spirv64", spirv64)
448 .Case("kalimba", kalimba)
449 .Case("lanai", lanai)
450 .Case("shave", shave)
451 .Case("wasm32", wasm32)
452 .Case("wasm64", wasm64)
453 .Case("renderscript32", renderscript32)
454 .Case("renderscript64", renderscript64)
455 .Case("ve", ve)
456 .Case("csky", csky)
457 .Case("loongarch32", loongarch32)
458 .Case("loongarch64", loongarch64)
459 .Case("dxil", dxil)
460 .Case("xtensa", xtensa)
462}
463
465 ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
466 ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
467
469 switch (ENDIAN) {
471 switch (ISA) {
473 arch = Triple::arm;
474 break;
476 arch = Triple::thumb;
477 break;
479 arch = Triple::aarch64;
480 break;
482 break;
483 }
484 break;
485 }
487 switch (ISA) {
489 arch = Triple::armeb;
490 break;
492 arch = Triple::thumbeb;
493 break;
495 arch = Triple::aarch64_be;
496 break;
498 break;
499 }
500 break;
501 }
503 break;
504 }
505 }
506
507 ArchName = ARM::getCanonicalArchName(ArchName);
508 if (ArchName.empty())
509 return Triple::UnknownArch;
510
511 // Thumb only exists in v4+
512 if (ISA == ARM::ISAKind::THUMB &&
513 (ArchName.starts_with("v2") || ArchName.starts_with("v3")))
514 return Triple::UnknownArch;
515
516 // Thumb only for v6m
518 unsigned Version = ARM::parseArchVersion(ArchName);
519 if (Profile == ARM::ProfileKind::M && Version == 6) {
520 if (ENDIAN == ARM::EndianKind::BIG)
521 return Triple::thumbeb;
522 else
523 return Triple::thumb;
524 }
525
526 return arch;
527}
528
530 auto AT =
532 .Cases("i386", "i486", "i586", "i686", Triple::x86)
533 // FIXME: Do we need to support these?
534 .Cases("i786", "i886", "i986", Triple::x86)
535 .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
536 .Cases("powerpc", "powerpcspe", "ppc", "ppc32", Triple::ppc)
537 .Cases("powerpcle", "ppcle", "ppc32le", Triple::ppcle)
538 .Cases("powerpc64", "ppu", "ppc64", Triple::ppc64)
539 .Cases("powerpc64le", "ppc64le", Triple::ppc64le)
540 .Case("xscale", Triple::arm)
541 .Case("xscaleeb", Triple::armeb)
542 .Case("aarch64", Triple::aarch64)
543 .Case("aarch64_be", Triple::aarch64_be)
544 .Case("aarch64_32", Triple::aarch64_32)
545 .Case("arc", Triple::arc)
546 .Case("arm64", Triple::aarch64)
547 .Case("arm64_32", Triple::aarch64_32)
548 .Case("arm64e", Triple::aarch64)
549 .Case("arm64ec", Triple::aarch64)
550 .Case("arm", Triple::arm)
551 .Case("armeb", Triple::armeb)
552 .Case("thumb", Triple::thumb)
553 .Case("thumbeb", Triple::thumbeb)
554 .Case("avr", Triple::avr)
555 .Case("m68k", Triple::m68k)
556 .Case("msp430", Triple::msp430)
557 .Cases("mips", "mipseb", "mipsallegrex", "mipsisa32r6", "mipsr6",
559 .Cases("mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el",
561 .Cases("mips64", "mips64eb", "mipsn32", "mipsisa64r6", "mips64r6",
562 "mipsn32r6", Triple::mips64)
563 .Cases("mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
564 "mipsn32r6el", Triple::mips64el)
565 .Case("r600", Triple::r600)
566 .Case("amdgcn", Triple::amdgcn)
567 .Case("riscv32", Triple::riscv32)
568 .Case("riscv64", Triple::riscv64)
569 .Case("hexagon", Triple::hexagon)
570 .Cases("s390x", "systemz", Triple::systemz)
571 .Case("sparc", Triple::sparc)
572 .Case("sparcel", Triple::sparcel)
573 .Cases("sparcv9", "sparc64", Triple::sparcv9)
574 .Case("tce", Triple::tce)
575 .Case("tcele", Triple::tcele)
576 .Case("xcore", Triple::xcore)
577 .Case("nvptx", Triple::nvptx)
578 .Case("nvptx64", Triple::nvptx64)
579 .Case("le32", Triple::le32)
580 .Case("le64", Triple::le64)
581 .Case("amdil", Triple::amdil)
582 .Case("amdil64", Triple::amdil64)
583 .Case("hsail", Triple::hsail)
584 .Case("hsail64", Triple::hsail64)
585 .Case("spir", Triple::spir)
586 .Case("spir64", Triple::spir64)
587 .Cases("spirv", "spirv1.5", "spirv1.6", Triple::spirv)
588 .Cases("spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
589 "spirv32v1.3", "spirv32v1.4", "spirv32v1.5",
590 "spirv32v1.6", Triple::spirv32)
591 .Cases("spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
592 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5",
593 "spirv64v1.6", Triple::spirv64)
594 .StartsWith("kalimba", Triple::kalimba)
595 .Case("lanai", Triple::lanai)
596 .Case("renderscript32", Triple::renderscript32)
597 .Case("renderscript64", Triple::renderscript64)
598 .Case("shave", Triple::shave)
599 .Case("ve", Triple::ve)
600 .Case("wasm32", Triple::wasm32)
601 .Case("wasm64", Triple::wasm64)
602 .Case("csky", Triple::csky)
603 .Case("loongarch32", Triple::loongarch32)
604 .Case("loongarch64", Triple::loongarch64)
605 .Cases("dxil", "dxilv1.0", "dxilv1.1", "dxilv1.2", "dxilv1.3",
606 "dxilv1.4", "dxilv1.5", "dxilv1.6", "dxilv1.7", "dxilv1.8",
608 .Case("xtensa", Triple::xtensa)
610
611 // Some architectures require special parsing logic just to compute the
612 // ArchType result.
613 if (AT == Triple::UnknownArch) {
614 if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
615 ArchName.starts_with("aarch64"))
616 return parseARMArch(ArchName);
617 if (ArchName.starts_with("bpf"))
618 return parseBPFArch(ArchName);
619 }
620
621 return AT;
622}
623
625 return StringSwitch<Triple::VendorType>(VendorName)
626 .Case("apple", Triple::Apple)
627 .Case("pc", Triple::PC)
628 .Case("scei", Triple::SCEI)
629 .Case("sie", Triple::SCEI)
630 .Case("fsl", Triple::Freescale)
631 .Case("ibm", Triple::IBM)
634 .Case("nvidia", Triple::NVIDIA)
635 .Case("csr", Triple::CSR)
636 .Case("amd", Triple::AMD)
637 .Case("mesa", Triple::Mesa)
638 .Case("suse", Triple::SUSE)
641}
642
644 return StringSwitch<Triple::OSType>(OSName)
645 .StartsWith("darwin", Triple::Darwin)
646 .StartsWith("dragonfly", Triple::DragonFly)
647 .StartsWith("freebsd", Triple::FreeBSD)
648 .StartsWith("fuchsia", Triple::Fuchsia)
649 .StartsWith("ios", Triple::IOS)
650 .StartsWith("kfreebsd", Triple::KFreeBSD)
651 .StartsWith("linux", Triple::Linux)
652 .StartsWith("lv2", Triple::Lv2)
653 .StartsWith("macos", Triple::MacOSX)
654 .StartsWith("netbsd", Triple::NetBSD)
655 .StartsWith("openbsd", Triple::OpenBSD)
656 .StartsWith("solaris", Triple::Solaris)
657 .StartsWith("uefi", Triple::UEFI)
658 .StartsWith("win32", Triple::Win32)
659 .StartsWith("windows", Triple::Win32)
660 .StartsWith("zos", Triple::ZOS)
661 .StartsWith("haiku", Triple::Haiku)
662 .StartsWith("rtems", Triple::RTEMS)
663 .StartsWith("nacl", Triple::NaCl)
664 .StartsWith("aix", Triple::AIX)
665 .StartsWith("cuda", Triple::CUDA)
666 .StartsWith("nvcl", Triple::NVCL)
667 .StartsWith("amdhsa", Triple::AMDHSA)
668 .StartsWith("ps4", Triple::PS4)
669 .StartsWith("ps5", Triple::PS5)
670 .StartsWith("elfiamcu", Triple::ELFIAMCU)
671 .StartsWith("tvos", Triple::TvOS)
672 .StartsWith("watchos", Triple::WatchOS)
673 .StartsWith("bridgeos", Triple::BridgeOS)
674 .StartsWith("driverkit", Triple::DriverKit)
675 .StartsWith("xros", Triple::XROS)
676 .StartsWith("visionos", Triple::XROS)
677 .StartsWith("mesa3d", Triple::Mesa3D)
678 .StartsWith("amdpal", Triple::AMDPAL)
680 .StartsWith("hurd", Triple::Hurd)
681 .StartsWith("wasi", Triple::WASI)
682 .StartsWith("emscripten", Triple::Emscripten)
683 .StartsWith("shadermodel", Triple::ShaderModel)
684 .StartsWith("liteos", Triple::LiteOS)
685 .StartsWith("serenity", Triple::Serenity)
686 .StartsWith("vulkan", Triple::Vulkan)
688}
689
691 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
692 .StartsWith("eabihf", Triple::EABIHF)
693 .StartsWith("eabi", Triple::EABI)
694 .StartsWith("gnuabin32", Triple::GNUABIN32)
695 .StartsWith("gnuabi64", Triple::GNUABI64)
696 .StartsWith("gnueabihf", Triple::GNUEABIHF)
697 .StartsWith("gnueabi", Triple::GNUEABI)
698 .StartsWith("gnuf32", Triple::GNUF32)
699 .StartsWith("gnuf64", Triple::GNUF64)
700 .StartsWith("gnusf", Triple::GNUSF)
701 .StartsWith("gnux32", Triple::GNUX32)
702 .StartsWith("gnu_ilp32", Triple::GNUILP32)
703 .StartsWith("code16", Triple::CODE16)
704 .StartsWith("gnu", Triple::GNU)
705 .StartsWith("android", Triple::Android)
706 .StartsWith("musleabihf", Triple::MuslEABIHF)
707 .StartsWith("musleabi", Triple::MuslEABI)
708 .StartsWith("muslx32", Triple::MuslX32)
709 .StartsWith("musl", Triple::Musl)
710 .StartsWith("msvc", Triple::MSVC)
711 .StartsWith("itanium", Triple::Itanium)
712 .StartsWith("cygnus", Triple::Cygnus)
713 .StartsWith("coreclr", Triple::CoreCLR)
714 .StartsWith("simulator", Triple::Simulator)
715 .StartsWith("macabi", Triple::MacABI)
716 .StartsWith("pixel", Triple::Pixel)
717 .StartsWith("vertex", Triple::Vertex)
718 .StartsWith("geometry", Triple::Geometry)
719 .StartsWith("hull", Triple::Hull)
720 .StartsWith("domain", Triple::Domain)
721 .StartsWith("compute", Triple::Compute)
722 .StartsWith("library", Triple::Library)
723 .StartsWith("raygeneration", Triple::RayGeneration)
724 .StartsWith("intersection", Triple::Intersection)
725 .StartsWith("anyhit", Triple::AnyHit)
726 .StartsWith("closesthit", Triple::ClosestHit)
727 .StartsWith("miss", Triple::Miss)
728 .StartsWith("callable", Triple::Callable)
729 .StartsWith("mesh", Triple::Mesh)
730 .StartsWith("amplification", Triple::Amplification)
731 .StartsWith("opencl", Triple::OpenCL)
733 .StartsWith("pauthtest", Triple::PAuthTest)
735}
736
738 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
739 // "xcoff" must come before "coff" because of the order-dependendent
740 // pattern matching.
741 .EndsWith("xcoff", Triple::XCOFF)
742 .EndsWith("coff", Triple::COFF)
743 .EndsWith("elf", Triple::ELF)
744 .EndsWith("goff", Triple::GOFF)
745 .EndsWith("macho", Triple::MachO)
746 .EndsWith("wasm", Triple::Wasm)
747 .EndsWith("spirv", Triple::SPIRV)
749}
750
752 if (SubArchName.starts_with("mips") &&
753 (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
755
756 if (SubArchName == "powerpcspe")
758
759 if (SubArchName == "arm64e")
761
762 if (SubArchName == "arm64ec")
764
765 if (SubArchName.starts_with("spirv"))
766 return StringSwitch<Triple::SubArchType>(SubArchName)
775
776 if (SubArchName.starts_with("dxil"))
777 return StringSwitch<Triple::SubArchType>(SubArchName)
788
789 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
790
791 // For now, this is the small part. Early return.
792 if (ARMSubArch.empty())
793 return StringSwitch<Triple::SubArchType>(SubArchName)
798
799 // ARM sub arch.
800 switch(ARM::parseArch(ARMSubArch)) {
801 case ARM::ArchKind::ARMV4:
802 return Triple::NoSubArch;
803 case ARM::ArchKind::ARMV4T:
805 case ARM::ArchKind::ARMV5T:
807 case ARM::ArchKind::ARMV5TE:
808 case ARM::ArchKind::IWMMXT:
809 case ARM::ArchKind::IWMMXT2:
810 case ARM::ArchKind::XSCALE:
811 case ARM::ArchKind::ARMV5TEJ:
813 case ARM::ArchKind::ARMV6:
815 case ARM::ArchKind::ARMV6K:
816 case ARM::ArchKind::ARMV6KZ:
818 case ARM::ArchKind::ARMV6T2:
820 case ARM::ArchKind::ARMV6M:
822 case ARM::ArchKind::ARMV7A:
823 case ARM::ArchKind::ARMV7R:
825 case ARM::ArchKind::ARMV7VE:
827 case ARM::ArchKind::ARMV7K:
829 case ARM::ArchKind::ARMV7M:
831 case ARM::ArchKind::ARMV7S:
833 case ARM::ArchKind::ARMV7EM:
835 case ARM::ArchKind::ARMV8A:
837 case ARM::ArchKind::ARMV8_1A:
839 case ARM::ArchKind::ARMV8_2A:
841 case ARM::ArchKind::ARMV8_3A:
843 case ARM::ArchKind::ARMV8_4A:
845 case ARM::ArchKind::ARMV8_5A:
847 case ARM::ArchKind::ARMV8_6A:
849 case ARM::ArchKind::ARMV8_7A:
851 case ARM::ArchKind::ARMV8_8A:
853 case ARM::ArchKind::ARMV8_9A:
855 case ARM::ArchKind::ARMV9A:
857 case ARM::ArchKind::ARMV9_1A:
859 case ARM::ArchKind::ARMV9_2A:
861 case ARM::ArchKind::ARMV9_3A:
863 case ARM::ArchKind::ARMV9_4A:
865 case ARM::ArchKind::ARMV9_5A:
867 case ARM::ArchKind::ARMV8R:
869 case ARM::ArchKind::ARMV8MBaseline:
871 case ARM::ArchKind::ARMV8MMainline:
873 case ARM::ArchKind::ARMV8_1MMainline:
875 default:
876 return Triple::NoSubArch;
877 }
878}
879
881 switch (T.getArch()) {
883 case Triple::aarch64:
885 case Triple::arm:
886 case Triple::thumb:
887 case Triple::x86:
888 case Triple::x86_64:
889 switch (T.getOS()) {
890 case Triple::Win32:
891 case Triple::UEFI:
892 return Triple::COFF;
893 default:
894 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
895 }
897 case Triple::amdgcn:
898 case Triple::amdil64:
899 case Triple::amdil:
900 case Triple::arc:
901 case Triple::armeb:
902 case Triple::avr:
903 case Triple::bpfeb:
904 case Triple::bpfel:
905 case Triple::csky:
906 case Triple::hexagon:
907 case Triple::hsail64:
908 case Triple::hsail:
909 case Triple::kalimba:
910 case Triple::lanai:
911 case Triple::le32:
912 case Triple::le64:
915 case Triple::m68k:
916 case Triple::mips64:
917 case Triple::mips64el:
918 case Triple::mips:
919 case Triple::mipsel:
920 case Triple::msp430:
921 case Triple::nvptx64:
922 case Triple::nvptx:
923 case Triple::ppc64le:
924 case Triple::ppcle:
925 case Triple::r600:
928 case Triple::riscv32:
929 case Triple::riscv64:
930 case Triple::shave:
931 case Triple::sparc:
932 case Triple::sparcel:
933 case Triple::sparcv9:
934 case Triple::spir64:
935 case Triple::spir:
936 case Triple::tce:
937 case Triple::tcele:
938 case Triple::thumbeb:
939 case Triple::ve:
940 case Triple::xcore:
941 case Triple::xtensa:
942 return Triple::ELF;
943
944 case Triple::ppc64:
945 case Triple::ppc:
946 if (T.isOSAIX())
947 return Triple::XCOFF;
948 if (T.isOSDarwin())
949 return Triple::MachO;
950 return Triple::ELF;
951
952 case Triple::systemz:
953 if (T.isOSzOS())
954 return Triple::GOFF;
955 return Triple::ELF;
956
957 case Triple::wasm32:
958 case Triple::wasm64:
959 return Triple::Wasm;
960
961 case Triple::spirv:
962 case Triple::spirv32:
963 case Triple::spirv64:
964 return Triple::SPIRV;
965
966 case Triple::dxil:
967 return Triple::DXContainer;
968 }
969 llvm_unreachable("unknown architecture");
970}
971
972/// Construct a triple from the string representation provided.
973///
974/// This stores the string representation and parses the various pieces into
975/// enum members.
977 : Data(Str.str()), Arch(UnknownArch), SubArch(NoSubArch),
978 Vendor(UnknownVendor), OS(UnknownOS), Environment(UnknownEnvironment),
979 ObjectFormat(UnknownObjectFormat) {
980 // Do minimal parsing by hand here.
981 SmallVector<StringRef, 4> Components;
982 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
983 if (Components.size() > 0) {
984 Arch = parseArch(Components[0]);
985 SubArch = parseSubArch(Components[0]);
986 if (Components.size() > 1) {
987 Vendor = parseVendor(Components[1]);
988 if (Components.size() > 2) {
989 OS = parseOS(Components[2]);
990 if (Components.size() > 3) {
991 Environment = parseEnvironment(Components[3]);
992 ObjectFormat = parseFormat(Components[3]);
993 }
994 }
995 } else {
996 Environment =
998 .StartsWith("mipsn32", Triple::GNUABIN32)
999 .StartsWith("mips64", Triple::GNUABI64)
1000 .StartsWith("mipsisa64", Triple::GNUABI64)
1001 .StartsWith("mipsisa32", Triple::GNU)
1002 .Cases("mips", "mipsel", "mipsr6", "mipsr6el", Triple::GNU)
1004 }
1005 }
1006 if (ObjectFormat == UnknownObjectFormat)
1007 ObjectFormat = getDefaultFormat(*this);
1008}
1009
1010/// Construct a triple from string representations of the architecture,
1011/// vendor, and OS.
1012///
1013/// This joins each argument into a canonical string representation and parses
1014/// them into enum members. It leaves the environment unknown and omits it from
1015/// the string representation.
1016Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1017 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1018 Arch(parseArch(ArchStr.str())),
1019 SubArch(parseSubArch(ArchStr.str())),
1020 Vendor(parseVendor(VendorStr.str())),
1021 OS(parseOS(OSStr.str())),
1022 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1023 ObjectFormat = getDefaultFormat(*this);
1024}
1025
1026/// Construct a triple from string representations of the architecture,
1027/// vendor, OS, and environment.
1028///
1029/// This joins each argument into a canonical string representation and parses
1030/// them into enum members.
1031Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1032 const Twine &EnvironmentStr)
1033 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1034 EnvironmentStr).str()),
1035 Arch(parseArch(ArchStr.str())),
1036 SubArch(parseSubArch(ArchStr.str())),
1037 Vendor(parseVendor(VendorStr.str())),
1038 OS(parseOS(OSStr.str())),
1039 Environment(parseEnvironment(EnvironmentStr.str())),
1040 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1041 if (ObjectFormat == Triple::UnknownObjectFormat)
1042 ObjectFormat = getDefaultFormat(*this);
1043}
1044
1046
1048 VersionTuple Ver =
1049 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1050 // Default DXIL minor version when Shader Model version is anything other
1051 // than 6.[0...8] or 6.x (which translates to latest current SM version)
1052 const unsigned SMMajor = 6;
1053 if (!Ver.empty()) {
1054 if (Ver.getMajor() == SMMajor) {
1055 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1056 switch (*SMMinor) {
1057 case 0:
1059 case 1:
1061 case 2:
1063 case 3:
1065 case 4:
1067 case 5:
1069 case 6:
1071 case 7:
1073 case 8:
1075 default:
1076 report_fatal_error("Unsupported Shader Model version", false);
1077 }
1078 }
1079 }
1080 } else {
1081 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1082 // shadermodel6.x is
1083 if (ShaderModelStr == "shadermodel6.x") {
1085 }
1086 }
1087 // DXIL version corresponding to Shader Model version other than 6.Minor
1088 // is 1.0
1090}
1091
1093 bool IsMinGW32 = false;
1094 bool IsCygwin = false;
1095
1096 // Parse into components.
1097 SmallVector<StringRef, 4> Components;
1098 Str.split(Components, '-');
1099
1100 // If the first component corresponds to a known architecture, preferentially
1101 // use it for the architecture. If the second component corresponds to a
1102 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1103 // component movement when a component parses as (eg) both a valid arch and a
1104 // valid os.
1105 ArchType Arch = UnknownArch;
1106 if (Components.size() > 0)
1107 Arch = parseArch(Components[0]);
1108 VendorType Vendor = UnknownVendor;
1109 if (Components.size() > 1)
1110 Vendor = parseVendor(Components[1]);
1111 OSType OS = UnknownOS;
1112 if (Components.size() > 2) {
1113 OS = parseOS(Components[2]);
1114 IsCygwin = Components[2].starts_with("cygwin");
1115 IsMinGW32 = Components[2].starts_with("mingw");
1116 }
1117 EnvironmentType Environment = UnknownEnvironment;
1118 if (Components.size() > 3)
1119 Environment = parseEnvironment(Components[3]);
1121 if (Components.size() > 4)
1122 ObjectFormat = parseFormat(Components[4]);
1123
1124 // Note which components are already in their final position. These will not
1125 // be moved.
1126 bool Found[4];
1127 Found[0] = Arch != UnknownArch;
1128 Found[1] = Vendor != UnknownVendor;
1129 Found[2] = OS != UnknownOS;
1130 Found[3] = Environment != UnknownEnvironment;
1131
1132 // If they are not there already, permute the components into their canonical
1133 // positions by seeing if they parse as a valid architecture, and if so moving
1134 // the component to the architecture position etc.
1135 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1136 if (Found[Pos])
1137 continue; // Already in the canonical position.
1138
1139 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1140 // Do not reparse any components that already matched.
1141 if (Idx < std::size(Found) && Found[Idx])
1142 continue;
1143
1144 // Does this component parse as valid for the target position?
1145 bool Valid = false;
1146 StringRef Comp = Components[Idx];
1147 switch (Pos) {
1148 default: llvm_unreachable("unexpected component type!");
1149 case 0:
1150 Arch = parseArch(Comp);
1151 Valid = Arch != UnknownArch;
1152 break;
1153 case 1:
1154 Vendor = parseVendor(Comp);
1155 Valid = Vendor != UnknownVendor;
1156 break;
1157 case 2:
1158 OS = parseOS(Comp);
1159 IsCygwin = Comp.starts_with("cygwin");
1160 IsMinGW32 = Comp.starts_with("mingw");
1161 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1162 break;
1163 case 3:
1164 Environment = parseEnvironment(Comp);
1165 Valid = Environment != UnknownEnvironment;
1166 if (!Valid) {
1167 ObjectFormat = parseFormat(Comp);
1168 Valid = ObjectFormat != UnknownObjectFormat;
1169 }
1170 break;
1171 }
1172 if (!Valid)
1173 continue; // Nope, try the next component.
1174
1175 // Move the component to the target position, pushing any non-fixed
1176 // components that are in the way to the right. This tends to give
1177 // good results in the common cases of a forgotten vendor component
1178 // or a wrongly positioned environment.
1179 if (Pos < Idx) {
1180 // Insert left, pushing the existing components to the right. For
1181 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1182 StringRef CurrentComponent(""); // The empty component.
1183 // Replace the component we are moving with an empty component.
1184 std::swap(CurrentComponent, Components[Idx]);
1185 // Insert the component being moved at Pos, displacing any existing
1186 // components to the right.
1187 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1188 // Skip over any fixed components.
1189 while (i < std::size(Found) && Found[i])
1190 ++i;
1191 // Place the component at the new position, getting the component
1192 // that was at this position - it will be moved right.
1193 std::swap(CurrentComponent, Components[i]);
1194 }
1195 } else if (Pos > Idx) {
1196 // Push right by inserting empty components until the component at Idx
1197 // reaches the target position Pos. For example, pc-a -> -pc-a when
1198 // moving pc to the second position.
1199 do {
1200 // Insert one empty component at Idx.
1201 StringRef CurrentComponent(""); // The empty component.
1202 for (unsigned i = Idx; i < Components.size();) {
1203 // Place the component at the new position, getting the component
1204 // that was at this position - it will be moved right.
1205 std::swap(CurrentComponent, Components[i]);
1206 // If it was placed on top of an empty component then we are done.
1207 if (CurrentComponent.empty())
1208 break;
1209 // Advance to the next component, skipping any fixed components.
1210 while (++i < std::size(Found) && Found[i])
1211 ;
1212 }
1213 // The last component was pushed off the end - append it.
1214 if (!CurrentComponent.empty())
1215 Components.push_back(CurrentComponent);
1216
1217 // Advance Idx to the component's new position.
1218 while (++Idx < std::size(Found) && Found[Idx])
1219 ;
1220 } while (Idx < Pos); // Add more until the final position is reached.
1221 }
1222 assert(Pos < Components.size() && Components[Pos] == Comp &&
1223 "Component moved wrong!");
1224 Found[Pos] = true;
1225 break;
1226 }
1227 }
1228
1229 // If "none" is in the middle component in a three-component triple, treat it
1230 // as the OS (Components[2]) instead of the vendor (Components[1]).
1231 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1232 Components[1] == "none" && Components[2].empty())
1233 std::swap(Components[1], Components[2]);
1234
1235 // Replace empty components with "unknown" value.
1236 for (StringRef &C : Components)
1237 if (C.empty())
1238 C = "unknown";
1239
1240 // Special case logic goes here. At this point Arch, Vendor and OS have the
1241 // correct values for the computed components.
1242 std::string NormalizedEnvironment;
1243 if (Environment == Triple::Android &&
1244 Components[3].starts_with("androideabi")) {
1245 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1246 if (AndroidVersion.empty()) {
1247 Components[3] = "android";
1248 } else {
1249 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1250 Components[3] = NormalizedEnvironment;
1251 }
1252 }
1253
1254 // SUSE uses "gnueabi" to mean "gnueabihf"
1255 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1256 Components[3] = "gnueabihf";
1257
1258 if (OS == Triple::Win32) {
1259 Components.resize(4);
1260 Components[2] = "windows";
1261 if (Environment == UnknownEnvironment) {
1262 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1263 Components[3] = "msvc";
1264 else
1265 Components[3] = getObjectFormatTypeName(ObjectFormat);
1266 }
1267 } else if (IsMinGW32) {
1268 Components.resize(4);
1269 Components[2] = "windows";
1270 Components[3] = "gnu";
1271 } else if (IsCygwin) {
1272 Components.resize(4);
1273 Components[2] = "windows";
1274 Components[3] = "cygnus";
1275 }
1276 if (IsMinGW32 || IsCygwin ||
1277 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1278 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1279 Components.resize(5);
1280 Components[4] = getObjectFormatTypeName(ObjectFormat);
1281 }
1282 }
1283
1284 // Normalize DXIL triple if it does not include DXIL version number.
1285 // Determine DXIL version number using the minor version number of Shader
1286 // Model version specified in target triple, if any. Prior to decoupling DXIL
1287 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1288 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1289 if (Components[0] == "dxil") {
1290 if (Components.size() > 4) {
1291 Components.resize(4);
1292 }
1293 // Add DXIL version only if shadermodel is specified in the triple
1294 if (OS == Triple::ShaderModel) {
1295 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1296 }
1297 }
1298 // Stick the corrected components back together to form the normalized string.
1299 return join(Components, "-");
1300}
1301
1303 return StringRef(Data).split('-').first; // Isolate first component
1304}
1305
1307 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1308 return Tmp.split('-').first; // Isolate second component
1309}
1310
1312 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1313 Tmp = Tmp.split('-').second; // Strip second component
1314 return Tmp.split('-').first; // Isolate third component
1315}
1316
1318 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1319 Tmp = Tmp.split('-').second; // Strip second component
1320 return Tmp.split('-').second; // Strip third component
1321}
1322
1324 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1325 return Tmp.split('-').second; // Strip second component
1326}
1327
1330 Version.tryParse(Name);
1331 return Version.withoutBuild();
1332}
1333
1336}
1337
1339 StringRef EnvironmentName = getEnvironmentName();
1340
1341 // none is a valid environment type - it basically amounts to a freestanding
1342 // environment.
1343 if (EnvironmentName == "none")
1344 return "";
1345
1346 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1347 EnvironmentName.consume_front(EnvironmentTypeName);
1348
1349 if (EnvironmentName.contains("-")) {
1350 // -obj is the suffix
1352 StringRef ObjectFormatTypeName =
1354 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1355 EnvironmentName.consume_back(tmp);
1356 }
1357 }
1358 return EnvironmentName;
1359}
1360
1362 StringRef OSName = getOSName();
1363 // Assume that the OS portion of the triple starts with the canonical name.
1364 StringRef OSTypeName = getOSTypeName(getOS());
1365 if (OSName.starts_with(OSTypeName))
1366 OSName = OSName.substr(OSTypeName.size());
1367 else if (getOS() == MacOSX)
1368 OSName.consume_front("macos");
1369 else if (OSName.starts_with("visionos"))
1370 OSName.consume_front("visionos");
1371
1372 return parseVersionFromName(OSName);
1373}
1374
1377
1378 switch (getOS()) {
1379 default: llvm_unreachable("unexpected OS for Darwin triple");
1380 case Darwin:
1381 // Default to darwin8, i.e., MacOSX 10.4.
1382 if (Version.getMajor() == 0)
1383 Version = VersionTuple(8);
1384 // Darwin version numbers are skewed from OS X versions.
1385 if (Version.getMajor() < 4) {
1386 return false;
1387 }
1388 if (Version.getMajor() <= 19) {
1389 Version = VersionTuple(10, Version.getMajor() - 4);
1390 } else {
1391 // darwin20+ corresponds to macOS 11+.
1392 Version = VersionTuple(11 + Version.getMajor() - 20);
1393 }
1394 break;
1395 case MacOSX:
1396 // Default to 10.4.
1397 if (Version.getMajor() == 0) {
1398 Version = VersionTuple(10, 4);
1399 } else if (Version.getMajor() < 10) {
1400 return false;
1401 }
1402 break;
1403 case IOS:
1404 case TvOS:
1405 case WatchOS:
1406 // Ignore the version from the triple. This is only handled because the
1407 // the clang driver combines OS X and IOS support into a common Darwin
1408 // toolchain that wants to know the OS X version number even when targeting
1409 // IOS.
1410 Version = VersionTuple(10, 4);
1411 break;
1412 case XROS:
1413 llvm_unreachable("OSX version isn't relevant for xrOS");
1414 case DriverKit:
1415 llvm_unreachable("OSX version isn't relevant for DriverKit");
1416 }
1417 return true;
1418}
1419
1421 switch (getOS()) {
1422 default: llvm_unreachable("unexpected OS for Darwin triple");
1423 case Darwin:
1424 case MacOSX:
1425 // Ignore the version from the triple. This is only handled because the
1426 // the clang driver combines OS X and IOS support into a common Darwin
1427 // toolchain that wants to know the iOS version number even when targeting
1428 // OS X.
1429 return VersionTuple(5);
1430 case IOS:
1431 case TvOS: {
1433 // Default to 5.0 (or 7.0 for arm64).
1434 if (Version.getMajor() == 0)
1435 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1436 return Version;
1437 }
1438 case XROS: {
1439 // xrOS 1 is aligned with iOS 17.
1441 return Version.withMajorReplaced(Version.getMajor() + 16);
1442 }
1443 case WatchOS:
1444 llvm_unreachable("conflicting triple info");
1445 case DriverKit:
1446 llvm_unreachable("DriverKit doesn't have an iOS version");
1447 }
1448}
1449
1451 switch (getOS()) {
1452 default: llvm_unreachable("unexpected OS for Darwin triple");
1453 case Darwin:
1454 case MacOSX:
1455 // Ignore the version from the triple. This is only handled because the
1456 // the clang driver combines OS X and IOS support into a common Darwin
1457 // toolchain that wants to know the iOS version number even when targeting
1458 // OS X.
1459 return VersionTuple(2);
1460 case WatchOS: {
1462 if (Version.getMajor() == 0)
1463 return VersionTuple(2);
1464 return Version;
1465 }
1466 case IOS:
1467 llvm_unreachable("conflicting triple info");
1468 case XROS:
1469 llvm_unreachable("watchOS version isn't relevant for xrOS");
1470 case DriverKit:
1471 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1472 }
1473}
1474
1476 switch (getOS()) {
1477 default:
1478 llvm_unreachable("unexpected OS for Darwin triple");
1479 case DriverKit:
1481 if (Version.getMajor() == 0)
1482 return Version.withMajorReplaced(19);
1483 return Version;
1484 }
1485}
1486
1488 if (getArch() != spirv || getOS() != Vulkan)
1489 llvm_unreachable("invalid Vulkan SPIR-V triple");
1490
1491 VersionTuple VulkanVersion = getOSVersion();
1492 SubArchType SpirvVersion = getSubArch();
1493
1495 // Vulkan 1.2 -> SPIR-V 1.5.
1497 // Vulkan 1.3 -> SPIR-V 1.6.
1499
1500 // If Vulkan version is unset, default to 1.2.
1501 if (VulkanVersion == VersionTuple(0))
1502 VulkanVersion = VersionTuple(1, 2);
1503
1504 if (ValidVersionMap.contains(VulkanVersion) &&
1505 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1506 SpirvVersion == NoSubArch))
1507 return VulkanVersion;
1508
1509 return VersionTuple(0);
1510}
1511
1513 if (getArch() != dxil || getOS() != ShaderModel)
1514 llvm_unreachable("invalid DXIL triple");
1515 StringRef Arch = getArchName();
1516 if (getSubArch() == NoSubArch)
1518 Arch.consume_front("dxilv");
1519 VersionTuple DXILVersion = parseVersionFromName(Arch);
1520 // FIXME: validate DXIL version against Shader Model version.
1521 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1522 return DXILVersion;
1523}
1524
1525void Triple::setTriple(const Twine &Str) {
1526 *this = Triple(Str);
1527}
1528
1530 setArchName(getArchName(Kind, SubArch));
1531}
1532
1535}
1536
1538 setOSName(getOSTypeName(Kind));
1539}
1540
1542 if (ObjectFormat == getDefaultFormat(*this))
1544
1546 getObjectFormatTypeName(ObjectFormat)).str());
1547}
1548
1550 if (Environment == UnknownEnvironment)
1552
1553 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1554 getObjectFormatTypeName(Kind)).str());
1555}
1556
1558 // Work around a miscompilation bug for Twines in gcc 4.0.3.
1560 Triple += Str;
1561 Triple += "-";
1562 Triple += getVendorName();
1563 Triple += "-";
1566}
1567
1569 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1570}
1571
1573 if (hasEnvironment())
1574 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1575 "-" + getEnvironmentName());
1576 else
1577 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1578}
1579
1581 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1582 "-" + Str);
1583}
1584
1586 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1587}
1588
1590 switch (Arch) {
1592 return 0;
1593
1594 case llvm::Triple::avr:
1596 return 16;
1597
1600 case llvm::Triple::arc:
1601 case llvm::Triple::arm:
1603 case llvm::Triple::csky:
1604 case llvm::Triple::dxil:
1609 case llvm::Triple::le32:
1611 case llvm::Triple::m68k:
1612 case llvm::Triple::mips:
1615 case llvm::Triple::ppc:
1617 case llvm::Triple::r600:
1623 case llvm::Triple::spir:
1625 case llvm::Triple::tce:
1630 case llvm::Triple::x86:
1633 return 32;
1634
1642 case llvm::Triple::le64:
1656 case llvm::Triple::ve:
1659 return 64;
1660 }
1661 llvm_unreachable("Invalid architecture value");
1662}
1663
1665 return getArchPointerBitWidth(getArch()) == 64;
1666}
1667
1669 return getArchPointerBitWidth(getArch()) == 32;
1670}
1671
1673 return getArchPointerBitWidth(getArch()) == 16;
1674}
1675
1677 Triple T(*this);
1678 switch (getArch()) {
1680 case Triple::amdgcn:
1681 case Triple::avr:
1682 case Triple::bpfeb:
1683 case Triple::bpfel:
1684 case Triple::msp430:
1685 case Triple::systemz:
1686 case Triple::ve:
1687 T.setArch(UnknownArch);
1688 break;
1689
1690 case Triple::aarch64_32:
1691 case Triple::amdil:
1692 case Triple::arc:
1693 case Triple::arm:
1694 case Triple::armeb:
1695 case Triple::csky:
1696 case Triple::dxil:
1697 case Triple::hexagon:
1698 case Triple::hsail:
1699 case Triple::kalimba:
1700 case Triple::lanai:
1701 case Triple::le32:
1703 case Triple::m68k:
1704 case Triple::mips:
1705 case Triple::mipsel:
1706 case Triple::nvptx:
1707 case Triple::ppc:
1708 case Triple::ppcle:
1709 case Triple::r600:
1711 case Triple::riscv32:
1712 case Triple::shave:
1713 case Triple::sparc:
1714 case Triple::sparcel:
1715 case Triple::spir:
1716 case Triple::spirv32:
1717 case Triple::tce:
1718 case Triple::tcele:
1719 case Triple::thumb:
1720 case Triple::thumbeb:
1721 case Triple::wasm32:
1722 case Triple::x86:
1723 case Triple::xcore:
1724 case Triple::xtensa:
1725 // Already 32-bit.
1726 break;
1727
1728 case Triple::aarch64: T.setArch(Triple::arm); break;
1729 case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1730 case Triple::amdil64: T.setArch(Triple::amdil); break;
1731 case Triple::hsail64: T.setArch(Triple::hsail); break;
1732 case Triple::le64: T.setArch(Triple::le32); break;
1733 case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
1734 case Triple::mips64:
1735 T.setArch(Triple::mips, getSubArch());
1736 break;
1737 case Triple::mips64el:
1738 T.setArch(Triple::mipsel, getSubArch());
1739 break;
1740 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1741 case Triple::ppc64: T.setArch(Triple::ppc); break;
1742 case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1743 case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1744 case Triple::riscv64: T.setArch(Triple::riscv32); break;
1745 case Triple::sparcv9: T.setArch(Triple::sparc); break;
1746 case Triple::spir64: T.setArch(Triple::spir); break;
1747 case Triple::spirv:
1748 case Triple::spirv64:
1749 T.setArch(Triple::spirv32, getSubArch());
1750 break;
1751 case Triple::wasm64: T.setArch(Triple::wasm32); break;
1752 case Triple::x86_64: T.setArch(Triple::x86); break;
1753 }
1754 return T;
1755}
1756
1758 Triple T(*this);
1759 switch (getArch()) {
1761 case Triple::arc:
1762 case Triple::avr:
1763 case Triple::csky:
1764 case Triple::dxil:
1765 case Triple::hexagon:
1766 case Triple::kalimba:
1767 case Triple::lanai:
1768 case Triple::m68k:
1769 case Triple::msp430:
1770 case Triple::r600:
1771 case Triple::shave:
1772 case Triple::sparcel:
1773 case Triple::tce:
1774 case Triple::tcele:
1775 case Triple::xcore:
1776 case Triple::xtensa:
1777 T.setArch(UnknownArch);
1778 break;
1779
1780 case Triple::aarch64:
1781 case Triple::aarch64_be:
1782 case Triple::amdgcn:
1783 case Triple::amdil64:
1784 case Triple::bpfeb:
1785 case Triple::bpfel:
1786 case Triple::hsail64:
1787 case Triple::le64:
1789 case Triple::mips64:
1790 case Triple::mips64el:
1791 case Triple::nvptx64:
1792 case Triple::ppc64:
1793 case Triple::ppc64le:
1795 case Triple::riscv64:
1796 case Triple::sparcv9:
1797 case Triple::spir64:
1798 case Triple::spirv64:
1799 case Triple::systemz:
1800 case Triple::ve:
1801 case Triple::wasm64:
1802 case Triple::x86_64:
1803 // Already 64-bit.
1804 break;
1805
1806 case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1807 case Triple::amdil: T.setArch(Triple::amdil64); break;
1808 case Triple::arm: T.setArch(Triple::aarch64); break;
1809 case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1810 case Triple::hsail: T.setArch(Triple::hsail64); break;
1811 case Triple::le32: T.setArch(Triple::le64); break;
1812 case Triple::loongarch32: T.setArch(Triple::loongarch64); break;
1813 case Triple::mips:
1814 T.setArch(Triple::mips64, getSubArch());
1815 break;
1816 case Triple::mipsel:
1817 T.setArch(Triple::mips64el, getSubArch());
1818 break;
1819 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1820 case Triple::ppc: T.setArch(Triple::ppc64); break;
1821 case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1822 case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1823 case Triple::riscv32: T.setArch(Triple::riscv64); break;
1824 case Triple::sparc: T.setArch(Triple::sparcv9); break;
1825 case Triple::spir: T.setArch(Triple::spir64); break;
1826 case Triple::spirv:
1827 case Triple::spirv32:
1828 T.setArch(Triple::spirv64, getSubArch());
1829 break;
1830 case Triple::thumb: T.setArch(Triple::aarch64); break;
1831 case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1832 case Triple::wasm32: T.setArch(Triple::wasm64); break;
1833 case Triple::x86: T.setArch(Triple::x86_64); break;
1834 }
1835 return T;
1836}
1837
1839 Triple T(*this);
1840 // Already big endian.
1841 if (!isLittleEndian())
1842 return T;
1843 switch (getArch()) {
1845 case Triple::amdgcn:
1846 case Triple::amdil64:
1847 case Triple::amdil:
1848 case Triple::avr:
1849 case Triple::dxil:
1850 case Triple::hexagon:
1851 case Triple::hsail64:
1852 case Triple::hsail:
1853 case Triple::kalimba:
1854 case Triple::le32:
1855 case Triple::le64:
1858 case Triple::msp430:
1859 case Triple::nvptx64:
1860 case Triple::nvptx:
1861 case Triple::r600:
1864 case Triple::riscv32:
1865 case Triple::riscv64:
1866 case Triple::shave:
1867 case Triple::spir64:
1868 case Triple::spir:
1869 case Triple::spirv:
1870 case Triple::spirv32:
1871 case Triple::spirv64:
1872 case Triple::wasm32:
1873 case Triple::wasm64:
1874 case Triple::x86:
1875 case Triple::x86_64:
1876 case Triple::xcore:
1877 case Triple::ve:
1878 case Triple::csky:
1879 case Triple::xtensa:
1880
1881 // ARM is intentionally unsupported here, changing the architecture would
1882 // drop any arch suffixes.
1883 case Triple::arm:
1884 case Triple::thumb:
1885 T.setArch(UnknownArch);
1886 break;
1887
1888 case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1889 case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1890 case Triple::mips64el:
1891 T.setArch(Triple::mips64, getSubArch());
1892 break;
1893 case Triple::mipsel:
1894 T.setArch(Triple::mips, getSubArch());
1895 break;
1896 case Triple::ppcle: T.setArch(Triple::ppc); break;
1897 case Triple::ppc64le: T.setArch(Triple::ppc64); break;
1898 case Triple::sparcel: T.setArch(Triple::sparc); break;
1899 case Triple::tcele: T.setArch(Triple::tce); break;
1900 default:
1901 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
1902 }
1903 return T;
1904}
1905
1907 Triple T(*this);
1908 if (isLittleEndian())
1909 return T;
1910
1911 switch (getArch()) {
1913 case Triple::lanai:
1914 case Triple::sparcv9:
1915 case Triple::systemz:
1916 case Triple::m68k:
1917
1918 // ARM is intentionally unsupported here, changing the architecture would
1919 // drop any arch suffixes.
1920 case Triple::armeb:
1921 case Triple::thumbeb:
1922 T.setArch(UnknownArch);
1923 break;
1924
1925 case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
1926 case Triple::bpfeb: T.setArch(Triple::bpfel); break;
1927 case Triple::mips64:
1928 T.setArch(Triple::mips64el, getSubArch());
1929 break;
1930 case Triple::mips:
1931 T.setArch(Triple::mipsel, getSubArch());
1932 break;
1933 case Triple::ppc: T.setArch(Triple::ppcle); break;
1934 case Triple::ppc64: T.setArch(Triple::ppc64le); break;
1935 case Triple::sparc: T.setArch(Triple::sparcel); break;
1936 case Triple::tce: T.setArch(Triple::tcele); break;
1937 default:
1938 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
1939 }
1940 return T;
1941}
1942
1944 switch (getArch()) {
1945 case Triple::aarch64:
1946 case Triple::aarch64_32:
1947 case Triple::amdgcn:
1948 case Triple::amdil64:
1949 case Triple::amdil:
1950 case Triple::arm:
1951 case Triple::avr:
1952 case Triple::bpfel:
1953 case Triple::csky:
1954 case Triple::dxil:
1955 case Triple::hexagon:
1956 case Triple::hsail64:
1957 case Triple::hsail:
1958 case Triple::kalimba:
1959 case Triple::le32:
1960 case Triple::le64:
1963 case Triple::mips64el:
1964 case Triple::mipsel:
1965 case Triple::msp430:
1966 case Triple::nvptx64:
1967 case Triple::nvptx:
1968 case Triple::ppcle:
1969 case Triple::ppc64le:
1970 case Triple::r600:
1973 case Triple::riscv32:
1974 case Triple::riscv64:
1975 case Triple::shave:
1976 case Triple::sparcel:
1977 case Triple::spir64:
1978 case Triple::spir:
1979 case Triple::spirv:
1980 case Triple::spirv32:
1981 case Triple::spirv64:
1982 case Triple::tcele:
1983 case Triple::thumb:
1984 case Triple::ve:
1985 case Triple::wasm32:
1986 case Triple::wasm64:
1987 case Triple::x86:
1988 case Triple::x86_64:
1989 case Triple::xcore:
1990 case Triple::xtensa:
1991 return true;
1992 default:
1993 return false;
1994 }
1995}
1996
1998 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1999 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
2000 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
2001 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
2002 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2003 if (getVendor() == Triple::Apple)
2004 return getSubArch() == Other.getSubArch() &&
2005 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2006 else
2007 return getSubArch() == Other.getSubArch() &&
2008 getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
2009 getEnvironment() == Other.getEnvironment() &&
2010 getObjectFormat() == Other.getObjectFormat();
2011 }
2012
2013 // If vendor is apple, ignore the version number.
2014 if (getVendor() == Triple::Apple)
2015 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2016 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2017
2018 return *this == Other;
2019}
2020
2021std::string Triple::merge(const Triple &Other) const {
2022 // If vendor is apple, pick the triple with the larger version number.
2023 if (getVendor() == Triple::Apple)
2024 if (Other.isOSVersionLT(*this))
2025 return str();
2026
2027 return Other.str();
2028}
2029
2030bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2031 unsigned Micro) const {
2032 assert(isMacOSX() && "Not an OS X triple!");
2033
2034 // If this is OS X, expect a sane version number.
2035 if (getOS() == Triple::MacOSX)
2036 return isOSVersionLT(Major, Minor, Micro);
2037
2038 // Otherwise, compare to the "Darwin" number.
2039 if (Major == 10) {
2040 return isOSVersionLT(Minor + 4, Micro, 0);
2041 } else {
2042 assert(Major >= 11 && "Unexpected major version");
2043 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2044 }
2045}
2046
2049 return VersionTuple();
2050 switch (getOS()) {
2051 case Triple::MacOSX:
2052 // ARM64 slice is supported starting from macOS 11.0+.
2053 return VersionTuple(11, 0, 0);
2054 case Triple::IOS:
2055 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2056 // ARM64 simulators are supported for iOS 14+.
2058 return VersionTuple(14, 0, 0);
2059 // ARM64e slice is supported starting from iOS 14.
2060 if (isArm64e())
2061 return VersionTuple(14, 0, 0);
2062 break;
2063 case Triple::TvOS:
2064 // ARM64 simulators are supported for tvOS 14+.
2066 return VersionTuple(14, 0, 0);
2067 break;
2068 case Triple::WatchOS:
2069 // ARM64 simulators are supported for watchOS 7+.
2071 return VersionTuple(7, 0, 0);
2072 break;
2073 case Triple::DriverKit:
2074 return VersionTuple(20, 0, 0);
2075 default:
2076 break;
2077 }
2078 return VersionTuple();
2079}
2080
2082 const VersionTuple &Version) {
2083 switch (OSKind) {
2084 case MacOSX:
2085 // macOS 10.16 is canonicalized to macOS 11.
2086 if (Version == VersionTuple(10, 16))
2087 return VersionTuple(11, 0);
2088 [[fallthrough]];
2089 default:
2090 return Version;
2091 }
2092}
2093
2094// HLSL triple environment orders are relied on in the front end
2095static_assert(Triple::Vertex - Triple::Pixel == 1,
2096 "incorrect HLSL stage order");
2097static_assert(Triple::Geometry - Triple::Pixel == 2,
2098 "incorrect HLSL stage order");
2099static_assert(Triple::Hull - Triple::Pixel == 3,
2100 "incorrect HLSL stage order");
2101static_assert(Triple::Domain - Triple::Pixel == 4,
2102 "incorrect HLSL stage order");
2103static_assert(Triple::Compute - Triple::Pixel == 5,
2104 "incorrect HLSL stage order");
2105static_assert(Triple::Library - Triple::Pixel == 6,
2106 "incorrect HLSL stage order");
2107static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2108 "incorrect HLSL stage order");
2109static_assert(Triple::Intersection - Triple::Pixel == 8,
2110 "incorrect HLSL stage order");
2111static_assert(Triple::AnyHit - Triple::Pixel == 9,
2112 "incorrect HLSL stage order");
2113static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2114 "incorrect HLSL stage order");
2115static_assert(Triple::Miss - Triple::Pixel == 11,
2116 "incorrect HLSL stage order");
2117static_assert(Triple::Callable - Triple::Pixel == 12,
2118 "incorrect HLSL stage order");
2119static_assert(Triple::Mesh - Triple::Pixel == 13,
2120 "incorrect HLSL stage order");
2121static_assert(Triple::Amplification - Triple::Pixel == 14,
2122 "incorrect HLSL stage order");
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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallString class.
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:690
static VersionTuple parseVersionFromName(StringRef Name)
Definition: Triple.cpp:1328
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition: Triple.cpp:880
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition: Triple.cpp:464
static Triple::OSType parseOS(StringRef OSName)
Definition: Triple.cpp:643
static StringRef getDXILArchNameFromShaderModel(StringRef ShaderModelStr)
Definition: Triple.cpp:1047
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition: Triple.cpp:377
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition: Triple.cpp:751
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition: Triple.cpp:737
static Triple::ArchType parseArch(StringRef ArchName)
Definition: Triple.cpp:529
static Triple::VendorType parseVendor(StringRef VendorName)
Definition: Triple.cpp:624
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:202
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition: DenseMap.h:145
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
size_t size() const
Definition: SmallVector.h:91
void resize(size_type N)
Definition: SmallVector.h:651
void push_back(const T &Elt)
Definition: SmallVector.h:426
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:685
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition: StringRef.h:640
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:556
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:250
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition: StringRef.h:594
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:409
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:620
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:262
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:44
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:69
R Default(T Value)
Definition: StringSwitch.h:182
StringSwitch & StartsWith(StringLiteral S, T Value)
Definition: StringSwitch.h:83
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
Definition: StringSwitch.h:90
StringSwitch & EndsWith(StringLiteral S, T Value)
Definition: StringSwitch.h:76
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
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:2030
VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1361
StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition: Triple.cpp:1306
VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1450
void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1557
void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition: Triple.cpp:1549
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1676
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition: Triple.h:284
@ UnknownEnvironment
Definition: Triple.h:245
@ ClosestHit
Definition: Triple.h:287
@ MuslEABIHF
Definition: Triple.h:263
@ Amplification
Definition: Triple.h:291
@ Intersection
Definition: Triple.h:285
std::string normalize() const
Return the normalized form of this triple's string.
Definition: Triple.h:368
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition: Triple.h:477
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1906
static StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition: Triple.cpp:239
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition: Triple.h:401
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition: Triple.h:378
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition: Triple.h:1033
void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1568
@ HermitCore
Definition: Triple.h:234
@ ShaderModel
Definition: Triple.h:238
@ Emscripten
Definition: Triple.h:237
void setOSAndEnvironmentName(StringRef Str)
Set the operating system and optional environment components with a single string.
Definition: Triple.cpp:1585
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1757
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1943
void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1541
StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition: Triple.cpp:1311
@ loongarch32
Definition: Triple.h:61
@ renderscript64
Definition: Triple.h:108
@ UnknownArch
Definition: Triple.h:47
@ aarch64_be
Definition: Triple.h:52
@ loongarch64
Definition: Triple.h:62
@ renderscript32
Definition: Triple.h:107
@ mips64el
Definition: Triple.h:67
@ aarch64_32
Definition: Triple.h:53
void setTriple(const Twine &Str)
Set all components to the new triple Str.
Definition: Triple.cpp:1525
OSType getOS() const
Get the parsed operating system type of this triple.
Definition: Triple.h:384
VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1334
static ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:392
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition: Triple.h:375
StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:1317
bool isSimulatorEnvironment() const
Definition: Triple.h:564
VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition: Triple.cpp:1512
const std::string & str() const
Definition: Triple.h:442
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition: Triple.h:392
VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition: Triple.cpp:1487
VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1475
static StringRef getArchTypeName(ArchType Kind)
Get the canonical name for the Kind architecture.
Definition: Triple.cpp:24
static StringRef getOSTypeName(OSType Kind)
Get the canonical name for the Kind operating system.
Definition: Triple.cpp:261
ObjectFormatType
Definition: Triple.h:299
@ DXContainer
Definition: Triple.h:303
@ UnknownObjectFormat
Definition: Triple.h:300
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:2021
@ UnknownVendor
Definition: Triple.h:182
@ OpenEmbedded
Definition: Triple.h:196
@ ImaginationTechnologies
Definition: Triple.h:189
@ MipsTechnologies
Definition: Triple.h:190
VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition: Triple.cpp:2047
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1664
StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition: Triple.cpp:1323
@ ARMSubArch_v6t2
Definition: Triple.h:144
@ MipsSubArch_r6
Definition: Triple.h:156
@ DXILSubArch_v1_2
Definition: Triple.h:172
@ ARMSubArch_v7
Definition: Triple.h:135
@ ARMSubArch_v8m_mainline
Definition: Triple.h:133
@ ARMSubArch_v8r
Definition: Triple.h:131
@ ARMSubArch_v9_1a
Definition: Triple.h:119
@ DXILSubArch_v1_1
Definition: Triple.h:171
@ LatestDXILSubArch
Definition: Triple.h:179
@ SPIRVSubArch_v10
Definition: Triple.h:161
@ SPIRVSubArch_v13
Definition: Triple.h:164
@ ARMSubArch_v7k
Definition: Triple.h:139
@ ARMSubArch_v8_7a
Definition: Triple.h:123
@ ARMSubArch_v8
Definition: Triple.h:130
@ SPIRVSubArch_v16
Definition: Triple.h:167
@ ARMSubArch_v8_1a
Definition: Triple.h:129
@ ARMSubArch_v9_2a
Definition: Triple.h:118
@ DXILSubArch_v1_3
Definition: Triple.h:173
@ SPIRVSubArch_v15
Definition: Triple.h:166
@ ARMSubArch_v7m
Definition: Triple.h:137
@ ARMSubArch_v6k
Definition: Triple.h:143
@ ARMSubArch_v5
Definition: Triple.h:145
@ AArch64SubArch_arm64e
Definition: Triple.h:149
@ ARMSubArch_v6
Definition: Triple.h:141
@ ARMSubArch_v9_5a
Definition: Triple.h:115
@ ARMSubArch_v7ve
Definition: Triple.h:140
@ ARMSubArch_v8m_baseline
Definition: Triple.h:132
@ ARMSubArch_v8_8a
Definition: Triple.h:122
@ ARMSubArch_v8_2a
Definition: Triple.h:128
@ ARMSubArch_v7s
Definition: Triple.h:138
@ DXILSubArch_v1_0
Definition: Triple.h:170
@ DXILSubArch_v1_7
Definition: Triple.h:177
@ KalimbaSubArch_v3
Definition: Triple.h:152
@ DXILSubArch_v1_5
Definition: Triple.h:175
@ ARMSubArch_v8_4a
Definition: Triple.h:126
@ ARMSubArch_v8_9a
Definition: Triple.h:121
@ ARMSubArch_v7em
Definition: Triple.h:136
@ SPIRVSubArch_v12
Definition: Triple.h:163
@ SPIRVSubArch_v14
Definition: Triple.h:165
@ KalimbaSubArch_v4
Definition: Triple.h:153
@ ARMSubArch_v8_1m_mainline
Definition: Triple.h:134
@ ARMSubArch_v8_3a
Definition: Triple.h:127
@ AArch64SubArch_arm64ec
Definition: Triple.h:150
@ ARMSubArch_v8_6a
Definition: Triple.h:124
@ ARMSubArch_v5te
Definition: Triple.h:146
@ KalimbaSubArch_v5
Definition: Triple.h:154
@ ARMSubArch_v4t
Definition: Triple.h:147
@ DXILSubArch_v1_6
Definition: Triple.h:176
@ DXILSubArch_v1_8
Definition: Triple.h:178
@ ARMSubArch_v9_4a
Definition: Triple.h:116
@ ARMSubArch_v8_5a
Definition: Triple.h:125
@ ARMSubArch_v6m
Definition: Triple.h:142
@ ARMSubArch_v9_3a
Definition: Triple.h:117
@ ARMSubArch_v9
Definition: Triple.h:120
@ DXILSubArch_v1_4
Definition: Triple.h:174
@ SPIRVSubArch_v11
Definition: Triple.h:162
@ PPCSubArch_spe
Definition: Triple.h:158
bool getMacOSXVersion(VersionTuple &Version) const
Parse the version number as with getOSVersion and then translate generic "darwin" versions to the cor...
Definition: Triple.cpp:1375
bool isMacOSX() const
Is this a Mac OS X triple.
Definition: Triple.h:524
void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition: Triple.cpp:1580
void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1537
void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1572
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition: Triple.h:381
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition: Triple.cpp:310
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:502
static VersionTuple getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version)
Returns a canonicalized OS version number for the specified OS.
Definition: Triple.cpp:2081
StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1302
bool isMacCatalystEnvironment() const
Definition: Triple.h:568
static StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition: Triple.cpp:362
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1672
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1838
VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1420
StringRef getEnvironmentVersionString() const
Get the version component of the environment component as a single string (the version after the envi...
Definition: Triple.cpp:1338
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1668
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1997
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition: Triple.h:387
static StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:149
void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1529
void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1533
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
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:29
unsigned getMajor() const
Retrieve the major version number.
Definition: VersionTuple.h:71
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
Definition: VersionTuple.h:66
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
Definition: VersionTuple.h:74
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
StringRef getCanonicalArchName(StringRef Arch)
MArch is expected to be of the form (arm|thumb)?(eb)?(v.
ISAKind parseArchISA(StringRef Arch)
ArchKind parseArch(StringRef Arch)
ProfileKind parseArchProfile(StringRef Arch)
unsigned parseArchVersion(StringRef Arch)
EndianKind parseArchEndian(StringRef Arch)
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:29
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
@ Other
Any other memory.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:860