[llvm] r231357 - [TableGen] Implement at least some support for multiple explicit results in an instruction pattern. No functional change to existing patterns.

Craig Topper craig.topper at gmail.com
Wed Mar 4 23:11:37 PST 2015


Author: ctopper
Date: Thu Mar  5 01:11:36 2015
New Revision: 231357

URL: http://llvm.org/viewvc/llvm-project?rev=231357&view=rev
Log:
[TableGen] Implement at least some support for multiple explicit results in an instruction pattern. No functional change to existing patterns.

This should help with the AVX512 masked gather changes Elena is working on. This patch is derived from some of the changes Elena made to tablegen, but modified by me to support arbitrary number of results.

Modified:
    llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp

Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=231357&r1=231356&r2=231357&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Thu Mar  5 01:11:36 2015
@@ -1222,8 +1222,7 @@ static unsigned GetNumNodeResults(Record
   if (Operator->isSubClassOf("Instruction")) {
     CodeGenInstruction &InstInfo = CDP.getTargetInfo().getInstruction(Operator);
 
-    // FIXME: Should allow access to all the results here.
-    unsigned NumDefsToAdd = InstInfo.Operands.NumDefs ? 1 : 0;
+    unsigned NumDefsToAdd = InstInfo.Operands.NumDefs;
 
     // Add on one implicit def if it has a resolvable type.
     if (InstInfo.HasOneImplicitDefWithKnownVT(CDP.getTargetInfo()) !=MVT::Other)
@@ -1800,8 +1799,7 @@ bool TreePatternNode::ApplyTypeConstrain
 
     // Apply the result types to the node, these come from the things in the
     // (outs) list of the instruction.
-    // FIXME: Cap at one result so far.
-    unsigned NumResultsToAdd = InstInfo.Operands.NumDefs ? 1 : 0;
+    unsigned NumResultsToAdd = InstInfo.Operands.NumDefs;
     for (unsigned ResNo = 0; ResNo != NumResultsToAdd; ++ResNo)
       MadeChange |= UpdateNodeTypeFromInst(ResNo, Inst.getResult(ResNo), TP);
 
@@ -2967,7 +2965,7 @@ const DAGInstruction &CodeGenDAGPatterns
 
     // Check that all of the results occur first in the list.
     std::vector<Record*> Results;
-    TreePatternNode *Res0Node = nullptr;
+    SmallVector<TreePatternNode *, 2> ResNodes;
     for (unsigned i = 0; i != NumResults; ++i) {
       if (i == CGI.Operands.size())
         I->error("'" + InstResults.begin()->first +
@@ -2979,8 +2977,8 @@ const DAGInstruction &CodeGenDAGPatterns
       if (!RNode)
         I->error("Operand $" + OpName + " does not exist in operand list!");
 
-      if (i == 0)
-        Res0Node = RNode;
+      ResNodes.push_back(RNode);
+
       Record *R = cast<DefInit>(RNode->getLeafValue())->getDef();
       if (!R)
         I->error("Operand $" + OpName + " should be a set destination: all "
@@ -3055,9 +3053,11 @@ const DAGInstruction &CodeGenDAGPatterns
     TreePatternNode *ResultPattern =
       new TreePatternNode(I->getRecord(), ResultNodeOperands,
                           GetNumNodeResults(I->getRecord(), *this));
-    // Copy fully inferred output node type to instruction result pattern.
-    for (unsigned i = 0; i != NumResults; ++i)
-      ResultPattern->setType(i, Res0Node->getExtType(i));
+    // Copy fully inferred output node types to instruction result pattern.
+    for (unsigned i = 0; i != NumResults; ++i) {
+      assert(ResNodes[i]->getNumTypes() == 1 && "FIXME: Unhandled");
+      ResultPattern->setType(i, ResNodes[i]->getExtType(0));
+    }
 
     // Create and insert the instruction.
     // FIXME: InstImpResults should not be part of DAGInstruction.





More information about the llvm-commits mailing list