[llvm] [LLVM] Add Intel vendor in Triple (PR #120250)
Nick Sarnie via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 17 07:49:54 PST 2024
https://github.com/sarnex created https://github.com/llvm/llvm-project/pull/120250
We plan to make use of this in SPIR-V-based OpenMP offloading.
>From 1e70ca7e03be809b8e032d8487d626e89204315a Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <nick.sarnie at intel.com>
Date: Tue, 17 Dec 2024 07:48:24 -0800
Subject: [PATCH] [LLVM] Add Intel vendor in Triple
We plan to make use of this in SPIR-V-based OpenMP offloading.
Signed-off-by: Sarnie, Nick <nick.sarnie at intel.com>
---
llvm/include/llvm/TargetParser/Triple.h | 3 +-
llvm/lib/TargetParser/Triple.cpp | 33 ++++++++++++----------
llvm/unittests/TargetParser/TripleTest.cpp | 6 ++++
3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 3a1a962003abf5..bd4051d00edbab 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -193,7 +193,8 @@ class Triple {
Mesa,
SUSE,
OpenEmbedded,
- LastVendorType = OpenEmbedded
+ Intel,
+ LastVendorType = Intel
};
enum OSType {
UnknownOS,
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index faabaf18d80710..7e040688dc1a7b 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -241,6 +241,8 @@ StringRef Triple::getVendorTypeName(VendorType Kind) {
case Freescale: return "fsl";
case IBM: return "ibm";
case ImaginationTechnologies: return "img";
+ case Intel:
+ return "intel";
case Mesa: return "mesa";
case MipsTechnologies: return "mti";
case NVIDIA: return "nvidia";
@@ -627,21 +629,22 @@ static Triple::ArchType parseArch(StringRef ArchName) {
static Triple::VendorType parseVendor(StringRef VendorName) {
return StringSwitch<Triple::VendorType>(VendorName)
- .Case("apple", Triple::Apple)
- .Case("pc", Triple::PC)
- .Case("scei", Triple::SCEI)
- .Case("sie", Triple::SCEI)
- .Case("fsl", Triple::Freescale)
- .Case("ibm", Triple::IBM)
- .Case("img", Triple::ImaginationTechnologies)
- .Case("mti", Triple::MipsTechnologies)
- .Case("nvidia", Triple::NVIDIA)
- .Case("csr", Triple::CSR)
- .Case("amd", Triple::AMD)
- .Case("mesa", Triple::Mesa)
- .Case("suse", Triple::SUSE)
- .Case("oe", Triple::OpenEmbedded)
- .Default(Triple::UnknownVendor);
+ .Case("apple", Triple::Apple)
+ .Case("pc", Triple::PC)
+ .Case("scei", Triple::SCEI)
+ .Case("sie", Triple::SCEI)
+ .Case("fsl", Triple::Freescale)
+ .Case("ibm", Triple::IBM)
+ .Case("img", Triple::ImaginationTechnologies)
+ .Case("mti", Triple::MipsTechnologies)
+ .Case("nvidia", Triple::NVIDIA)
+ .Case("csr", Triple::CSR)
+ .Case("amd", Triple::AMD)
+ .Case("mesa", Triple::Mesa)
+ .Case("suse", Triple::SUSE)
+ .Case("oe", Triple::OpenEmbedded)
+ .Case("intel", Triple::Intel)
+ .Default(Triple::UnknownVendor);
}
static Triple::OSType parseOS(StringRef OSName) {
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index 87f9083fa344c2..7fb7625f8c2d10 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -1347,6 +1347,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::LLVM, T.getEnvironment());
+ T = Triple("spirv64-intel-unknown");
+ EXPECT_EQ(Triple::spirv64, T.getArch());
+ EXPECT_EQ(Triple::Intel, T.getVendor());
+ EXPECT_EQ(Triple::UnknownOS, T.getOS());
+ EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
T = Triple("huh");
EXPECT_EQ(Triple::UnknownArch, T.getArch());
}
More information about the llvm-commits
mailing list