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.equals("bpf")) {
378 return Triple::bpfel;
379 else
380 return Triple::bpfeb;
381 } else if (ArchName.equals("bpf_be") || ArchName.equals("bpfeb")) {
382 return Triple::bpfeb;
383 } else if (ArchName.equals("bpf_le") || ArchName.equals("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 bool IsMinGW32 = false;
1046 bool IsCygwin = false;
1047
1048 // Parse into components.
1049 SmallVector<StringRef, 4> Components;
1050 Str.split(Components, '-');
1051
1052 // If the first component corresponds to a known architecture, preferentially
1053 // use it for the architecture. If the second component corresponds to a
1054 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1055 // component movement when a component parses as (eg) both a valid arch and a
1056 // valid os.
1057 ArchType Arch = UnknownArch;
1058 if (Components.size() > 0)
1059 Arch = parseArch(Components[0]);
1060 VendorType Vendor = UnknownVendor;
1061 if (Components.size() > 1)
1062 Vendor = parseVendor(Components[1]);
1063 OSType OS = UnknownOS;
1064 if (Components.size() > 2) {
1065 OS = parseOS(Components[2]);
1066 IsCygwin = Components[2].starts_with("cygwin");
1067 IsMinGW32 = Components[2].starts_with("mingw");
1068 }
1069 EnvironmentType Environment = UnknownEnvironment;
1070 if (Components.size() > 3)
1071 Environment = parseEnvironment(Components[3]);
1073 if (Components.size() > 4)
1074 ObjectFormat = parseFormat(Components[4]);
1075
1076 // Note which components are already in their final position. These will not
1077 // be moved.
1078 bool Found[4];
1079 Found[0] = Arch != UnknownArch;
1080 Found[1] = Vendor != UnknownVendor;
1081 Found[2] = OS != UnknownOS;
1082 Found[3] = Environment != UnknownEnvironment;
1083
1084 // If they are not there already, permute the components into their canonical
1085 // positions by seeing if they parse as a valid architecture, and if so moving
1086 // the component to the architecture position etc.
1087 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1088 if (Found[Pos])
1089 continue; // Already in the canonical position.
1090
1091 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1092 // Do not reparse any components that already matched.
1093 if (Idx < std::size(Found) && Found[Idx])
1094 continue;
1095
1096 // Does this component parse as valid for the target position?
1097 bool Valid = false;
1098 StringRef Comp = Components[Idx];
1099 switch (Pos) {
1100 default: llvm_unreachable("unexpected component type!");
1101 case 0:
1102 Arch = parseArch(Comp);
1103 Valid = Arch != UnknownArch;
1104 break;
1105 case 1:
1106 Vendor = parseVendor(Comp);
1107 Valid = Vendor != UnknownVendor;
1108 break;
1109 case 2:
1110 OS = parseOS(Comp);
1111 IsCygwin = Comp.starts_with("cygwin");
1112 IsMinGW32 = Comp.starts_with("mingw");
1113 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1114 break;
1115 case 3:
1116 Environment = parseEnvironment(Comp);
1117 Valid = Environment != UnknownEnvironment;
1118 if (!Valid) {
1119 ObjectFormat = parseFormat(Comp);
1120 Valid = ObjectFormat != UnknownObjectFormat;
1121 }
1122 break;
1123 }
1124 if (!Valid)
1125 continue; // Nope, try the next component.
1126
1127 // Move the component to the target position, pushing any non-fixed
1128 // components that are in the way to the right. This tends to give
1129 // good results in the common cases of a forgotten vendor component
1130 // or a wrongly positioned environment.
1131 if (Pos < Idx) {
1132 // Insert left, pushing the existing components to the right. For
1133 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1134 StringRef CurrentComponent(""); // The empty component.
1135 // Replace the component we are moving with an empty component.
1136 std::swap(CurrentComponent, Components[Idx]);
1137 // Insert the component being moved at Pos, displacing any existing
1138 // components to the right.
1139 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1140 // Skip over any fixed components.
1141 while (i < std::size(Found) && Found[i])
1142 ++i;
1143 // Place the component at the new position, getting the component
1144 // that was at this position - it will be moved right.
1145 std::swap(CurrentComponent, Components[i]);
1146 }
1147 } else if (Pos > Idx) {
1148 // Push right by inserting empty components until the component at Idx
1149 // reaches the target position Pos. For example, pc-a -> -pc-a when
1150 // moving pc to the second position.
1151 do {
1152 // Insert one empty component at Idx.
1153 StringRef CurrentComponent(""); // The empty component.
1154 for (unsigned i = Idx; i < Components.size();) {
1155 // Place the component at the new position, getting the component
1156 // that was at this position - it will be moved right.
1157 std::swap(CurrentComponent, Components[i]);
1158 // If it was placed on top of an empty component then we are done.
1159 if (CurrentComponent.empty())
1160 break;
1161 // Advance to the next component, skipping any fixed components.
1162 while (++i < std::size(Found) && Found[i])
1163 ;
1164 }
1165 // The last component was pushed off the end - append it.
1166 if (!CurrentComponent.empty())
1167 Components.push_back(CurrentComponent);
1168
1169 // Advance Idx to the component's new position.
1170 while (++Idx < std::size(Found) && Found[Idx])
1171 ;
1172 } while (Idx < Pos); // Add more until the final position is reached.
1173 }
1174 assert(Pos < Components.size() && Components[Pos] == Comp &&
1175 "Component moved wrong!");
1176 Found[Pos] = true;
1177 break;
1178 }
1179 }
1180
1181 // If "none" is in the middle component in a three-component triple, treat it
1182 // as the OS (Components[2]) instead of the vendor (Components[1]).
1183 if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1184 Components[1] == "none" && Components[2].empty())
1185 std::swap(Components[1], Components[2]);
1186
1187 // Replace empty components with "unknown" value.
1188 for (StringRef &C : Components)
1189 if (C.empty())
1190 C = "unknown";
1191
1192 // Special case logic goes here. At this point Arch, Vendor and OS have the
1193 // correct values for the computed components.
1194 std::string NormalizedEnvironment;
1195 if (Environment == Triple::Android &&
1196 Components[3].starts_with("androideabi")) {
1197 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1198 if (AndroidVersion.empty()) {
1199 Components[3] = "android";
1200 } else {
1201 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1202 Components[3] = NormalizedEnvironment;
1203 }
1204 }
1205
1206 // SUSE uses "gnueabi" to mean "gnueabihf"
1207 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1208 Components[3] = "gnueabihf";
1209
1210 if (OS == Triple::Win32) {
1211 Components.resize(4);
1212 Components[2] = "windows";
1213 if (Environment == UnknownEnvironment) {
1214 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1215 Components[3] = "msvc";
1216 else
1217 Components[3] = getObjectFormatTypeName(ObjectFormat);
1218 }
1219 } else if (IsMinGW32) {
1220 Components.resize(4);
1221 Components[2] = "windows";
1222 Components[3] = "gnu";
1223 } else if (IsCygwin) {
1224 Components.resize(4);
1225 Components[2] = "windows";
1226 Components[3] = "cygnus";
1227 }
1228 if (IsMinGW32 || IsCygwin ||
1229 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1230 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1231 Components.resize(5);
1232 Components[4] = getObjectFormatTypeName(ObjectFormat);
1233 }
1234 }
1235
1236 // Normalize DXIL triple if it does not include DXIL version number.
1237 // Determine DXIL version number using the minor version number of Shader
1238 // Model version specified in target triple, if any. Prior to decoupling DXIL
1239 // version numbering from that of Shader Model DXIL version 1.Y corresponds to
1240 // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
1241 if (Components[0] == "dxil") {
1242 if (Components.size() > 4) {
1243 Components.resize(4);
1244 }
1245 // Add DXIL version only if shadermodel is specified in the triple
1246 if (OS == Triple::ShaderModel) {
1247 VersionTuple Ver =
1248 parseVersionFromName(Components[2].drop_front(strlen("shadermodel")));
1249 // Default DXIL minor version when Shader Model version is anything other
1250 // than 6.[0...8] or 6.x (which translates to latest current SM version)
1251 // DXIL version corresponding to Shader Model version other than 6.x
1252 // is 1.0
1253 unsigned DXILMinor = 0;
1254 const unsigned SMMajor = 6;
1255 const unsigned LatestCurrentDXILMinor = 8;
1256 if (!Ver.empty()) {
1257 if (Ver.getMajor() == SMMajor) {
1258 if (std::optional<unsigned> SMMinor = Ver.getMinor()) {
1259 DXILMinor = *SMMinor;
1260 // Ensure specified minor version is supported
1261 if (DXILMinor > LatestCurrentDXILMinor) {
1262 report_fatal_error("Unsupported Shader Model version", false);
1263 }
1264 }
1265 }
1266 } else {
1267 // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1268 // shadermodel6.x is
1269 if (Components[2] == "shadermodel6.x") {
1270 DXILMinor = LatestCurrentDXILMinor;
1271 }
1272 }
1273 Components[0] =
1274 Components[0].str().append("v1.").append(std::to_string(DXILMinor));
1275 }
1276 }
1277 // Stick the corrected components back together to form the normalized string.
1278 return join(Components, "-");
1279}
1280
1282 return StringRef(Data).split('-').first; // Isolate first component
1283}
1284
1286 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1287 return Tmp.split('-').first; // Isolate second component
1288}
1289
1291 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1292 Tmp = Tmp.split('-').second; // Strip second component
1293 return Tmp.split('-').first; // Isolate third component
1294}
1295
1297 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1298 Tmp = Tmp.split('-').second; // Strip second component
1299 return Tmp.split('-').second; // Strip third component
1300}
1301
1303 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1304 return Tmp.split('-').second; // Strip second component
1305}
1306
1308 VersionTuple Version;
1309 Version.tryParse(Name);
1310 return Version.withoutBuild();
1311}
1312
1315}
1316
1318 StringRef EnvironmentName = getEnvironmentName();
1319
1320 // none is a valid environment type - it basically amounts to a freestanding
1321 // environment.
1322 if (EnvironmentName == "none")
1323 return "";
1324
1325 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1326 EnvironmentName.consume_front(EnvironmentTypeName);
1327
1328 if (EnvironmentName.contains("-")) {
1329 // -obj is the suffix
1331 StringRef ObjectFormatTypeName =
1333 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1334 EnvironmentName.consume_back(tmp);
1335 }
1336 }
1337 return EnvironmentName;
1338}
1339
1341 StringRef OSName = getOSName();
1342 // Assume that the OS portion of the triple starts with the canonical name.
1343 StringRef OSTypeName = getOSTypeName(getOS());
1344 if (OSName.starts_with(OSTypeName))
1345 OSName = OSName.substr(OSTypeName.size());
1346 else if (getOS() == MacOSX)
1347 OSName.consume_front("macos");
1348 else if (OSName.starts_with("visionos"))
1349 OSName.consume_front("visionos");
1350
1351 return parseVersionFromName(OSName);
1352}
1353
1355 Version = getOSVersion();
1356
1357 switch (getOS()) {
1358 default: llvm_unreachable("unexpected OS for Darwin triple");
1359 case Darwin:
1360 // Default to darwin8, i.e., MacOSX 10.4.
1361 if (Version.getMajor() == 0)
1362 Version = VersionTuple(8);
1363 // Darwin version numbers are skewed from OS X versions.
1364 if (Version.getMajor() < 4) {
1365 return false;
1366 }
1367 if (Version.getMajor() <= 19) {
1368 Version = VersionTuple(10, Version.getMajor() - 4);
1369 } else {
1370 // darwin20+ corresponds to macOS 11+.
1371 Version = VersionTuple(11 + Version.getMajor() - 20);
1372 }
1373 break;
1374 case MacOSX:
1375 // Default to 10.4.
1376 if (Version.getMajor() == 0) {
1377 Version = VersionTuple(10, 4);
1378 } else if (Version.getMajor() < 10) {
1379 return false;
1380 }
1381 break;
1382 case IOS:
1383 case TvOS:
1384 case WatchOS:
1385 // Ignore the version from the triple. This is only handled because the
1386 // the clang driver combines OS X and IOS support into a common Darwin
1387 // toolchain that wants to know the OS X version number even when targeting
1388 // IOS.
1389 Version = VersionTuple(10, 4);
1390 break;
1391 case XROS:
1392 llvm_unreachable("OSX version isn't relevant for xrOS");
1393 case DriverKit:
1394 llvm_unreachable("OSX version isn't relevant for DriverKit");
1395 }
1396 return true;
1397}
1398
1400 switch (getOS()) {
1401 default: llvm_unreachable("unexpected OS for Darwin triple");
1402 case Darwin:
1403 case MacOSX:
1404 // Ignore the version from the triple. This is only handled because the
1405 // the clang driver combines OS X and IOS support into a common Darwin
1406 // toolchain that wants to know the iOS version number even when targeting
1407 // OS X.
1408 return VersionTuple(5);
1409 case IOS:
1410 case TvOS: {
1411 VersionTuple Version = getOSVersion();
1412 // Default to 5.0 (or 7.0 for arm64).
1413 if (Version.getMajor() == 0)
1414 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1415 return Version;
1416 }
1417 case XROS: {
1418 // xrOS 1 is aligned with iOS 17.
1419 VersionTuple Version = getOSVersion();
1420 return Version.withMajorReplaced(Version.getMajor() + 16);
1421 }
1422 case WatchOS:
1423 llvm_unreachable("conflicting triple info");
1424 case DriverKit:
1425 llvm_unreachable("DriverKit doesn't have an iOS version");
1426 }
1427}
1428
1430 switch (getOS()) {
1431 default: llvm_unreachable("unexpected OS for Darwin triple");
1432 case Darwin:
1433 case MacOSX:
1434 // Ignore the version from the triple. This is only handled because the
1435 // the clang driver combines OS X and IOS support into a common Darwin
1436 // toolchain that wants to know the iOS version number even when targeting
1437 // OS X.
1438 return VersionTuple(2);
1439 case WatchOS: {
1440 VersionTuple Version = getOSVersion();
1441 if (Version.getMajor() == 0)
1442 return VersionTuple(2);
1443 return Version;
1444 }
1445 case IOS:
1446 llvm_unreachable("conflicting triple info");
1447 case XROS:
1448 llvm_unreachable("watchOS version isn't relevant for xrOS");
1449 case DriverKit:
1450 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1451 }
1452}
1453
1455 switch (getOS()) {
1456 default:
1457 llvm_unreachable("unexpected OS for Darwin triple");
1458 case DriverKit:
1459 VersionTuple Version = getOSVersion();
1460 if (Version.getMajor() == 0)
1461 return Version.withMajorReplaced(19);
1462 return Version;
1463 }
1464}
1465
1467 if (getArch() != spirv || getOS() != Vulkan)
1468 llvm_unreachable("invalid Vulkan SPIR-V triple");
1469
1470 VersionTuple VulkanVersion = getOSVersion();
1471 SubArchType SpirvVersion = getSubArch();
1472
1474 // Vulkan 1.2 -> SPIR-V 1.5.
1476 // Vulkan 1.3 -> SPIR-V 1.6.
1478
1479 // If Vulkan version is unset, default to 1.2.
1480 if (VulkanVersion == VersionTuple(0))
1481 VulkanVersion = VersionTuple(1, 2);
1482
1483 if (ValidVersionMap.contains(VulkanVersion) &&
1484 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1485 SpirvVersion == NoSubArch))
1486 return VulkanVersion;
1487
1488 return VersionTuple(0);
1489}
1490
1491void Triple::setTriple(const Twine &Str) {
1492 *this = Triple(Str);
1493}
1494
1496 setArchName(getArchName(Kind, SubArch));
1497}
1498
1501}
1502
1504 setOSName(getOSTypeName(Kind));
1505}
1506
1508 if (ObjectFormat == getDefaultFormat(*this))
1510
1512 getObjectFormatTypeName(ObjectFormat)).str());
1513}
1514
1516 if (Environment == UnknownEnvironment)
1518
1519 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1520 getObjectFormatTypeName(Kind)).str());
1521}
1522
1524 // Work around a miscompilation bug for Twines in gcc 4.0.3.
1526 Triple += Str;
1527 Triple += "-";
1528 Triple += getVendorName();
1529 Triple += "-";
1532}
1533
1535 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1536}
1537
1539 if (hasEnvironment())
1540 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1541 "-" + getEnvironmentName());
1542 else
1543 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1544}
1545
1547 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1548 "-" + Str);
1549}
1550
1552 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1553}
1554
1556 switch (Arch) {
1558 return 0;
1559
1560 case llvm::Triple::avr:
1562 return 16;
1563
1566 case llvm::Triple::arc:
1567 case llvm::Triple::arm:
1569 case llvm::Triple::csky:
1570 case llvm::Triple::dxil:
1575 case llvm::Triple::le32:
1577 case llvm::Triple::m68k:
1578 case llvm::Triple::mips:
1581 case llvm::Triple::ppc:
1583 case llvm::Triple::r600:
1589 case llvm::Triple::spir:
1591 case llvm::Triple::tce:
1596 case llvm::Triple::x86:
1599 return 32;
1600
1608 case llvm::Triple::le64:
1622 case llvm::Triple::ve:
1625 return 64;
1626 }
1627 llvm_unreachable("Invalid architecture value");
1628}
1629
1631 return getArchPointerBitWidth(getArch()) == 64;
1632}
1633
1635 return getArchPointerBitWidth(getArch()) == 32;
1636}
1637
1639 return getArchPointerBitWidth(getArch()) == 16;
1640}
1641
1643 Triple T(*this);
1644 switch (getArch()) {
1646 case Triple::amdgcn:
1647 case Triple::avr:
1648 case Triple::bpfeb:
1649 case Triple::bpfel:
1650 case Triple::msp430:
1651 case Triple::systemz:
1652 case Triple::ve:
1653 T.setArch(UnknownArch);
1654 break;
1655
1656 case Triple::aarch64_32:
1657 case Triple::amdil:
1658 case Triple::arc:
1659 case Triple::arm:
1660 case Triple::armeb:
1661 case Triple::csky:
1662 case Triple::dxil:
1663 case Triple::hexagon:
1664 case Triple::hsail:
1665 case Triple::kalimba:
1666 case Triple::lanai:
1667 case Triple::le32:
1669 case Triple::m68k:
1670 case Triple::mips:
1671 case Triple::mipsel:
1672 case Triple::nvptx:
1673 case Triple::ppc:
1674 case Triple::ppcle:
1675 case Triple::r600:
1677 case Triple::riscv32:
1678 case Triple::shave:
1679 case Triple::sparc:
1680 case Triple::sparcel:
1681 case Triple::spir:
1682 case Triple::spirv32:
1683 case Triple::tce:
1684 case Triple::tcele:
1685 case Triple::thumb:
1686 case Triple::thumbeb:
1687 case Triple::wasm32:
1688 case Triple::x86:
1689 case Triple::xcore:
1690 case Triple::xtensa:
1691 // Already 32-bit.
1692 break;
1693
1694 case Triple::aarch64: T.setArch(Triple::arm); break;
1695 case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1696 case Triple::amdil64: T.setArch(Triple::amdil); break;
1697 case Triple::hsail64: T.setArch(Triple::hsail); break;
1698 case Triple::le64: T.setArch(Triple::le32); break;
1699 case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
1700 case Triple::mips64:
1701 T.setArch(Triple::mips, getSubArch());
1702 break;
1703 case Triple::mips64el:
1704 T.setArch(Triple::mipsel, getSubArch());
1705 break;
1706 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1707 case Triple::ppc64: T.setArch(Triple::ppc); break;
1708 case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1709 case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1710 case Triple::riscv64: T.setArch(Triple::riscv32); break;
1711 case Triple::sparcv9: T.setArch(Triple::sparc); break;
1712 case Triple::spir64: T.setArch(Triple::spir); break;
1713 case Triple::spirv:
1714 case Triple::spirv64:
1715 T.setArch(Triple::spirv32, getSubArch());
1716 break;
1717 case Triple::wasm64: T.setArch(Triple::wasm32); break;
1718 case Triple::x86_64: T.setArch(Triple::x86); break;
1719 }
1720 return T;
1721}
1722
1724 Triple T(*this);
1725 switch (getArch()) {
1727 case Triple::arc:
1728 case Triple::avr:
1729 case Triple::csky:
1730 case Triple::dxil:
1731 case Triple::hexagon:
1732 case Triple::kalimba:
1733 case Triple::lanai:
1734 case Triple::m68k:
1735 case Triple::msp430:
1736 case Triple::r600:
1737 case Triple::shave:
1738 case Triple::sparcel:
1739 case Triple::tce:
1740 case Triple::tcele:
1741 case Triple::xcore:
1742 case Triple::xtensa:
1743 T.setArch(UnknownArch);
1744 break;
1745
1746 case Triple::aarch64:
1747 case Triple::aarch64_be:
1748 case Triple::amdgcn:
1749 case Triple::amdil64:
1750 case Triple::bpfeb:
1751 case Triple::bpfel:
1752 case Triple::hsail64:
1753 case Triple::le64:
1755 case Triple::mips64:
1756 case Triple::mips64el:
1757 case Triple::nvptx64:
1758 case Triple::ppc64:
1759 case Triple::ppc64le:
1761 case Triple::riscv64:
1762 case Triple::sparcv9:
1763 case Triple::spir64:
1764 case Triple::spirv64:
1765 case Triple::systemz:
1766 case Triple::ve:
1767 case Triple::wasm64:
1768 case Triple::x86_64:
1769 // Already 64-bit.
1770 break;
1771
1772 case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1773 case Triple::amdil: T.setArch(Triple::amdil64); break;
1774 case Triple::arm: T.setArch(Triple::aarch64); break;
1775 case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1776 case Triple::hsail: T.setArch(Triple::hsail64); break;
1777 case Triple::le32: T.setArch(Triple::le64); break;
1778 case Triple::loongarch32: T.setArch(Triple::loongarch64); break;
1779 case Triple::mips:
1780 T.setArch(Triple::mips64, getSubArch());
1781 break;
1782 case Triple::mipsel:
1783 T.setArch(Triple::mips64el, getSubArch());
1784 break;
1785 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1786 case Triple::ppc: T.setArch(Triple::ppc64); break;
1787 case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1788 case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1789 case Triple::riscv32: T.setArch(Triple::riscv64); break;
1790 case Triple::sparc: T.setArch(Triple::sparcv9); break;
1791 case Triple::spir: T.setArch(Triple::spir64); break;
1792 case Triple::spirv:
1793 case Triple::spirv32:
1794 T.setArch(Triple::spirv64, getSubArch());
1795 break;
1796 case Triple::thumb: T.setArch(Triple::aarch64); break;
1797 case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1798 case Triple::wasm32: T.setArch(Triple::wasm64); break;
1799 case Triple::x86: T.setArch(Triple::x86_64); break;
1800 }
1801 return T;
1802}
1803
1805 Triple T(*this);
1806 // Already big endian.
1807 if (!isLittleEndian())
1808 return T;
1809 switch (getArch()) {
1811 case Triple::amdgcn:
1812 case Triple::amdil64:
1813 case Triple::amdil:
1814 case Triple::avr:
1815 case Triple::dxil:
1816 case Triple::hexagon:
1817 case Triple::hsail64:
1818 case Triple::hsail:
1819 case Triple::kalimba:
1820 case Triple::le32:
1821 case Triple::le64:
1824 case Triple::msp430:
1825 case Triple::nvptx64:
1826 case Triple::nvptx:
1827 case Triple::r600:
1830 case Triple::riscv32:
1831 case Triple::riscv64:
1832 case Triple::shave:
1833 case Triple::spir64:
1834 case Triple::spir:
1835 case Triple::spirv:
1836 case Triple::spirv32:
1837 case Triple::spirv64:
1838 case Triple::wasm32:
1839 case Triple::wasm64:
1840 case Triple::x86:
1841 case Triple::x86_64:
1842 case Triple::xcore:
1843 case Triple::ve:
1844 case Triple::csky:
1845 case Triple::xtensa:
1846
1847 // ARM is intentionally unsupported here, changing the architecture would
1848 // drop any arch suffixes.
1849 case Triple::arm:
1850 case Triple::thumb:
1851 T.setArch(UnknownArch);
1852 break;
1853
1854 case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1855 case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1856 case Triple::mips64el:
1857 T.setArch(Triple::mips64, getSubArch());
1858 break;
1859 case Triple::mipsel:
1860 T.setArch(Triple::mips, getSubArch());
1861 break;
1862 case Triple::ppcle: T.setArch(Triple::ppc); break;
1863 case Triple::ppc64le: T.setArch(Triple::ppc64); break;
1864 case Triple::sparcel: T.setArch(Triple::sparc); break;
1865 case Triple::tcele: T.setArch(Triple::tce); break;
1866 default:
1867 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
1868 }
1869 return T;
1870}
1871
1873 Triple T(*this);
1874 if (isLittleEndian())
1875 return T;
1876
1877 switch (getArch()) {
1879 case Triple::lanai:
1880 case Triple::sparcv9:
1881 case Triple::systemz:
1882 case Triple::m68k:
1883
1884 // ARM is intentionally unsupported here, changing the architecture would
1885 // drop any arch suffixes.
1886 case Triple::armeb:
1887 case Triple::thumbeb:
1888 T.setArch(UnknownArch);
1889 break;
1890
1891 case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
1892 case Triple::bpfeb: T.setArch(Triple::bpfel); break;
1893 case Triple::mips64:
1894 T.setArch(Triple::mips64el, getSubArch());
1895 break;
1896 case Triple::mips:
1897 T.setArch(Triple::mipsel, getSubArch());
1898 break;
1899 case Triple::ppc: T.setArch(Triple::ppcle); break;
1900 case Triple::ppc64: T.setArch(Triple::ppc64le); break;
1901 case Triple::sparc: T.setArch(Triple::sparcel); break;
1902 case Triple::tce: T.setArch(Triple::tcele); break;
1903 default:
1904 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
1905 }
1906 return T;
1907}
1908
1910 switch (getArch()) {
1911 case Triple::aarch64:
1912 case Triple::aarch64_32:
1913 case Triple::amdgcn:
1914 case Triple::amdil64:
1915 case Triple::amdil:
1916 case Triple::arm:
1917 case Triple::avr:
1918 case Triple::bpfel:
1919 case Triple::csky:
1920 case Triple::dxil:
1921 case Triple::hexagon:
1922 case Triple::hsail64:
1923 case Triple::hsail:
1924 case Triple::kalimba:
1925 case Triple::le32:
1926 case Triple::le64:
1929 case Triple::mips64el:
1930 case Triple::mipsel:
1931 case Triple::msp430:
1932 case Triple::nvptx64:
1933 case Triple::nvptx:
1934 case Triple::ppcle:
1935 case Triple::ppc64le:
1936 case Triple::r600:
1939 case Triple::riscv32:
1940 case Triple::riscv64:
1941 case Triple::shave:
1942 case Triple::sparcel:
1943 case Triple::spir64:
1944 case Triple::spir:
1945 case Triple::spirv:
1946 case Triple::spirv32:
1947 case Triple::spirv64:
1948 case Triple::tcele:
1949 case Triple::thumb:
1950 case Triple::ve:
1951 case Triple::wasm32:
1952 case Triple::wasm64:
1953 case Triple::x86:
1954 case Triple::x86_64:
1955 case Triple::xcore:
1956 case Triple::xtensa:
1957 return true;
1958 default:
1959 return false;
1960 }
1961}
1962
1964 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1965 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
1966 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
1967 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
1968 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
1969 if (getVendor() == Triple::Apple)
1970 return getSubArch() == Other.getSubArch() &&
1971 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1972 else
1973 return getSubArch() == Other.getSubArch() &&
1974 getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
1975 getEnvironment() == Other.getEnvironment() &&
1976 getObjectFormat() == Other.getObjectFormat();
1977 }
1978
1979 // If vendor is apple, ignore the version number.
1980 if (getVendor() == Triple::Apple)
1981 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
1982 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1983
1984 return *this == Other;
1985}
1986
1987std::string Triple::merge(const Triple &Other) const {
1988 // If vendor is apple, pick the triple with the larger version number.
1989 if (getVendor() == Triple::Apple)
1990 if (Other.isOSVersionLT(*this))
1991 return str();
1992
1993 return Other.str();
1994}
1995
1996bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
1997 unsigned Micro) const {
1998 assert(isMacOSX() && "Not an OS X triple!");
1999
2000 // If this is OS X, expect a sane version number.
2001 if (getOS() == Triple::MacOSX)
2002 return isOSVersionLT(Major, Minor, Micro);
2003
2004 // Otherwise, compare to the "Darwin" number.
2005 if (Major == 10) {
2006 return isOSVersionLT(Minor + 4, Micro, 0);
2007 } else {
2008 assert(Major >= 11 && "Unexpected major version");
2009 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
2010 }
2011}
2012
2015 return VersionTuple();
2016 switch (getOS()) {
2017 case Triple::MacOSX:
2018 // ARM64 slice is supported starting from macOS 11.0+.
2019 return VersionTuple(11, 0, 0);
2020 case Triple::IOS:
2021 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
2022 // ARM64 simulators are supported for iOS 14+.
2024 return VersionTuple(14, 0, 0);
2025 // ARM64e slice is supported starting from iOS 14.
2026 if (isArm64e())
2027 return VersionTuple(14, 0, 0);
2028 break;
2029 case Triple::TvOS:
2030 // ARM64 simulators are supported for tvOS 14+.
2032 return VersionTuple(14, 0, 0);
2033 break;
2034 case Triple::WatchOS:
2035 // ARM64 simulators are supported for watchOS 7+.
2037 return VersionTuple(7, 0, 0);
2038 break;
2039 case Triple::DriverKit:
2040 return VersionTuple(20, 0, 0);
2041 default:
2042 break;
2043 }
2044 return VersionTuple();
2045}
2046
2048 const VersionTuple &Version) {
2049 switch (OSKind) {
2050 case MacOSX:
2051 // macOS 10.16 is canonicalized to macOS 11.
2052 if (Version == VersionTuple(10, 16))
2053 return VersionTuple(11, 0);
2054 [[fallthrough]];
2055 default:
2056 return Version;
2057 }
2058}
2059
2060// HLSL triple environment orders are relied on in the front end
2061static_assert(Triple::Vertex - Triple::Pixel == 1,
2062 "incorrect HLSL stage order");
2063static_assert(Triple::Geometry - Triple::Pixel == 2,
2064 "incorrect HLSL stage order");
2065static_assert(Triple::Hull - Triple::Pixel == 3,
2066 "incorrect HLSL stage order");
2067static_assert(Triple::Domain - Triple::Pixel == 4,
2068 "incorrect HLSL stage order");
2069static_assert(Triple::Compute - Triple::Pixel == 5,
2070 "incorrect HLSL stage order");
2071static_assert(Triple::Library - Triple::Pixel == 6,
2072 "incorrect HLSL stage order");
2073static_assert(Triple::RayGeneration - Triple::Pixel == 7,
2074 "incorrect HLSL stage order");
2075static_assert(Triple::Intersection - Triple::Pixel == 8,
2076 "incorrect HLSL stage order");
2077static_assert(Triple::AnyHit - Triple::Pixel == 9,
2078 "incorrect HLSL stage order");
2079static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2080 "incorrect HLSL stage order");
2081static_assert(Triple::Miss - Triple::Pixel == 11,
2082 "incorrect HLSL stage order");
2083static_assert(Triple::Callable - Triple::Pixel == 12,
2084 "incorrect HLSL stage order");
2085static_assert(Triple::Mesh - Triple::Pixel == 13,
2086 "incorrect HLSL stage order");
2087static_assert(Triple::Amplification - Triple::Pixel == 14,
2088 "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:1307
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 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 append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:696
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
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 equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:164
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:1996
VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1340
StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition: Triple.cpp:1285
VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1429
void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1523
void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition: Triple.cpp:1515
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1642
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:471
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1872
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:1027
void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1534
@ 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:1551
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1723
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1909
void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1507
StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition: Triple.cpp:1290
@ 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:1491
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:1313
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:1296
bool isSimulatorEnvironment() const
Definition: Triple.h:558
const std::string & str() const
Definition: Triple.h:436
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:1466
VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1454
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:1987
@ 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:2013
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1630
StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition: Triple.cpp:1302
@ 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
@ 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:1354
bool isMacOSX() const
Is this a Mac OS X triple.
Definition: Triple.h:518
void setEnvironmentName(StringRef Str)
Set the optional environment (fourth) component of the triple by name.
Definition: Triple.cpp:1546
void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1503
void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1538
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:496
static VersionTuple getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version)
Returns a canonicalized OS version number for the specified OS.
Definition: Triple.cpp:2047
StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1281
bool isMacCatalystEnvironment() const
Definition: Triple.h:562
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:1638
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1804
VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1399
StringRef getEnvironmentVersionString() const
Get the version component of the environment component as a single string (the version after the envi...
Definition: Triple.cpp:1317
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1634
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1963
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:1495
void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1499
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