LLVM 17.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 spirv32: return "spirv32";
74 case spirv64: return "spirv64";
75 case systemz: return "s390x";
76 case tce: return "tce";
77 case tcele: return "tcele";
78 case thumb: return "thumb";
79 case thumbeb: return "thumbeb";
80 case ve: return "ve";
81 case wasm32: return "wasm32";
82 case wasm64: return "wasm64";
83 case x86: return "i386";
84 case x86_64: return "x86_64";
85 case xcore: return "xcore";
86 case xtensa: return "xtensa";
87 }
88
89 llvm_unreachable("Invalid ArchType!");
90}
91
93 switch (Kind) {
94 default:
95 return StringRef();
96
97 case aarch64:
98 case aarch64_be:
99 case aarch64_32: return "aarch64";
100
101 case arc: return "arc";
102
103 case arm:
104 case armeb:
105 case thumb:
106 case thumbeb: return "arm";
107
108 case avr: return "avr";
109
110 case ppc64:
111 case ppc64le:
112 case ppc:
113 case ppcle: return "ppc";
114
115 case m68k: return "m68k";
116
117 case mips:
118 case mipsel:
119 case mips64:
120 case mips64el: return "mips";
121
122 case hexagon: return "hexagon";
123
124 case amdgcn: return "amdgcn";
125 case r600: return "r600";
126
127 case bpfel:
128 case bpfeb: return "bpf";
129
130 case sparcv9:
131 case sparcel:
132 case sparc: return "sparc";
133
134 case systemz: return "s390";
135
136 case x86:
137 case x86_64: return "x86";
138
139 case xcore: return "xcore";
140
141 // NVPTX intrinsics are namespaced under nvvm.
142 case nvptx: return "nvvm";
143 case nvptx64: return "nvvm";
144
145 case le32: return "le32";
146 case le64: return "le64";
147
148 case amdil:
149 case amdil64: return "amdil";
150
151 case hsail:
152 case hsail64: return "hsail";
153
154 case spir:
155 case spir64: return "spir";
156
157 case spirv32:
158 case spirv64: return "spirv";
159
160 case kalimba: return "kalimba";
161 case lanai: return "lanai";
162 case shave: return "shave";
163 case wasm32:
164 case wasm64: return "wasm";
165
166 case riscv32:
167 case riscv64: return "riscv";
168
169 case ve: return "ve";
170 case csky: return "csky";
171
172 case loongarch32:
173 case loongarch64: return "loongarch";
174
175 case dxil: return "dx";
176
177 case xtensa: return "xtensa";
178 }
179}
180
182 switch (Kind) {
183 case UnknownVendor: return "unknown";
184
185 case AMD: return "amd";
186 case Apple: return "apple";
187 case CSR: return "csr";
188 case Freescale: return "fsl";
189 case IBM: return "ibm";
190 case ImaginationTechnologies: return "img";
191 case Mesa: return "mesa";
192 case MipsTechnologies: return "mti";
193 case Myriad: return "myriad";
194 case NVIDIA: return "nvidia";
195 case OpenEmbedded: return "oe";
196 case PC: return "pc";
197 case SCEI: return "scei";
198 case SUSE: return "suse";
199 }
200
201 llvm_unreachable("Invalid VendorType!");
202}
203
205 switch (Kind) {
206 case UnknownOS: return "unknown";
207
208 case AIX: return "aix";
209 case AMDHSA: return "amdhsa";
210 case AMDPAL: return "amdpal";
211 case Ananas: return "ananas";
212 case CUDA: return "cuda";
213 case CloudABI: return "cloudabi";
214 case Contiki: return "contiki";
215 case Darwin: return "darwin";
216 case DragonFly: return "dragonfly";
217 case DriverKit: return "driverkit";
218 case ELFIAMCU: return "elfiamcu";
219 case Emscripten: return "emscripten";
220 case FreeBSD: return "freebsd";
221 case Fuchsia: return "fuchsia";
222 case Haiku: return "haiku";
223 case HermitCore: return "hermit";
224 case Hurd: return "hurd";
225 case IOS: return "ios";
226 case KFreeBSD: return "kfreebsd";
227 case Linux: return "linux";
228 case Lv2: return "lv2";
229 case MacOSX: return "macosx";
230 case Mesa3D: return "mesa3d";
231 case Minix: return "minix";
232 case NVCL: return "nvcl";
233 case NaCl: return "nacl";
234 case NetBSD: return "netbsd";
235 case OpenBSD: return "openbsd";
236 case PS4: return "ps4";
237 case PS5: return "ps5";
238 case RTEMS: return "rtems";
239 case Solaris: return "solaris";
240 case TvOS: return "tvos";
241 case WASI: return "wasi";
242 case WatchOS: return "watchos";
243 case Win32: return "windows";
244 case ZOS: return "zos";
245 case ShaderModel: return "shadermodel";
246 case LiteOS: return "liteos";
247 }
248
249 llvm_unreachable("Invalid OSType");
250}
251
253 switch (Kind) {
254 case UnknownEnvironment: return "unknown";
255 case Android: return "android";
256 case CODE16: return "code16";
257 case CoreCLR: return "coreclr";
258 case Cygnus: return "cygnus";
259 case EABI: return "eabi";
260 case EABIHF: return "eabihf";
261 case GNU: return "gnu";
262 case GNUABI64: return "gnuabi64";
263 case GNUABIN32: return "gnuabin32";
264 case GNUEABI: return "gnueabi";
265 case GNUEABIHF: return "gnueabihf";
266 case GNUF32: return "gnuf32";
267 case GNUF64: return "gnuf64";
268 case GNUSF: return "gnusf";
269 case GNUX32: return "gnux32";
270 case GNUILP32: return "gnu_ilp32";
271 case Itanium: return "itanium";
272 case MSVC: return "msvc";
273 case MacABI: return "macabi";
274 case Musl: return "musl";
275 case MuslEABI: return "musleabi";
276 case MuslEABIHF: return "musleabihf";
277 case MuslX32: return "muslx32";
278 case Simulator: return "simulator";
279 case Pixel: return "pixel";
280 case Vertex: return "vertex";
281 case Geometry: return "geometry";
282 case Hull: return "hull";
283 case Domain: return "domain";
284 case Compute: return "compute";
285 case Library: return "library";
286 case RayGeneration: return "raygeneration";
287 case Intersection: return "intersection";
288 case AnyHit: return "anyhit";
289 case ClosestHit: return "closesthit";
290 case Miss: return "miss";
291 case Callable: return "callable";
292 case Mesh: return "mesh";
293 case Amplification: return "amplification";
294 case OpenHOS: return "ohos";
295 }
296
297 llvm_unreachable("Invalid EnvironmentType!");
298}
299
301 switch (Kind) {
302 case UnknownObjectFormat: return "";
303 case COFF: return "coff";
304 case ELF: return "elf";
305 case GOFF: return "goff";
306 case MachO: return "macho";
307 case Wasm: return "wasm";
308 case XCOFF: return "xcoff";
309 case DXContainer: return "dxcontainer";
310 case SPIRV: return "spirv";
311 }
312 llvm_unreachable("unknown object format type");
313}
314
316 if (ArchName.equals("bpf")) {
318 return Triple::bpfel;
319 else
320 return Triple::bpfeb;
321 } else if (ArchName.equals("bpf_be") || ArchName.equals("bpfeb")) {
322 return Triple::bpfeb;
323 } else if (ArchName.equals("bpf_le") || ArchName.equals("bpfel")) {
324 return Triple::bpfel;
325 } else {
326 return Triple::UnknownArch;
327 }
328}
329
333 .Case("aarch64", aarch64)
334 .Case("aarch64_be", aarch64_be)
335 .Case("aarch64_32", aarch64_32)
336 .Case("arc", arc)
337 .Case("arm64", aarch64) // "arm64" is an alias for "aarch64"
338 .Case("arm64_32", aarch64_32)
339 .Case("arm", arm)
340 .Case("armeb", armeb)
341 .Case("avr", avr)
342 .StartsWith("bpf", BPFArch)
343 .Case("m68k", m68k)
344 .Case("mips", mips)
345 .Case("mipsel", mipsel)
346 .Case("mips64", mips64)
347 .Case("mips64el", mips64el)
348 .Case("msp430", msp430)
349 .Case("ppc64", ppc64)
350 .Case("ppc32", ppc)
351 .Case("ppc", ppc)
352 .Case("ppc32le", ppcle)
353 .Case("ppcle", ppcle)
354 .Case("ppc64le", ppc64le)
355 .Case("r600", r600)
356 .Case("amdgcn", amdgcn)
357 .Case("riscv32", riscv32)
358 .Case("riscv64", riscv64)
359 .Case("hexagon", hexagon)
360 .Case("sparc", sparc)
361 .Case("sparcel", sparcel)
362 .Case("sparcv9", sparcv9)
363 .Case("s390x", systemz)
364 .Case("systemz", systemz)
365 .Case("tce", tce)
366 .Case("tcele", tcele)
367 .Case("thumb", thumb)
368 .Case("thumbeb", thumbeb)
369 .Case("x86", x86)
370 .Case("i386", x86)
371 .Case("x86-64", x86_64)
372 .Case("xcore", xcore)
373 .Case("nvptx", nvptx)
374 .Case("nvptx64", nvptx64)
375 .Case("le32", le32)
376 .Case("le64", le64)
377 .Case("amdil", amdil)
378 .Case("amdil64", amdil64)
379 .Case("hsail", hsail)
380 .Case("hsail64", hsail64)
381 .Case("spir", spir)
382 .Case("spir64", spir64)
383 .Case("spirv32", spirv32)
384 .Case("spirv64", spirv64)
385 .Case("kalimba", kalimba)
386 .Case("lanai", lanai)
387 .Case("shave", shave)
388 .Case("wasm32", wasm32)
389 .Case("wasm64", wasm64)
390 .Case("renderscript32", renderscript32)
391 .Case("renderscript64", renderscript64)
392 .Case("ve", ve)
393 .Case("csky", csky)
394 .Case("loongarch32", loongarch32)
395 .Case("loongarch64", loongarch64)
396 .Case("dxil", dxil)
397 .Case("xtensa", xtensa)
399}
400
402 ARM::ISAKind ISA = ARM::parseArchISA(ArchName);
403 ARM::EndianKind ENDIAN = ARM::parseArchEndian(ArchName);
404
406 switch (ENDIAN) {
408 switch (ISA) {
410 arch = Triple::arm;
411 break;
413 arch = Triple::thumb;
414 break;
416 arch = Triple::aarch64;
417 break;
419 break;
420 }
421 break;
422 }
424 switch (ISA) {
426 arch = Triple::armeb;
427 break;
429 arch = Triple::thumbeb;
430 break;
432 arch = Triple::aarch64_be;
433 break;
435 break;
436 }
437 break;
438 }
440 break;
441 }
442 }
443
444 ArchName = ARM::getCanonicalArchName(ArchName);
445 if (ArchName.empty())
446 return Triple::UnknownArch;
447
448 // Thumb only exists in v4+
449 if (ISA == ARM::ISAKind::THUMB &&
450 (ArchName.startswith("v2") || ArchName.startswith("v3")))
451 return Triple::UnknownArch;
452
453 // Thumb only for v6m
455 unsigned Version = ARM::parseArchVersion(ArchName);
456 if (Profile == ARM::ProfileKind::M && Version == 6) {
457 if (ENDIAN == ARM::EndianKind::BIG)
458 return Triple::thumbeb;
459 else
460 return Triple::thumb;
461 }
462
463 return arch;
464}
465
467 auto AT = StringSwitch<Triple::ArchType>(ArchName)
468 .Cases("i386", "i486", "i586", "i686", Triple::x86)
469 // FIXME: Do we need to support these?
470 .Cases("i786", "i886", "i986", Triple::x86)
471 .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
472 .Cases("powerpc", "powerpcspe", "ppc", "ppc32", Triple::ppc)
473 .Cases("powerpcle", "ppcle", "ppc32le", Triple::ppcle)
474 .Cases("powerpc64", "ppu", "ppc64", Triple::ppc64)
475 .Cases("powerpc64le", "ppc64le", Triple::ppc64le)
476 .Case("xscale", Triple::arm)
477 .Case("xscaleeb", Triple::armeb)
478 .Case("aarch64", Triple::aarch64)
479 .Case("aarch64_be", Triple::aarch64_be)
480 .Case("aarch64_32", Triple::aarch64_32)
481 .Case("arc", Triple::arc)
482 .Case("arm64", Triple::aarch64)
483 .Case("arm64_32", Triple::aarch64_32)
484 .Case("arm64e", Triple::aarch64)
485 .Case("arm64ec", Triple::aarch64)
486 .Case("arm", Triple::arm)
487 .Case("armeb", Triple::armeb)
488 .Case("thumb", Triple::thumb)
489 .Case("thumbeb", Triple::thumbeb)
490 .Case("avr", Triple::avr)
491 .Case("m68k", Triple::m68k)
492 .Case("msp430", Triple::msp430)
493 .Cases("mips", "mipseb", "mipsallegrex", "mipsisa32r6",
494 "mipsr6", Triple::mips)
495 .Cases("mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el",
497 .Cases("mips64", "mips64eb", "mipsn32", "mipsisa64r6",
498 "mips64r6", "mipsn32r6", Triple::mips64)
499 .Cases("mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
500 "mipsn32r6el", Triple::mips64el)
501 .Case("r600", Triple::r600)
502 .Case("amdgcn", Triple::amdgcn)
503 .Case("riscv32", Triple::riscv32)
504 .Case("riscv64", Triple::riscv64)
505 .Case("hexagon", Triple::hexagon)
506 .Cases("s390x", "systemz", Triple::systemz)
507 .Case("sparc", Triple::sparc)
508 .Case("sparcel", Triple::sparcel)
509 .Cases("sparcv9", "sparc64", Triple::sparcv9)
510 .Case("tce", Triple::tce)
511 .Case("tcele", Triple::tcele)
512 .Case("xcore", Triple::xcore)
513 .Case("nvptx", Triple::nvptx)
514 .Case("nvptx64", Triple::nvptx64)
515 .Case("le32", Triple::le32)
516 .Case("le64", Triple::le64)
517 .Case("amdil", Triple::amdil)
518 .Case("amdil64", Triple::amdil64)
519 .Case("hsail", Triple::hsail)
520 .Case("hsail64", Triple::hsail64)
521 .Case("spir", Triple::spir)
522 .Case("spir64", Triple::spir64)
523 .Cases("spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
524 "spirv32v1.3", "spirv32v1.4", "spirv32v1.5", Triple::spirv32)
525 .Cases("spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
526 "spirv64v1.3", "spirv64v1.4", "spirv64v1.5", Triple::spirv64)
527 .StartsWith("kalimba", Triple::kalimba)
528 .Case("lanai", Triple::lanai)
529 .Case("renderscript32", Triple::renderscript32)
530 .Case("renderscript64", Triple::renderscript64)
531 .Case("shave", Triple::shave)
532 .Case("ve", Triple::ve)
533 .Case("wasm32", Triple::wasm32)
534 .Case("wasm64", Triple::wasm64)
535 .Case("csky", Triple::csky)
536 .Case("loongarch32", Triple::loongarch32)
537 .Case("loongarch64", Triple::loongarch64)
538 .Case("dxil", Triple::dxil)
539 .Case("xtensa", Triple::xtensa)
541
542 // Some architectures require special parsing logic just to compute the
543 // ArchType result.
544 if (AT == Triple::UnknownArch) {
545 if (ArchName.startswith("arm") || ArchName.startswith("thumb") ||
546 ArchName.startswith("aarch64"))
547 return parseARMArch(ArchName);
548 if (ArchName.startswith("bpf"))
549 return parseBPFArch(ArchName);
550 }
551
552 return AT;
553}
554
556 return StringSwitch<Triple::VendorType>(VendorName)
557 .Case("apple", Triple::Apple)
558 .Case("pc", Triple::PC)
559 .Case("scei", Triple::SCEI)
560 .Case("sie", Triple::SCEI)
561 .Case("fsl", Triple::Freescale)
562 .Case("ibm", Triple::IBM)
565 .Case("nvidia", Triple::NVIDIA)
566 .Case("csr", Triple::CSR)
567 .Case("myriad", Triple::Myriad)
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("ananas", Triple::Ananas)
578 .StartsWith("cloudabi", Triple::CloudABI)
579 .StartsWith("darwin", Triple::Darwin)
580 .StartsWith("dragonfly", Triple::DragonFly)
581 .StartsWith("freebsd", Triple::FreeBSD)
582 .StartsWith("fuchsia", Triple::Fuchsia)
583 .StartsWith("ios", Triple::IOS)
584 .StartsWith("kfreebsd", Triple::KFreeBSD)
585 .StartsWith("linux", Triple::Linux)
586 .StartsWith("lv2", Triple::Lv2)
587 .StartsWith("macos", Triple::MacOSX)
588 .StartsWith("netbsd", Triple::NetBSD)
589 .StartsWith("openbsd", Triple::OpenBSD)
590 .StartsWith("solaris", Triple::Solaris)
591 .StartsWith("win32", Triple::Win32)
592 .StartsWith("windows", Triple::Win32)
593 .StartsWith("zos", Triple::ZOS)
594 .StartsWith("haiku", Triple::Haiku)
595 .StartsWith("minix", Triple::Minix)
596 .StartsWith("rtems", Triple::RTEMS)
597 .StartsWith("nacl", Triple::NaCl)
598 .StartsWith("aix", Triple::AIX)
599 .StartsWith("cuda", Triple::CUDA)
600 .StartsWith("nvcl", Triple::NVCL)
601 .StartsWith("amdhsa", Triple::AMDHSA)
602 .StartsWith("ps4", Triple::PS4)
603 .StartsWith("ps5", Triple::PS5)
604 .StartsWith("elfiamcu", Triple::ELFIAMCU)
605 .StartsWith("tvos", Triple::TvOS)
606 .StartsWith("watchos", Triple::WatchOS)
607 .StartsWith("driverkit", Triple::DriverKit)
608 .StartsWith("mesa3d", Triple::Mesa3D)
609 .StartsWith("contiki", Triple::Contiki)
610 .StartsWith("amdpal", Triple::AMDPAL)
612 .StartsWith("hurd", Triple::Hurd)
613 .StartsWith("wasi", Triple::WASI)
614 .StartsWith("emscripten", Triple::Emscripten)
615 .StartsWith("shadermodel", Triple::ShaderModel)
616 .StartsWith("liteos", Triple::LiteOS)
618}
619
621 return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
622 .StartsWith("eabihf", Triple::EABIHF)
623 .StartsWith("eabi", Triple::EABI)
624 .StartsWith("gnuabin32", Triple::GNUABIN32)
625 .StartsWith("gnuabi64", Triple::GNUABI64)
626 .StartsWith("gnueabihf", Triple::GNUEABIHF)
627 .StartsWith("gnueabi", Triple::GNUEABI)
628 .StartsWith("gnuf32", Triple::GNUF32)
629 .StartsWith("gnuf64", Triple::GNUF64)
630 .StartsWith("gnusf", Triple::GNUSF)
631 .StartsWith("gnux32", Triple::GNUX32)
632 .StartsWith("gnu_ilp32", Triple::GNUILP32)
633 .StartsWith("code16", Triple::CODE16)
634 .StartsWith("gnu", Triple::GNU)
635 .StartsWith("android", Triple::Android)
636 .StartsWith("musleabihf", Triple::MuslEABIHF)
637 .StartsWith("musleabi", Triple::MuslEABI)
638 .StartsWith("muslx32", Triple::MuslX32)
639 .StartsWith("musl", Triple::Musl)
640 .StartsWith("msvc", Triple::MSVC)
641 .StartsWith("itanium", Triple::Itanium)
642 .StartsWith("cygnus", Triple::Cygnus)
643 .StartsWith("coreclr", Triple::CoreCLR)
644 .StartsWith("simulator", Triple::Simulator)
645 .StartsWith("macabi", Triple::MacABI)
646 .StartsWith("pixel", Triple::Pixel)
647 .StartsWith("vertex", Triple::Vertex)
648 .StartsWith("geometry", Triple::Geometry)
649 .StartsWith("hull", Triple::Hull)
650 .StartsWith("domain", Triple::Domain)
651 .StartsWith("compute", Triple::Compute)
652 .StartsWith("library", Triple::Library)
653 .StartsWith("raygeneration", Triple::RayGeneration)
654 .StartsWith("intersection", Triple::Intersection)
655 .StartsWith("anyhit", Triple::AnyHit)
656 .StartsWith("closesthit", Triple::ClosestHit)
657 .StartsWith("miss", Triple::Miss)
658 .StartsWith("callable", Triple::Callable)
659 .StartsWith("mesh", Triple::Mesh)
660 .StartsWith("amplification", Triple::Amplification)
663}
664
666 return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
667 // "xcoff" must come before "coff" because of the order-dependendent
668 // pattern matching.
669 .EndsWith("xcoff", Triple::XCOFF)
670 .EndsWith("coff", Triple::COFF)
671 .EndsWith("elf", Triple::ELF)
672 .EndsWith("goff", Triple::GOFF)
673 .EndsWith("macho", Triple::MachO)
674 .EndsWith("wasm", Triple::Wasm)
675 .EndsWith("spirv", Triple::SPIRV)
677}
678
680 if (SubArchName.startswith("mips") &&
681 (SubArchName.endswith("r6el") || SubArchName.endswith("r6")))
683
684 if (SubArchName == "powerpcspe")
686
687 if (SubArchName == "arm64e")
689
690 if (SubArchName == "arm64ec")
692
693 if (SubArchName.startswith("spirv"))
694 return StringSwitch<Triple::SubArchType>(SubArchName)
702
703 StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
704
705 // For now, this is the small part. Early return.
706 if (ARMSubArch.empty())
707 return StringSwitch<Triple::SubArchType>(SubArchName)
712
713 // ARM sub arch.
714 switch(ARM::parseArch(ARMSubArch)) {
715 case ARM::ArchKind::ARMV4:
716 return Triple::NoSubArch;
717 case ARM::ArchKind::ARMV4T:
719 case ARM::ArchKind::ARMV5T:
721 case ARM::ArchKind::ARMV5TE:
722 case ARM::ArchKind::IWMMXT:
723 case ARM::ArchKind::IWMMXT2:
724 case ARM::ArchKind::XSCALE:
725 case ARM::ArchKind::ARMV5TEJ:
727 case ARM::ArchKind::ARMV6:
729 case ARM::ArchKind::ARMV6K:
730 case ARM::ArchKind::ARMV6KZ:
732 case ARM::ArchKind::ARMV6T2:
734 case ARM::ArchKind::ARMV6M:
736 case ARM::ArchKind::ARMV7A:
737 case ARM::ArchKind::ARMV7R:
739 case ARM::ArchKind::ARMV7VE:
741 case ARM::ArchKind::ARMV7K:
743 case ARM::ArchKind::ARMV7M:
745 case ARM::ArchKind::ARMV7S:
747 case ARM::ArchKind::ARMV7EM:
749 case ARM::ArchKind::ARMV8A:
751 case ARM::ArchKind::ARMV8_1A:
753 case ARM::ArchKind::ARMV8_2A:
755 case ARM::ArchKind::ARMV8_3A:
757 case ARM::ArchKind::ARMV8_4A:
759 case ARM::ArchKind::ARMV8_5A:
761 case ARM::ArchKind::ARMV8_6A:
763 case ARM::ArchKind::ARMV8_7A:
765 case ARM::ArchKind::ARMV8_8A:
767 case ARM::ArchKind::ARMV8_9A:
769 case ARM::ArchKind::ARMV9A:
771 case ARM::ArchKind::ARMV9_1A:
773 case ARM::ArchKind::ARMV9_2A:
775 case ARM::ArchKind::ARMV9_3A:
777 case ARM::ArchKind::ARMV9_4A:
779 case ARM::ArchKind::ARMV8R:
781 case ARM::ArchKind::ARMV8MBaseline:
783 case ARM::ArchKind::ARMV8MMainline:
785 case ARM::ArchKind::ARMV8_1MMainline:
787 default:
788 return Triple::NoSubArch;
789 }
790}
791
793 switch (T.getArch()) {
795 case Triple::aarch64:
797 case Triple::arm:
798 case Triple::thumb:
799 case Triple::x86:
800 case Triple::x86_64:
801 if (T.isOSDarwin())
802 return Triple::MachO;
803 else if (T.isOSWindows())
804 return Triple::COFF;
805 return Triple::ELF;
806
808 case Triple::amdgcn:
809 case Triple::amdil64:
810 case Triple::amdil:
811 case Triple::arc:
812 case Triple::armeb:
813 case Triple::avr:
814 case Triple::bpfeb:
815 case Triple::bpfel:
816 case Triple::csky:
817 case Triple::hexagon:
818 case Triple::hsail64:
819 case Triple::hsail:
820 case Triple::kalimba:
821 case Triple::lanai:
822 case Triple::le32:
823 case Triple::le64:
826 case Triple::m68k:
827 case Triple::mips64:
828 case Triple::mips64el:
829 case Triple::mips:
830 case Triple::mipsel:
831 case Triple::msp430:
832 case Triple::nvptx64:
833 case Triple::nvptx:
834 case Triple::ppc64le:
835 case Triple::ppcle:
836 case Triple::r600:
839 case Triple::riscv32:
840 case Triple::riscv64:
841 case Triple::shave:
842 case Triple::sparc:
843 case Triple::sparcel:
844 case Triple::sparcv9:
845 case Triple::spir64:
846 case Triple::spir:
847 case Triple::tce:
848 case Triple::tcele:
849 case Triple::thumbeb:
850 case Triple::ve:
851 case Triple::xcore:
852 case Triple::xtensa:
853 return Triple::ELF;
854
855 case Triple::ppc64:
856 case Triple::ppc:
857 if (T.isOSAIX())
858 return Triple::XCOFF;
859 return Triple::ELF;
860
861 case Triple::systemz:
862 if (T.isOSzOS())
863 return Triple::GOFF;
864 return Triple::ELF;
865
866 case Triple::wasm32:
867 case Triple::wasm64:
868 return Triple::Wasm;
869
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:
1456 case llvm::Triple::ve:
1459 return 64;
1460 }
1461 llvm_unreachable("Invalid architecture value");
1462}
1463
1465 return getArchPointerBitWidth(getArch()) == 64;
1466}
1467
1469 return getArchPointerBitWidth(getArch()) == 32;
1470}
1471
1473 return getArchPointerBitWidth(getArch()) == 16;
1474}
1475
1477 Triple T(*this);
1478 switch (getArch()) {
1480 case Triple::amdgcn:
1481 case Triple::avr:
1482 case Triple::bpfeb:
1483 case Triple::bpfel:
1484 case Triple::msp430:
1485 case Triple::systemz:
1486 case Triple::ve:
1487 T.setArch(UnknownArch);
1488 break;
1489
1490 case Triple::aarch64_32:
1491 case Triple::amdil:
1492 case Triple::arc:
1493 case Triple::arm:
1494 case Triple::armeb:
1495 case Triple::csky:
1496 case Triple::dxil:
1497 case Triple::hexagon:
1498 case Triple::hsail:
1499 case Triple::kalimba:
1500 case Triple::lanai:
1501 case Triple::le32:
1503 case Triple::m68k:
1504 case Triple::mips:
1505 case Triple::mipsel:
1506 case Triple::nvptx:
1507 case Triple::ppc:
1508 case Triple::ppcle:
1509 case Triple::r600:
1511 case Triple::riscv32:
1512 case Triple::shave:
1513 case Triple::sparc:
1514 case Triple::sparcel:
1515 case Triple::spir:
1516 case Triple::spirv32:
1517 case Triple::tce:
1518 case Triple::tcele:
1519 case Triple::thumb:
1520 case Triple::thumbeb:
1521 case Triple::wasm32:
1522 case Triple::x86:
1523 case Triple::xcore:
1524 case Triple::xtensa:
1525 // Already 32-bit.
1526 break;
1527
1528 case Triple::aarch64: T.setArch(Triple::arm); break;
1529 case Triple::aarch64_be: T.setArch(Triple::armeb); break;
1530 case Triple::amdil64: T.setArch(Triple::amdil); break;
1531 case Triple::hsail64: T.setArch(Triple::hsail); break;
1532 case Triple::le64: T.setArch(Triple::le32); break;
1533 case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
1534 case Triple::mips64:
1535 T.setArch(Triple::mips, getSubArch());
1536 break;
1537 case Triple::mips64el:
1538 T.setArch(Triple::mipsel, getSubArch());
1539 break;
1540 case Triple::nvptx64: T.setArch(Triple::nvptx); break;
1541 case Triple::ppc64: T.setArch(Triple::ppc); break;
1542 case Triple::ppc64le: T.setArch(Triple::ppcle); break;
1543 case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
1544 case Triple::riscv64: T.setArch(Triple::riscv32); break;
1545 case Triple::sparcv9: T.setArch(Triple::sparc); break;
1546 case Triple::spir64: T.setArch(Triple::spir); break;
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::spirv32:
1626 T.setArch(Triple::spirv64, getSubArch());
1627 break;
1628 case Triple::thumb: T.setArch(Triple::aarch64); break;
1629 case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
1630 case Triple::wasm32: T.setArch(Triple::wasm64); break;
1631 case Triple::x86: T.setArch(Triple::x86_64); break;
1632 }
1633 return T;
1634}
1635
1637 Triple T(*this);
1638 // Already big endian.
1639 if (!isLittleEndian())
1640 return T;
1641 switch (getArch()) {
1643 case Triple::amdgcn:
1644 case Triple::amdil64:
1645 case Triple::amdil:
1646 case Triple::avr:
1647 case Triple::dxil:
1648 case Triple::hexagon:
1649 case Triple::hsail64:
1650 case Triple::hsail:
1651 case Triple::kalimba:
1652 case Triple::le32:
1653 case Triple::le64:
1656 case Triple::msp430:
1657 case Triple::nvptx64:
1658 case Triple::nvptx:
1659 case Triple::r600:
1662 case Triple::riscv32:
1663 case Triple::riscv64:
1664 case Triple::shave:
1665 case Triple::spir64:
1666 case Triple::spir:
1667 case Triple::spirv32:
1668 case Triple::spirv64:
1669 case Triple::wasm32:
1670 case Triple::wasm64:
1671 case Triple::x86:
1672 case Triple::x86_64:
1673 case Triple::xcore:
1674 case Triple::ve:
1675 case Triple::csky:
1676 case Triple::xtensa:
1677
1678 // ARM is intentionally unsupported here, changing the architecture would
1679 // drop any arch suffixes.
1680 case Triple::arm:
1681 case Triple::thumb:
1682 T.setArch(UnknownArch);
1683 break;
1684
1685 case Triple::aarch64: T.setArch(Triple::aarch64_be); break;
1686 case Triple::bpfel: T.setArch(Triple::bpfeb); break;
1687 case Triple::mips64el:
1688 T.setArch(Triple::mips64, getSubArch());
1689 break;
1690 case Triple::mipsel:
1691 T.setArch(Triple::mips, getSubArch());
1692 break;
1693 case Triple::ppcle: T.setArch(Triple::ppc); break;
1694 case Triple::ppc64le: T.setArch(Triple::ppc64); break;
1695 case Triple::sparcel: T.setArch(Triple::sparc); break;
1696 case Triple::tcele: T.setArch(Triple::tce); break;
1697 default:
1698 llvm_unreachable("getBigEndianArchVariant: unknown triple.");
1699 }
1700 return T;
1701}
1702
1704 Triple T(*this);
1705 if (isLittleEndian())
1706 return T;
1707
1708 switch (getArch()) {
1710 case Triple::lanai:
1711 case Triple::sparcv9:
1712 case Triple::systemz:
1713 case Triple::m68k:
1714
1715 // ARM is intentionally unsupported here, changing the architecture would
1716 // drop any arch suffixes.
1717 case Triple::armeb:
1718 case Triple::thumbeb:
1719 T.setArch(UnknownArch);
1720 break;
1721
1722 case Triple::aarch64_be: T.setArch(Triple::aarch64); break;
1723 case Triple::bpfeb: T.setArch(Triple::bpfel); break;
1724 case Triple::mips64:
1725 T.setArch(Triple::mips64el, getSubArch());
1726 break;
1727 case Triple::mips:
1728 T.setArch(Triple::mipsel, getSubArch());
1729 break;
1730 case Triple::ppc: T.setArch(Triple::ppcle); break;
1731 case Triple::ppc64: T.setArch(Triple::ppc64le); break;
1732 case Triple::sparc: T.setArch(Triple::sparcel); break;
1733 case Triple::tce: T.setArch(Triple::tcele); break;
1734 default:
1735 llvm_unreachable("getLittleEndianArchVariant: unknown triple.");
1736 }
1737 return T;
1738}
1739
1741 switch (getArch()) {
1742 case Triple::aarch64:
1743 case Triple::aarch64_32:
1744 case Triple::amdgcn:
1745 case Triple::amdil64:
1746 case Triple::amdil:
1747 case Triple::arm:
1748 case Triple::avr:
1749 case Triple::bpfel:
1750 case Triple::csky:
1751 case Triple::dxil:
1752 case Triple::hexagon:
1753 case Triple::hsail64:
1754 case Triple::hsail:
1755 case Triple::kalimba:
1756 case Triple::le32:
1757 case Triple::le64:
1760 case Triple::mips64el:
1761 case Triple::mipsel:
1762 case Triple::msp430:
1763 case Triple::nvptx64:
1764 case Triple::nvptx:
1765 case Triple::ppcle:
1766 case Triple::ppc64le:
1767 case Triple::r600:
1770 case Triple::riscv32:
1771 case Triple::riscv64:
1772 case Triple::shave:
1773 case Triple::sparcel:
1774 case Triple::spir64:
1775 case Triple::spir:
1776 case Triple::spirv32:
1777 case Triple::spirv64:
1778 case Triple::tcele:
1779 case Triple::thumb:
1780 case Triple::ve:
1781 case Triple::wasm32:
1782 case Triple::wasm64:
1783 case Triple::x86:
1784 case Triple::x86_64:
1785 case Triple::xcore:
1786 case Triple::xtensa:
1787 return true;
1788 default:
1789 return false;
1790 }
1791}
1792
1794 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1795 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
1796 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
1797 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
1798 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
1799 if (getVendor() == Triple::Apple)
1800 return getSubArch() == Other.getSubArch() &&
1801 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1802 else
1803 return getSubArch() == Other.getSubArch() &&
1804 getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
1805 getEnvironment() == Other.getEnvironment() &&
1806 getObjectFormat() == Other.getObjectFormat();
1807 }
1808
1809 // If vendor is apple, ignore the version number.
1810 if (getVendor() == Triple::Apple)
1811 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
1812 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1813
1814 return *this == Other;
1815}
1816
1817std::string Triple::merge(const Triple &Other) const {
1818 // If vendor is apple, pick the triple with the larger version number.
1819 if (getVendor() == Triple::Apple)
1820 if (Other.isOSVersionLT(*this))
1821 return str();
1822
1823 return Other.str();
1824}
1825
1826bool Triple::isMacOSXVersionLT(unsigned Major, unsigned Minor,
1827 unsigned Micro) const {
1828 assert(isMacOSX() && "Not an OS X triple!");
1829
1830 // If this is OS X, expect a sane version number.
1831 if (getOS() == Triple::MacOSX)
1832 return isOSVersionLT(Major, Minor, Micro);
1833
1834 // Otherwise, compare to the "Darwin" number.
1835 if (Major == 10) {
1836 return isOSVersionLT(Minor + 4, Micro, 0);
1837 } else {
1838 assert(Major >= 11 && "Unexpected major version");
1839 return isOSVersionLT(Major - 11 + 20, Minor, Micro);
1840 }
1841}
1842
1845 return VersionTuple();
1846 switch (getOS()) {
1847 case Triple::MacOSX:
1848 // ARM64 slice is supported starting from macOS 11.0+.
1849 return VersionTuple(11, 0, 0);
1850 case Triple::IOS:
1851 // ARM64 slice is supported starting from Mac Catalyst 14 (macOS 11).
1852 // ARM64 simulators are supported for iOS 14+.
1854 return VersionTuple(14, 0, 0);
1855 // ARM64e slice is supported starting from iOS 14.
1856 if (isArm64e())
1857 return VersionTuple(14, 0, 0);
1858 break;
1859 case Triple::TvOS:
1860 // ARM64 simulators are supported for tvOS 14+.
1862 return VersionTuple(14, 0, 0);
1863 break;
1864 case Triple::WatchOS:
1865 // ARM64 simulators are supported for watchOS 7+.
1867 return VersionTuple(7, 0, 0);
1868 break;
1869 case Triple::DriverKit:
1870 return VersionTuple(20, 0, 0);
1871 default:
1872 break;
1873 }
1874 return VersionTuple();
1875}
1876
1878 const VersionTuple &Version) {
1879 switch (OSKind) {
1880 case MacOSX:
1881 // macOS 10.16 is canonicalized to macOS 11.
1882 if (Version == VersionTuple(10, 16))
1883 return VersionTuple(11, 0);
1884 [[fallthrough]];
1885 default:
1886 return Version;
1887 }
1888}
1889
1890// HLSL triple environment orders are relied on in the front end
1891static_assert(Triple::Vertex - Triple::Pixel == 1,
1892 "incorrect HLSL stage order");
1893static_assert(Triple::Geometry - Triple::Pixel == 2,
1894 "incorrect HLSL stage order");
1895static_assert(Triple::Hull - Triple::Pixel == 3,
1896 "incorrect HLSL stage order");
1897static_assert(Triple::Domain - Triple::Pixel == 4,
1898 "incorrect HLSL stage order");
1899static_assert(Triple::Compute - Triple::Pixel == 5,
1900 "incorrect HLSL stage order");
1901static_assert(Triple::Library - Triple::Pixel == 6,
1902 "incorrect HLSL stage order");
1903static_assert(Triple::RayGeneration - Triple::Pixel == 7,
1904 "incorrect HLSL stage order");
1905static_assert(Triple::Intersection - Triple::Pixel == 8,
1906 "incorrect HLSL stage order");
1907static_assert(Triple::AnyHit - Triple::Pixel == 9,
1908 "incorrect HLSL stage order");
1909static_assert(Triple::ClosestHit - Triple::Pixel == 10,
1910 "incorrect HLSL stage order");
1911static_assert(Triple::Miss - Triple::Pixel == 11,
1912 "incorrect HLSL stage order");
1913static_assert(Triple::Callable - Triple::Pixel == 12,
1914 "incorrect HLSL stage order");
1915static_assert(Triple::Mesh - Triple::Pixel == 13,
1916 "incorrect HLSL stage order");
1917static_assert(Triple::Amplification - Triple::Pixel == 14,
1918 "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:620
static VersionTuple parseVersionFromName(StringRef Name)
Definition: Triple.cpp:1196
static Triple::ObjectFormatType getDefaultFormat(const Triple &T)
Definition: Triple.cpp:792
static Triple::ArchType parseARMArch(StringRef ArchName)
Definition: Triple.cpp:401
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:315
static Triple::SubArchType parseSubArch(StringRef SubArchName)
Definition: Triple.cpp:679
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
Definition: Triple.cpp:665
static Triple::ArchType parseArch(StringRef ArchName)
Definition: Triple.cpp:466
static Triple::VendorType parseVendor(StringRef VendorName)
Definition: Triple.cpp:555
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:698
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:569
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:633
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:277
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:1826
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:1476
Triple()=default
Default constructor is the same as an empty string and leaves all triple fields unknown.
@ RayGeneration
Definition: Triple.h:269
@ UnknownEnvironment
Definition: Triple.h:230
@ ClosestHit
Definition: Triple.h:272
@ MuslEABIHF
Definition: Triple.h:248
@ Amplification
Definition: Triple.h:276
@ Intersection
Definition: Triple.h:270
std::string normalize() const
Return the normalized form of this triple's string.
Definition: Triple.h:349
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1703
static StringRef getVendorTypeName(VendorType Kind)
Get the canonical name for the Kind vendor.
Definition: Triple.cpp:181
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Definition: Triple.h:382
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
Definition: Triple.h:359
bool isArm64e() const
Tests whether the target is the Apple "arm64e" AArch64 subarch.
Definition: Triple.h:959
void setVendorName(StringRef Str)
Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1369
@ HermitCore
Definition: Triple.h:221
@ ShaderModel
Definition: Triple.h:225
@ Emscripten
Definition: Triple.h:224
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:1556
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1740
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:107
@ UnknownArch
Definition: Triple.h:47
@ aarch64_be
Definition: Triple.h:52
@ loongarch64
Definition: Triple.h:62
@ renderscript32
Definition: Triple.h:106
@ 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:365
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:330
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition: Triple.h:356
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:523
const std::string & str() const
Definition: Triple.h:415
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
Definition: Triple.h:373
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:204
ObjectFormatType
Definition: Triple.h:280
@ DXContainer
Definition: Triple.h:284
@ UnknownObjectFormat
Definition: Triple.h:281
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:1817
@ UnknownVendor
Definition: Triple.h:167
@ OpenEmbedded
Definition: Triple.h:182
@ ImaginationTechnologies
Definition: Triple.h:174
@ MipsTechnologies
Definition: Triple.h:175
VersionTuple getMinimumSupportedOSVersion() const
Some platforms have different minimum supported OS versions that varies by the architecture specified...
Definition: Triple.cpp:1843
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1464
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:142
@ MipsSubArch_r6
Definition: Triple.h:154
@ ARMSubArch_v7
Definition: Triple.h:133
@ ARMSubArch_v8m_mainline
Definition: Triple.h:131
@ ARMSubArch_v8r
Definition: Triple.h:129
@ ARMSubArch_v9_1a
Definition: Triple.h:117
@ SPIRVSubArch_v10
Definition: Triple.h:159
@ SPIRVSubArch_v13
Definition: Triple.h:162
@ ARMSubArch_v7k
Definition: Triple.h:137
@ ARMSubArch_v8_7a
Definition: Triple.h:121
@ ARMSubArch_v8
Definition: Triple.h:128
@ ARMSubArch_v8_1a
Definition: Triple.h:127
@ ARMSubArch_v9_2a
Definition: Triple.h:116
@ SPIRVSubArch_v15
Definition: Triple.h:164
@ ARMSubArch_v7m
Definition: Triple.h:135
@ ARMSubArch_v6k
Definition: Triple.h:141
@ ARMSubArch_v5
Definition: Triple.h:143
@ AArch64SubArch_arm64e
Definition: Triple.h:147
@ ARMSubArch_v6
Definition: Triple.h:139
@ ARMSubArch_v7ve
Definition: Triple.h:138
@ ARMSubArch_v8m_baseline
Definition: Triple.h:130
@ ARMSubArch_v8_8a
Definition: Triple.h:120
@ ARMSubArch_v8_2a
Definition: Triple.h:126
@ ARMSubArch_v7s
Definition: Triple.h:136
@ KalimbaSubArch_v3
Definition: Triple.h:150
@ ARMSubArch_v8_4a
Definition: Triple.h:124
@ ARMSubArch_v8_9a
Definition: Triple.h:119
@ ARMSubArch_v7em
Definition: Triple.h:134
@ SPIRVSubArch_v12
Definition: Triple.h:161
@ SPIRVSubArch_v14
Definition: Triple.h:163
@ KalimbaSubArch_v4
Definition: Triple.h:151
@ ARMSubArch_v8_1m_mainline
Definition: Triple.h:132
@ ARMSubArch_v8_3a
Definition: Triple.h:125
@ AArch64SubArch_arm64ec
Definition: Triple.h:148
@ ARMSubArch_v8_6a
Definition: Triple.h:122
@ ARMSubArch_v5te
Definition: Triple.h:144
@ KalimbaSubArch_v5
Definition: Triple.h:152
@ ARMSubArch_v4t
Definition: Triple.h:145
@ ARMSubArch_v9_4a
Definition: Triple.h:114
@ ARMSubArch_v8_5a
Definition: Triple.h:123
@ ARMSubArch_v6m
Definition: Triple.h:140
@ ARMSubArch_v9_3a
Definition: Triple.h:115
@ ARMSubArch_v9
Definition: Triple.h:118
@ SPIRVSubArch_v11
Definition: Triple.h:160
@ PPCSubArch_spe
Definition: Triple.h:156
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:486
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:362
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Definition: Triple.cpp:252
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:464
static VersionTuple getCanonicalVersionForOS(OSType OSKind, const VersionTuple &Version)
Returns a canonicalized OS version number for the specified OS.
Definition: Triple.cpp:1877
StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition: Triple.cpp:1142
bool isMacCatalystEnvironment() const
Definition: Triple.h:527
static StringRef getObjectFormatTypeName(ObjectFormatType ObjectFormat)
Get the name for the Object format.
Definition: Triple.cpp:300
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1472
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1636
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:1468
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1793
bool hasEnvironment() const
Does this triple have the optional environment (fourth) component?
Definition: Triple.h:368
static StringRef getArchTypePrefix(ArchType Kind)
Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:92
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:70
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:860