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