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