diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index c95b16dd4e8c..76fe6d38f2d0 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -182,7 +182,8 @@ class Triple { Mesa3D, Contiki, AMDPAL, // AMD PAL Runtime - LastOSType = AMDPAL + HermitCore, // HermitCore Unikernel/Multikernel + LastOSType = HermitCore }; enum EnvironmentType { UnknownEnvironment, diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h index bff58fef6af9..58cb3aeda8d9 100644 --- a/include/llvm/MC/MCELFObjectWriter.h +++ b/include/llvm/MC/MCELFObjectWriter.h @@ -73,6 +73,8 @@ class MCELFObjectTargetWriter : public MCObjectTargetWriter { switch (OSType) { case Triple::CloudABI: return ELF::ELFOSABI_CLOUDABI; + case Triple::HermitCore: + return ELF::ELFOSABI_STANDALONE; case Triple::PS4: case Triple::FreeBSD: return ELF::ELFOSABI_FREEBSD; diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index b14d6492b1ed..10b4fce37975 100644 --- a/lib/Support/Triple.cpp +++ b/lib/Support/Triple.cpp @@ -209,6 +209,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { case Mesa3D: return "mesa3d"; case Contiki: return "contiki"; case AMDPAL: return "amdpal"; + case HermitCore: return "hermit"; } llvm_unreachable("Invalid OSType"); @@ -502,6 +503,7 @@ static Triple::OSType parseOS(StringRef OSName) { .StartsWith("mesa3d", Triple::Mesa3D) .StartsWith("contiki", Triple::Contiki) .StartsWith("amdpal", Triple::AMDPAL) + .StartsWith("hermit", Triple::HermitCore) .Default(Triple::UnknownOS); } diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp index 3963a966ef62..a3d4920eebec 100644 --- a/unittests/ADT/TripleTest.cpp +++ b/unittests/ADT/TripleTest.cpp @@ -235,6 +235,12 @@ TEST(TripleTest, ParsedIDs) { EXPECT_EQ(Triple::Fuchsia, T.getOS()); EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("x86_64-unknown-hermit"); + EXPECT_EQ(Triple::x86_64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::HermitCore, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("wasm32-unknown-unknown"); EXPECT_EQ(Triple::wasm32, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor());