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