Emit a redundant check for immediates at root context, e.g. (imm 0).
authorChris Lattner <sabre@nondot.org>
Mon, 1 Mar 2010 07:27:07 +0000 (07:27 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 1 Mar 2010 07:27:07 +0000 (07:27 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97440 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelMatcher.h
utils/TableGen/DAGISelMatcherGen.cpp

index 8b6b32291429899381441e6a70b6b0929ca18b15..1634cd2ecdd5dadd0571a340467d8df466df30ec 100644 (file)
@@ -55,7 +55,6 @@ public:
     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.
index 95cfa5b251cee4ecd081be3340db604fbbb4dd8e..62442d0c22c6d82335037fffbafd8906c889fba8 100644 (file)
@@ -205,8 +205,17 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
     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) {