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", Triple::spirv32)
563 .Cases("spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
564 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5", Triple::spirv64)
565 .StartsWith("kalimba", Triple::kalimba)
566 .Case("lanai", Triple::lanai)
567 .Case("renderscript32", Triple::renderscript32)
568 .Case("renderscript64", Triple::renderscript64)
569 .Case("shave", Triple::shave)
570 .Case("ve", Triple::ve)
571 .Case("wasm32", Triple::wasm32)
572 .Case("wasm64", Triple::wasm64)
573 .Case("csky", Triple::csky)
574 .Case("loongarch32", Triple::loongarch32)
575 .Case("loongarch64", Triple::loongarch64)
576 .Cases("dxil", "dxilv1.0", "dxilv1.1", "dxilv1.2", "dxilv1.3",
577 "dxilv1.4", "dxilv1.5", "dxilv1.6", "dxilv1.7", "dxilv1.8",
579 .Case("xtensa", Triple::xtensa)
581
582 // Some architectures require special parsing logic just to compute the
583 // ArchType result.
584 if (AT == Triple::UnknownArch) {
585 if (ArchName.starts_with("arm") || ArchName.starts_with("thumb") ||
586 ArchName.starts_with("aarch64"))
587 return parseARMArch(ArchName);
588 if (ArchName.starts_with("bpf"))
589 return parseBPFArch(ArchName);
590 }
591
592 return AT;
593}
594
596 return StringSwitch<Triple::VendorType>(VendorName)
597 .Case("apple", Triple::Apple)
598 .Case("pc", Triple::PC)
599 .Case("scei", Triple::SCEI)
600 .Case("sie", Triple::SCEI)
601 .Case("fsl", Triple::Freescale)
602 .Case("ibm", Triple::IBM)
605 .Case("nvidia", Triple::NVIDIA)
606 .Case("csr", Triple::CSR)
607 .Case("amd", Triple::AMD)
608 .Case("mesa", Triple::Mesa)
609 .Case("suse", Triple::SUSE)
612}
613
615 return StringSwitch<Triple::OSType>(OSName)
616 .StartsWith("darwin", Triple::Darwin)
617 .StartsWith("dragonfly", Triple::DragonFly)
618 .StartsWith("freebsd", Triple::FreeBSD)
619 .StartsWith("fuchsia", Triple::Fuchsia)
620 .StartsWith("ios", Triple::IOS)
621 .StartsWith("kfreebsd", Triple::KFreeBSD)
622 .StartsWith("linux", Triple::Linux)
623 .StartsWith("lv2", Triple::Lv2)
624 .StartsWith("macos", Triple::MacOSX)
625 .StartsWith("netbsd", Triple::NetBSD)
626 .StartsWith("openbsd", Triple::OpenBSD)
627 .StartsWith("solaris", Triple::Solaris)
628 .StartsWith("uefi", Triple::UEFI)
629 .StartsWith("win32", Triple::Win32)
630 .StartsWith("windows", Triple::Win32)
631 .StartsWith("zos", Triple::ZOS)
632 .StartsWith("haiku", Triple::Haiku)
633 .StartsWith("rtems", Triple::RTEMS)
634 .StartsWith("nacl", Triple::NaCl)
635 .StartsWith("aix", Triple::AIX)
636 .StartsWith("cuda", Triple::CUDA)
637 .StartsWith("nvcl", Triple::NVCL)
638 .StartsWith("amdhsa", Triple::AMDHSA)
639 .StartsWith("ps4", Triple::PS4)
640 .StartsWith("ps5", Triple::PS5)
641 .StartsWith("elfiamcu", Triple::ELFIAMCU)
642 .StartsWith("tvos", Triple::TvOS)
643 .StartsWith("watchos", Triple::WatchOS)
644 .StartsWith("bridgeos", Triple::BridgeOS)
645 .StartsWith("driverkit", Triple::DriverKit)
646 .StartsWith("xros", Triple::XROS)
647 .StartsWith("visionos", Triple::XROS)
648 .StartsWith("mesa3d", Triple::Mesa3D)
649 .StartsWith("amdpal", Triple::AMDPAL)
651 .StartsWith("hurd", Triple::Hurd)
652 .StartsWith("wasi", Triple::WASI)
653 .StartsWith("emscripten", Triple::Emscripten)
654 .StartsWith("shadermodel", Triple::ShaderModel)
655 .StartsWith("liteos", Triple::LiteOS)
656 .StartsWith("serenity", Triple::Serenity)
657 .StartsWith("vulkan", Triple::Vulkan)
659}
660
662 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
663 .StartsWith("eabihf", Triple::EABIHF)
664 .StartsWith("eabi", Triple::EABI)
665 .StartsWith("gnuabin32", Triple::GNUABIN32)
666 .StartsWith("gnuabi64", Triple::GNUABI64)
667 .StartsWith("gnueabihf", Triple::GNUEABIHF)
668 .StartsWith("gnueabi", Triple::GNUEABI)
669 .StartsWith("gnuf32", Triple::GNUF32)
670 .StartsWith("gnuf64", Triple::GNUF64)
671 .StartsWith("gnusf", Triple::GNUSF)
672 .StartsWith("gnux32", Triple::GNUX32)
673 .StartsWith("gnu_ilp32", Triple::GNUILP32)
674 .StartsWith("code16", Triple::CODE16)
675 .StartsWith("gnu", Triple::GNU)
676 .StartsWith("android", Triple::Android)
677 .StartsWith("musleabihf", Triple::MuslEABIHF)
678 .StartsWith("musleabi", Triple::MuslEABI)
679 .StartsWith("muslx32", Triple::MuslX32)
680 .StartsWith("musl", Triple::Musl)
681 .StartsWith("msvc", Triple::MSVC)
682 .StartsWith("itanium", Triple::Itanium)
683 .StartsWith("cygnus", Triple::Cygnus)
684 .StartsWith("coreclr", Triple::CoreCLR)
685 .StartsWith("simulator", Triple::Simulator)
686 .StartsWith("macabi", Triple::MacABI)
687 .StartsWith("pixel", Triple::Pixel)
688 .StartsWith("vertex", Triple::Vertex)
689 .StartsWith("geometry", Triple::Geometry)
690 .StartsWith("hull", Triple::Hull)
691 .StartsWith("domain", Triple::Domain)
692 .StartsWith("compute", Triple::Compute)
693 .StartsWith("library", Triple::Library)
694 .StartsWith("raygeneration", Triple::RayGeneration)
695 .StartsWith("intersection", Triple::Intersection)
696 .StartsWith("anyhit", Triple::AnyHit)
697 .StartsWith("closesthit", Triple::ClosestHit)
698 .StartsWith("miss", Triple::Miss)
699 .StartsWith("callable", Triple::Callable)
700 .StartsWith("mesh", Triple::Mesh)
701 .StartsWith("amplification", Triple::Amplification)
702 .StartsWith("opencl", Triple::OpenCL)
705}
706
708 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
709 // "xcoff" must come before "coff" because of the order-dependendent
710 // pattern matching.
711 .EndsWith("xcoff", Triple::XCOFF)
712 .EndsWith("coff", Triple::COFF)
713 .EndsWith("elf", Triple::ELF)
714 .EndsWith("goff", Triple::GOFF)
715 .EndsWith("macho", Triple::MachO)
716 .EndsWith("wasm", Triple::Wasm)
717 .EndsWith("spirv", Triple::SPIRV)
719}
720
722 if (SubArchName.starts_with("mips") &&
723 (SubArchName.ends_with("r6el") || SubArchName.ends_with("r6")))
725
726 if (SubArchName == "powerpcspe")
728
729 if (SubArchName == "arm64e")
731
732 if (SubArchName == "arm64ec")
734
735 if (SubArchName.starts_with("spirv"))
736 return StringSwitch<Triple::SubArchType>(SubArchName)
745
746 if (SubArchName.starts_with("dxil"))
747 return StringSwitch<Triple::SubArchType>(SubArchName)
758
759 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
760
761 // For now, this is the small part. Early return.
762 if (ARMSubArch.empty())
763 return StringSwitch<Triple::SubArchType>(SubArchName)
768
769 // ARM sub arch.
770 switch(ARM::parseArch(ARMSubArch)) {
771 case ARM::ArchKind::ARMV4:
772 return Triple::NoSubArch;
773 case ARM::ArchKind::ARMV4T:
775 case ARM::ArchKind::ARMV5T:
777 case ARM::ArchKind::ARMV5TE:
778 case ARM::ArchKind::IWMMXT:
779 case ARM::ArchKind::IWMMXT2:
780 case ARM::ArchKind::XSCALE:
781 case ARM::ArchKind::ARMV5TEJ:
783 case ARM::ArchKind::ARMV6:
785 case ARM::ArchKind::ARMV6K:
786 case ARM::ArchKind::ARMV6KZ:
788 case ARM::ArchKind::ARMV6T2:
790 case ARM::ArchKind::ARMV6M:
792 case ARM::ArchKind::ARMV7A:
793 case ARM::ArchKind::ARMV7R:
795 case ARM::ArchKind::ARMV7VE:
797 case ARM::ArchKind::ARMV7K:
799 case ARM::ArchKind::ARMV7M:
801 case ARM::ArchKind::ARMV7S:
803 case ARM::ArchKind::ARMV7EM:
805 case ARM::ArchKind::ARMV8A:
807 case ARM::ArchKind::ARMV8_1A:
809 case ARM::ArchKind::ARMV8_2A:
811 case ARM::ArchKind::ARMV8_3A:
813 case ARM::ArchKind::ARMV8_4A:
815 case ARM::ArchKind::ARMV8_5A:
817 case ARM::ArchKind::ARMV8_6A:
819 case ARM::ArchKind::ARMV8_7A:
821 case ARM::ArchKind::ARMV8_8A:
823 case ARM::ArchKind::ARMV8_9A:
825 case ARM::ArchKind::ARMV9A:
827 case ARM::ArchKind::ARMV9_1A:
829 case ARM::ArchKind::ARMV9_2A:
831 case ARM::ArchKind::ARMV9_3A:
833 case ARM::ArchKind::ARMV9_4A:
835 case ARM::ArchKind::ARMV9_5A:
837 case ARM::ArchKind::ARMV8R:
839 case ARM::ArchKind::ARMV8MBaseline:
841 case ARM::ArchKind::ARMV8MMainline:
843 case ARM::ArchKind::ARMV8_1MMainline:
845 default:
846 return Triple::NoSubArch;
847 }
848}
849
851 switch (T.getArch()) {
853 case Triple::aarch64:
855 case Triple::arm:
856 case Triple::thumb:
857 case Triple::x86:
858 case Triple::x86_64:
859 switch (T.getOS()) {
860 case Triple::Win32:
861 case Triple::UEFI:
862 return Triple::COFF;
863 default:
864 return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
865 }
867 case Triple::amdgcn:
868 case Triple::amdil64:
869 case Triple::amdil:
870 case Triple::arc:
871 case Triple::armeb:
872 case Triple::avr:
873 case Triple::bpfeb:
874 case Triple::bpfel:
875 case Triple::csky:
876 case Triple::hexagon:
877 case Triple::hsail64:
878 case Triple::hsail:
879 case Triple::kalimba:
880 case Triple::lanai:
881 case Triple::le32:
882 case Triple::le64:
885 case Triple::m68k:
886 case Triple::mips64:
887 case Triple::mips64el:
888 case Triple::mips:
889 case Triple::mipsel:
890 case Triple::msp430:
891 case Triple::nvptx64:
892 case Triple::nvptx:
893 case Triple::ppc64le:
894 case Triple::ppcle:
895 case Triple::r600:
898 case Triple::riscv32:
899 case Triple::riscv64:
900 case Triple::shave:
901 case Triple::sparc:
902 case Triple::sparcel:
903 case Triple::sparcv9:
904 case Triple::spir64:
905 case Triple::spir:
906 case Triple::tce:
907 case Triple::tcele:
908 case Triple::thumbeb:
909 case Triple::ve:
910 case Triple::xcore:
911 case Triple::xtensa:
912 return Triple::ELF;
913
914 case Triple::ppc64:
915 case Triple::ppc:
916 if (T.isOSAIX())
917 return Triple::XCOFF;
918 if (T.isOSDarwin())
919 return Triple::MachO;
920 return Triple::ELF;
921
922 case Triple::systemz:
923 if (T.isOSzOS())
924 return Triple::GOFF;
925 return Triple::ELF;
926
927 case Triple::wasm32:
928 case Triple::wasm64:
929 return Triple::Wasm;
930
931 case Triple::spirv:
932 case Triple::spirv32:
933 case Triple::spirv64:
934 return Triple::SPIRV;
935
936 case Triple::dxil:
937 return Triple::DXContainer;
938 }
939 llvm_unreachable("unknown architecture");
940}
941
942/// Construct a triple from the string representation provided.
943///
944/// This stores the string representation and parses the various pieces into
945/// enum members.
947 : Data(Str.str()), Arch(UnknownArch), SubArch(NoSubArch),
948 Vendor(UnknownVendor), OS(UnknownOS), Environment(UnknownEnvironment),
949 ObjectFormat(UnknownObjectFormat) {
950 // Do minimal parsing by hand here.
951 SmallVector<StringRef, 4> Components;
952 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
953 if (Components.size() > 0) {
954 Arch = parseArch(Components[0]);
955 SubArch = parseSubArch(Components[0]);
956 if (Components.size() > 1) {
957 Vendor = parseVendor(Components[1]);
958 if (Components.size() > 2) {
959 OS = parseOS(Components[2]);
960 if (Components.size() > 3) {
961 Environment = parseEnvironment(Components[3]);
962 ObjectFormat = parseFormat(Components[3]);
963 }
964 }
965 } else {
966 Environment =
968 .StartsWith("mipsn32", Triple::GNUABIN32)
969 .StartsWith("mips64", Triple::GNUABI64)
970 .StartsWith("mipsisa64", Triple::GNUABI64)
971 .StartsWith("mipsisa32", Triple::GNU)
972 .Cases("mips", "mipsel", "mipsr6", "mipsr6el", Triple::GNU)
974 }
975 }
976 if (ObjectFormat == UnknownObjectFormat)
977 ObjectFormat = getDefaultFormat(*this);
978}
979
980/// Construct a triple from string representations of the architecture,
981/// vendor, and OS.
982///
983/// This joins each argument into a canonical string representation and parses
984/// them into enum members. It leaves the environment unknown and omits it from
985/// the string representation.
986Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
987 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
988 Arch(parseArch(ArchStr.str())),
989 SubArch(parseSubArch(ArchStr.str())),
990 Vendor(parseVendor(VendorStr.str())),
991 OS(parseOS(OSStr.str())),
992 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
993 ObjectFormat = getDefaultFormat(*this);
994}
995
996/// Construct a triple from string representations of the architecture,
997/// vendor, OS, and environment.
998///
999/// This joins each argument into a canonical string representation and parses
1000/// them into enum members.
1001Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1002 const Twine &EnvironmentStr)
1003 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
1004 EnvironmentStr).str()),
1005 Arch(parseArch(ArchStr.str())),
1006 SubArch(parseSubArch(ArchStr.str())),
1007 Vendor(parseVendor(VendorStr.str())),
1008 OS(parseOS(OSStr.str())),
1009 Environment(parseEnvironment(EnvironmentStr.str())),
1010 ObjectFormat(parseFormat(EnvironmentStr.str())) {
1011 if (ObjectFormat == Triple::UnknownObjectFormat)
1012 ObjectFormat = getDefaultFormat(*this);
1013}
1014
1016 bool IsMinGW32 = false;
1017 bool IsCygwin = false;
1018
1019 // Parse into components.
1020 SmallVector<StringRef, 4> Components;
1021 Str.split(Components, '-');
1022
1023 // If the first component corresponds to a known architecture, preferentially
1024 // use it for the architecture. If the second component corresponds to a
1025 // known vendor, preferentially use it for the vendor, etc. This avoids silly
1026 // component movement when a component parses as (eg) both a valid arch and a
1027 // valid os.
1028 ArchType Arch = UnknownArch;
1029 if (Components.size() > 0)
1030 Arch = parseArch(Components[0]);
1031 VendorType Vendor = UnknownVendor;
1032 if (Components.size() > 1)
1033 Vendor = parseVendor(Components[1]);
1034 OSType OS = UnknownOS;
1035 if (Components.size() > 2) {
1036 OS = parseOS(Components[2]);
1037 IsCygwin = Components[2].starts_with("cygwin");
1038 IsMinGW32 = Components[2].starts_with("mingw");
1039 }
1040 EnvironmentType Environment = UnknownEnvironment;
1041 if (Components.size() > 3)
1042 Environment = parseEnvironment(Components[3]);
1044 if (Components.size() > 4)
1045 ObjectFormat = parseFormat(Components[4]);
1046
1047 // Note which components are already in their final position. These will not
1048 // be moved.
1049 bool Found[4];
1050 Found[0] = Arch != UnknownArch;
1051 Found[1] = Vendor != UnknownVendor;
1052 Found[2] = OS != UnknownOS;
1053 Found[3] = Environment != UnknownEnvironment;
1054
1055 // If they are not there already, permute the components into their canonical
1056 // positions by seeing if they parse as a valid architecture, and if so moving
1057 // the component to the architecture position etc.
1058 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
1059 if (Found[Pos])
1060 continue; // Already in the canonical position.
1061
1062 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
1063 // Do not reparse any components that already matched.
1064 if (Idx < std::size(Found) && Found[Idx])
1065 continue;
1066
1067 // Does this component parse as valid for the target position?
1068 bool Valid = false;
1069 StringRef Comp = Components[Idx];
1070 switch (Pos) {
1071 default: llvm_unreachable("unexpected component type!");
1072 case 0:
1073 Arch = parseArch(Comp);
1074 Valid = Arch != UnknownArch;
1075 break;
1076 case 1:
1077 Vendor = parseVendor(Comp);
1078 Valid = Vendor != UnknownVendor;
1079 break;
1080 case 2:
1081 OS = parseOS(Comp);
1082 IsCygwin = Comp.starts_with("cygwin");
1083 IsMinGW32 = Comp.starts_with("mingw");
1084 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1085 break;
1086 case 3:
1087 Environment = parseEnvironment(Comp);
1088 Valid = Environment != UnknownEnvironment;
1089 if (!Valid) {
1090 ObjectFormat = parseFormat(Comp);
1091 Valid = ObjectFormat != UnknownObjectFormat;
1092 }
1093 break;
1094 }
1095 if (!Valid)
1096 continue; // Nope, try the next component.
1097
1098 // Move the component to the target position, pushing any non-fixed
1099 // components that are in the way to the right. This tends to give
1100 // good results in the common cases of a forgotten vendor component
1101 // or a wrongly positioned environment.
1102 if (Pos < Idx) {
1103 // Insert left, pushing the existing components to the right. For
1104 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1105 StringRef CurrentComponent(""); // The empty component.
1106 // Replace the component we are moving with an empty component.
1107 std::swap(CurrentComponent, Components[Idx]);
1108 // Insert the component being moved at Pos, displacing any existing
1109 // components to the right.
1110 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1111 // Skip over any fixed components.
1112 while (i < std::size(Found) && Found[i])
1113 ++i;
1114 // Place the component at the new position, getting the component
1115 // that was at this position - it will be moved right.
1116 std::swap(CurrentComponent, Components[i]);
1117 }
1118 } else if (Pos > Idx) {
1119 // Push right by inserting empty components until the component at Idx
1120 // reaches the target position Pos. For example, pc-a -> -pc-a when
1121 // moving pc to the second position.
1122 do {
1123 // Insert one empty component at Idx.
1124 StringRef CurrentComponent(""); // The empty component.
1125 for (unsigned i = Idx; i < Components.size();) {
1126 // Place the component at the new position, getting the component
1127 // that was at this position - it will be moved right.
1128 std::swap(CurrentComponent, Components[i]);
1129 // If it was placed on top of an empty component then we are done.
1130 if (CurrentComponent.empty())
1131 break;
1132 // Advance to the next component, skipping any fixed components.
1133 while (++i < std::size(Found) && Found[i])
1134 ;
1135 }
1136 // The last component was pushed off the end - append it.
1137 if (!CurrentComponent.empty())
1138 Components.push_back(CurrentComponent);
1139
1140 // Advance Idx to the component's new position.
1141 while (++Idx < std::size(Found) && Found[Idx])
1142 ;
1143 } while (Idx < Pos); // Add more until the final position is reached.
1144 }
1145 assert(Pos < Components.size() && Components[Pos] == Comp &&
1146 "Component moved wrong!");
1147 Found[Pos] = true;
1148 break;
1149 }
1150 }
1151
1152 // Replace empty components with "unknown" value.
1153 for (StringRef &C : Components)
1154 if (C.empty())
1155 C = "unknown";
1156
1157 // Special case logic goes here. At this point Arch, Vendor and OS have the
1158 // correct values for the computed components.
1159 std::string NormalizedEnvironment;
1160 if (Environment == Triple::Android &&
1161 Components[3].starts_with("androideabi")) {
1162 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1163 if (AndroidVersion.empty()) {
1164 Components[3] = "android";
1165 } else {
1166 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1167 Components[3] = NormalizedEnvironment;
1168 }
1169 }
1170
1171 // SUSE uses "gnueabi" to mean "gnueabihf"
1172 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1173 Components[3] = "gnueabihf";
1174
1175 if (OS == Triple::Win32) {
1176 Components.resize(4);
1177 Components[2] = "windows";
1178 if (Environment == UnknownEnvironment) {
1179 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1180 Components[3] = "msvc";
1181 else
1182 Components[3] = getObjectFormatTypeName(ObjectFormat);
1183 }
1184 } else if (IsMinGW32) {
1185 Components.resize(4);
1186 Components[2] = "windows";
1187 Components[3] = "gnu";
1188 } else if (IsCygwin) {
1189 Components.resize(4);
1190 Components[2] = "windows";
1191 Components[3] = "cygnus";
1192 }
1193 if (IsMinGW32 || IsCygwin ||
1194 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1195 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1196 Components.resize(5);
1197 Components[4] = getObjectFormatTypeName(ObjectFormat);
1198 }
1199 }
1200
1201 // Stick the corrected components back together to form the normalized string.
1202 return join(Components, "-");
1203}
1204
1206 return StringRef(Data).split('-').first; // Isolate first component
1207}
1208
1210 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1211 return Tmp.split('-').first; // Isolate second component
1212}
1213
1215 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1216 Tmp = Tmp.split('-').second; // Strip second component
1217 return Tmp.split('-').first; // Isolate third component
1218}
1219
1221 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1222 Tmp = Tmp.split('-').second; // Strip second component
1223 return Tmp.split('-').second; // Strip third component
1224}
1225
1227 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1228 return Tmp.split('-').second; // Strip second component
1229}
1230
1232 VersionTuple Version;
1233 Version.tryParse(Name);
1234 return Version.withoutBuild();
1235}
1236
1239}
1240
1242 StringRef EnvironmentName = getEnvironmentName();
1243
1244 // none is a valid environment type - it basically amounts to a freestanding
1245 // environment.
1246 if (EnvironmentName == "none")
1247 return "";
1248
1249 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1250 EnvironmentName.consume_front(EnvironmentTypeName);
1251
1252 if (EnvironmentName.contains("-")) {
1253 // -obj is the suffix
1255 StringRef ObjectFormatTypeName =
1257 const std::string tmp = (Twine("-") + ObjectFormatTypeName).str();
1258 EnvironmentName.consume_back(tmp);
1259 }
1260 }
1261 return EnvironmentName;
1262}
1263
1265 StringRef OSName = getOSName();
1266 // Assume that the OS portion of the triple starts with the canonical name.
1267 StringRef OSTypeName = getOSTypeName(getOS());
1268 if (OSName.starts_with(OSTypeName))
1269 OSName = OSName.substr(OSTypeName.size());
1270 else if (getOS() == MacOSX)
1271 OSName.consume_front("macos");
1272 else if (OSName.starts_with("visionos"))
1273 OSName.consume_front("visionos");
1274
1275 return parseVersionFromName(OSName);
1276}
1277
1279 Version = getOSVersion();
1280
1281 switch (getOS()) {
1282 default: llvm_unreachable("unexpected OS for Darwin triple");
1283 case Darwin:
1284 // Default to darwin8, i.e., MacOSX 10.4.
1285 if (Version.getMajor() == 0)
1286 Version = VersionTuple(8);
1287 // Darwin version numbers are skewed from OS X versions.
1288 if (Version.getMajor() < 4) {
1289 return false;
1290 }
1291 if (Version.getMajor() <= 19) {
1292 Version = VersionTuple(10, Version.getMajor() - 4);
1293 } else {
1294 // darwin20+ corresponds to macOS 11+.
1295 Version = VersionTuple(11 + Version.getMajor() - 20);
1296 }
1297 break;
1298 case MacOSX:
1299 // Default to 10.4.
1300 if (Version.getMajor() == 0) {
1301 Version = VersionTuple(10, 4);
1302 } else if (Version.getMajor() < 10) {
1303 return false;
1304 }
1305 break;
1306 case IOS:
1307 case TvOS:
1308 case WatchOS:
1309 // Ignore the version from the triple. This is only handled because the
1310 // the clang driver combines OS X and IOS support into a common Darwin
1311 // toolchain that wants to know the OS X version number even when targeting
1312 // IOS.
1313 Version = VersionTuple(10, 4);
1314 break;
1315 case XROS:
1316 llvm_unreachable("OSX version isn't relevant for xrOS");
1317 case DriverKit:
1318 llvm_unreachable("OSX version isn't relevant for DriverKit");
1319 }
1320 return true;
1321}
1322
1324 switch (getOS()) {
1325 default: llvm_unreachable("unexpected OS for Darwin triple");
1326 case Darwin:
1327 case MacOSX:
1328 // Ignore the version from the triple. This is only handled because the
1329 // the clang driver combines OS X and IOS support into a common Darwin
1330 // toolchain that wants to know the iOS version number even when targeting
1331 // OS X.
1332 return VersionTuple(5);
1333 case IOS:
1334 case TvOS: {
1335 VersionTuple Version = getOSVersion();
1336 // Default to 5.0 (or 7.0 for arm64).
1337 if (Version.getMajor() == 0)
1338 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1339 return Version;
1340 }
1341 case XROS: {
1342 // xrOS 1 is aligned with iOS 17.
1343 VersionTuple Version = getOSVersion();
1344 return Version.withMajorReplaced(Version.getMajor() + 16);
1345 }
1346 case WatchOS:
1347 llvm_unreachable("conflicting triple info");
1348 case DriverKit:
1349 llvm_unreachable("DriverKit doesn't have an iOS version");
1350 }
1351}
1352
1354 switch (getOS()) {
1355 default: llvm_unreachable("unexpected OS for Darwin triple");
1356 case Darwin:
1357 case MacOSX:
1358 // Ignore the version from the triple. This is only handled because the
1359 // the clang driver combines OS X and IOS support into a common Darwin
1360 // toolchain that wants to know the iOS version number even when targeting
1361 // OS X.
1362 return VersionTuple(2);
1363 case WatchOS: {
1364 VersionTuple Version = getOSVersion();
1365 if (Version.getMajor() == 0)
1366 return VersionTuple(2);
1367 return Version;
1368 }
1369 case IOS:
1370 llvm_unreachable("conflicting triple info");
1371 case XROS:
1372 llvm_unreachable("watchOS version isn't relevant for xrOS");
1373 case DriverKit:
1374 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1375 }
1376}
1377
1379 switch (getOS()) {
1380 default:
1381 llvm_unreachable("unexpected OS for Darwin triple");
1382 case DriverKit:
1383 VersionTuple Version = getOSVersion();
1384 if (Version.getMajor() == 0)
1385 return Version.withMajorReplaced(19);
1386 return Version;
1387 }
1388}
1389
1391 if (getArch() != spirv || getOS() != Vulkan)
1392 llvm_unreachable("invalid Vulkan SPIR-V triple");
1393
1394 VersionTuple VulkanVersion = getOSVersion();
1395 SubArchType SpirvVersion = getSubArch();
1396
1398 // Vulkan 1.2 -> SPIR-V 1.5.
1400 // Vulkan 1.3 -> SPIR-V 1.6.
1402
1403 // If Vulkan version is unset, default to 1.2.
1404 if (VulkanVersion == VersionTuple(0))
1405 VulkanVersion = VersionTuple(1, 2);
1406
1407 if (ValidVersionMap.contains(VulkanVersion) &&
1408 (ValidVersionMap.lookup(VulkanVersion) == SpirvVersion ||
1409 SpirvVersion == NoSubArch))
1410 return VulkanVersion;
1411
1412 return VersionTuple(0);
1413}
1414
1415void Triple::setTriple(const Twine &Str) {
1416 *this = Triple(Str);
1417}
1418
1420 setArchName(getArchName(Kind, SubArch));
1421}
1422
1425}
1426
1428 setOSName(getOSTypeName(Kind));
1429}
1430
1432 if (ObjectFormat == getDefaultFormat(*this))
1434
1436 getObjectFormatTypeName(ObjectFormat)).str());
1437}
1438
1440 if (Environment == UnknownEnvironment)
1442
1443 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1444 getObjectFormatTypeName(Kind)).str());
1445}
1446
1448 // Work around a miscompilation bug for Twines in gcc 4.0.3.
1450 Triple += Str;
1451 Triple += "-";
1452 Triple += getVendorName();
1453 Triple += "-";
1456}
1457
1459 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1460}
1461
1463 if (hasEnvironment())
1464 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1465 "-" + getEnvironmentName());
1466 else
1467 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1468}
1469
1471 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1472 "-" + Str);
1473}
1474
1476 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1477}
1478
1480 switch (Arch) {
1482 return 0;
1483
1484 case llvm::Triple::avr:
1486 return 16;
1487
1490 case llvm::Triple::arc:
1491 case llvm::Triple::arm:
1493 case llvm::Triple::csky:
1494 case llvm::Triple::dxil:
1499 case llvm::Triple::le32:
1501 case llvm::Triple::m68k:
1502 case llvm::Triple::mips:
1505 case llvm::Triple::ppc:
1507 case llvm::Triple::r600:
1513 case llvm::Triple::spir:
1515 case llvm::Triple::tce:
1520 case llvm::Triple::x86:
1523 return 32;
1524
1532 case llvm::Triple::le64:
1546 case llvm::Triple::ve:
1549 return 64;
1550 }
1551 llvm_unreachable("Invalid architecture value");
1552}
1553
1555 return getArchPointerBitWidth(getArch()) == 64;
1556}
1557
1559 return getArchPointerBitWidth(getArch()) == 32;
1560}
1561
1563 return getArchPointerBitWidth(getArch()) == 16;
1564}
1565
1567 Triple T(*this);
1568 switch (getArch()) {
1570 case Triple::amdgcn:
1571 case Triple::avr:
1572 case Triple::bpfeb:
1573 case Triple::bpfel:
1574 case Triple::msp430:
1575 case Triple::systemz:
1576 case Triple::ve:
1577 T.setArch(UnknownArch);
1578 break;
1579
1580 case Triple::aarch64_32:
1581 case Triple::amdil:
1582 case Triple::arc:
1583 case Triple::arm:
1584 case Triple::armeb:
1585 case Triple::csky:
1586 case Triple::dxil:
1587 case Triple::hexagon:
1588 case Triple::hsail:
1589 case Triple::kalimba:
1590 case Triple::lanai:
1591 case Triple::le32:
1593 case Triple::m68k:
1594 case Triple::mips:
1595 case Triple::mipsel:
1596 case Triple::nvptx:
1597 case Triple::ppc:
1598 case Triple::ppcle:
1599 case Triple::r600:
1601 case Triple::riscv32:
1602 case Triple::shave:
1603 case Triple::sparc:
1604 case Triple::sparcel:
1605 case Triple::spir:
1606 case Triple::spirv32:
1607 case Triple::tce:
1608 case Triple::tcele:
1609 case Triple::thumb:
1610 case Triple::thumbeb:
1611 case Triple::wasm32:
1612 case Triple::x86:
1613 case Triple::xcore:
1614 case Triple::xtensa:
1615 // Already 32-bit.
1616 break;
1617
1618 case Triple::aarch64: T.setArch(Triple::arm); break;
1619 case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1620 case Triple::amdil64: T.setArch(Triple::amdil); break;
1621 case Triple::hsail64: T.setArch(Triple::hsail); break;
1622 case Triple::le64: T.setArch(Triple::le32); break;
1623 case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
1624 case Triple::mips64:
1625 T.setArch(Triple::mips, getSubArch());
1626 break;
1627 case Triple::mips64el:
1628 T.setArch(Triple::mipsel, getSubArch());
1629 break;
1630 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1631 case Triple::ppc64: T.setArch(Triple::ppc); break;
1632 case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1633 case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1634 case Triple::riscv64: T.setArch(Triple::riscv32); break;
1635 case Triple::sparcv9: T.setArch(Triple::sparc); break;
1636 case Triple::spir64: T.setArch(Triple::spir); break;
1637 case Triple::spirv:
1638 case Triple::spirv64:
1639 T.setArch(Triple::spirv32, getSubArch());
1640 break;
1641 case Triple::wasm64: T.setArch(Triple::wasm32); break;
1642 case Triple::x86_64: T.setArch(Triple::x86); break;
1643 }
1644 return T;
1645}
1646
1648 Triple T(*this);
1649 switch (getArch()) {
1651 case Triple::arc:
1652 case Triple::avr:
1653 case Triple::csky:
1654 case Triple::dxil:
1655 case Triple::hexagon:
1656 case Triple::kalimba:
1657 case Triple::lanai:
1658 case Triple::m68k:
1659 case Triple::msp430:
1660 case Triple::r600:
1661 case Triple::shave:
1662 case Triple::sparcel:
1663 case Triple::tce:
1664 case Triple::tcele:
1665 case Triple::xcore:
1666 case Triple::xtensa:
1667 T.setArch(UnknownArch);
1668 break;
1669
1670 case Triple::aarch64:
1671 case Triple::aarch64_be:
1672 case Triple::amdgcn:
1673 case Triple::amdil64:
1674 case Triple::bpfeb:
1675 case Triple::bpfel:
1676 case Triple::hsail64:
1677 case Triple::le64:
1679 case Triple::mips64:
1680 case Triple::mips64el:
1681 case Triple::nvptx64:
1682 case Triple::ppc64:
1683 case Triple::ppc64le:
1685 case Triple::riscv64:
1686 case Triple::sparcv9:
1687 case Triple::spir64:
1688 case Triple::spirv64:
1689 case Triple::systemz:
1690 case Triple::ve:
1691 case Triple::wasm64:
1692 case Triple::x86_64:
1693 // Already 64-bit.
1694 break;
1695
1696 case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1697 case Triple::amdil: T.setArch(Triple::amdil64); break;
1698 case Triple::arm: T.setArch(Triple::aarch64); break;
1699 case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1700 case Triple::hsail: T.setArch(Triple::hsail64); break;
1701 case Triple::le32: T.setArch(Triple::le64); break;
1702 case Triple::loongarch32: T.setArch(Triple::loongarch64); break;
1703 case Triple::mips:
1704 T.setArch(Triple::mips64, getSubArch());
1705 break;
1706 case Triple::mipsel:
1707 T.setArch(Triple::mips64el, getSubArch());
1708 break;
1709 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1710 case Triple::ppc: T.setArch(Triple::ppc64); break;
1711 case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1712 case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1713 case Triple::riscv32: T.setArch(Triple::riscv64); break;
1714 case Triple::sparc: T.setArch(Triple::sparcv9); break;
1715 case Triple::spir: T.setArch(Triple::spir64); break;
1716 case Triple::spirv:
1717 case Triple::spirv32:
1718 T.setArch(Triple::spirv64, getSubArch());
1719 break;
1720 case Triple::thumb: T.setArch(Triple::aarch64); break;
1721 case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1722 case Triple::wasm32: T.setArch(Triple::wasm64); break;
1723 case Triple::x86: T.setArch(Triple::x86_64); break;
1724 }
1725 return T;
1726}
1727
1729 Triple T(*this);
1730 // Already big endian.
1731 if (!isLittleEndian())
1732 return T;
1733 switch (getArch()) {
1735 case Triple::amdgcn:
1736 case Triple::amdil64:
1737 case Triple::amdil:
1738 case Triple::avr:
1739 case Triple::dxil:
1740 case Triple::hexagon:
1741 case Triple::hsail64:
1742 case Triple::hsail:
1743 case Triple::kalimba:
1744 case Triple::le32:
1745 case Triple::le64:
1748 case Triple::msp430:
1749 case Triple::nvptx64:
1750 case Triple::nvptx:
1751 case Triple::r600:
1754 case Triple::riscv32:
1755 case Triple::riscv64:
1756 case Triple::shave:
1757 case Triple::spir64:
1758 case Triple::spir:
1759 case Triple::spirv:
1760 case Triple::spirv32:
1761 case Triple::spirv64:
1762 case Triple::wasm32:
1763 case Triple::wasm64:
1764 case Triple::x86:
1765 case Triple::x86_64:
1766 case Triple::xcore:
1767 case Triple::ve:
1768 case Triple::csky:
1769 case Triple::xtensa:
1770
1771 // ARM is intentionally unsupported here, changing the architecture would
1772 // drop any arch suffixes.
1773 case Triple::arm:
1774 case Triple::thumb:
1775 T.setArch(UnknownArch);
1776 break;
1777
1778 case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1779 case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1780 case Triple::mips64el:
1781 T.setArch(Triple::mips64, getSubArch());
1782 break;
1783 case Triple::mipsel:
1784 T.setArch(Triple::mips, getSubArch());
1785 break;
1786 case Triple::ppcle: T.setArch(Triple::ppc); break;
1787 case Triple::ppc64le: T.setArch(Triple::ppc64); break;
1788 case Triple::sparcel: T.setArch(Triple::sparc); break;
1789 case Triple::tcele: T.setArch(Triple::tce); break;
1790 default:
1791 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
1792 }
1793 return T;
1794}
1795
1797 Triple T(*this);
1798 if (isLittleEndian())
1799 return T;
1800
1801 switch (getArch()) {
1803 case Triple::lanai:
1804 case Triple::sparcv9:
1805 case Triple::systemz:
1806 case Triple::m68k:
1807
1808 // ARM is intentionally unsupported here, changing the architecture would
1809 // drop any arch suffixes.
1810 case Triple::armeb:
1811 case Triple::thumbeb:
1812 T.setArch(UnknownArch);
1813 break;
1814
1815 case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
1816 case Triple::bpfeb: T.setArch(Triple::bpfel); break;
1817 case Triple::mips64:
1818 T.setArch(Triple::mips64el, getSubArch());
1819 break;
1820 case Triple::mips:
1821 T.setArch(Triple::mipsel, getSubArch());
1822 break;
1823 case Triple::ppc: T.setArch(Triple::ppcle); break;
1824 case Triple::ppc64: T.setArch(Triple::ppc64le); break;
1825 case Triple::sparc: T.setArch(Triple::sparcel); break;
1826 case Triple::tce: T.setArch(Triple::tcele); break;
1827 default:
1828 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
1829 }
1830 return T;
1831}
1832
1834 switch (getArch()) {
1835 case Triple::aarch64:
1836 case Triple::aarch64_32:
1837 case Triple::amdgcn:
1838 case Triple::amdil64:
1839 case Triple::amdil:
1840 case Triple::arm:
1841 case Triple::avr:
1842 case Triple::bpfel:
1843 case Triple::csky:
1844 case Triple::dxil:
1845 case Triple::hexagon:
1846 case Triple::hsail64:
1847 case Triple::hsail:
1848 case Triple::kalimba:
1849 case Triple::le32:
1850 case Triple::le64:
1853 case Triple::mips64el:
1854 case Triple::mipsel:
1855 case Triple::msp430:
1856 case Triple::nvptx64:
1857 case Triple::nvptx:
1858 case Triple::ppcle:
1859 case Triple::ppc64le:
1860 case Triple::r600:
1863 case Triple::riscv32:
1864 case Triple::riscv64:
1865 case Triple::shave:
1866 case Triple::sparcel:
1867 case Triple::spir64:
1868 case Triple::spir:
1869 case Triple::spirv:
1870 case Triple::spirv32:
1871 case Triple::spirv64:
1872 case Triple::tcele:
1873 case Triple::thumb:
1874 case Triple::ve:
1875 case Triple::wasm32:
1876 case Triple::wasm64:
1877 case Triple::x86:
1878 case Triple::x86_64:
1879 case Triple::xcore:
1880 case Triple::xtensa:
1881 return true;
1882 default:
1883 return false;
1884 }
1885}
1886
1888 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1889 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
1890 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
1891 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
1892 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
1893 if (getVendor() == Triple::Apple)
1894 return getSubArch() == Other.getSubArch() &&
1895 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1896 else
1897 return getSubArch() == Other.getSubArch() &&
1898 getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
1899 getEnvironment() == Other.getEnvironment() &&
1900 getObjectFormat() == Other.getObjectFormat();
1901 }
1902
1903 // If vendor is apple, ignore the version number.
1904 if (getVendor() == Triple::Apple)
1905 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
1906 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1907
1908 return *this == Other;
1909}
1910
1911std::string Triple::merge(const Triple &Other) const {
1912 // If vendor is apple, pick the triple with the larger version number.
1913 if (getVendor() == Triple::Apple)
1914 if (Other.isOSVersionLT(*this))
1915 return str();
1916
1917 return Other.str();
1918}
1919
1920bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
1921 unsigned Micro) const {
1922 assert(isMacOSX() && "Not an OS X triple!");
1923
1924 // If this is OS X, expect a sane version number.
1925 if (getOS() == Triple::MacOSX)
1926 return isOSVersionLT(Major, Minor, Micro);
1927
1928 // Otherwise, compare to the "Darwin" number.
1929 if (Major == 10) {
1930 return isOSVersionLT(Minor + 4, Micro, 0);
1931 } else {
1932 assert(Major >= 11 && "Unexpected major version");
1933 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
1934 }
1935}
1936
1939 return VersionTuple();
1940 switch (getOS()) {
1941 case Triple::MacOSX:
1942 // ARM64 slice is supported starting from macOS 11.0+.
1943 return VersionTuple(11, 0, 0);
1944 case Triple::IOS:
1945 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
1946 // ARM64 simulators are supported for iOS 14+.
1948 return VersionTuple(14, 0, 0);
1949 // ARM64e slice is supported starting from iOS 14.
1950 if (isArm64e())
1951 return VersionTuple(14, 0, 0);
1952 break;
1953 case Triple::TvOS:
1954 // ARM64 simulators are supported for tvOS 14+.
1956 return VersionTuple(14, 0, 0);
1957 break;
1958 case Triple::WatchOS:
1959 // ARM64 simulators are supported for watchOS 7+.
1961 return VersionTuple(7, 0, 0);
1962 break;
1963 case Triple::DriverKit:
1964 return VersionTuple(20, 0, 0);
1965 default:
1966 break;
1967 }
1968 return VersionTuple();
1969}
1970
1972 const VersionTuple &Version) {
1973 switch (OSKind) {
1974 case MacOSX:
1975 // macOS 10.16 is canonicalized to macOS 11.
1976 if (Version == VersionTuple(10, 16))
1977 return VersionTuple(11, 0);
1978 [[fallthrough]];
1979 default:
1980 return Version;
1981 }
1982}
1983
1984// HLSL triple environment orders are relied on in the front end
1985static_assert(Triple::Vertex - Triple::Pixel == 1,
1986 "incorrect HLSL stage order");
1987static_assert(Triple::Geometry - Triple::Pixel == 2,
1988 "incorrect HLSL stage order");
1989static_assert(Triple::Hull - Triple::Pixel == 3,
1990 "incorrect HLSL stage order");
1991static_assert(Triple::Domain - Triple::Pixel == 4,
1992 "incorrect HLSL stage order");
1993static_assert(Triple::Compute - Triple::Pixel == 5,
1994 "incorrect HLSL stage order");
1995static_assert(Triple::Library - Triple::Pixel == 6,
1996 "incorrect HLSL stage order");
1997static_assert(Triple::RayGeneration - Triple::Pixel == 7,
1998 "incorrect HLSL stage order");
1999static_assert(Triple::Intersection - Triple::Pixel == 8,
2000 "incorrect HLSL stage order");
2001static_assert(Triple::AnyHit - Triple::Pixel == 9,
2002 "incorrect HLSL stage order");
2003static_assert(Triple::ClosestHit - Triple::Pixel == 10,
2004 "incorrect HLSL stage order");
2005static_assert(Triple::Miss - Triple::Pixel == 11,
2006 "incorrect HLSL stage order");
2007static_assert(Triple::Callable - Triple::Pixel == 12,
2008 "incorrect HLSL stage order");
2009static_assert(Triple::Mesh - Triple::Pixel == 13,
2010 "incorrect HLSL stage order");
2011static_assert(Triple::Amplification - Triple::Pixel == 14,
2012 "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:661
static VersionTuple parseVersionFromName(StringRef Name)
Definition: Triple.cpp:1231
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition: Triple.cpp:850
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition: Triple.cpp:437
static Triple::OSType parseOS(StringRef OSName)
Definition: Triple.cpp:614
static Triple::ArchType parseBPFArch(StringRef ArchName)
Definition: Triple.cpp:350
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition: Triple.cpp:721
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition: Triple.cpp:707
static Triple::ArchType parseArch(StringRef ArchName)
Definition: Triple.cpp:502
static Triple::VendorType parseVendor(StringRef VendorName)
Definition: Triple.cpp:595
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:696
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition: StringRef.h:651
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:567
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:420
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:631
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:271
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:1920
VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1264
StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition: Triple.cpp:1209
VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1353
void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1447
void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition: Triple.cpp:1439
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1566
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:1796
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:1458
@ 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:1475
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1647
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1833
void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1431
StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition: Triple.cpp:1214
@ 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:1415
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:1237
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:1220
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:1390
VersionTuple getDriverKitVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1378
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:1911
@ 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:1937
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1554
StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition: Triple.cpp:1226
@ 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:1278
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:1470
void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1427
void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1462
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:1971
StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1205
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:1562
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1728
VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1323
StringRef getEnvironmentVersionString() const
Get the version component of the environment component as a single string (the version after the envi...
Definition: Triple.cpp:1241
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1558
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1887
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:1419
void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1423
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