[llvm] [Triple] Add target triple support for CheriotRTOS. (PR #155374)
Owen Anderson via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 26 01:52:45 PDT 2025
https://github.com/resistor created https://github.com/llvm/llvm-project/pull/155374
For context, CheriotRTOS is a custom RTOS co-designed for the CHERIoT
CHERI-enabled RISCV32E platform. It uses a custom ABI and linkage model,
necesitating representing it in the target triple.
>From f43e1573472897910198dbc2f59c169eeda8dca4 Mon Sep 17 00:00:00 2001
From: Owen Anderson <resistor at mac.com>
Date: Tue, 26 Aug 2025 16:50:08 +0800
Subject: [PATCH] [Triple] Add target triple support for CheriotRTOS.
For context, CheriotRTOS is a custom RTOS co-designed for the CHERIoT
CHERI-enabled RISCV32E platform. It uses a custom ABI and linkage model,
necesitating representing it in the target triple.
---
llvm/include/llvm/TargetParser/Triple.h | 3 ++-
llvm/lib/TargetParser/Triple.cpp | 2 ++
llvm/unittests/TargetParser/TripleTest.cpp | 5 +++++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index ede9797ac7488..f85984ed4f328 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -245,7 +245,8 @@ class Triple {
LiteOS,
Serenity,
Vulkan, // Vulkan SPIR-V
- LastOSType = Vulkan
+ CheriotRTOS,
+ LastOSType = CheriotRTOS
};
enum EnvironmentType {
UnknownEnvironment,
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 6acb0bc49ecfe..8eb863aee02d9 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -329,6 +329,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case LiteOS: return "liteos";
case XROS: return "xros";
case Vulkan: return "vulkan";
+ case CheriotRTOS: return "cheriotrtos";
}
llvm_unreachable("Invalid OSType");
@@ -729,6 +730,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("liteos", Triple::LiteOS)
.StartsWith("serenity", Triple::Serenity)
.StartsWith("vulkan", Triple::Vulkan)
+ .StartsWith("cheriotrtos", Triple::CheriotRTOS)
.Default(Triple::UnknownOS);
}
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index 35927e340a257..7d07615d273d7 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -1381,6 +1381,11 @@ TEST(TripleTest, ParsedIDs) {
T = Triple("huh");
EXPECT_EQ(Triple::UnknownArch, T.getArch());
+
+ T = Triple("riscv32-unknown-cheriotrtos");
+ EXPECT_EQ(Triple::riscv32, T.getArch());
+ EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+ EXPECT_EQ(Triple::CheriotRTOS, T.getOS());
}
static std::string Join(StringRef A, StringRef B, StringRef C) {
More information about the llvm-commits
mailing list