D54378-hurd-triple
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Mon, 30 Dec 2019 14:31:05 +0000 (14:31 +0000)
committerPeter Michael Green <plugwash@raspbian.org>
Mon, 30 Dec 2019 14:31:05 +0000 (14:31 +0000)
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
lib/Support/Triple.cpp
unittests/ADT/TripleTest.cpp

index c95b16dd4e8c8052ed0c91b0758a52f9c8fb72fa..f532a4458a9132aea50a8301ee52744b0c618afc 100644 (file)
@@ -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();
   }
 
index b14d6492b1ed86f583319fa5d501f2cc9098c890..bcf7c52a3e5b2ec95283b9a85cfeb5dd9c411864 100644 (file)
@@ -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);
 }
 
index b6b470d34e2bec43f2bf53c99242ccb411fddaee..ee5fa1961c16e41eb92ff6d7ea3300042b5f688f 100644 (file)
@@ -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());