[llvm-commits] [llvm] r97440 - in /llvm/trunk/utils/TableGen: DAGISelMatcher.h DAGISelMatcherGen.cpp

Chris Lattner sabre at nondot.org
Sun Feb 28 23:27:07 PST 2010


Author: lattner
Date: Mon Mar  1 01:27:07 2010
New Revision: 97440

URL: http://llvm.org/viewvc/llvm-project?rev=97440&view=rev
Log:
Emit a redundant check for immediates at root context, e.g. (imm 0).
This allows formation of OpcodeSwitch for top level patterns, in
particular on X86.  This saves about 1K of data space in the x86
table and makes the dispatch much more efficient.

Modified:
    llvm/trunk/utils/TableGen/DAGISelMatcher.h
    llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp

Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=97440&r1=97439&r2=97440&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Mon Mar  1 01:27:07 2010
@@ -55,7 +55,6 @@
     CheckPredicate,       // Fail if node predicate fails.
     CheckOpcode,          // Fail if not opcode.
     SwitchOpcode,         // Dispatch based on opcode.
-    CheckMultiOpcode,     // Fail if not in opcode list.
     CheckType,            // Fail if not correct type.
     CheckChildType,       // Fail if child has wrong type.
     CheckInteger,         // Fail if wrong val.

Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=97440&r1=97439&r2=97440&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Mon Mar  1 01:27:07 2010
@@ -205,8 +205,17 @@
     AddMatcher(new CheckPredicateMatcher(N->getPredicateFns()[i]));
   
   // Direct match against an integer constant.
-  if (IntInit *II = dynamic_cast<IntInit*>(N->getLeafValue()))
+  if (IntInit *II = dynamic_cast<IntInit*>(N->getLeafValue())) {
+    // If this is the root of the dag we're matching, we emit a redundant opcode
+    // check to ensure that this gets folded into the normal top-level
+    // OpcodeSwitch.
+    if (N == Pattern.getSrcPattern()) {
+      const SDNodeInfo &NI = CGP.getSDNodeInfo(CGP.getSDNodeNamed("imm"));
+      AddMatcher(new CheckOpcodeMatcher(NI));
+    }
+
     return AddMatcher(new CheckIntegerMatcher(II->getValue()));
+  }
   
   DefInit *DI = dynamic_cast<DefInit*>(N->getLeafValue());
   if (DI == 0) {





More information about the llvm-commits mailing list