[llvm-branch-commits] [llvm-branch] r119205 - in /llvm/branches/Apple/whitney: include/llvm/Target/Target.td lib/Target/X86/X86InstrInfo.td utils/TableGen/AsmMatcherEmitter.cpp

Daniel Dunbar daniel at zuster.org
Mon Nov 15 13:43:33 PST 2010


Author: ddunbar
Date: Mon Nov 15 15:43:33 2010
New Revision: 119205

URL: http://llvm.org/viewvc/llvm-project?rev=119205&view=rev
Log:
Merge r117831:
--
Author: Chris Lattner <clattner at apple.com>
Date:   Sat Oct 30 19:38:20 2010 +0000

    Resolve a terrible hack in tblgen: instead of hardcoding
    "In32BitMode" and "In64BitMode" into tblgen, allow any
    predicate that inherits from AssemblerPredicate.

Modified:
    llvm/branches/Apple/whitney/include/llvm/Target/Target.td
    llvm/branches/Apple/whitney/lib/Target/X86/X86InstrInfo.td
    llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/branches/Apple/whitney/include/llvm/Target/Target.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/include/llvm/Target/Target.td?rev=119205&r1=119204&r2=119205&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/include/llvm/Target/Target.td (original)
+++ llvm/branches/Apple/whitney/include/llvm/Target/Target.td Mon Nov 15 15:43:33 2010
@@ -251,6 +251,11 @@
 /// selector matching code. Currently each predicate is just a string.
 class Predicate<string cond> {
   string CondString = cond;
+  
+  /// AssemblerMatcherPredicate - If this feature can be used by the assembler
+  /// matcher, this is true.  Targets should set this by inheriting their
+  /// feature from the AssemblerPredicate class in addition to Predicate.
+  bit AssemblerMatcherPredicate = 0;
 }
 
 /// NoHonorSignDependentRounding - This predicate is true if support for
@@ -529,6 +534,13 @@
 }
 def DefaultAsmParser : AsmParser;
 
+/// AssemblerPredicate - This is a Predicate that can be used when the assembler
+/// matches instructions and aliases.
+class AssemblerPredicate {
+  bit AssemblerMatcherPredicate = 1;
+}
+
+
 
 /// MnemonicAlias - This class allows targets to define assembler mnemonic
 /// aliases.  This should be used when all forms of one mnemonic are accepted

Modified: llvm/branches/Apple/whitney/lib/Target/X86/X86InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/Target/X86/X86InstrInfo.td?rev=119205&r1=119204&r2=119205&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/branches/Apple/whitney/lib/Target/X86/X86InstrInfo.td Mon Nov 15 15:43:33 2010
@@ -414,8 +414,8 @@
 def HasFMA4      : Predicate<"Subtarget->hasFMA4()">;
 def FPStackf32   : Predicate<"!Subtarget->hasSSE1()">;
 def FPStackf64   : Predicate<"!Subtarget->hasSSE2()">;
-def In32BitMode  : Predicate<"!Subtarget->is64Bit()">;
-def In64BitMode  : Predicate<"Subtarget->is64Bit()">;
+def In32BitMode  : Predicate<"!Subtarget->is64Bit()">, AssemblerPredicate;
+def In64BitMode  : Predicate<"Subtarget->is64Bit()">, AssemblerPredicate;
 def IsWin64      : Predicate<"Subtarget->isTargetWin64()">;
 def NotWin64     : Predicate<"!Subtarget->isTargetWin64()">;
 def SmallCode    : Predicate<"TM.getCodeModel() == CodeModel::Small">;

Modified: llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp?rev=119205&r1=119204&r2=119205&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp Mon Nov 15 15:43:33 2010
@@ -963,27 +963,15 @@
     }
 
     // Compute the require features.
-    ListInit *Predicates = CGI.TheDef->getValueAsListInit("Predicates");
-    for (unsigned i = 0, e = Predicates->getSize(); i != e; ++i) {
-      if (DefInit *Pred = dynamic_cast<DefInit*>(Predicates->getElement(i))) {
-        // Ignore OptForSize and OptForSpeed, they aren't really requirements,
-        // rather they are hints to isel.
-        //
-        // FIXME: Find better way to model this.
-        if (Pred->getDef()->getName() == "OptForSize" ||
-            Pred->getDef()->getName() == "OptForSpeed")
-          continue;
-
-        // FIXME: Total hack; for now, we just limit ourselves to In32BitMode
-        // and In64BitMode, because we aren't going to have the right feature
-        // masks for SSE and friends. We need to decide what we are going to do
-        // about CPU subtypes to implement this the right way.
-        if (Pred->getDef()->getName() != "In32BitMode" &&
-            Pred->getDef()->getName() != "In64BitMode")
-          continue;
-
-        II->RequiredFeatures.push_back(getSubtargetFeature(Pred->getDef()));
-      }
+    std::vector<Record*> Predicates =
+      CGI.TheDef->getValueAsListOfDefs("Predicates");
+    for (unsigned i = 0, e = Predicates.size(); i != e; ++i) {
+      Record *Pred = Predicates[i];
+      // Ignore predicates that are not intended for the assembler.
+      if (!Pred->getValueAsBit("AssemblerMatcherPredicate"))
+        continue;
+        
+      II->RequiredFeatures.push_back(getSubtargetFeature(Pred));
     }
 
     Instructions.push_back(II.take());
@@ -1523,14 +1511,10 @@
   for (unsigned i = 0, e = ReqFeatures.size(); i != e; ++i) {
     Record *Pred = ReqFeatures[i];
   
-    // FIXME: Total hack; for now, we just limit ourselves to In32BitMode
-    // and In64BitMode, because we aren't going to have the right feature
-    // masks for SSE and friends. We need to decide what we are going to do
-    // about CPU subtypes to implement this the right way.
-    if (Pred->getName() != "In32BitMode" &&
-        Pred->getName() != "In64BitMode")
+    // Ignore predicates that are not intended for the assembler.
+    if (!Pred->getValueAsBit("AssemblerMatcherPredicate"))
       continue;
-
+ 
     if (NumFeatures)
       Result += '|';
     





More information about the llvm-branch-commits mailing list