aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Triple.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/Triple.cpp')
-rw-r--r--llvm/lib/Support/Triple.cpp194
1 files changed, 172 insertions, 22 deletions
diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index a9afcc9db96a..6696d158b2c1 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -37,6 +37,7 @@ StringRef Triple::getArchTypeName(ArchType Kind) {
case bpfeb: return "bpfeb";
case bpfel: return "bpfel";
case csky: return "csky";
+ case dxil: return "dxil";
case hexagon: return "hexagon";
case hsail64: return "hsail64";
case hsail: return "hsail";
@@ -44,6 +45,8 @@ StringRef Triple::getArchTypeName(ArchType Kind) {
case lanai: return "lanai";
case le32: return "le32";
case le64: return "le64";
+ case loongarch32: return "loongarch32";
+ case loongarch64: return "loongarch64";
case m68k: return "m68k";
case mips64: return "mips64";
case mips64el: return "mips64el";
@@ -164,6 +167,11 @@ StringRef Triple::getArchTypePrefix(ArchType Kind) {
case ve: return "ve";
case csky: return "csky";
+
+ case loongarch32:
+ case loongarch64: return "loongarch";
+
+ case dxil: return "dx";
}
}
@@ -203,6 +211,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case Contiki: return "contiki";
case Darwin: return "darwin";
case DragonFly: return "dragonfly";
+ case DriverKit: return "driverkit";
case ELFIAMCU: return "elfiamcu";
case Emscripten: return "emscripten";
case FreeBSD: return "freebsd";
@@ -222,6 +231,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case NetBSD: return "netbsd";
case OpenBSD: return "openbsd";
case PS4: return "ps4";
+ case PS5: return "ps5";
case RTEMS: return "rtems";
case Solaris: return "solaris";
case TvOS: return "tvos";
@@ -229,6 +239,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case WatchOS: return "watchos";
case Win32: return "windows";
case ZOS: return "zos";
+ case ShaderModel: return "shadermodel";
}
llvm_unreachable("Invalid OSType");
@@ -258,6 +269,21 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
case MuslEABIHF: return "musleabihf";
case MuslX32: return "muslx32";
case Simulator: return "simulator";
+ case Pixel: return "pixel";
+ case Vertex: return "vertex";
+ case Geometry: return "geometry";
+ case Hull: return "hull";
+ case Domain: return "domain";
+ case Compute: return "compute";
+ case Library: return "library";
+ case RayGeneration: return "raygeneration";
+ case Intersection: return "intersection";
+ case AnyHit: return "anyhit";
+ case ClosestHit: return "closesthit";
+ case Miss: return "miss";
+ case Callable: return "callable";
+ case Mesh: return "mesh";
+ case Amplification: return "amplification";
}
llvm_unreachable("Invalid EnvironmentType!");
@@ -311,12 +337,14 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
.Case("sparc", sparc)
.Case("sparcel", sparcel)
.Case("sparcv9", sparcv9)
+ .Case("s390x", systemz)
.Case("systemz", systemz)
.Case("tce", tce)
.Case("tcele", tcele)
.Case("thumb", thumb)
.Case("thumbeb", thumbeb)
.Case("x86", x86)
+ .Case("i386", x86)
.Case("x86-64", x86_64)
.Case("xcore", xcore)
.Case("nvptx", nvptx)
@@ -340,6 +368,9 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
.Case("renderscript64", renderscript64)
.Case("ve", ve)
.Case("csky", csky)
+ .Case("loongarch32", loongarch32)
+ .Case("loongarch64", loongarch64)
+ .Case("dxil", dxil)
.Default(UnknownArch);
}
@@ -464,8 +495,10 @@ static Triple::ArchType parseArch(StringRef ArchName) {
.Case("hsail64", Triple::hsail64)
.Case("spir", Triple::spir)
.Case("spir64", Triple::spir64)
- .Case("spirv32", Triple::spirv32)
- .Case("spirv64", Triple::spirv64)
+ .Cases("spirv32", "spirv32v1.0", "spirv32v1.1", "spirv32v1.2",
+ "spirv32v1.3", "spirv32v1.4", "spirv32v1.5", Triple::spirv32)
+ .Cases("spirv64", "spirv64v1.0", "spirv64v1.1", "spirv64v1.2",
+ "spirv64v1.3", "spirv64v1.4", "spirv64v1.5", Triple::spirv64)
.StartsWith("kalimba", Triple::kalimba)
.Case("lanai", Triple::lanai)
.Case("renderscript32", Triple::renderscript32)
@@ -475,6 +508,9 @@ static Triple::ArchType parseArch(StringRef ArchName) {
.Case("wasm32", Triple::wasm32)
.Case("wasm64", Triple::wasm64)
.Case("csky", Triple::csky)
+ .Case("loongarch32", Triple::loongarch32)
+ .Case("loongarch64", Triple::loongarch64)
+ .Case("dxil", Triple::dxil)
.Default(Triple::UnknownArch);
// Some architectures require special parsing logic just to compute the
@@ -538,9 +574,11 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("nvcl", Triple::NVCL)
.StartsWith("amdhsa", Triple::AMDHSA)
.StartsWith("ps4", Triple::PS4)
+ .StartsWith("ps5", Triple::PS5)
.StartsWith("elfiamcu", Triple::ELFIAMCU)
.StartsWith("tvos", Triple::TvOS)
.StartsWith("watchos", Triple::WatchOS)
+ .StartsWith("driverkit", Triple::DriverKit)
.StartsWith("mesa3d", Triple::Mesa3D)
.StartsWith("contiki", Triple::Contiki)
.StartsWith("amdpal", Triple::AMDPAL)
@@ -548,6 +586,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("hurd", Triple::Hurd)
.StartsWith("wasi", Triple::WASI)
.StartsWith("emscripten", Triple::Emscripten)
+ .StartsWith("shadermodel", Triple::ShaderModel)
.Default(Triple::UnknownOS);
}
@@ -574,20 +613,36 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
.StartsWith("coreclr", Triple::CoreCLR)
.StartsWith("simulator", Triple::Simulator)
.StartsWith("macabi", Triple::MacABI)
+ .StartsWith("pixel", Triple::Pixel)
+ .StartsWith("vertex", Triple::Vertex)
+ .StartsWith("geometry", Triple::Geometry)
+ .StartsWith("hull", Triple::Hull)
+ .StartsWith("domain", Triple::Domain)
+ .StartsWith("compute", Triple::Compute)
+ .StartsWith("library", Triple::Library)
+ .StartsWith("raygeneration", Triple::RayGeneration)
+ .StartsWith("intersection", Triple::Intersection)
+ .StartsWith("anyhit", Triple::AnyHit)
+ .StartsWith("closesthit", Triple::ClosestHit)
+ .StartsWith("miss", Triple::Miss)
+ .StartsWith("callable", Triple::Callable)
+ .StartsWith("mesh", Triple::Mesh)
+ .StartsWith("amplification", Triple::Amplification)
.Default(Triple::UnknownEnvironment);
}
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
- // "xcoff" must come before "coff" because of the order-dependendent
- // pattern matching.
- .EndsWith("xcoff", Triple::XCOFF)
- .EndsWith("coff", Triple::COFF)
- .EndsWith("elf", Triple::ELF)
- .EndsWith("goff", Triple::GOFF)
- .EndsWith("macho", Triple::MachO)
- .EndsWith("wasm", Triple::Wasm)
- .Default(Triple::UnknownObjectFormat);
+ // "xcoff" must come before "coff" because of the order-dependendent
+ // pattern matching.
+ .EndsWith("xcoff", Triple::XCOFF)
+ .EndsWith("coff", Triple::COFF)
+ .EndsWith("elf", Triple::ELF)
+ .EndsWith("goff", Triple::GOFF)
+ .EndsWith("macho", Triple::MachO)
+ .EndsWith("wasm", Triple::Wasm)
+ .EndsWith("spirv", Triple::SPIRV)
+ .Default(Triple::UnknownObjectFormat);
}
static Triple::SubArchType parseSubArch(StringRef SubArchName) {
@@ -601,6 +656,16 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
if (SubArchName == "arm64e")
return Triple::AArch64SubArch_arm64e;
+ if (SubArchName.startswith("spirv"))
+ return StringSwitch<Triple::SubArchType>(SubArchName)
+ .EndsWith("v1.0", Triple::SPIRVSubArch_v10)
+ .EndsWith("v1.1", Triple::SPIRVSubArch_v11)
+ .EndsWith("v1.2", Triple::SPIRVSubArch_v12)
+ .EndsWith("v1.3", Triple::SPIRVSubArch_v13)
+ .EndsWith("v1.4", Triple::SPIRVSubArch_v14)
+ .EndsWith("v1.5", Triple::SPIRVSubArch_v15)
+ .Default(Triple::NoSubArch);
+
StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
// For now, this is the small part. Early return.
@@ -688,13 +753,24 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
switch (Kind) {
- case Triple::UnknownObjectFormat: return "";
- case Triple::COFF: return "coff";
- case Triple::ELF: return "elf";
- case Triple::GOFF: return "goff";
- case Triple::MachO: return "macho";
- case Triple::Wasm: return "wasm";
- case Triple::XCOFF: return "xcoff";
+ case Triple::UnknownObjectFormat:
+ return "";
+ case Triple::COFF:
+ return "coff";
+ case Triple::ELF:
+ return "elf";
+ case Triple::GOFF:
+ return "goff";
+ case Triple::MachO:
+ return "macho";
+ case Triple::Wasm:
+ return "wasm";
+ case Triple::XCOFF:
+ return "xcoff";
+ case Triple::DXContainer:
+ return "dxcontainer";
+ case Triple::SPIRV:
+ return "spirv";
}
llvm_unreachable("unknown object format type");
}
@@ -731,6 +807,8 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
case Triple::lanai:
case Triple::le32:
case Triple::le64:
+ case Triple::loongarch32:
+ case Triple::loongarch64:
case Triple::m68k:
case Triple::mips64:
case Triple::mips64el:
@@ -776,8 +854,10 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
case Triple::spirv32:
case Triple::spirv64:
- // TODO: In future this will be Triple::SPIRV.
- return Triple::UnknownObjectFormat;
+ return Triple::SPIRV;
+
+ case Triple::dxil:
+ return Triple::DXContainer;
}
llvm_unreachable("unknown architecture");
}
@@ -1158,6 +1238,8 @@ bool Triple::getMacOSXVersion(VersionTuple &Version) const {
// IOS.
Version = VersionTuple(10, 4);
break;
+ case DriverKit:
+ llvm_unreachable("OSX version isn't relevant for DriverKit");
}
return true;
}
@@ -1182,6 +1264,8 @@ VersionTuple Triple::getiOSVersion() const {
}
case WatchOS:
llvm_unreachable("conflicting triple info");
+ case DriverKit:
+ llvm_unreachable("DriverKit doesn't have an iOS version");
}
}
@@ -1203,6 +1287,20 @@ VersionTuple Triple::getWatchOSVersion() const {
}
case IOS:
llvm_unreachable("conflicting triple info");
+ case DriverKit:
+ llvm_unreachable("DriverKit doesn't have a WatchOS version");
+ }
+}
+
+VersionTuple Triple::getDriverKitVersion() const {
+ switch (getOS()) {
+ default:
+ llvm_unreachable("unexpected OS for Darwin triple");
+ case DriverKit:
+ VersionTuple Version = getOSVersion();
+ if (Version.getMajor() == 0)
+ return Version.withMajorReplaced(19);
+ return Version;
}
}
@@ -1285,11 +1383,13 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
case llvm::Triple::arm:
case llvm::Triple::armeb:
case llvm::Triple::csky:
+ case llvm::Triple::dxil:
case llvm::Triple::hexagon:
case llvm::Triple::hsail:
case llvm::Triple::kalimba:
case llvm::Triple::lanai:
case llvm::Triple::le32:
+ case llvm::Triple::loongarch32:
case llvm::Triple::m68k:
case llvm::Triple::mips:
case llvm::Triple::mipsel:
@@ -1321,6 +1421,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
case llvm::Triple::bpfel:
case llvm::Triple::hsail64:
case llvm::Triple::le64:
+ case llvm::Triple::loongarch64:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
case llvm::Triple::nvptx64:
@@ -1372,11 +1473,13 @@ Triple Triple::get32BitArchVariant() const {
case Triple::arm:
case Triple::armeb:
case Triple::csky:
+ case Triple::dxil:
case Triple::hexagon:
case Triple::hsail:
case Triple::kalimba:
case Triple::lanai:
case Triple::le32:
+ case Triple::loongarch32:
case Triple::m68k:
case Triple::mips:
case Triple::mipsel:
@@ -1406,6 +1509,7 @@ Triple Triple::get32BitArchVariant() const {
case Triple::amdil64: T.setArch(Triple::amdil); break;
case Triple::hsail64: T.setArch(Triple::hsail); break;
case Triple::le64: T.setArch(Triple::le32); break;
+ case Triple::loongarch64: T.setArch(Triple::loongarch32); break;
case Triple::mips64:
T.setArch(Triple::mips, getSubArch());
break;
@@ -1419,7 +1523,9 @@ Triple Triple::get32BitArchVariant() const {
case Triple::riscv64: T.setArch(Triple::riscv32); break;
case Triple::sparcv9: T.setArch(Triple::sparc); break;
case Triple::spir64: T.setArch(Triple::spir); break;
- case Triple::spirv64: T.setArch(Triple::spirv32); break;
+ case Triple::spirv64:
+ T.setArch(Triple::spirv32, getSubArch());
+ break;
case Triple::wasm64: T.setArch(Triple::wasm32); break;
case Triple::x86_64: T.setArch(Triple::x86); break;
}
@@ -1433,6 +1539,7 @@ Triple Triple::get64BitArchVariant() const {
case Triple::arc:
case Triple::avr:
case Triple::csky:
+ case Triple::dxil:
case Triple::hexagon:
case Triple::kalimba:
case Triple::lanai:
@@ -1455,6 +1562,7 @@ Triple Triple::get64BitArchVariant() const {
case Triple::bpfel:
case Triple::hsail64:
case Triple::le64:
+ case Triple::loongarch64:
case Triple::mips64:
case Triple::mips64el:
case Triple::nvptx64:
@@ -1478,6 +1586,7 @@ Triple Triple::get64BitArchVariant() const {
case Triple::armeb: T.setArch(Triple::aarch64_be); break;
case Triple::hsail: T.setArch(Triple::hsail64); break;
case Triple::le32: T.setArch(Triple::le64); break;
+ case Triple::loongarch32: T.setArch(Triple::loongarch64); break;
case Triple::mips:
T.setArch(Triple::mips64, getSubArch());
break;
@@ -1491,7 +1600,9 @@ Triple Triple::get64BitArchVariant() const {
case Triple::riscv32: T.setArch(Triple::riscv64); break;
case Triple::sparc: T.setArch(Triple::sparcv9); break;
case Triple::spir: T.setArch(Triple::spir64); break;
- case Triple::spirv32: T.setArch(Triple::spirv64); break;
+ case Triple::spirv32:
+ T.setArch(Triple::spirv64, getSubArch());
+ break;
case Triple::thumb: T.setArch(Triple::aarch64); break;
case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
case Triple::wasm32: T.setArch(Triple::wasm64); break;
@@ -1511,12 +1622,15 @@ Triple Triple::getBigEndianArchVariant() const {
case Triple::amdil64:
case Triple::amdil:
case Triple::avr:
+ case Triple::dxil:
case Triple::hexagon:
case Triple::hsail64:
case Triple::hsail:
case Triple::kalimba:
case Triple::le32:
case Triple::le64:
+ case Triple::loongarch32:
+ case Triple::loongarch64:
case Triple::msp430:
case Triple::nvptx64:
case Triple::nvptx:
@@ -1611,12 +1725,15 @@ bool Triple::isLittleEndian() const {
case Triple::avr:
case Triple::bpfel:
case Triple::csky:
+ case Triple::dxil:
case Triple::hexagon:
case Triple::hsail64:
case Triple::hsail:
case Triple::kalimba:
case Triple::le32:
case Triple::le64:
+ case Triple::loongarch32:
+ case Triple::loongarch64:
case Triple::mips64el:
case Triple::mipsel:
case Triple::msp430:
@@ -1725,6 +1842,8 @@ VersionTuple Triple::getMinimumSupportedOSVersion() const {
if (isSimulatorEnvironment())
return VersionTuple(7, 0, 0);
break;
+ case Triple::DriverKit:
+ return VersionTuple(20, 0, 0);
default:
break;
}
@@ -1755,6 +1874,7 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const {
case llvm::Triple::MacOSX:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
+ case llvm::Triple::DriverKit:
if (MArch == "v7k")
return "cortex-a7";
break;
@@ -1811,3 +1931,33 @@ VersionTuple Triple::getCanonicalVersionForOS(OSType OSKind,
return Version;
}
}
+
+// HLSL triple environment orders are relied on in the front end
+static_assert(Triple::Vertex - Triple::Pixel == 1,
+ "incorrect HLSL stage order");
+static_assert(Triple::Geometry - Triple::Pixel == 2,
+ "incorrect HLSL stage order");
+static_assert(Triple::Hull - Triple::Pixel == 3,
+ "incorrect HLSL stage order");
+static_assert(Triple::Domain - Triple::Pixel == 4,
+ "incorrect HLSL stage order");
+static_assert(Triple::Compute - Triple::Pixel == 5,
+ "incorrect HLSL stage order");
+static_assert(Triple::Library - Triple::Pixel == 6,
+ "incorrect HLSL stage order");
+static_assert(Triple::RayGeneration - Triple::Pixel == 7,
+ "incorrect HLSL stage order");
+static_assert(Triple::Intersection - Triple::Pixel == 8,
+ "incorrect HLSL stage order");
+static_assert(Triple::AnyHit - Triple::Pixel == 9,
+ "incorrect HLSL stage order");
+static_assert(Triple::ClosestHit - Triple::Pixel == 10,
+ "incorrect HLSL stage order");
+static_assert(Triple::Miss - Triple::Pixel == 11,
+ "incorrect HLSL stage order");
+static_assert(Triple::Callable - Triple::Pixel == 12,
+ "incorrect HLSL stage order");
+static_assert(Triple::Mesh - Triple::Pixel == 13,
+ "incorrect HLSL stage order");
+static_assert(Triple::Amplification - Triple::Pixel == 14,
+ "incorrect HLSL stage order");