enhance EmitNodeMatcher to keep track of the recorded slot numbers
authorChris Lattner <sabre@nondot.org>
Sun, 28 Feb 2010 02:41:25 +0000 (02:41 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 28 Feb 2010 02:41:25 +0000 (02:41 +0000)
it will populate.

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

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

index d6f4f78876881a53e1b4abb181671656e43e6c86..d939edb563e83d4ab3fa2b80900f917cfd2fe07a 100644 (file)
@@ -172,7 +172,7 @@ void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
 
 void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent);
-  OS << (isSelectNodeTo() ? "SelectNodeTo: " : "EmitNode: ")
+  OS << (isa<SelectNodeToMatcher>(this) ? "SelectNodeTo: " : "EmitNode: ")
      << OpcodeName << ": <todo flags> ";
 
   for (unsigned i = 0, e = VTs.size(); i != e; ++i)
index 3d73262ef881d8980de4d5c74c1be20b8cdf4c96..b91b591ceecd840b09afd8e3ca15d1a46e1b228b 100644 (file)
@@ -893,8 +893,6 @@ public:
       HasChain(hasChain), HasFlag(hasFlag), HasMemRefs(hasmemrefs),
       NumFixedArityOperands(numfixedarityoperands) {}
   
-  bool isSelectNodeTo() const { return getKind() == SelectNodeTo; }
-  
   const std::string &getOpcodeName() const { return OpcodeName; }
   
   unsigned getNumVTs() const { return VTs.size(); }
@@ -926,15 +924,18 @@ private:
   
 /// EmitNodeMatcher - This signals a successful match and generates a node.
 class EmitNodeMatcher : public EmitNodeMatcherCommon {
+  unsigned FirstResultSlot;
 public:
   EmitNodeMatcher(const std::string &opcodeName,
                   const MVT::SimpleValueType *vts, unsigned numvts,
                   const unsigned *operands, unsigned numops,
                   bool hasChain, bool hasFlag, bool hasmemrefs,
-                  int numfixedarityoperands)
+                  int numfixedarityoperands, unsigned firstresultslot)
   : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain,
-                          hasFlag, hasmemrefs, numfixedarityoperands, false)
-    {}
+                          hasFlag, hasmemrefs, numfixedarityoperands, false),
+    FirstResultSlot(firstresultslot) {}
+  
+  unsigned getFirstResultSlot() const { return FirstResultSlot; }
   
   static inline bool classof(const Matcher *N) {
     return N->getKind() == EmitNode;
index 84e33f39235e68783cb6dcf85344bc9641454eba..942a61225ee1c53b72c94ddf5b78f2b31cfec3a6 100644 (file)
@@ -392,7 +392,7 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
   case Matcher::EmitNode:
   case Matcher::SelectNodeTo: {
     const EmitNodeMatcherCommon *EN = cast<EmitNodeMatcherCommon>(N);
-    OS << (EN->isSelectNodeTo() ? "OPC_EmitNode" : "OPC_SelectNodeTo");
+    OS << (isa<EmitNodeMatcher>(EN) ? "OPC_EmitNode" : "OPC_SelectNodeTo");
     OS << ", TARGET_OPCODE(" << EN->getOpcodeName() << "), 0";
     
     if (EN->hasChain())   OS << "|OPFL_Chain";
@@ -413,6 +413,20 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
       // is too large to represent with a byte.
       NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS);
     }
+    
+    // Print the result #'s for EmitNode.
+    if (const EmitNodeMatcher *E = dyn_cast<EmitNodeMatcher>(EN)) {
+      if (EN->getVT(0) != MVT::Flag && EN->getVT(0) != MVT::Other) {
+        OS.PadToColumn(CommentIndent) << "// Results = ";
+        unsigned First = E->getFirstResultSlot();
+        for (unsigned i = 0, e = EN->getNumVTs(); i != e; ++i) {
+          if (EN->getVT(0) == MVT::Flag || EN->getVT(0) == MVT::Other)
+            break;
+          OS << "#" << First+i << " ";
+        }
+      }
+    }
+    
     OS << '\n';
     return 6+EN->getNumVTs()+NumOperandBytes;
   }
index ee385074a9eb26fb11fd72ecebaef6f88d90d95f..18735de0e22f67becedcb937c8ccdbbee434e434 100644 (file)
@@ -749,7 +749,8 @@ EmitResultInstructionAsOperand(const TreePatternNode *N,
                                  ResultVTs.data(), ResultVTs.size(),
                                  InstOps.data(), InstOps.size(),
                                  NodeHasChain, TreeHasInFlag,
-                                 NodeHasMemRefs, NumFixedArityOperands));
+                                 NodeHasMemRefs, NumFixedArityOperands,
+                                 NextRecordedOperandNo));
   
   // The non-chain and non-flag results of the newly emitted node get recorded.
   for (unsigned i = 0, e = ResultVTs.size(); i != e; ++i) {
index 79534574363c44bde131817acce37c092c2aec90..12c4c1b079733c3ade0ca5ed08cf95cbe68e8492 100644 (file)
@@ -66,10 +66,9 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr) {
   
   // Turn EmitNode->CompleteMatch into SelectNodeTo if we can.
   if (EmitNodeMatcher *EN = dyn_cast<EmitNodeMatcher>(N))
-    if (CompleteMatchMatcher *CM = cast<CompleteMatchMatcher>(EN->getNext())) {
+    if (CompleteMatchMatcher *CM =
+          dyn_cast<CompleteMatchMatcher>(EN->getNext())) {
       (void)CM;
-      
-      
     }
   
   ContractNodes(N->getNextPtr());