[llvm] 7ef6b21 - [llvm] Add triple for SerenityOS
Brad Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 2 02:31:00 PDT 2023
Author: Andrew Kaster
Date: 2023-11-02T05:28:12-04:00
New Revision: 7ef6b21c3e2cd8e477124840f4acf64e11f60616
URL: https://github.com/llvm/llvm-project/commit/7ef6b21c3e2cd8e477124840f4acf64e11f60616
DIFF: https://github.com/llvm/llvm-project/commit/7ef6b21c3e2cd8e477124840f4acf64e11f60616.diff
LOG: [llvm] Add triple for SerenityOS
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D154395
Added:
Modified:
llvm/include/llvm/TargetParser/Triple.h
llvm/lib/TargetParser/Triple.cpp
llvm/unittests/TargetParser/TripleTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 0f56ac68c851f67..414b86d53aff6b3 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -221,7 +221,8 @@ class Triple {
Emscripten,
ShaderModel, // DirectX ShaderModel
LiteOS,
- LastOSType = LiteOS
+ Serenity,
+ LastOSType = Serenity
};
enum EnvironmentType {
UnknownEnvironment,
@@ -668,6 +669,10 @@ class Triple {
return getOS() == Triple::AIX;
}
+ bool isOSSerenity() const {
+ return getOS() == Triple::Serenity;
+ }
+
/// Tests whether the OS uses the ELF binary format.
bool isOSBinFormatELF() const {
return getObjectFormat() == Triple::ELF;
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 5d4eb79675f8916..c5e9ad43d225888 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -264,6 +264,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case PS5: return "ps5";
case RTEMS: return "rtems";
case Solaris: return "solaris";
+ case Serenity: return "serenity";
case TvOS: return "tvos";
case UEFI: return "uefi";
case WASI: return "wasi";
@@ -641,6 +642,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("emscripten", Triple::Emscripten)
.StartsWith("shadermodel", Triple::ShaderModel)
.StartsWith("liteos", Triple::LiteOS)
+ .StartsWith("serenity", Triple::Serenity)
.Default(Triple::UnknownOS);
}
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index 0a43b1a8925d1ea..575e2ca381df362 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -1003,6 +1003,18 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::LiteOS, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+ T = Triple("x86_64-pc-serenity");
+ EXPECT_EQ(Triple::x86_64, T.getArch());
+ EXPECT_EQ(Triple::PC, T.getVendor());
+ EXPECT_EQ(Triple::Serenity, T.getOS());
+ EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
+ T = Triple("aarch64-pc-serenity");
+ EXPECT_EQ(Triple::aarch64, T.getArch());
+ EXPECT_EQ(Triple::PC, T.getVendor());
+ EXPECT_EQ(Triple::Serenity, 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