Skip to content

[llvm] Add triples for managarm #87845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/include/llvm/TargetParser/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class Triple {
Linux,
Lv2, // PS3
MacOSX,
Managarm,
NetBSD,
OpenBSD,
Solaris,
Expand Down Expand Up @@ -299,6 +300,7 @@ class Triple {
Amplification,
OpenCL,
OpenHOS,
Mlibc,
Copy link
Member

@MaskRay MaskRay May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how Mlibc is intended to be used but LLVM LTO warns about differing target triples, which may make a not-necessary environment more harmful.


PAuthTest,

Expand Down Expand Up @@ -849,6 +851,8 @@ class Triple {

bool isVulkanOS() const { return getOS() == Triple::Vulkan; }

bool isOSManagarm() const { return getOS() == Triple::Managarm; }

bool isShaderStageEnvironment() const {
EnvironmentType Env = getEnvironment();
return Env == Triple::Pixel || Env == Triple::Vertex ||
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/TargetParser/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case Linux: return "linux";
case Lv2: return "lv2";
case MacOSX: return "macosx";
case Managarm:
return "managarm";
case Mesa3D: return "mesa3d";
case NVCL: return "nvcl";
case NaCl: return "nacl";
Expand Down Expand Up @@ -384,6 +386,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
return "pauthtest";
case LLVM:
return "llvm";
case Mlibc:
return "mlibc";
}

llvm_unreachable("Invalid EnvironmentType!");
Expand Down Expand Up @@ -678,6 +682,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("linux", Triple::Linux)
.StartsWith("lv2", Triple::Lv2)
.StartsWith("macos", Triple::MacOSX)
.StartsWith("managarm", Triple::Managarm)
.StartsWith("netbsd", Triple::NetBSD)
.StartsWith("openbsd", Triple::OpenBSD)
.StartsWith("solaris", Triple::Solaris)
Expand Down Expand Up @@ -766,6 +771,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
.StartsWith("ohos", Triple::OpenHOS)
.StartsWith("pauthtest", Triple::PAuthTest)
.StartsWith("llvm", Triple::LLVM)
.StartsWith("mlibc", Triple::Mlibc)
.Default(Triple::UnknownEnvironment);
}

Expand Down
18 changes: 18 additions & 0 deletions llvm/unittests/TargetParser/TripleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,24 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::UnknownOS, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("aarch64-unknown-managarm-mlibc");
EXPECT_EQ(Triple::aarch64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Managarm, T.getOS());
EXPECT_EQ(Triple::Mlibc, T.getEnvironment());

T = Triple("x86_64-unknown-managarm-mlibc");
EXPECT_EQ(Triple::x86_64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Managarm, T.getOS());
EXPECT_EQ(Triple::Mlibc, T.getEnvironment());

T = Triple("riscv64-unknown-managarm-mlibc");
EXPECT_EQ(Triple::riscv64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Managarm, T.getOS());
EXPECT_EQ(Triple::Mlibc, T.getEnvironment());

T = Triple("huh");
EXPECT_EQ(Triple::UnknownArch, T.getArch());
}
Expand Down