[llvm-commits] [llvm] r96458 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/DAGISelMatcher.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp utils/TableGen/DAGISelMatcherGen.cpp

Chris Lattner sabre at nondot.org
Tue Feb 16 22:23:40 PST 2010


Author: lattner
Date: Wed Feb 17 00:23:39 2010
New Revision: 96458

URL: http://llvm.org/viewvc/llvm-project?rev=96458&view=rev
Log:
Emulate the current isel's "IsChainCompatible" logic for now.
I'd like to eventually rip it out, but for now producing the
same selections as the old matcher is more important.

Modified:
    llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h
    llvm/trunk/utils/TableGen/DAGISelMatcher.cpp
    llvm/trunk/utils/TableGen/DAGISelMatcher.h
    llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp
    llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp

Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96458&r1=96457&r2=96458&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Wed Feb 17 00:23:39 2010
@@ -217,7 +217,8 @@
   OPC_CheckComplexPat,
   OPC_CheckAndImm1, OPC_CheckAndImm2, OPC_CheckAndImm4, OPC_CheckAndImm8,
   OPC_CheckOrImm1, OPC_CheckOrImm2, OPC_CheckOrImm4, OPC_CheckOrImm8,
-  OPC_CheckFoldableChainNode
+  OPC_CheckFoldableChainNode,
+  OPC_CheckChainCompatible
 };
 
 struct MatchScope {
@@ -409,6 +410,13 @@
       
       continue;
     }
+    case OPC_CheckChainCompatible: {
+      unsigned PrevNode = MatcherTable[MatcherIndex++];
+      assert(PrevNode < RecordedNodes.size() && "Invalid CheckChainCompatible");
+      if (!IsChainCompatible(RecordedNodes[PrevNode].getNode(), N.getNode()))
+        break;
+      continue;
+    }
     }
     
     // If the code reached this point, then the match failed pop out to the next

Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=96458&r1=96457&r2=96458&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Wed Feb 17 00:23:39 2010
@@ -111,3 +111,9 @@
   OS.indent(indent) << "CheckFoldableChainNode\n";
   printChild(OS, indent);
 }
+
+void CheckChainCompatibleMatcherNode::print(raw_ostream &OS,
+                                              unsigned indent) const {
+  OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n";
+  printChild(OS, indent);
+}

Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96458&r1=96457&r2=96458&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Wed Feb 17 00:23:39 2010
@@ -50,7 +50,8 @@
     CheckComplexPat,
     CheckAndImm,
     CheckOrImm,
-    CheckFoldableChainNode
+    CheckFoldableChainNode,
+    CheckChainCompatible
   };
   const KindTy Kind;
   
@@ -380,6 +381,25 @@
   virtual void print(raw_ostream &OS, unsigned indent = 0) const;
 };
 
+/// CheckChainCompatibleMatcherNode - Verify that the current node's chain
+/// operand is 'compatible' with the specified recorded node's.
+class CheckChainCompatibleMatcherNode : public MatcherNodeWithChild {
+  unsigned PreviousOp;
+public:
+  CheckChainCompatibleMatcherNode(unsigned previousop)
+    : MatcherNodeWithChild(CheckChainCompatible), PreviousOp(previousop) {}
+  
+  unsigned getPreviousOp() const { return PreviousOp; }
+  
+  static inline bool classof(const MatcherNode *N) {
+    return N->getKind() == CheckChainCompatible;
+  }
+  
+  virtual void print(raw_ostream &OS, unsigned indent = 0) const;
+};
+  
+  
+
 } // end namespace llvm
 
 #endif

Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96458&r1=96457&r2=96458&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Wed Feb 17 00:23:39 2010
@@ -204,6 +204,10 @@
   case MatcherNode::CheckFoldableChainNode:
     OS << "OPC_CheckFoldableChainNode,\n";
     return 1;
+  case MatcherNode::CheckChainCompatible:
+    OS << "OPC_CheckChainCompatible, "
+       << cast<CheckChainCompatibleMatcherNode>(N)->getPreviousOp() << ",\n";
+    return 2;
   }
   assert(0 && "Unreachable");
   return 0;

Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96458&r1=96457&r2=96458&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Wed Feb 17 00:23:39 2010
@@ -165,6 +165,16 @@
       assert(NextRecordedOperandNo > 1 &&
              "Should have recorded input/result chains at least!");
       InputChains.push_back(NextRecordedOperandNo-1);
+
+      // IF we need to check chains, do so, see comment for
+      // "NodeHasProperty(SDNPHasChain" below.
+      if (InputChains.size() > 1) {
+        // FIXME: This is broken, we should eliminate this nonsense completely,
+        // but we want to produce the same selections that the old matcher does
+        // for now.
+        unsigned PrevOp = InputChains[InputChains.size()-2];
+        AddMatcherNode(new CheckChainCompatibleMatcherNode(PrevOp));
+      }
     }
     return;
   }
@@ -229,10 +239,13 @@
     // sure that folding the chain won't induce cycles in the DAG.  This could
     // happen if there were an intermediate node between the indbr and load, for
     // example.
-    
-    // FIXME: Emit "IsChainCompatible(lastchain.getNode(), CurrentNode)".
-    // Rename IsChainCompatible -> IsChainUnreachable, add comment about
-    // complexity.
+    if (InputChains.size() > 1) {
+      // FIXME: This is broken, we should eliminate this nonsense completely,
+      // but we want to produce the same selections that the old matcher does
+      // for now.
+      unsigned PrevOp = InputChains[InputChains.size()-2];
+      AddMatcherNode(new CheckChainCompatibleMatcherNode(PrevOp));
+    }
     
     // Don't look at the input chain when matching the tree pattern to the
     // SDNode.





More information about the llvm-commits mailing list