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 return Triple::ELF;
803
805 case Triple::amdgcn:
806 case Triple::amdil64:
807 case Triple::amdil:
808 case Triple::arc:
809 case Triple::armeb:
810 case Triple::avr:
811 case Triple::bpfeb:
812 case Triple::bpfel:
813 case Triple::csky:
814 case Triple::hexagon:
815 case Triple::hsail64:
816 case Triple::hsail:
817 case Triple::kalimba:
818 case Triple::lanai:
819 case Triple::le32:
820 case Triple::le64:
823 case Triple::m68k:
824 case Triple::mips64:
825 case Triple::mips64el:
826 case Triple::mips:
827 case Triple::mipsel:
828 case Triple::msp430:
829 case Triple::nvptx64:
830 case Triple::nvptx:
831 case Triple::ppc64le:
832 case Triple::ppcle:
833 case Triple::r600:
836 case Triple::riscv32:
837 case Triple::riscv64:
838 case Triple::shave:
839 case Triple::sparc:
840 case Triple::sparcel:
841 case Triple::sparcv9:
842 case Triple::spir64:
843 case Triple::spir:
844 case Triple::tce:
845 case Triple::tcele:
846 case Triple::thumbeb:
847 case Triple::ve:
848 case Triple::xcore:
849 case Triple::xtensa:
850 return Triple::ELF;
851
852 case Triple::ppc64:
853 case Triple::ppc:
854 if (T.isOSAIX())
855 return Triple::XCOFF;
856 return Triple::ELF;
857
858 case Triple::systemz:
859 if (T.isOSzOS())
860 return Triple::GOFF;
861 return Triple::ELF;
862
863 case Triple::wasm32:
864 case Triple::wasm64:
865 return Triple::Wasm;
866
867 case Triple::spirv:
868 case Triple::spirv32:
869 case Triple::spirv64:
870 return Triple::SPIRV;
871
872 case Triple::dxil:
873 return Triple::DXContainer;
874 }
875 llvm_unreachable("unknown architecture");
876}
877
878/// Construct a triple from the string representation provided.
879///
880/// This stores the string representation and parses the various pieces into
881/// enum members.
883 : Data(Str.str()), Arch(UnknownArch), SubArch(NoSubArch),
884 Vendor(UnknownVendor), OS(UnknownOS), Environment(UnknownEnvironment),
885 ObjectFormat(UnknownObjectFormat) {
886 // Do minimal parsing by hand here.
887 SmallVector<StringRef, 4> Components;
888 StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
889 if (Components.size() > 0) {
890 Arch = parseArch(Components[0]);
891 SubArch = parseSubArch(Components[0]);
892 if (Components.size() > 1) {
893 Vendor = parseVendor(Components[1]);
894 if (Components.size() > 2) {
895 OS = parseOS(Components[2]);
896 if (Components.size() > 3) {
897 Environment = parseEnvironment(Components[3]);
898 ObjectFormat = parseFormat(Components[3]);
899 }
900 }
901 } else {
902 Environment =
904 .StartsWith("mipsn32", Triple::GNUABIN32)
905 .StartsWith("mips64", Triple::GNUABI64)
906 .StartsWith("mipsisa64", Triple::GNUABI64)
907 .StartsWith("mipsisa32", Triple::GNU)
908 .Cases("mips", "mipsel", "mipsr6", "mipsr6el", Triple::GNU)
910 }
911 }
912 if (ObjectFormat == UnknownObjectFormat)
913 ObjectFormat = getDefaultFormat(*this);
914}
915
916/// Construct a triple from string representations of the architecture,
917/// vendor, and OS.
918///
919/// This joins each argument into a canonical string representation and parses
920/// them into enum members. It leaves the environment unknown and omits it from
921/// the string representation.
922Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
923 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
924 Arch(parseArch(ArchStr.str())),
925 SubArch(parseSubArch(ArchStr.str())),
926 Vendor(parseVendor(VendorStr.str())),
927 OS(parseOS(OSStr.str())),
928 Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
929 ObjectFormat = getDefaultFormat(*this);
930}
931
932/// Construct a triple from string representations of the architecture,
933/// vendor, OS, and environment.
934///
935/// This joins each argument into a canonical string representation and parses
936/// them into enum members.
937Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
938 const Twine &EnvironmentStr)
939 : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
940 EnvironmentStr).str()),
941 Arch(parseArch(ArchStr.str())),
942 SubArch(parseSubArch(ArchStr.str())),
943 Vendor(parseVendor(VendorStr.str())),
944 OS(parseOS(OSStr.str())),
945 Environment(parseEnvironment(EnvironmentStr.str())),
946 ObjectFormat(parseFormat(EnvironmentStr.str())) {
947 if (ObjectFormat == Triple::UnknownObjectFormat)
948 ObjectFormat = getDefaultFormat(*this);
949}
950
951std::string Triple::normalize(StringRef Str) {
952 bool IsMinGW32 = false;
953 bool IsCygwin = false;
954
955 // Parse into components.
956 SmallVector<StringRef, 4> Components;
957 Str.split(Components, '-');
958
959 // If the first component corresponds to a known architecture, preferentially
960 // use it for the architecture. If the second component corresponds to a
961 // known vendor, preferentially use it for the vendor, etc. This avoids silly
962 // component movement when a component parses as (eg) both a valid arch and a
963 // valid os.
964 ArchType Arch = UnknownArch;
965 if (Components.size() > 0)
966 Arch = parseArch(Components[0]);
967 VendorType Vendor = UnknownVendor;
968 if (Components.size() > 1)
969 Vendor = parseVendor(Components[1]);
970 OSType OS = UnknownOS;
971 if (Components.size() > 2) {
972 OS = parseOS(Components[2]);
973 IsCygwin = Components[2].startswith("cygwin");
974 IsMinGW32 = Components[2].startswith("mingw");
975 }
977 if (Components.size() > 3)
978 Environment = parseEnvironment(Components[3]);
980 if (Components.size() > 4)
981 ObjectFormat = parseFormat(Components[4]);
982
983 // Note which components are already in their final position. These will not
984 // be moved.
985 bool Found[4];
986 Found[0] = Arch != UnknownArch;
987 Found[1] = Vendor != UnknownVendor;
988 Found[2] = OS != UnknownOS;
989 Found[3] = Environment != UnknownEnvironment;
990
991 // If they are not there already, permute the components into their canonical
992 // positions by seeing if they parse as a valid architecture, and if so moving
993 // the component to the architecture position etc.
994 for (unsigned Pos = 0; Pos != std::size(Found); ++Pos) {
995 if (Found[Pos])
996 continue; // Already in the canonical position.
997
998 for (unsigned Idx = 0; Idx != Components.size(); ++Idx) {
999 // Do not reparse any components that already matched.
1000 if (Idx < std::size(Found) && Found[Idx])
1001 continue;
1002
1003 // Does this component parse as valid for the target position?
1004 bool Valid = false;
1005 StringRef Comp = Components[Idx];
1006 switch (Pos) {
1007 default: llvm_unreachable("unexpected component type!");
1008 case 0:
1009 Arch = parseArch(Comp);
1010 Valid = Arch != UnknownArch;
1011 break;
1012 case 1:
1013 Vendor = parseVendor(Comp);
1014 Valid = Vendor != UnknownVendor;
1015 break;
1016 case 2:
1017 OS = parseOS(Comp);
1018 IsCygwin = Comp.startswith("cygwin");
1019 IsMinGW32 = Comp.startswith("mingw");
1020 Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
1021 break;
1022 case 3:
1023 Environment = parseEnvironment(Comp);
1024 Valid = Environment != UnknownEnvironment;
1025 if (!Valid) {
1026 ObjectFormat = parseFormat(Comp);
1027 Valid = ObjectFormat != UnknownObjectFormat;
1028 }
1029 break;
1030 }
1031 if (!Valid)
1032 continue; // Nope, try the next component.
1033
1034 // Move the component to the target position, pushing any non-fixed
1035 // components that are in the way to the right. This tends to give
1036 // good results in the common cases of a forgotten vendor component
1037 // or a wrongly positioned environment.
1038 if (Pos < Idx) {
1039 // Insert left, pushing the existing components to the right. For
1040 // example, a-b-i386 -> i386-a-b when moving i386 to the front.
1041 StringRef CurrentComponent(""); // The empty component.
1042 // Replace the component we are moving with an empty component.
1043 std::swap(CurrentComponent, Components[Idx]);
1044 // Insert the component being moved at Pos, displacing any existing
1045 // components to the right.
1046 for (unsigned i = Pos; !CurrentComponent.empty(); ++i) {
1047 // Skip over any fixed components.
1048 while (i < std::size(Found) && Found[i])
1049 ++i;
1050 // Place the component at the new position, getting the component
1051 // that was at this position - it will be moved right.
1052 std::swap(CurrentComponent, Components[i]);
1053 }
1054 } else if (Pos > Idx) {
1055 // Push right by inserting empty components until the component at Idx
1056 // reaches the target position Pos. For example, pc-a -> -pc-a when
1057 // moving pc to the second position.
1058 do {
1059 // Insert one empty component at Idx.
1060 StringRef CurrentComponent(""); // The empty component.
1061 for (unsigned i = Idx; i < Components.size();) {
1062 // Place the component at the new position, getting the component
1063 // that was at this position - it will be moved right.
1064 std::swap(CurrentComponent, Components[i]);
1065 // If it was placed on top of an empty component then we are done.
1066 if (CurrentComponent.empty())
1067 break;
1068 // Advance to the next component, skipping any fixed components.
1069 while (++i < std::size(Found) && Found[i])
1070 ;
1071 }
1072 // The last component was pushed off the end - append it.
1073 if (!CurrentComponent.empty())
1074 Components.push_back(CurrentComponent);
1075
1076 // Advance Idx to the component's new position.
1077 while (++Idx < std::size(Found) && Found[Idx])
1078 ;
1079 } while (Idx < Pos); // Add more until the final position is reached.
1080 }
1081 assert(Pos < Components.size() && Components[Pos] == Comp &&
1082 "Component moved wrong!");
1083 Found[Pos] = true;
1084 break;
1085 }
1086 }
1087
1088 // Replace empty components with "unknown" value.
1089 for (StringRef &C : Components)
1090 if (C.empty())
1091 C = "unknown";
1092
1093 // Special case logic goes here. At this point Arch, Vendor and OS have the
1094 // correct values for the computed components.
1095 std::string NormalizedEnvironment;
1096 if (Environment == Triple::Android && Components[3].startswith("androideabi")) {
1097 StringRef AndroidVersion = Components[3].drop_front(strlen("androideabi"));
1098 if (AndroidVersion.empty()) {
1099 Components[3] = "android";
1100 } else {
1101 NormalizedEnvironment = Twine("android", AndroidVersion).str();
1102 Components[3] = NormalizedEnvironment;
1103 }
1104 }
1105
1106 // SUSE uses "gnueabi" to mean "gnueabihf"
1107 if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
1108 Components[3] = "gnueabihf";
1109
1110 if (OS == Triple::Win32) {
1111 Components.resize(4);
1112 Components[2] = "windows";
1113 if (Environment == UnknownEnvironment) {
1114 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
1115 Components[3] = "msvc";
1116 else
1117 Components[3] = getObjectFormatTypeName(ObjectFormat);
1118 }
1119 } else if (IsMinGW32) {
1120 Components.resize(4);
1121 Components[2] = "windows";
1122 Components[3] = "gnu";
1123 } else if (IsCygwin) {
1124 Components.resize(4);
1125 Components[2] = "windows";
1126 Components[3] = "cygnus";
1127 }
1128 if (IsMinGW32 || IsCygwin ||
1129 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
1130 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
1131 Components.resize(5);
1132 Components[4] = getObjectFormatTypeName(ObjectFormat);
1133 }
1134 }
1135
1136 // Stick the corrected components back together to form the normalized string.
1137 return join(Components, "-");
1138}
1139
1141 return StringRef(Data).split('-').first; // Isolate first component
1142}
1143
1145 switch (Kind) {
1146 case Triple::mips:
1147 if (SubArch == MipsSubArch_r6)
1148 return "mipsisa32r6";
1149 break;
1150 case Triple::mipsel:
1151 if (SubArch == MipsSubArch_r6)
1152 return "mipsisa32r6el";
1153 break;
1154 case Triple::mips64:
1155 if (SubArch == MipsSubArch_r6)
1156 return "mipsisa64r6";
1157 break;
1158 case Triple::mips64el:
1159 if (SubArch == MipsSubArch_r6)
1160 return "mipsisa64r6el";
1161 break;
1162 case Triple::aarch64:
1163 if (SubArch == AArch64SubArch_arm64ec)
1164 return "arm64ec";
1165 break;
1166 default:
1167 break;
1168 }
1169 return getArchTypeName(Kind);
1170}
1171
1173 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1174 return Tmp.split('-').first; // Isolate second component
1175}
1176
1178 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1179 Tmp = Tmp.split('-').second; // Strip second component
1180 return Tmp.split('-').first; // Isolate third component
1181}
1182
1184 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1185 Tmp = Tmp.split('-').second; // Strip second component
1186 return Tmp.split('-').second; // Strip third component
1187}
1188
1190 StringRef Tmp = StringRef(Data).split('-').second; // Strip first component
1191 return Tmp.split('-').second; // Strip second component
1192}
1193
1195 VersionTuple Version;
1196 Version.tryParse(Name);
1197 return Version.withoutBuild();
1198}
1199
1201 StringRef EnvironmentName = getEnvironmentName();
1202 StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
1203 if (EnvironmentName.startswith(EnvironmentTypeName))
1204 EnvironmentName = EnvironmentName.substr(EnvironmentTypeName.size());
1205
1206 return parseVersionFromName(EnvironmentName);
1207}
1208
1210 StringRef OSName = getOSName();
1211 // Assume that the OS portion of the triple starts with the canonical name.
1212 StringRef OSTypeName = getOSTypeName(getOS());
1213 if (OSName.startswith(OSTypeName))
1214 OSName = OSName.substr(OSTypeName.size());
1215 else if (getOS() == MacOSX)
1216 OSName.consume_front("macos");
1217
1218 return parseVersionFromName(OSName);
1219}
1220
1222 Version = getOSVersion();
1223
1224 switch (getOS()) {
1225 default: llvm_unreachable("unexpected OS for Darwin triple");
1226 case Darwin:
1227 // Default to darwin8, i.e., MacOSX 10.4.
1228 if (Version.getMajor() == 0)
1229 Version = VersionTuple(8);
1230 // Darwin version numbers are skewed from OS X versions.
1231 if (Version.getMajor() < 4) {
1232 return false;
1233 }
1234 if (Version.getMajor() <= 19) {
1235 Version = VersionTuple(10, Version.getMajor() - 4);
1236 } else {
1237 // darwin20+ corresponds to macOS 11+.
1238 Version = VersionTuple(11 + Version.getMajor() - 20);
1239 }
1240 break;
1241 case MacOSX:
1242 // Default to 10.4.
1243 if (Version.getMajor() == 0) {
1244 Version = VersionTuple(10, 4);
1245 } else if (Version.getMajor() < 10) {
1246 return false;
1247 }
1248 break;
1249 case IOS:
1250 case TvOS:
1251 case WatchOS:
1252 // Ignore the version from the triple. This is only handled because the
1253 // the clang driver combines OS X and IOS support into a common Darwin
1254 // toolchain that wants to know the OS X version number even when targeting
1255 // IOS.
1256 Version = VersionTuple(10, 4);
1257 break;
1258 case DriverKit:
1259 llvm_unreachable("OSX version isn't relevant for DriverKit");
1260 }
1261 return true;
1262}
1263
1265 switch (getOS()) {
1266 default: llvm_unreachable("unexpected OS for Darwin triple");
1267 case Darwin:
1268 case MacOSX:
1269 // Ignore the version from the triple. This is only handled because the
1270 // the clang driver combines OS X and IOS support into a common Darwin
1271 // toolchain that wants to know the iOS version number even when targeting
1272 // OS X.
1273 return VersionTuple(5);
1274 case IOS:
1275 case TvOS: {
1276 VersionTuple Version = getOSVersion();
1277 // Default to 5.0 (or 7.0 for arm64).
1278 if (Version.getMajor() == 0)
1279 return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
1280 return Version;
1281 }
1282 case WatchOS:
1283 llvm_unreachable("conflicting triple info");
1284 case DriverKit:
1285 llvm_unreachable("DriverKit doesn't have an iOS version");
1286 }
1287}
1288
1290 switch (getOS()) {
1291 default: llvm_unreachable("unexpected OS for Darwin triple");
1292 case Darwin:
1293 case MacOSX:
1294 // Ignore the version from the triple. This is only handled because the
1295 // the clang driver combines OS X and IOS support into a common Darwin
1296 // toolchain that wants to know the iOS version number even when targeting
1297 // OS X.
1298 return VersionTuple(2);
1299 case WatchOS: {
1300 VersionTuple Version = getOSVersion();
1301 if (Version.getMajor() == 0)
1302 return VersionTuple(2);
1303 return Version;
1304 }
1305 case IOS:
1306 llvm_unreachable("conflicting triple info");
1307 case DriverKit:
1308 llvm_unreachable("DriverKit doesn't have a WatchOS version");
1309 }
1310}
1311
1313 switch (getOS()) {
1314 default:
1315 llvm_unreachable("unexpected OS for Darwin triple");
1316 case DriverKit:
1317 VersionTuple Version = getOSVersion();
1318 if (Version.getMajor() == 0)
1319 return Version.withMajorReplaced(19);
1320 return Version;
1321 }
1322}
1323
1324void Triple::setTriple(const Twine &Str) {
1325 *this = Triple(Str);
1326}
1327
1329 setArchName(getArchName(Kind, SubArch));
1330}
1331
1334}
1335
1337 setOSName(getOSTypeName(Kind));
1338}
1339
1341 if (ObjectFormat == getDefaultFormat(*this))
1343
1345 getObjectFormatTypeName(ObjectFormat)).str());
1346}
1347
1349 if (Environment == UnknownEnvironment)
1351
1352 setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
1353 getObjectFormatTypeName(Kind)).str());
1354}
1355
1357 // Work around a miscompilation bug for Twines in gcc 4.0.3.
1359 Triple += Str;
1360 Triple += "-";
1361 Triple += getVendorName();
1362 Triple += "-";
1365}
1366
1368 setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName());
1369}
1370
1372 if (hasEnvironment())
1373 setTriple(getArchName() + "-" + getVendorName() + "-" + Str +
1374 "-" + getEnvironmentName());
1375 else
1376 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1377}
1378
1380 setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() +
1381 "-" + Str);
1382}
1383
1385 setTriple(getArchName() + "-" + getVendorName() + "-" + Str);
1386}
1387
1389 switch (Arch) {
1391 return 0;
1392
1393 case llvm::Triple::avr:
1395 return 16;
1396
1399 case llvm::Triple::arc:
1400 case llvm::Triple::arm:
1402 case llvm::Triple::csky:
1403 case llvm::Triple::dxil:
1408 case llvm::Triple::le32:
1410 case llvm::Triple::m68k:
1411 case llvm::Triple::mips:
1414 case llvm::Triple::ppc:
1416 case llvm::Triple::r600:
1422 case llvm::Triple::spir:
1424 case llvm::Triple::tce:
1429 case llvm::Triple::x86:
1432 return 32;
1433
1441 case llvm::Triple::le64:
1455 case llvm::Triple::ve:
1458 return 64;
1459 }
1460 llvm_unreachable("Invalid architecture value");
1461}
1462
1464 return getArchPointerBitWidth(getArch()) == 64;
1465}
1466
1468 return getArchPointerBitWidth(getArch()) == 32;
1469}
1470
1472 return getArchPointerBitWidth(getArch()) == 16;
1473}
1474
1476 Triple T(*this);
1477 switch (getArch()) {
1479 case Triple::amdgcn:
1480 case Triple::avr:
1481 case Triple::bpfeb:
1482 case Triple::bpfel:
1483 case Triple::msp430:
1484 case Triple::systemz:
1485 case Triple::ve:
1486 T.setArch(UnknownArch);
1487 break;
1488
1489 case Triple::aarch64_32:
1490 case Triple::amdil:
1491 case Triple::arc:
1492 case Triple::arm:
1493 case Triple::armeb:
1494 case Triple::csky:
1495 case Triple::dxil:
1496 case Triple::hexagon:
1497 case Triple::hsail:
1498 case Triple::kalimba:
1499 case Triple::lanai:
1500 case Triple::le32:
1502 case Triple::m68k:
1503 case Triple::mips:
1504 case Triple::mipsel:
1505 case Triple::nvptx:
1506 case Triple::ppc:
1507 case Triple::ppcle:
1508 case Triple::r600:
1510 case Triple::riscv32:
1511 case Triple::shave:
1512 case Triple::sparc:
1513 case Triple::sparcel:
1514 case Triple::spir:
1515 case Triple::spirv32:
1516 case Triple::tce:
1517 case Triple::tcele:
1518 case Triple::thumb:
1519 case Triple::thumbeb:
1520 case Triple::wasm32:
1521 case Triple::x86:
1522 case Triple::xcore:
1523 case Triple::xtensa:
1524 // Already 32-bit.
1525 break;
1526
1527 case Triple::aarch64: T.setArch(Triple::arm); break;
1528 case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1529 case Triple::amdil64: T.setArch(Triple::amdil); break;
1530 case Triple::hsail64: T.setArch(Triple::hsail); break;
1531 case Triple::le64: T.setArch(Triple::le32); break;
1532 case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
1533 case Triple::mips64:
1534 T.setArch(Triple::mips, getSubArch());
1535 break;
1536 case Triple::mips64el:
1537 T.setArch(Triple::mipsel, getSubArch());
1538 break;
1539 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1540 case Triple::ppc64: T.setArch(Triple::ppc); break;
1541 case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1542 case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1543 case Triple::riscv64: T.setArch(Triple::riscv32); break;
1544 case Triple::sparcv9: T.setArch(Triple::sparc); break;
1545 case Triple::spir64: T.setArch(Triple::spir); break;
1546 case Triple::spirv:
1547 case Triple::spirv64:
1548 T.setArch(Triple::spirv32, getSubArch());
1549 break;
1550 case Triple::wasm64: T.setArch(Triple::wasm32); break;
1551 case Triple::x86_64: T.setArch(Triple::x86); break;
1552 }
1553 return T;
1554}
1555
1557 Triple T(*this);
1558 switch (getArch()) {
1560 case Triple::arc:
1561 case Triple::avr:
1562 case Triple::csky:
1563 case Triple::dxil:
1564 case Triple::hexagon:
1565 case Triple::kalimba:
1566 case Triple::lanai:
1567 case Triple::m68k:
1568 case Triple::msp430:
1569 case Triple::r600:
1570 case Triple::shave:
1571 case Triple::sparcel:
1572 case Triple::tce:
1573 case Triple::tcele:
1574 case Triple::xcore:
1575 case Triple::xtensa:
1576 T.setArch(UnknownArch);
1577 break;
1578
1579 case Triple::aarch64:
1580 case Triple::aarch64_be:
1581 case Triple::amdgcn:
1582 case Triple::amdil64:
1583 case Triple::bpfeb:
1584 case Triple::bpfel:
1585 case Triple::hsail64:
1586 case Triple::le64:
1588 case Triple::mips64:
1589 case Triple::mips64el:
1590 case Triple::nvptx64:
1591 case Triple::ppc64:
1592 case Triple::ppc64le:
1594 case Triple::riscv64:
1595 case Triple::sparcv9:
1596 case Triple::spir64:
1597 case Triple::spirv64:
1598 case Triple::systemz:
1599 case Triple::ve:
1600 case Triple::wasm64:
1601 case Triple::x86_64:
1602 // Already 64-bit.
1603 break;
1604
1605 case Triple::aarch64_32: T.setArch(Triple::aarch64); break;
1606 case Triple::amdil: T.setArch(Triple::amdil64); break;
1607 case Triple::arm: T.setArch(Triple::aarch64); break;
1608 case Triple::armeb: T.setArch(Triple::aarch64_be); break;
1609 case Triple::hsail: T.setArch(Triple::hsail64); break;
1610 case Triple::le32: T.setArch(Triple::le64); break;
1611 case Triple::loongarch32: T.setArch(Triple::loongarch64); break;
1612 case Triple::mips:
1613 T.setArch(Triple::mips64, getSubArch());
1614 break;
1615 case Triple::mipsel:
1616 T.setArch(Triple::mips64el, getSubArch());
1617 break;
1618 case Triple::nvptx: T.setArch(Triple::nvptx64); break;
1619 case Triple::ppc: T.setArch(Triple::ppc64); break;
1620 case Triple::ppcle: T.setArch(Triple::ppc64le); break;
1621 case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
1622 case Triple::riscv32: T.setArch(Triple::riscv64); break;
1623 case Triple::sparc: T.setArch(Triple::sparcv9); break;
1624 case Triple::spir: T.setArch(Triple::spir64); break;
1625 case Triple::spirv:
1626 case Triple::spirv32:
1627 T.setArch(Triple::spirv64, getSubArch());
1628 break;
1629 case Triple::thumb: T.setArch(Triple::aarch64); break;
1630 case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1631 case Triple::wasm32: T.setArch(Triple::wasm64); break;
1632 case Triple::x86: T.setArch(Triple::x86_64); break;
1633 }
1634 return T;
1635}
1636
1638 Triple T(*this);
1639 // Already big endian.
1640 if (!isLittleEndian())
1641 return T;
1642 switch (getArch()) {
1644 case Triple::amdgcn:
1645 case Triple::amdil64:
1646 case Triple::amdil:
1647 case Triple::avr:
1648 case Triple::dxil:
1649 case Triple::hexagon:
1650 case Triple::hsail64:
1651 case Triple::hsail:
1652 case Triple::kalimba:
1653 case Triple::le32:
1654 case Triple::le64:
1657 case Triple::msp430:
1658 case Triple::nvptx64:
1659 case Triple::nvptx:
1660 case Triple::r600:
1663 case Triple::riscv32:
1664 case Triple::riscv64:
1665 case Triple::shave:
1666 case Triple::spir64:
1667 case Triple::spir:
1668 case Triple::spirv:
1669 case Triple::spirv32:
1670 case Triple::spirv64:
1671 case Triple::wasm32:
1672 case Triple::wasm64:
1673 case Triple::x86:
1674 case Triple::x86_64:
1675 case Triple::xcore:
1676 case Triple::ve:
1677 case Triple::csky:
1678 case Triple::xtensa:
1679
1680 // ARM is intentionally unsupported here, changing the architecture would
1681 // drop any arch suffixes.
1682 case Triple::arm:
1683 case Triple::thumb:
1684 T.setArch(UnknownArch);
1685 break;
1686
1687 case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1688 case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1689 case Triple::mips64el:
1690 T.setArch(Triple::mips64, getSubArch());
1691 break;
1692 case Triple::mipsel:
1693 T.setArch(Triple::mips, getSubArch());
1694 break;
1695 case Triple::ppcle: T.setArch(Triple::ppc); break;
1696 case Triple::ppc64le: T.setArch(Triple::ppc64); break;
1697 case Triple::sparcel: T.setArch(Triple::sparc); break;
1698 case Triple::tcele: T.setArch(Triple::tce); break;
1699 default:
1700 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
1701 }
1702 return T;
1703}
1704
1706 Triple T(*this);
1707 if (isLittleEndian())
1708 return T;
1709
1710 switch (getArch()) {
1712 case Triple::lanai:
1713 case Triple::sparcv9:
1714 case Triple::systemz:
1715 case Triple::m68k:
1716
1717 // ARM is intentionally unsupported here, changing the architecture would
1718 // drop any arch suffixes.
1719 case Triple::armeb:
1720 case Triple::thumbeb:
1721 T.setArch(UnknownArch);
1722 break;
1723
1724 case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
1725 case Triple::bpfeb: T.setArch(Triple::bpfel); break;
1726 case Triple::mips64:
1727 T.setArch(Triple::mips64el, getSubArch());
1728 break;
1729 case Triple::mips:
1730 T.setArch(Triple::mipsel, getSubArch());
1731 break;
1732 case Triple::ppc: T.setArch(Triple::ppcle); break;
1733 case Triple::ppc64: T.setArch(Triple::ppc64le); break;
1734 case Triple::sparc: T.setArch(Triple::sparcel); break;
1735 case Triple::tce: T.setArch(Triple::tcele); break;
1736 default:
1737 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
1738 }
1739 return T;
1740}
1741
1743 switch (getArch()) {
1744 case Triple::aarch64:
1745 case Triple::aarch64_32:
1746 case Triple::amdgcn:
1747 case Triple::amdil64:
1748 case Triple::amdil:
1749 case Triple::arm:
1750 case Triple::avr:
1751 case Triple::bpfel:
1752 case Triple::csky:
1753 case Triple::dxil:
1754 case Triple::hexagon:
1755 case Triple::hsail64:
1756 case Triple::hsail:
1757 case Triple::kalimba:
1758 case Triple::le32:
1759 case Triple::le64:
1762 case Triple::mips64el:
1763 case Triple::mipsel:
1764 case Triple::msp430:
1765 case Triple::nvptx64:
1766 case Triple::nvptx:
1767 case Triple::ppcle:
1768 case Triple::ppc64le:
1769 case Triple::r600:
1772 case Triple::riscv32:
1773 case Triple::riscv64:
1774 case Triple::shave:
1775 case Triple::sparcel:
1776 case Triple::spir64:
1777 case Triple::spir:
1778 case Triple::spirv:
1779 case Triple::spirv32:
1780 case Triple::spirv64:
1781 case Triple::tcele:
1782 case Triple::thumb:
1783 case Triple::ve:
1784 case Triple::wasm32:
1785 case Triple::wasm64:
1786 case Triple::x86:
1787 case Triple::x86_64:
1788 case Triple::xcore:
1789 case Triple::xtensa:
1790 return true;
1791 default:
1792 return false;
1793 }
1794}
1795
1797 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1798 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
1799 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
1800 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
1801 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
1802 if (getVendor() == Triple::Apple)
1803 return getSubArch() == Other.getSubArch() &&
1804 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1805 else
1806 return getSubArch() == Other.getSubArch() &&
1807 getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
1808 getEnvironment() == Other.getEnvironment() &&
1809 getObjectFormat() == Other.getObjectFormat();
1810 }
1811
1812 // If vendor is apple, ignore the version number.
1813 if (getVendor() == Triple::Apple)
1814 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
1815 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1816
1817 return *this == Other;
1818}
1819
1820std::string Triple::merge(const Triple &Other) const {
1821 // If vendor is apple, pick the triple with the larger version number.
1822 if (getVendor() == Triple::Apple)
1823 if (Other.isOSVersionLT(*this))
1824 return str();
1825
1826 return Other.str();
1827}
1828
1829bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
1830 unsigned Micro) const {
1831 assert(isMacOSX() && "Not an OS X triple!");
1832
1833 // If this is OS X, expect a sane version number.
1834 if (getOS() == Triple::MacOSX)
1835 return isOSVersionLT(Major, Minor, Micro);
1836
1837 // Otherwise, compare to the "Darwin" number.
1838 if (Major == 10) {
1839 return isOSVersionLT(Minor + 4, Micro, 0);
1840 } else {
1841 assert(Major >= 11 && "Unexpected major version");
1842 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
1843 }
1844}
1845
1848 return VersionTuple();
1849 switch (getOS()) {
1850 case Triple::MacOSX:
1851 // ARM64 slice is supported starting from macOS 11.0+.
1852 return VersionTuple(11, 0, 0);
1853 case Triple::IOS:
1854 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
1855 // ARM64 simulators are supported for iOS 14+.
1857 return VersionTuple(14, 0, 0);
1858 // ARM64e slice is supported starting from iOS 14.
1859 if (isArm64e())
1860 return VersionTuple(14, 0, 0);
1861 break;
1862 case Triple::TvOS:
1863 // ARM64 simulators are supported for tvOS 14+.
1865 return VersionTuple(14, 0, 0);
1866 break;
1867 case Triple::WatchOS:
1868 // ARM64 simulators are supported for watchOS 7+.
1870 return VersionTuple(7, 0, 0);
1871 break;
1872 case Triple::DriverKit:
1873 return VersionTuple(20, 0, 0);
1874 default:
1875 break;
1876 }
1877 return VersionTuple();
1878}
1879
1881 const VersionTuple &Version) {
1882 switch (OSKind) {
1883 case MacOSX:
1884 // macOS 10.16 is canonicalized to macOS 11.
1885 if (Version == VersionTuple(10, 16))
1886 return VersionTuple(11, 0);
1887 [[fallthrough]];
1888 default:
1889 return Version;
1890 }
1891}
1892
1893// HLSL triple environment orders are relied on in the front end
1894static_assert(Triple::Vertex - Triple::Pixel == 1,
1895 "incorrect HLSL stage order");
1896static_assert(Triple::Geometry - Triple::Pixel == 2,
1897 "incorrect HLSL stage order");
1898static_assert(Triple::Hull - Triple::Pixel == 3,
1899 "incorrect HLSL stage order");
1900static_assert(Triple::Domain - Triple::Pixel == 4,
1901 "incorrect HLSL stage order");
1902static_assert(Triple::Compute - Triple::Pixel == 5,
1903 "incorrect HLSL stage order");
1904static_assert(Triple::Library - Triple::Pixel == 6,
1905 "incorrect HLSL stage order");
1906static_assert(Triple::RayGeneration - Triple::Pixel == 7,
1907 "incorrect HLSL stage order");
1908static_assert(Triple::Intersection - Triple::Pixel == 8,
1909 "incorrect HLSL stage order");
1910static_assert(Triple::AnyHit - Triple::Pixel == 9,
1911 "incorrect HLSL stage order");
1912static_assert(Triple::ClosestHit - Triple::Pixel == 10,
1913 "incorrect HLSL stage order");
1914static_assert(Triple::Miss - Triple::Pixel == 11,
1915 "incorrect HLSL stage order");
1916static_assert(Triple::Callable - Triple::Pixel == 12,
1917 "incorrect HLSL stage order");
1918static_assert(Triple::Mesh - Triple::Pixel == 13,
1919 "incorrect HLSL stage order");
1920static_assert(Triple::Amplification - Triple::Pixel == 14,
1921 "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:1194
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:1388
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:1829
VersionTuple getOSVersion() const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1209
StringRef getVendorName() const
Get the vendor (second) component of the triple.
Definition: Triple.cpp:1172
VersionTuple getWatchOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1289
void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1356
void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
Definition: Triple.cpp:1348
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1475
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:1705
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:1367
@ 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:1384
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1556
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1742
void setEnvironment(EnvironmentType Kind)
Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1340
StringRef getOSName() const
Get the operating system (third) component of the triple.
Definition: Triple.cpp:1177
@ 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:1324
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:1200
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:1183
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:1312
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:1820
@ 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:1846
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1463
StringRef getOSAndEnvironmentName() const
Get the operating system and optional environment components as a single string (separated by a '-' i...
Definition: Triple.cpp:1189
@ 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:1221
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:1379
void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
Definition: Triple.cpp:1336
void setOSName(StringRef Str)
Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1371
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:1880
StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1140
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:1471
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1637
VersionTuple getiOSVersion() const
Parse the version number as with getOSVersion.
Definition: Triple.cpp:1264
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1467
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1796
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:1328
void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1332
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