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