From 5776b5c3d4c5f2b72ee60956220981a45162099e Mon Sep 17 00:00:00 2001 From: LLVM Packaging Team Date: Sun, 21 Apr 2019 21:55:47 +0100 Subject: [PATCH] D54378-hurd-triple Add Hurd triplet to LLVMSupport This introduces GNU Hurd as a new target OS. https://reviews.llvm.org/D54378 Gbp-Pq: Topic hurd Gbp-Pq: Name D54378-hurd-triple.diff --- include/llvm/ADT/Triple.h | 11 +++++++++-- lib/Support/Triple.cpp | 2 ++ unittests/ADT/TripleTest.cpp | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index c95b16dd4..f532a4458 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -182,7 +182,8 @@ public: Mesa3D, Contiki, AMDPAL, // AMD PAL Runtime - LastOSType = AMDPAL + Hurd, // GNU/Hurd + LastOSType = Hurd }; enum EnvironmentType { UnknownEnvironment, @@ -578,9 +579,15 @@ public: 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(); } diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index b14d6492b..bcf7c52a3 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 Hurd: return "hurd"; } 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("hurd", Triple::Hurd) .Default(Triple::UnknownOS); } diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp index b6b470d34..ee5fa1961 100644 --- a/unittests/ADT/TripleTest.cpp +++ b/unittests/ADT/TripleTest.cpp @@ -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()); -- 2.30.2