[PATCH] D110900: Triple: Add RedHat vendor

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 31 01:42:11 PDT 2023


tstellar updated this revision to Diff 509942.
tstellar added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110900/new/

https://reviews.llvm.org/D110900

Files:
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/TargetParser/Triple.cpp
  llvm/unittests/TargetParser/TripleTest.cpp


Index: llvm/unittests/TargetParser/TripleTest.cpp
===================================================================
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -145,6 +145,12 @@
   EXPECT_EQ(Triple::SCEI, T.getVendor());
   EXPECT_EQ(Triple::PS5, T.getOS());
 
+  T = Triple("x86_64-redhat-linux");
+  EXPECT_EQ(Triple::x86_64, T.getArch());
+  EXPECT_EQ(Triple::RedHat, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(true, T.isGNUEnvironment());
+
   T = Triple("powerpc-ibm-aix");
   EXPECT_EQ(Triple::ppc, T.getArch());
   EXPECT_EQ(Triple::IBM, T.getVendor());
Index: llvm/lib/TargetParser/Triple.cpp
===================================================================
--- llvm/lib/TargetParser/Triple.cpp
+++ llvm/lib/TargetParser/Triple.cpp
@@ -196,6 +196,7 @@
   case PC: return "pc";
   case SCEI: return "scei";
   case SUSE: return "suse";
+  case RedHat: return "redhat";
   }
 
   llvm_unreachable("Invalid VendorType!");
@@ -554,6 +555,7 @@
     .Case("mesa", Triple::Mesa)
     .Case("suse", Triple::SUSE)
     .Case("oe", Triple::OpenEmbedded)
+    .Case("redhat", Triple::RedHat)
     .Default(Triple::UnknownVendor);
 }
 
Index: llvm/include/llvm/TargetParser/Triple.h
===================================================================
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -180,7 +180,8 @@
     Mesa,
     SUSE,
     OpenEmbedded,
-    LastVendorType = OpenEmbedded
+    RedHat,
+    LastVendorType = RedHat
   };
   enum OSType {
     UnknownOS,
@@ -563,12 +564,22 @@
   bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
 
   bool isGNUEnvironment() const {
-    EnvironmentType Env = getEnvironment();
-    return Env == Triple::GNU || Env == Triple::GNUABIN32 ||
-           Env == Triple::GNUABI64 || Env == Triple::GNUEABI ||
-           Env == Triple::GNUEABIHF || Env == Triple::GNUF32 ||
-           Env == Triple::GNUF64 || Env == Triple::GNUSF ||
-           Env == Triple::GNUX32;
+    switch (getEnvironment()) {
+    case Triple::GNU:
+    case Triple::GNUABIN32:
+    case Triple::GNUABI64:
+    case Triple::GNUEABI:
+    case Triple::GNUEABIHF:
+    case Triple::GNUF32:
+    case Triple::GNUF64:
+    case Triple::GNUSF:
+    case Triple::GNUX32:
+        return true;
+    case Triple::UnknownEnvironment:
+        return getVendor() == RedHat;
+    default:
+        return false;
+    }
   }
 
   bool isOSContiki() const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110900.509942.patch
Type: text/x-patch
Size: 2509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230331/20975bb6/attachment.bin>


More information about the llvm-commits mailing list