Skip to content

Commit 7672216

Browse files
authored
[LLVM] Add environment triple for 'llvm' (llvm#117218)
Summary: The LLVM C library is an in-development environment for running executables on various systems. Similarly how we have `-gnu` to indicate that we are using a GNU toolchain we should support `-llvm` to indicate the LLVM C library. This patch only adds the basic support for the triple and does not do any necessary clang changes to handle compiling with it. Fixes llvm#117251
1 parent bd8a953 commit 7672216

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ class Triple {
268268
MuslF32,
269269
MuslSF,
270270
MuslX32,
271+
LLVM,
271272

272273
MSVC,
273274
Itanium,

llvm/lib/TargetParser/Triple.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
360360
case OpenHOS: return "ohos";
361361
case PAuthTest:
362362
return "pauthtest";
363+
case LLVM:
364+
return "llvm";
363365
}
364366

365367
llvm_unreachable("Invalid EnvironmentType!");
@@ -740,6 +742,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
740742
.StartsWith("opencl", Triple::OpenCL)
741743
.StartsWith("ohos", Triple::OpenHOS)
742744
.StartsWith("pauthtest", Triple::PAuthTest)
745+
.StartsWith("llvm", Triple::LLVM)
743746
.Default(Triple::UnknownEnvironment);
744747
}
745748

llvm/unittests/TargetParser/TripleTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,12 @@ TEST(TripleTest, ParsedIDs) {
13411341
EXPECT_TRUE(T.isTime64ABI());
13421342
EXPECT_TRUE(T.isHardFloatABI());
13431343

1344+
T = Triple("x86_64-pc-linux-llvm");
1345+
EXPECT_EQ(Triple::x86_64, T.getArch());
1346+
EXPECT_EQ(Triple::PC, T.getVendor());
1347+
EXPECT_EQ(Triple::Linux, T.getOS());
1348+
EXPECT_EQ(Triple::LLVM, T.getEnvironment());
1349+
13441350
T = Triple("huh");
13451351
EXPECT_EQ(Triple::UnknownArch, T.getArch());
13461352
}

0 commit comments

Comments
 (0)