[llvm] 5dbcf5e - [X86] Add Feature64Bit to the 'generic' CPU and remove feature string hacking in X86Subtarget constructor

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 23 09:16:35 PDT 2020


Author: Craig Topper
Date: 2020-07-23T09:16:18-07:00
New Revision: 5dbcf5e3ccafb90d07b749e437c8e9089eda8516

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

LOG: [X86] Add Feature64Bit to the 'generic' CPU and remove feature string hacking in X86Subtarget constructor

Feature64Bit is only used by a check in the X86Subtarget
constructor to ensure that the CPU selected supports 64-bit mode
when the triple is for 64-bit mode.

'generic' is the default CPU in llc and so needs to be able to
pass this check. Previously we did this by detecting the name and
adding the feature to the feature string. But there doesn't seem
to be any reason we can't just add the feature to the CPU directly.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86.td
    llvm/lib/Target/X86/X86Subtarget.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 70954cbfbea8..69d83ab1528c 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -1022,8 +1022,12 @@ class Proc<string Name, list<SubtargetFeature> Features>
 
 // NOTE: CMPXCHG8B is here for legacy compatibility so that it is only disabled
 // if i386/i486 is specifically requested.
+// NOTE: 64Bit is here as "generic" is the default llc CPU. The X86Subtarget
+// constructor checks that any CPU used in 64-bit mode has Feature64Bit enabled.
+// It has no effect on code generation.
 def : Proc<"generic",         [FeatureX87, FeatureSlowUAMem16,
-                               FeatureCMPXCHG8B, FeatureInsertVZEROUPPER]>;
+                               FeatureCMPXCHG8B, Feature64Bit,
+                               FeatureInsertVZEROUPPER]>;
 def : Proc<"i386",            [FeatureX87, FeatureSlowUAMem16,
                                FeatureInsertVZEROUPPER]>;
 def : Proc<"i486",            [FeatureX87, FeatureSlowUAMem16,

diff  --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp
index 43888d9adf1b..ff2a94bcac8e 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -239,14 +239,6 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
       FullFS = "+sse2," + FullFS;
     else
       FullFS = "+sse2";
-
-    // If no CPU was specified, enable 64bit feature to satisy later check.
-    if (CPU == "generic") {
-      if (!FullFS.empty())
-        FullFS = "+64bit," + FullFS;
-      else
-        FullFS = "+64bit";
-    }
   }
 
   // Parse features string and set the CPU.


        


More information about the llvm-commits mailing list