LLVM 19.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 }
356
357 llvm_unreachable("Invalid EnvironmentType!");
358}
359
361 switch (Kind) {
362 case UnknownObjectFormat: return "";
363 case COFF: return "coff";
364 case ELF: return "elf";
365 case GOFF: return "goff";
366 case MachO: return "macho";
367 case Wasm: return "wasm";
368 case XCOFF: return "xcoff";
369 case DXContainer: return "dxcontainer";
370 case SPIRV: return "spirv";
371 }
372 llvm_unreachable("unknown object format type");
373}
374
376 if (ArchName == "bpf") {
378 return Triple::bpfel;
379 else
380 return Triple::bpfeb;
381 } else if (ArchName == "bpf_be" || ArchName == "bpfeb") {
382 return Triple::bpfeb;
383 } else if (ArchName == "bpf_le" || ArchName == "bpfel") {
384 return Triple::bpfel;
385 } else {
386 return Triple::UnknownArch;
387 }
388}
389
393 .Case("aarch64", aarch64)
394 .Case("aarch64_be", aarch64_be)
395 .Case("aarch64_32", aarch64_32)
396 .Case("arc", arc)
397 .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
398 .Case("arm64_32", aarch64_32)
399 .Case("arm", arm)
400 .Case("armeb", armeb)
401 .Case("avr", avr)
402 .StartsWith("bpf", BPFArch)
403 .Case("m68k", m68k)
404 .Case("mips", mips)
405 .Case("mipsel", mipsel)
406 .Case("mips64", mips64)
407 .Case("mips64el", mips64el)
408 .Case("msp430", msp430)
409 .Case("ppc64", ppc64)
410 .Case("ppc32", ppc)
411 .Case("ppc", ppc)
412 .Case("ppc32le", ppcle)
413 .Case("ppcle", ppcle)
414 .Case("ppc64le", ppc64le)
415 .Case("r600", r600)
416 .Case("amdgcn", amdgcn)
417 .Case("riscv32", riscv32)
418 .Case("riscv64", riscv64)
419 .Case("hexagon", hexagon)
420 .Case("sparc", sparc)
421 .Case("sparcel", sparcel)
422 .Case("sparcv9", sparcv9)
423 .Case("s390x", systemz)
424 .Case("systemz", systemz)
425 .Case("tce", tce)
426 .Case("tcele", tcele)
427 .Case("thumb", thumb)
428 .Case("thumbeb", thumbeb)
429 .Case("x86", x86)
430 .Case("i386", x86)
431 .Case("x86-64", x86_64)
432 .Case("xcore", xcore)
433 .Case("nvptx", nvptx)
434 .Case("nvptx64", nvptx64)
435 .Case("le32", le32)
436 .Case("le64", le64)
437 .Case("amdil", amdil)
438 .Case("amdil64", amdil64)
439 .Case("hsail", hsail)
440 .Case("hsail64", hsail64)
441 .Case("spir", spir)
442 .Case("spir64", spir64)
443 .Case("spirv", spirv)
444 .Case("spirv32", spirv32)
445 .Case("spirv64", spirv64)
446 .Case("kalimba", kalimba)
447 .Case("lanai", lanai)
448 .Case("shave", shave)
449 .Case("wasm32", wasm32)
450 .Case("wasm64", wasm64)
451 .Case("renderscript32", renderscript32)
452 .Case("renderscript64", renderscript64)
453 .Case("ve", ve)
454 .Case("csky", csky)
455 .Case("loongarch32", loongarch32)
456 .Case("loongarch64", loongarch64)
457 .Case("dxil", dxil)
458 .Case("xtensa", xtensa)
460}
461
463 ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
464 ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
465
467 switch (ENDIAN) {
469 switch (ISA) {
471 arch = Triple::arm;
472 break;
474 arch = Triple::thumb;
475 break;
477 arch = Triple::aarch64;
478 break;
480 break;
481 }
482 break;
483 }
485 switch (ISA) {
487 arch = Triple::armeb;
488 break;
490 arch = Triple::thumbeb;
491 break;
493 arch = Triple::aarch64_be;
494 break;
496 break;
497 }
498 break;
499 }
501 break;
502 }
503 }
504
505 ArchName = ARM::getCanonicalArchName(ArchName);
506 if (ArchName.empty())
507 return Triple::UnknownArch;
508
509 // Thumb only exists in v4+
510 if (ISA == ARM::ISAKind::THUMB &&
511 (ArchName.starts_with("v2") || ArchName.starts_with("v3")))
512 return Triple::UnknownArch;
513
514 // Thumb only for v6m
516 unsigned Version = ARM::parseArchVersion(ArchName);
517 if (Profile == ARM::ProfileKind::M && Version == 6) {
518 if (ENDIAN == ARM::EndianKind::BIG)
519 return Triple::thumbeb;
520 else
521 return Triple::thumb;
522 }
523
524 return arch;
525}
526
528 auto AT =
530 .Cases("i386", "i486", "i586", "i686", Triple::x86)
531 // FIXME: Do we need to support these?
532 .Cases("i786", "i886", "i986", Triple::x86)
533 .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
534 .Cases("powerpc", "powerpcspe", "ppc", "ppc32", Triple::ppc)
535 .Cases("powerpcle", "ppcle", "ppc32le", Triple::ppcle)
536 .Cases("powerpc64", "ppu", "ppc64", Triple::ppc64)
537 .Cases("powerpc64le", "ppc64le", Triple::ppc64le)
538 .Case("xscale", Triple::arm)
539 .Case("xscaleeb", Triple::armeb)
540 .Case("aarch64", Triple::aarch64)
541 .Case("aarch64_be", Triple::aarch64_be)
542 .Case("aarch64_32", Triple::aarch64_32)
543 .Case("arc", Triple::arc)
544 .Case("arm64", Triple::aarch64)
545 .Case("arm64_32", Triple::aarch64_32)
546 .Case("arm64e", Triple::aarch64)
547 .Case("arm64ec", Triple::aarch64)
548 .Case("arm", Triple::arm)
549 .Case("armeb", Triple::armeb)
550 .Case("thumb", Triple::thumb)
551 .Case("thumbeb", Triple::thumbeb)
552 .Case("avr", Triple::avr)
553 .Case("m68k", Triple::m68k)
554 .Case("msp430", Triple::msp430)
555 .Cases("mips", "mipseb", "mipsallegrex", "mipsisa32r6", "mipsr6",
557 .Cases("mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el",
559 .Cases("mips64", "mips64eb", "mipsn32", "mipsisa64r6", "mips64r6",
560 "mipsn32r6", Triple::mips64)
561 .Cases("mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
562 "mipsn32r6el", Triple::mips64el)
563 .Case("r600", Triple::r600)
564 .Case("amdgcn", Triple::amdgcn)
565 .Case("riscv32", Triple::riscv32)
566 .Case("riscv64", Triple::riscv64)
567 .Case("hexagon", Triple::hexagon)
568 .Cases("s390x", "systemz", Triple::systemz)
569 .Case("sparc", Triple::sparc)
570 .Case("sparcel", Triple::sparcel)
571 .Cases("sparcv9", "sparc64", Triple::sparcv9)
572 .Case("tce", Triple::tce)
573 .Case("tcele", Triple::tcele)
574 .Case("xcore", Triple::xcore)
575 .Case("nvptx", Triple::nvptx)
576 .Case("nvptx64", Triple::nvptx64)
577 .Case("le32", Triple::le32)
578 .Case("le64", Triple::le64)
579 .Case("amdil", Triple::amdil)
580 .Case("amdil64", Triple::amdil64)
581 .Case("hsail", Triple::hsail)
582 .Case("hsail64", Triple::hsail64)
583 .Case("spir", Triple::spir)
584 .Case("spir64", Triple::spir64)
585 .Cases("spirv", "spirv1.5", "spirv1.6", Triple::spirv)
586 .Cases("spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
587 "spirv32v1.3", "spirv32v1.4", "spirv32v1.5",
588 "spirv32v1.6", Triple::spirv32)
589 .Cases("spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
590 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5",
591 "spirv64v1.6", Triple::spirv64)
592 .StartsWith("kalimba", Triple::kalimba)
593 .Case("lanai", Triple::lanai)
594 .Case("renderscript32", Triple::renderscript32)
595 .Case("renderscript64", Triple::renderscript64)
596 .Case("shave", Triple::shave)
597 .Case("ve", Triple::ve)
598 .Case("wasm32", Triple::wasm32)
599 .Case("wasm64", Triple::wasm64)
600 .Case("csky", Triple::csky)
601 .Case("loongarch32", Triple::loongarch32)
602 .Case("loongarch64", Triple::loongarch64)
603 .Cases("dxil", "dxilv1.0", "dxilv1.1", "dxilv1.2", "dxilv1.3",
604 "dxilv1.4", "dxilv1.5", "dxilv1.6", "dxilv1.7", "dxilv1.8",
606 .Case("xtensa", Triple::xtensa)
608
609 // Some architectures require special parsing logic just to compute the
610 // ArchType result.
611 if (AT == Triple::UnknownArch) {
612 if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
613 ArchName.starts_with("aarch64"))
614 return parseARMArch(ArchName);
615 if (ArchName.starts_with("bpf"))
616 return parseBPFArch(ArchName);
617 }
618
619 return AT;
620}
621
623 return StringSwitch<Triple::VendorType>(VendorName)
624 .Case("apple", Triple::Apple)
625 .Case("pc", Triple::PC)
626 .Case("scei", Triple::SCEI)
627 .Case("sie", Triple::SCEI)
628 .Case("fsl", Triple::Freescale)
629 .Case("ibm", Triple::IBM)
632 .Case("nvidia", Triple::NVIDIA)
633 .Case("csr", Triple::CSR)
634 .Case("amd", Triple::AMD)
635 .Case("mesa", Triple::Mesa)
636 .Case("suse", Triple::SUSE)
639}
640
642 return StringSwitch<Triple::OSType>(OSName)
643 .StartsWith("darwin", Triple::Darwin)
644 .StartsWith("dragonfly", Triple::DragonFly)
645 .StartsWith("freebsd", Triple::FreeBSD)
646 .StartsWith("fuchsia", Triple::Fuchsia)
647 .StartsWith("ios", Triple::IOS)
648 .StartsWith("kfreebsd", Triple::KFreeBSD)
649 .StartsWith("linux", Triple::Linux)
650 .StartsWith("lv2", Triple::Lv2)
651 .StartsWith("macos", Triple::MacOSX)
652 .StartsWith("netbsd", Triple::NetBSD)
653 .StartsWith("openbsd", Triple::OpenBSD)
654 .StartsWith("solaris", Triple::Solaris)
655 .StartsWith("uefi", Triple::UEFI)
656 .StartsWith("win32", Triple::Win32)
657 .StartsWith("windows", Triple::Win32)
658 .StartsWith("zos", Triple::ZOS)
659 .StartsWith("haiku", Triple::Haiku)
660 .StartsWith("rtems", Triple::RTEMS)
661 .StartsWith("nacl", Triple::NaCl)
662 .StartsWith("aix", Triple::AIX)
663 .StartsWith("cuda", Triple::CUDA)
664 .StartsWith("nvcl", Triple::NVCL)
665 .StartsWith("amdhsa", Triple::AMDHSA)
666 .StartsWith("ps4", Triple::PS4)
667 .StartsWith("ps5", Triple::PS5)
668 .StartsWith("elfiamcu", Triple::ELFIAMCU)
669 .StartsWith("tvos", Triple::TvOS)
670 .StartsWith("watchos", Triple::WatchOS)
671 .StartsWith("bridgeos", Triple::BridgeOS)
672 .StartsWith("driverkit", Triple::DriverKit)
673 .StartsWith("xros", Triple::XROS)
674 .StartsWith("visionos", Triple::XROS)
675 .StartsWith("mesa3d", Triple::Mesa3D)
676 .StartsWith("amdpal", Triple::AMDPAL)
678 .StartsWith("hurd", Triple::Hurd)
679 .StartsWith("wasi", Triple::WASI)
680 .StartsWith("emscripten", Triple::Emscripten)
681 .StartsWith("shadermodel", Triple::ShaderModel)
682 .StartsWith("liteos", Triple::LiteOS)
683 .StartsWith("serenity", Triple::Serenity)
684 .StartsWith("vulkan", Triple::Vulkan)
686}
687
689 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
690 .StartsWith("eabihf", Triple::EABIHF)
691 .StartsWith("eabi", Triple::EABI)
692 .StartsWith("gnuabin32", Triple::GNUABIN32)
693 .StartsWith("gnuabi64", Triple::GNUABI64)
694 .StartsWith("gnueabihf", Triple::GNUEABIHF)
695 .StartsWith("gnueabi", Triple::GNUEABI)
696 .StartsWith("gnuf32", Triple::GNUF32)
697 .StartsWith("gnuf64", Triple::GNUF64)
698 .StartsWith("gnusf", Triple::GNUSF)
699 .StartsWith("gnux32", Triple::GNUX32)
700 .StartsWith("gnu_ilp32", Triple::GNUILP32)
701 .StartsWith("code16", Triple::CODE16)
702 .StartsWith("gnu", Triple::GNU)
703 .StartsWith("android", Triple::Android)
704 .StartsWith("musleabihf", Triple::MuslEABIHF)
705 .StartsWith("musleabi", Triple::MuslEABI)
706 .StartsWith("muslx32", Triple::MuslX32)
707 .StartsWith("musl", Triple::Musl)
708 .StartsWith("msvc", Triple::MSVC)
709 .StartsWith("itanium", Triple::Itanium)
710 .StartsWith("cygnus", Triple::Cygnus)
711 .StartsWith("coreclr", Triple::CoreCLR)
712 .StartsWith("simulator", Triple::Simulator)
713 .StartsWith("macabi", Triple::MacABI)
714 .StartsWith("pixel", Triple::Pixel)
715 .StartsWith("vertex", Triple::Vertex)
716 .StartsWith("geometry", Triple::Geometry)
717 .StartsWith("hull", Triple::Hull)
718 .StartsWith("domain", Triple::Domain)
719 .StartsWith("compute", Triple::Compute)
720 .StartsWith("library", Triple::Library)
721 .StartsWith("raygeneration", Triple::RayGeneration)
722 .StartsWith("intersection", Triple::Intersection)
723 .StartsWith("anyhit", Triple::AnyHit)
724 .StartsWith("closesthit", Triple::ClosestHit)
725 .StartsWith("miss", Triple::Miss)
726 .StartsWith("callable", Triple::Callable)
727 .StartsWith("mesh", Triple::Mesh)
728 .StartsWith("amplification", Triple::Amplification)
729 .StartsWith("opencl", Triple::OpenCL)
732}
733
735 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
736 // "xcoff" must come before "coff" because of the order-dependendent
737 // pattern matching.
738 .EndsWith("xcoff", Triple::XCOFF)
739 .EndsWith("coff", Triple::COFF)
740 .EndsWith("elf", Triple::ELF)
741 .EndsWith("goff", Triple::GOFF)
742 .EndsWith("macho", Triple::MachO)
743 .EndsWith("wasm", Triple::Wasm)
744 .EndsWith("spirv", Triple::SPIRV)
746}
747
749 if (SubArchName.starts_with("mips") &&
750 (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
752
753 if (SubArchName == "powerpcspe")
755
756 if (SubArchName == "arm64e")
758
759 if (SubArchName == "arm64ec")
761
762 if (SubArchName.starts_with("spirv"))
763 return StringSwitch<Triple::SubArchType>(SubArchName)
772
773 if (SubArchName.starts_with("dxil"))
774 return StringSwitch<Triple::SubArchType>(SubArchName)
785
786 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
787
788 // For now, this is the small part. Early return.
789 if (ARMSubArch.empty())
790 return StringSwitch<Triple::SubArchType>(SubArchName)
795
796 // ARM sub arch.
797 switch(ARM::parseArch(ARMSubArch)) {
798 case ARM::ArchKind::ARMV4:
799 return Triple::NoSubArch;
800 case ARM::ArchKind::ARMV4T:
802 case ARM::ArchKind::ARMV5T:
804 case ARM::ArchKind::ARMV5TE:
805 case ARM::ArchKind::IWMMXT:
806 case ARM::ArchKind::IWMMXT2:
807 case ARM::ArchKind::XSCALE:
808 case ARM::ArchKind::ARMV5TEJ:
810 case ARM::ArchKind::ARMV6:
812 case ARM::ArchKind::ARMV6K:
813 case ARM::ArchKind::ARMV6KZ:
815 case ARM::ArchKind::ARMV6T2:
817 case ARM::ArchKind::ARMV6M:
819 case ARM::ArchKind::ARMV7A:
820 case ARM::ArchKind::ARMV7R:
822 case ARM::ArchKind::ARMV7VE:
824 case ARM::ArchKind::ARMV7K:
826 case ARM::ArchKind::ARMV7M:
828 case ARM::ArchKind::ARMV7S:
830 case ARM::ArchKind::ARMV7EM:
832 case ARM::ArchKind::ARMV8A:
834 case ARM::ArchKind::ARMV8_1A:
836 case ARM::ArchKind::ARMV8_2A:
838 case ARM::ArchKind::ARMV8_3A:
840 case ARM::ArchKind::ARMV8_4A:
842 case ARM::ArchKind::ARMV8_5A:
844 case ARM::ArchKind::ARMV8_6A:
846 case ARM::ArchKind::ARMV8_7A:
848 case ARM::ArchKind::ARMV8_8A:
850 case ARM::ArchKind::ARMV8_9A:
852 case ARM::ArchKind::ARMV9A:
854 case ARM::ArchKind::ARMV9_1A:
856 case ARM::ArchKind::ARMV9_2A:
858 case ARM::ArchKind::ARMV9_3A:
860 case ARM::ArchKind::ARMV9_4A:
862 case ARM::ArchKind::ARMV9_5A:
864 case ARM::ArchKind::ARMV8R:
866 case ARM::ArchKind::ARMV8MBaseline:
868 case ARM::ArchKind::ARMV8MMainline:
870 case ARM::ArchKind::ARMV8_1MMainline:
872 default:
873 return Triple::NoSubArch;
874 }
875}
876
878 switch (T.getArch()) {
880 case Triple::aarch64:
882 case Triple::arm:
883 case Triple::thumb:
884 case Triple::x86:
885 case Triple::x86_64:
886 switch (T.getOS()) {
887 case Triple::Win32:
888 case Triple::UEFI:
889 return Triple::COFF;
890 default:
891 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
892 }
894 case Triple::amdgcn:
895 case Triple::amdil64:
896 case Triple::amdil:
897 case Triple::arc:
898 case Triple::armeb:
899 case Triple::avr:
900 case Triple::bpfeb:
901 case Triple::bpfel:
902 case Triple::csky:
903 case Triple::hexagon:
904 case Triple::hsail64:
905 case Triple::hsail:
906 case Triple::kalimba:
907 case Triple::lanai:
908 case Triple::le32:
909 case Triple::le64:
912 case Triple::m68k:
913 case Triple::mips64:
914 case Triple::mips64el:
915 case Triple::mips:
916 case Triple::mipsel:
917 case Triple::msp430:
918 case Triple::nvptx64:
919 case Triple::nvptx:
920 case Triple::ppc64le:
921 case Triple::ppcle:
922 case Triple::r600:
925 case Triple::riscv32:
926 case Triple::riscv64:
927 case Triple::shave:
928 case Triple::sparc:
929 case Triple::sparcel:
930 case Triple::sparcv9:
931 case Triple::spir64:
932 case Triple::spir:
933 case Triple::tce:
934 case Triple::tcele:
935 case Triple::thumbeb:
936 case Triple::ve:
937 case Triple::xcore:
938 case Triple::xtensa:
939 return Triple::ELF;
940
941 case Triple::ppc64:
942 case Triple::ppc:
943 if (T.isOSAIX())
944 return Triple::XCOFF;
945 if (T.isOSDarwin())
946 return Triple::MachO;
947 return Triple::ELF;
948
949 case Triple::systemz:
950 if (T.isOSzOS())
951 return Triple::GOFF;
952 return Triple::ELF;
953
954 case Triple::wasm32:
955 case Triple::wasm64:
956 return Triple::Wasm;
957
958 case Triple::spirv:
959 case Triple::spirv32:
960 case Triple::spirv64:
961 return Triple::SPIRV;
962
963 case Triple::dxil:
964 return Triple::DXContainer;
965 }
966 llvm_unreachable("unknown architecture");
967}
968
969/// Construct a triple from the string representation provided.
970///
971/// This stores the string representation and parses the various pieces into
972/// enum members.
974 : Data(Str.str()), Arch(UnknownArch), SubArch(NoSubArch),
975 Vendor(UnknownVendor), OS(UnknownOS), Environment(UnknownEnvironment),
976 ObjectFormat(UnknownObjectFormat) {
977 // Do minimal parsing by hand here.
978 SmallVector<StringRef, 4> Components;
979 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
980 if (Components.size() > 0) {
981 Arch = parseArch(Components[0]);
982 SubArch = parseSubArch(Components[0]);
983 if (Components.size() > 1) {
984 Vendor = parseVendor(Components[1]);
985 if (Components.size() > 2) {
986 OS = parseOS(Components[2]);
987 if (Components.size() > 3) {
988 Environment = parseEnvironment(Components[3]);
989 ObjectFormat = parseFormat(Components[3]);
990 }
991 }
992 } else {
993 Environment =
995 .StartsWith("mipsn32", Triple::GNUABIN32)
996 .StartsWith("mips64", Triple::GNUABI64)
997 .StartsWith("mipsisa64", Triple::GNUABI64)
998 .StartsWith("mipsisa32", Triple::GNU)
999 .Cases("mips", "mipsel", "mipsr6", "mipsr6el", Triple::GNU)
1001 }
1002 }
1003 if (ObjectFormat == UnknownObjectFormat)
1004 ObjectFormat = getDefaultFormat(*this);
1005}
1006
1007/// Construct a triple from string representations of the architecture,
1008/// vendor, and OS.
1009///
1010/// This joins each argument into a canonical string representation and parses
1011/// them into enum members. It leaves the environment unknown and omits it from
1012/// the string representation.
1013Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
1014 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
1015 Arch(parseArch(ArchStr.str())),
1016 SubArch(parseSubArch(ArchStr.str())),
1017 Vendor(parseVendor(VendorStr.str())),
1018 OS(parseOS(OSStr.str())),
1019 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
1020 ObjectFormat = getDefaultFormat(*this);
1021}
1022
1023/// Construct a triple from string representations of the architecture,
1024/// vendor, OS, and environment.
1025///
1026/// This joins each argument into a canonical string representation and parses
1027/// them into enum members.
1028Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1029 const Twine &EnvironmentStr)
1030 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1031 EnvironmentStr).str()),
1032 Arch(parseArch(ArchStr.str())),
1033 SubArch(parseSubArch(ArchStr.str())),
1034 Vendor(parseVendor(VendorStr.str())),
1035 OS(parseOS(OSStr.str())),
1036 Environment(parseEnvironment(EnvironmentStr.str())),
1037 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1038 if (ObjectFormat == Triple::UnknownObjectFormat)
1039 ObjectFormat = getDefaultFormat(*this);
1040}
1041
1043
1045 VersionTuple Ver =
1046 parseVersionFromName(ShaderModelStr.drop_front(strlen("shadermodel")));
1047 // Default DXIL minor version when Shader Model version is anything other
1048 // than 6.[0...8] or 6.x (which translates to latest current SM version)
1049 const unsigned SMMajor = 6;
1050 if (!Ver.empty()) {
1051 if (Ver.getMajor() == SMMajor) {
1052 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1053 switch (*SMMinor) {
1054 case 0:
1056 case 1:
1058 case 2:
1060 case 3:
1062 case 4:
1064 case 5:
1066 case 6:
1068 case 7:
1070 case 8:
1072 default:
1073 report_fatal_error("Unsupported Shader Model version", false);
1074 }
1075 }
1076 }
1077 } else {
1078 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1079 // shadermodel6.x is
1080 if (ShaderModelStr == "shadermodel6.x") {
1082 }
1083 }
1084 // DXIL version corresponding to Shader Model version other than 6.Minor
1085 // is 1.0
1087}
1088
1090 bool IsMinGW32 = false;
1091 bool IsCygwin = false;
1092
1093 // Parse into components.
1094 SmallVector<StringRef, 4> Components;
1095 Str.split(Components, '-');
1096
1097 // If the first component corresponds to a known architecture, preferentially
1098 // use it for the architecture. If the second component corresponds to a
1099 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1100 // component movement when a component parses as (eg) both a valid arch and a
1101 // valid os.
1102 ArchType Arch = UnknownArch;
1103 if (Components.size() > 0)
1104 Arch = parseArch(Components[0]);
1105 VendorType Vendor = UnknownVendor;
1106 if (Components.size() > 1)
1107 Vendor = parseVendor(Components[1]);
1108 OSType OS = UnknownOS;
1109 if (Components.size() > 2) {
1110 OS = parseOS(Components[2]);
1111 IsCygwin = Components[2].starts_with("cygwin");
1112 IsMinGW32 = Components[2].starts_with("mingw");
1113 }
1114 EnvironmentType Environment = UnknownEnvironment;
1115 if (Components.size() > 3)
1116 Environment = parseEnvironment(Components[3]);
1118 if (Components.size() > 4)
1119 ObjectFormat = parseFormat(Components[4]);
1120
1121 // Note which components are already in their final position. These will not
1122 // be moved.
1123 bool Found[4];
1124 Found[0] = Arch != UnknownArch;
1125 Found[1] = Vendor != UnknownVendor;
1126 Found[2] = OS != UnknownOS;
1127 Found[3] = Environment != UnknownEnvironment;
1128
1129 // If they are not there already, permute the components into their canonical
1130 // positions by seeing if they parse as a valid architecture, and if so moving
1131 // the component to the architecture position etc.
1132 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1133 if (Found[Pos])
1134 continue; // Already in the canonical position.
1135
1136 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1137 // Do not reparse any components that already matched.
1138 if (Idx < std::size(Found) && Found[Idx])
1139 continue;
1140
1141 // Does this component parse as valid for the target position?
1142 bool Valid = false;
1143 StringRef Comp = Components[Idx];
1144 switch (Pos) {
1145 default: llvm_unreachable("unexpected component type!");
1146 case 0:
1147 Arch = parseArch(Comp);
1148 Valid = Arch != UnknownArch;
1149 break;
1150 case 1:
1151 Vendor = parseVendor(Comp);
1152 Valid = Vendor != UnknownVendor;
1153 break;
1154 case 2:
1155 OS = parseOS(Comp);
1156 IsCygwin = Comp.starts_with("cygwin");
1157 IsMinGW32 = Comp.starts_with("mingw");
1158 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1159 break;
1160 case 3:
1161 Environment = parseEnvironment(Comp);
1162 Valid = Environment != UnknownEnvironment;
1163 if (!Valid) {
1164 ObjectFormat = parseFormat(Comp);
1165 Valid = ObjectFormat != UnknownObjectFormat;
1166 }
1167 break;
1168 }
1169 if (!Valid)
1170 continue; // Nope, try the next component.
1171
1172 // Move the component to the target position, pushing any non-fixed
1173 // components that are in the way to the right. This tends to give
1174 // good results in the common cases of a forgotten vendor component
1175 // or a wrongly positioned environment.
1176 if (Pos < Idx) {
1177 // Insert left, pushing the existing components to the right. For
1178 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1179 StringRef CurrentComponent(""); // The empty component.
1180 // Replace the component we are moving with an empty component.
1181 std::swap(CurrentComponent, Components[Idx]);
1182 // Insert the component being moved at Pos, displacing any existing
1183 // components to the right.
1184 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1185 // Skip over any fixed components.
1186 while (i < std::size(Found) && Found[i])
1187 ++i;
1188 // Place the component at the new position, getting the component
1189 // that was at this position - it will be moved right.
1190 std::swap(CurrentComponent, Components[i]);
1191 }
1192 } else if (Pos > Idx) {
1193 // Push right by inserting empty components until the component at Idx
1194 // reaches the target position Pos. For example, pc-a -> -pc-a when
1195 // moving pc to the second position.
1196 do {
1197 // Insert one empty component at Idx.
1198 StringRef CurrentComponent(""); // The empty component.
1199 for (unsigned i = Idx; i < Components.size();) {
1200 // Place the component at the new position, getting the component
1201 // that was at this position - it will be moved right.
1202 std::swap(CurrentComponent, Components[i]);
1203 // If it was placed on top of an empty component then we are done.
1204 if (CurrentComponent.empty())
1205 break;
1206 // Advance to the next component, skipping any fixed components.
1207 while (++i < std::size(Found) && Found[i])
1208 ;
1209 }
1210 // The last component was pushed off the end - append it.
1211 if (!CurrentComponent.empty())
1212 Components.push_back(CurrentComponent);
1213
1214 // Advance Idx to the component's new position.
1215 while (++Idx < std::size(Found) && Found[Idx])
1216 ;
1217 } while (Idx < Pos); // Add more until the final position is reached.
1218 }
1219 assert(Pos < Components.size() && Components[Pos] == Comp &&
1220 "Component moved wrong!");
1221 Found[Pos] = true;
1222 break;
1223 }
1224 }
1225
1226 // If "none" is in the middle component in a three-component triple, treat it
1227 // as the OS (Components[2]) instead of the vendor (Components[1]).
1228 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1229 Components[1] == "none" && Components[2].empty())
1230 std::swap(Components[1], Components[2]);
1231
1232 // Replace empty components with "unknown" value.
1233 for (StringRef &C : Components)
1234 if (C.empty())
1235 C = "unknown";
1236
1237 // Special case logic goes here. At this point Arch, Vendor and OS have the
1238 // correct values for the computed components.
1239 std::string NormalizedEnvironment;
1240 if (Environment == Triple::Android &&
1241 Components[3].starts_with("androideabi")) {
1242 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1243 if (AndroidVersion.empty()) {
1244 Components[3] = "android";
1245 } else {
1246 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1247 Components[3] = NormalizedEnvironment;
1248 }
1249 }
1250
1251 // SUSE uses "gnueabi" to mean "gnueabihf"
1252 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1253 Components[3] = "gnueabihf";
1254
1255 if (OS == Triple::Win32) {
1256 Components.resize(4);
1257 Components[2] = "windows";
1258 if (Environment == UnknownEnvironment) {
1259 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1260 Components[3] = "msvc";
1261 else
1262 Components[3] = getObjectFormatTypeName(ObjectFormat);
1263 }
1264 } else if (IsMinGW32) {
1265 Components.resize(4);
1266 Components[2] = "windows";
1267 Components[3] = "gnu";
1268 } else if (IsCygwin) {
1269 Components.resize(4);
1270 Components[2] = "windows";
1271 Components[3] = "cygnus";
1272 }
1273 if (IsMinGW32 || IsCygwin ||
1274 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1275 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1276 Components.resize(5);
1277 Components[4] = getObjectFormatTypeName(ObjectFormat);
1278 }
1279 }
1280
1281 // Normalize DXIL triple if it does not include DXIL version number.
1282 // Determine DXIL version number using the minor version number of Shader
1283 // Model version specified in target triple, if any. Prior to decoupling DXIL
1284 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1285 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1286 if (Components[0] == "dxil") {
1287 if (Components.size() > 4) {
1288 Components.resize(4);
1289 }
1290 // Add DXIL version only if shadermodel is specified in the triple
1291 if (OS == Triple::ShaderModel) {
1292 Components[0] = getDXILArchNameFromShaderModel(Components[2]);
1293 }
1294 }
1295 // Stick the corrected components back together to form the normalized string.
1296 return join(Components, "-");
1297}
1298
1300 return StringRef(Data).split('-').first; // Isolate first component
1301}
1302
1304 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1305 return Tmp.split('-').first; // Isolate second component
1306}
1307
1309 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1310 Tmp = Tmp.split('-').second; // Strip second component
1311 return Tmp.split('-').first; // Isolate third component
1312}
1313
1315 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1316 Tmp = Tmp.split('-').second; // Strip second component
1317 return Tmp.split('-').second; // Strip third component
1318}
1319
1321 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1322 return Tmp.split('-').second; // Strip second component
1323}
1324
1327 Version.tryParse(Name);
1328 return Version.withoutBuild();
1329}
1330
1333}
1334
1336 StringRef EnvironmentName = getEnvironmentName();
1337
1338 // none is a valid environment type - it basically amounts to a freestanding
1339 // environment.
1340 if (EnvironmentName == "none")
1341 return "";
1342
1343 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1344 EnvironmentName.consume_front(EnvironmentTypeName);
1345
1346 if (EnvironmentName.contains("-")) {
1347 // -obj is the suffix
1349 StringRef ObjectFormatTypeName =
1351 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1352 EnvironmentName.consume_back(tmp);
1353 }
1354 }
1355 return EnvironmentName;
1356}
1357
1359 StringRef OSName = getOSName();
1360 // Assume that the OS portion of the triple starts with the canonical name.
1361 StringRef OSTypeName = getOSTypeName(getOS());
1362 if (OSName.starts_with(OSTypeName))
1363 OSName = OSName.substr(OSTypeName.size());
1364 else if (getOS() == MacOSX)
1365 OSName.consume_front("macos");
1366 else if (OSName.starts_with("visionos"))
1367 OSName.consume_front("visionos");
1368
1369 return parseVersionFromName(OSName);
1370}
1371
1374
1375 switch (getOS()) {
1376 default: llvm_unreachable("unexpected OS for Darwin triple");
1377 case Darwin:
1378 // Default to darwin8, i.e., MacOSX 10.4.
1379 if (Version.getMajor() == 0)
1380 Version = VersionTuple(8);
1381 // Darwin version numbers are skewed from OS X versions.
1382 if (Version.getMajor() < 4) {
1383 return false;
1384 }
1385 if (Version.getMajor() <= 19) {
1386 Version = VersionTuple(10, Version.getMajor() - 4);
1387 } else {
1388 // darwin20+ corresponds to macOS 11+.
1389 Version = VersionTuple(11 + Version.getMajor() - 20);
1390 }
1391 break;
1392 case MacOSX:
1393 // Default to 10.4.
1394 if (Version.getMajor() == 0) {
1395 Version = VersionTuple(10, 4);
1396 } else if (Version.getMajor() < 10) {
1397 return false;
1398 }
1399 break;
1400 case IOS:
1401 case TvOS:
1402 case WatchOS:
1403 // Ignore the version from the triple. This is only handled because the
1404 // the clang driver combines OS X and IOS support into a common Darwin
1405 // toolchain that wants to know the OS X version number even when targeting
1406 // IOS.
1407 Version = VersionTuple(10, 4);
1408 break;
1409 case XROS:
1410 llvm_unreachable("OSX version isn't relevant for xrOS");
1411 case DriverKit:
1412 llvm_unreachable("OSX version isn't relevant for DriverKit");
1413 }
1414 return true;
1415}
1416
1418 switch (getOS()) {
1419 default: llvm_unreachable("unexpected OS for Darwin triple");
1420 case Darwin:
1421 case MacOSX:
1422 // Ignore the version from the triple. This is only handled because the
1423 // the clang driver combines OS X and IOS support into a common Darwin
1424 // toolchain that wants to know the iOS version number even when targeting
1425 // OS X.
1426 return VersionTuple(5);
1427 case IOS:
1428 case TvOS: {
1430 // Default to 5.0 (or 7.0 for arm64).
1431 if (Version.getMajor() == 0)
1432 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1433 return Version;
1434 }
1435 case XROS: {
1436 // xrOS 1 is aligned with iOS 17.
1438 return Version.withMajorReplaced(Version.getMajor() + 16);
1439 }
1440 case WatchOS:
1441 llvm_unreachable("conflicting triple info");
1442 case DriverKit:
1443 llvm_unreachable("DriverKit doesn't have an iOS version");
1444 }
1445}
1446
1448 switch (getOS()) {
1449 default: llvm_unreachable("unexpected OS for Darwin triple");
1450 case Darwin:
1451 case MacOSX:
1452 // Ignore the version from the triple. This is only handled because the
1453 // the clang driver combines OS X and IOS support into a common Darwin
1454 // toolchain that wants to know the iOS version number even when targeting
1455 // OS X.
1456 return VersionTuple(2);
1457 case WatchOS: {
1459 if (Version.getMajor() == 0)
1460 return VersionTuple(2);
1461 return Version;
1462 }
1463 case IOS:
1464 llvm_unreachable("conflicting triple info");
1465 case XROS:
1466 llvm_unreachable("watchOS version isn't relevant for xrOS");
1467 case DriverKit:
1468 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1469 }
1470}
1471
1473 switch (getOS()) {
1474 default:
1475 llvm_unreachable("unexpected OS for Darwin triple");
1476 case DriverKit:
1478 if (Version.getMajor() == 0)
1479 return Version.withMajorReplaced(19);
1480 return Version;
1481 }
1482}
1483
1485 if (getArch() != spirv || getOS() != Vulkan)
1486 llvm_unreachable("invalid Vulkan SPIR-V triple");
1487
1488 VersionTuple VulkanVersion = getOSVersion();
1489 SubArchType SpirvVersion = getSubArch();
1490
1492 // Vulkan 1.2 -> SPIR-V 1.5.
1494 // Vulkan 1.3 -> SPIR-V 1.6.
1496
1497 // If Vulkan version is unset, default to 1.2.
1498 if (VulkanVersion == VersionTuple(0))
1499 VulkanVersion = VersionTuple(1, 2);
1500
1501 if (ValidVersionMap.contains(VulkanVersion) &&
1502 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1503 SpirvVersion == NoSubArch))
1504 return VulkanVersion;
1505
1506 return VersionTuple(0);
1507}
1508
1510 if (getArch() != dxil || getOS() != ShaderModel)
1511 llvm_unreachable("invalid DXIL triple");
1512 StringRef Arch = getArchName();
1513 if (getSubArch() == NoSubArch)
1515 Arch.consume_front("dxilv");
1516 VersionTuple DXILVersion = parseVersionFromName(Arch);
1517 // FIXME: validate DXIL version against Shader Model version.
1518 // Tracked by https://github.com/llvm/llvm-project/issues/91388
1519 return DXILVersion;
1520}
1521
1522void Triple::setTriple(const Twine &Str) {
1523 *this = Triple(Str);
1524}
1525
1527 setArchName(getArchName(Kind, SubArch));
1528}
1529
1532}
1533
1535 setOSName(getOSTypeName(Kind));
1536}
1537
1539 if (ObjectFormat == getDefaultFormat(*this))
1541
1543 getObjectFormatTypeName(ObjectFormat)).str());
1544}
1545
1547 if (Environment == UnknownEnvironment)
1549
1550 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1551 getObjectFormatTypeName(Kind)).str());
1552}
1553
1555 // Work around a miscompilation bug for Twines in gcc 4.0.3.
1557 Triple += Str;
1558 Triple += "-";
1559 Triple += getVendorName();
1560 Triple += "-";
1563}
1564
1566 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1567}
1568
1570 if (hasEnvironment())
1571 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1572 "-" + getEnvironmentName());
1573 else
1574 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1575}
1576
1578 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1579 "-" + Str);
1580}
1581
1583 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1584}
1585
1587 switch (Arch) {
1589 return 0;
1590
1591 case llvm::Triple::avr:
1593 return 16;
1594
1597 case llvm::Triple::arc:
1598 case llvm::Triple::arm:
1600 case llvm::Triple::csky:
1601 case llvm::Triple::dxil:
1606 case llvm::Triple::le32:
1608 case llvm::Triple::m68k:
1609 case llvm::Triple::mips:
1612 case llvm::Triple::ppc:
1614 case llvm::Triple::r600:
1620 case llvm::Triple::spir:
1622 case llvm::Triple::tce:
1627 case llvm::Triple::x86:
1630 return 32;
1631
1639 case llvm::Triple::le64:
1653 case llvm::Triple::ve:
1656 return 64;
1657 }
1658 llvm_unreachable("Invalid architecture value");
1659}
1660
1662 return getArchPointerBitWidth(getArch()) == 64;
1663}
1664
1666 return getArchPointerBitWidth(getArch()) == 32;
1667}
1668
1670 return getArchPointerBitWidth(getArch()) == 16;
1671}
1672
1674 Triple T(*this);
1675 switch (getArch()) {
1677 case Triple::amdgcn:
1678 case Triple::avr:
1679 case Triple::bpfeb:
1680 case Triple::bpfel:
1681 case Triple::msp430:
1682 case Triple::systemz:
1683 case Triple::ve:
1684 T.setArch(UnknownArch);
1685 break;
1686
1687 case Triple::aarch64_32:
1688 case Triple::amdil:
1689 case Triple::arc:
1690 case Triple::arm:
1691 case Triple::armeb:
1692 case Triple::csky:
1693 case Triple::dxil:
1694 case Triple::hexagon:
1695 case Triple::hsail:
1696 case Triple::kalimba:
1697 case Triple::lanai:
1698 case Triple::le32:
1700 case Triple::m68k:
1701 case Triple::mips:
1702 case Triple::mipsel:
1703 case Triple::nvptx:
1704 case Triple::ppc:
1705 case Triple::ppcle:
1706 case Triple::r600:
1708 case Triple::riscv32:
1709 case Triple::shave:
1710 case Triple::sparc:
1711 case Triple::sparcel:
1712 case Triple::spir:
1713 case Triple::spirv32:
1714 case Triple::tce:
1715 case Triple::tcele:
1716 case Triple::thumb:
1717 case Triple::thumbeb:
1718 case Triple::wasm32:
1719 case Triple::x86:
1720 case Triple::xcore:
1721 case Triple::xtensa:
1722 // Already 32-bit.
1723 break;
1724
1725 case Triple::aarch64: T.setArch(Triple::arm); break;
1726 case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1727 case Triple::amdil64: T.setArch(Triple::amdil); break;
1728 case Triple::hsail64: T.setArch(Triple::hsail); break;
1729 case Triple::le64: T.setArch(Triple::le32); break;
1730 case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
1731 case Triple::mips64:
1732 T.setArch(Triple::mips, getSubArch());
1733 break;
1734 case Triple::mips64el:
1735 T.setArch(Triple::mipsel, getSubArch());
1736 break;
1737 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1738 case Triple::ppc64: T.setArch(Triple::ppc); break;
1739 case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1740 case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1741 case Triple::riscv64: T.setArch(Triple::riscv32); break;
1742 case Triple::sparcv9: T.setArch(Triple::sparc); break;
1743 case Triple::spir64: T.setArch(Triple::spir); break;
1744 case Triple::spirv:
1745 case Triple::spirv64:
1746 T.setArch(Triple::spirv32, getSubArch());
1747 break;
1748 case Triple::wasm64: T.setArch(Triple::wasm32); break;
1749 case Triple::x86_64: T.setArch(Triple::x86); break;
1750 }
1751 return T;
1752}
1753
1755 Triple T(*this);
1756 switch (getArch()) {
1758 case Triple::arc:
1759 case Triple::avr:
1760 case Triple::csky:
1761 case Triple::dxil:
1762 case Triple::hexagon:
1763 case Triple::kalimba:
1764 case Triple::lanai:
1765 case Triple::m68k:
1766 case Triple::msp430:
1767 case Triple::r600:
1768 case Triple::shave:
1769 case Triple::sparcel:
1770 case Triple::tce:
1771 case Triple::tcele:
1772 case Triple::xcore:
1773 case Triple::xtensa:
1774 T.setArch(UnknownArch);
1775 break;
1776
1777 case Triple::aarch64:
1778 case Triple::aarch64_be:
1779 case Triple::amdgcn:
1780 case Triple::amdil64:
1781 case Triple::bpfeb:
1782 case Triple::bpfel:
1783 case Triple::hsail64:
1784 case Triple::le64:
1786 case Triple::mips64:
1787 case Triple::mips64el:
1788 case Triple::nvptx64:
1789 case Triple::ppc64:
1790 case Triple::ppc64le:
1792 case Triple::riscv64:
1793 case Triple::sparcv9:
1794 case Triple::spir64:
1795 case Triple::spirv64:
1796 case Triple::systemz:
1797 case Triple::ve:
1798 case Triple::wasm64:
1799 case Triple::x86_64:
1800 // Already 64-bit.
1801 break;
1802
1803 case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1804 case Triple::amdil: T.setArch(Triple::amdil64); break;
1805 case Triple::arm: T.setArch(Triple::aarch64); break;
1806 case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1807 case Triple::hsail: T.setArch(Triple::hsail64); break;
1808 case Triple::le32: T.setArch(Triple::le64); break;
1809 case Triple::loongarch32: T.setArch(Triple::loongarch64); break;
1810 case Triple::mips:
1811 T.setArch(Triple::mips64, getSubArch());
1812 break;
1813 case Triple::mipsel:
1814 T.setArch(Triple::mips64el, getSubArch());
1815 break;
1816 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1817 case Triple::ppc: T.setArch(Triple::ppc64); break;
1818 case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1819 case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1820 case Triple::riscv32: T.setArch(Triple::riscv64); break;
1821 case Triple::sparc: T.setArch(Triple::sparcv9); break;
1822 case Triple::spir: T.setArch(Triple::spir64); break;
1823 case Triple::spirv:
1824 case Triple::spirv32:
1825 T.setArch(Triple::spirv64, getSubArch());
1826 break;
1827 case Triple::thumb: T.setArch(Triple::aarch64); break;
1828 case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1829 case Triple::wasm32: T.setArch(Triple::wasm64); break;
1830 case Triple::x86: T.setArch(Triple::x86_64); break;
1831 }
1832 return T;
1833}
1834
1836 Triple T(*this);
1837 // Already big endian.
1838 if (!isLittleEndian())
1839 return T;
1840 switch (getArch()) {
1842 case Triple::amdgcn:
1843 case Triple::amdil64:
1844 case Triple::amdil:
1845 case Triple::avr:
1846 case Triple::dxil:
1847 case Triple::hexagon:
1848 case Triple::hsail64:
1849 case Triple::hsail:
1850 case Triple::kalimba:
1851 case Triple::le32:
1852 case Triple::le64:
1855 case Triple::msp430:
1856 case Triple::nvptx64:
1857 case Triple::nvptx:
1858 case Triple::r600:
1861 case Triple::riscv32:
1862 case Triple::riscv64:
1863 case Triple::shave:
1864 case Triple::spir64:
1865 case Triple::spir:
1866 case Triple::spirv:
1867 case Triple::spirv32:
1868 case Triple::spirv64:
1869 case Triple::wasm32:
1870 case Triple::wasm64:
1871 case Triple::x86:
1872 case Triple::x86_64:
1873 case Triple::xcore:
1874 case Triple::ve:
1875 case Triple::csky:
1876 case Triple::xtensa:
1877
1878 // ARM is intentionally unsupported here, changing the architecture would
1879 // drop any arch suffixes.
1880 case Triple::arm:
1881 case Triple::thumb:
1882 T.setArch(UnknownArch);
1883 break;
1884
1885 case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1886 case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1887 case Triple::mips64el:
1888 T.setArch(Triple::mips64, getSubArch());
1889 break;
1890 case Triple::mipsel:
1891 T.setArch(Triple::mips, getSubArch());
1892 break;
1893 case Triple::ppcle: T.setArch(Triple::ppc); break;
1894 case Triple::ppc64le: T.setArch(Triple::ppc64); break;
1895 case Triple::sparcel: T.setArch(Triple::sparc); break;
1896 case Triple::tcele: T.setArch(Triple::tce); break;
1897 default:
1898 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
1899 }
1900 return T;
1901}
1902
1904 Triple T(*this);
1905 if (isLittleEndian())
1906 return T;
1907
1908 switch (getArch()) {
1910 case Triple::lanai:
1911 case Triple::sparcv9:
1912 case Triple::systemz:
1913 case Triple::m68k:
1914
1915 // ARM is intentionally unsupported here, changing the architecture would
1916 // drop any arch suffixes.
1917 case Triple::armeb:
1918 case Triple::thumbeb:
1919 T.setArch(UnknownArch);
1920 break;
1921
1922 case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
1923 case Triple::bpfeb: T.setArch(Triple::bpfel); break;
1924 case Triple::mips64:
1925 T.setArch(Triple::mips64el, getSubArch());
1926 break;
1927 case Triple::mips:
1928 T.setArch(Triple::mipsel, getSubArch());
1929 break;
1930 case Triple::ppc: T.setArch(Triple::ppcle); break;
1931 case Triple::ppc64: T.setArch(Triple::ppc64le); break;
1932 case Triple::sparc: T.setArch(Triple::sparcel); break;
1933 case Triple::tce: T.setArch(Triple::tcele); break;
1934 default:
1935 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
1936 }
1937 return T;
1938}
1939
1941 switch (getArch()) {
1942 case Triple::aarch64:
1943 case Triple::aarch64_32:
1944 case Triple::amdgcn:
1945 case Triple::amdil64:
1946 case Triple::amdil:
1947 case Triple::arm:
1948 case Triple::avr:
1949 case Triple::bpfel:
1950 case Triple::csky:
1951 case Triple::dxil:
1952 case Triple::hexagon:
1953 case Triple::hsail64:
1954 case Triple::hsail:
1955 case Triple::kalimba:
1956 case Triple::le32:
1957 case Triple::le64:
1960 case Triple::mips64el:
1961 case Triple::mipsel:
1962 case Triple::msp430:
1963 case Triple::nvptx64:
1964 case Triple::nvptx:
1965 case Triple::ppcle:
1966 case Triple::ppc64le:
1967 case Triple::r600:
1970 case Triple::riscv32:
1971 case Triple::riscv64:
1972 case Triple::shave:
1973 case Triple::sparcel:
1974 case Triple::spir64:
1975 case Triple::spir:
1976 case Triple::spirv:
1977 case Triple::spirv32:
1978 case Triple::spirv64:
1979 case Triple::tcele:
1980 case Triple::thumb:
1981 case Triple::ve:
1982 case Triple::wasm32:
1983 case Triple::wasm64:
1984 case Triple::x86:
1985 case Triple::x86_64:
1986 case Triple::xcore:
1987 case Triple::xtensa:
1988 return true;
1989 default:
1990 return false;
1991 }
1992}
1993
1995 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1996 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
1997 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
1998 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
1999 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
2000 if (getVendor() == Triple::Apple)
2001 return getSubArch() == Other.getSubArch() &&
2002 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2003 else
2004 return getSubArch() == Other.getSubArch() &&
2005 getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
2006 getEnvironment() == Other.getEnvironment() &&
2007 getObjectFormat() == Other.getObjectFormat();
2008 }
2009
2010 // If vendor is apple, ignore the version number.
2011 if (getVendor() == Triple::Apple)
2012 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
2013 getVendor() == Other.getVendor() && getOS() == Other.getOS();
2014
2015 return *this == Other;
2016}
2017
2018std::string Triple::merge(const Triple &Other) const {
2019 // If vendor is apple, pick the triple with the larger version number.
2020 if (getVendor() == Triple::Apple)
2021 if (Other.isOSVersionLT(*this))
2022 return str();
2023
2024 return Other.str();
2025}
2026
2027bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
2028 unsigned Micro) const {
2029 assert(isMacOSX() && "Not an OS X triple!");
2030
2031 // If this is OS X, expect a sane version number.
2032 if (getOS() == Triple::MacOSX)
2033 return isOSVersionLT(Major, Minor, Micro);
2034
2035 // Otherwise, compare to the "Darwin" number.
2036 if (Major == 10) {
2037 return isOSVersionLT(Minor + 4, Micro, 0);
2038 } else {
2039 assert(Major >= 11 && "Unexpected major version");
2040 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2041 }
2042}
2043
2046 return VersionTuple();
2047 switch (getOS()) {
2048 case Triple::MacOSX:
2049 // ARM64 slice is supported starting from macOS 11.0+.
2050 return VersionTuple(11, 0, 0);
2051 case Triple::IOS:
2052 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2053 // ARM64 simulators are supported for iOS 14+.
2055 return VersionTuple(14, 0, 0);
2056 // ARM64e slice is supported starting from iOS 14.
2057 if (isArm64e())
2058 return VersionTuple(14, 0, 0);
2059 break;
2060 case Triple::TvOS:
2061 // ARM64 simulators are supported for tvOS 14+.
2063 return VersionTuple(14, 0, 0);
2064 break;
2065 case Triple::WatchOS:
2066 // ARM64 simulators are supported for watchOS 7+.
2068 return VersionTuple(7, 0, 0);
2069 break;
2070 case Triple::DriverKit:
2071 return VersionTuple(20, 0, 0);
2072 default:
2073 break;
2074 }
2075 return VersionTuple();
2076}
2077
2079 const VersionTuple &Version) {
2080 switch (OSKind) {
2081 case MacOSX:
2082 // macOS 10.16 is canonicalized to macOS 11.
2083 if (Version == VersionTuple(10, 16))
2084 return VersionTuple(11, 0);
2085 [[fallthrough]];
2086 default:
2087 return Version;
2088 }
2089}
2090
2091// HLSL triple environment orders are relied on in the front end
2092static_assert(Triple::Vertex - Triple::Pixel == 1,
2093 "incorrect HLSL stage order");
2094static_assert(Triple::Geometry - Triple::Pixel == 2,
2095 "incorrect HLSL stage order");
2096static_assert(Triple::Hull - Triple::Pixel == 3,
2097 "incorrect HLSL stage order");
2098static_assert(Triple::Domain - Triple::Pixel == 4,
2099 "incorrect HLSL stage order");
2100static_assert(Triple::Compute - Triple::Pixel == 5,
2101 "incorrect HLSL stage order");
2102static_assert(Triple::Library - Triple::Pixel == 6,
2103 "incorrect HLSL stage order");
2104static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2105 "incorrect HLSL stage order");
2106static_assert(Triple::Intersection - Triple::Pixel == 8,
2107 "incorrect HLSL stage order");
2108static_assert(Triple::AnyHit - Triple::Pixel == 9,
2109 "incorrect HLSL stage order");
2110static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2111 "incorrect HLSL stage order");
2112static_assert(Triple::Miss - Triple::Pixel == 11,
2113 "incorrect HLSL stage order");
2114static_assert(Triple::Callable - Triple::Pixel == 12,
2115 "incorrect HLSL stage order");
2116static_assert(Triple::Mesh - Triple::Pixel == 13,
2117 "incorrect HLSL stage order");
2118static_assert(Triple::Amplification - Triple::Pixel == 14,
2119 "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:688
static VersionTuple parseVersionFromName(StringRef Name)
Definition: Triple.cpp:1325
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition: Triple.cpp:877
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition: Triple.cpp:462
static Triple::OSType parseOS(StringRef OSName)
Definition: Triple.cpp:641
static StringRef getDXILArchNameFromShaderModel(StringRef ShaderModelStr)
Definition: Triple.cpp:1044
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition: Triple.cpp:375
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition: Triple.cpp:748
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition: Triple.cpp:734
static Triple::ArchType parseArch(StringRef ArchName)
Definition: Triple.cpp:527
static Triple::VendorType parseVendor(StringRef VendorName)
Definition: Triple.cpp:622
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:692
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition: StringRef.h:647
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:563
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:257
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:601
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:416
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:627
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:269
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:2027
VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1358
StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition: Triple.cpp:1303
VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1447
void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1554
void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition: Triple.cpp:1546
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1673
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:366
unsigned getArchPointerBitWidth() const
Returns the pointer width of this architecture.
Definition: Triple.h:475
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1903
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:399
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition: Triple.h:376
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition: Triple.h:1031
void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1565
@ 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:1582
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1754
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1940
void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1538
StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition: Triple.cpp:1308
@ 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:1522
OSType getOS() const
Get the parsed operating system type of this triple.
Definition: Triple.h:382
VersionTuple getEnvironmentVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1331
static ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:390
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition: Triple.h:373
StringRef getEnvironmentName() const
Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:1314
bool isSimulatorEnvironment() const
Definition: Triple.h:562
VersionTuple getDXILVersion() const
Parse the DXIL version number from the OSVersion and DXIL version (SubArch).
Definition: Triple.cpp:1509
const std::string & str() const
Definition: Triple.h:440
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition: Triple.h:390
VersionTuple getVulkanVersion() const
Parse the Vulkan version number from the OSVersion and SPIR-V version (SubArch).
Definition: Triple.cpp:1484
VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1472
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:297
@ DXContainer
Definition: Triple.h:301
@ UnknownObjectFormat
Definition: Triple.h:298
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:2018
@ 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:2044
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1661
StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition: Triple.cpp:1320
@ 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:1372
bool isMacOSX() const
Is this a Mac OS X triple.
Definition: Triple.h:522
void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition: Triple.cpp:1577
void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1534
void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1569
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition: Triple.h:379
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:500
static VersionTuple getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version)
Returns a canonicalized OS version number for the specified OS.
Definition: Triple.cpp:2078
StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1299
bool isMacCatalystEnvironment() const
Definition: Triple.h:566
static StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition: Triple.cpp:360
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1669
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1835
VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1417
StringRef getEnvironmentVersionString() const
Get the version component of the environment component as a single string (the version after the envi...
Definition: Triple.cpp:1335
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1665
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1994
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition: Triple.h:385
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:1526
void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1530
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:156
@ Other
Any other memory.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:860