[clang] c359c5d - [X86] Centalize the 'sse4' hack to a single place in X86TargetInfo::setFeatureEnabledImpl. NFCI

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 6 15:01:01 PDT 2020


Author: Craig Topper
Date: 2020-07-06T15:00:32-07:00
New Revision: c359c5d534429c96f1cebdf8d845b8120e9c2ef0

URL: https://github.com/llvm/llvm-project/commit/c359c5d534429c96f1cebdf8d845b8120e9c2ef0
DIFF: https://github.com/llvm/llvm-project/commit/c359c5d534429c96f1cebdf8d845b8120e9c2ef0.diff

LOG: [X86] Centalize the 'sse4' hack to a single place in X86TargetInfo::setFeatureEnabledImpl. NFCI

Instead of detecting the string in 2 places. Just swap the string
to 'sse4.1' or 'sse4.2' at the top of the function.

Prep work for a patch to switch the rest of this function to a
table based system. And I don't want to include 'sse4a' in the
table.

Added: 
    

Modified: 
    clang/lib/Basic/Targets/X86.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 30f4570ecc02..2c6742b9042a 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -295,11 +295,18 @@ void X86TargetInfo::setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level,
 
 void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
                                           StringRef Name, bool Enabled) {
-  // This is a bit of a hack to deal with the sse4 target feature when used
-  // as part of the target attribute. We handle sse4 correctly everywhere
-  // else. See below for more information on how we handle the sse4 options.
-  if (Name != "sse4")
-    Features[Name] = Enabled;
+  if (Name == "sse4") {
+    // We can get here via the __target__ attribute since that's not controlled
+    // via the -msse4/-mno-sse4 command line alias. Handle this the same way
+    // here - turn on the sse4.2 if enabled, turn off the sse4.1 level if
+    // disabled.
+    if (Enabled)
+      Name = "sse4.2";
+    else
+      Name = "sse4.1";
+  }
+
+  Features[Name] = Enabled;
 
   if (Name == "mmx") {
     setMMXLevel(Features, MMX, Enabled);
@@ -381,15 +388,6 @@ void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
   } else if (Name == "sha") {
     if (Enabled)
       setSSELevel(Features, SSE2, Enabled);
-  } else if (Name == "sse4") {
-    // We can get here via the __target__ attribute since that's not controlled
-    // via the -msse4/-mno-sse4 command line alias. Handle this the same way
-    // here - turn on the sse4.2 if enabled, turn off the sse4.1 level if
-    // disabled.
-    if (Enabled)
-      setSSELevel(Features, SSE42, Enabled);
-    else
-      setSSELevel(Features, SSE41, Enabled);
   } else if (Name == "xsave") {
     if (!Enabled)
       Features["xsaveopt"] = Features["xsavec"] = Features["xsaves"] = false;


        


More information about the cfe-commits mailing list