Skip to content

Commit 4989dbc

Browse files
committed
Add support for CHERI "purecap" as an environment in target triples.
For context, CHERI architectures can support two modes: * Hybrid mode, in which capabilities co-exist alongside normal pointers. * Pure capability mode, in which all pointers are replaced with capabilities. Hybrid mode does not require any indication in the target triple, as it is treated the same as any other extension to the parent ISA. Pure cap mode, however, is a different ABI from the native ABI of the parent architecture.
1 parent fb2cbc0 commit 4989dbc

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ class Triple {
270270
MuslX32,
271271
LLVM,
272272

273+
CheriPureCap,
274+
273275
MSVC,
274276
Itanium,
275277
Cygnus,

llvm/lib/TargetParser/Triple.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
362362
return "pauthtest";
363363
case LLVM:
364364
return "llvm";
365+
case CheriPureCap:
366+
return "purecap";
365367
}
366368

367369
llvm_unreachable("Invalid EnvironmentType!");
@@ -743,6 +745,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
743745
.StartsWith("ohos", Triple::OpenHOS)
744746
.StartsWith("pauthtest", Triple::PAuthTest)
745747
.StartsWith("llvm", Triple::LLVM)
748+
.StartsWith("purecap", Triple::CheriPureCap)
746749
.Default(Triple::UnknownEnvironment);
747750
}
748751

llvm/unittests/TargetParser/TripleTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,12 @@ TEST(TripleTest, ParsedIDs) {
13471347
EXPECT_EQ(Triple::Linux, T.getOS());
13481348
EXPECT_EQ(Triple::LLVM, T.getEnvironment());
13491349

1350+
T = Triple("riscv64-unknown-linux-purecap");
1351+
EXPECT_EQ(Triple::riscv64, T.getArch());
1352+
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1353+
EXPECT_EQ(Triple::Linux, T.getOS());
1354+
EXPECT_EQ(Triple::CheriPureCap, T.getEnvironment());
1355+
13501356
T = Triple("huh");
13511357
EXPECT_EQ(Triple::UnknownArch, T.getArch());
13521358
}

0 commit comments

Comments
 (0)