Skip to content

Commit

Permalink
Add Hurd target to LLVMSupport (1/2)
Browse files Browse the repository at this point in the history
Add the required target triples to LLVMSupport to support Hurd
in LLVM (formally `pc-hurd-gnu`).

Patch by sthibaul (Samuel Thibault)

Differential Revision: https://reviews.llvm.org/D54378

llvm-svn: 347832
  • Loading branch information
Kristina Brooks committed Nov 29, 2018
1 parent bcae407 commit 69127e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions llvm/include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ class Triple {
Contiki,
AMDPAL, // AMD PAL Runtime
HermitCore, // HermitCore Unikernel/Multikernel
LastOSType = HermitCore
Hurd, // GNU/Hurd
LastOSType = Hurd
};
enum EnvironmentType {
UnknownEnvironment,
Expand Down Expand Up @@ -582,9 +583,15 @@ class Triple {
return getOS() == Triple::KFreeBSD;
}

/// Tests whether the OS is Hurd.
bool isOSHurd() const {
return getOS() == Triple::Hurd;
}

/// Tests whether the OS uses glibc.
bool isOSGlibc() const {
return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD) &&
return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
getOS() == Triple::Hurd) &&
!isAndroid();
}

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case Contiki: return "contiki";
case AMDPAL: return "amdpal";
case HermitCore: return "hermit";
case Hurd: return "hurd";
}

llvm_unreachable("Invalid OSType");
Expand Down Expand Up @@ -508,6 +509,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("contiki", Triple::Contiki)
.StartsWith("amdpal", Triple::AMDPAL)
.StartsWith("hermit", Triple::HermitCore)
.StartsWith("hurd", Triple::Hurd)
.Default(Triple::UnknownOS);
}

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

T = Triple("i386-pc-hurd-gnu");
EXPECT_EQ(Triple::x86, T.getArch());
EXPECT_EQ(Triple::PC, T.getVendor());
EXPECT_EQ(Triple::Hurd, T.getOS());
EXPECT_EQ(Triple::GNU, T.getEnvironment());

T = Triple("x86_64-pc-linux-gnu");
EXPECT_EQ(Triple::x86_64, T.getArch());
EXPECT_EQ(Triple::PC, T.getVendor());
Expand Down

0 comments on commit 69127e1

Please sign in to comment.