[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Sep 14 11:19:37 PDT 2005



Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.18 -> 1.19
---
Log message:

Verify that set destinations occur first in the instruction operand list.


---
Diffs of the changes:  (+28 -2)

 DAGISelEmitter.cpp |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.18 llvm/utils/TableGen/DAGISelEmitter.cpp:1.19
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.18	Wed Sep 14 01:03:10 2005
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Wed Sep 14 13:19:25 2005
@@ -701,8 +701,34 @@
     // the instruction.  This determines the order that operands are added to
     // the machine instruction the node corresponds to.
     unsigned NumResults = SetDestinations.size();
-    //assert(NumResults == 1 &&
-    //       "This code only handles a single set right now!");
+
+    // Parse the operands list from the (ops) list, validating it.
+    std::vector<std::string> &Args = I->getArgList();
+    assert(Args.empty() && "Args list should still be empty here!");
+    CodeGenInstruction &CGI = Target.getInstruction(Instrs[i]->getName());
+
+    // Check that all of the results occur first in the list.
+    for (unsigned i = 0; i != NumResults; ++i) {
+      const std::string &OpName = CGI.OperandList[i].Name;
+      if (OpName.empty())
+        I->error("Operand #" + utostr(i) + " in operands list has no name!");
+      
+      // Check that it exists in SetDestinations.
+      Record *R = SetDestinations[OpName];
+      if (R == 0)
+        I->error("Operand $" + OpName + " should be a set destination: all "
+                 "outputs must occur before inputs in operand list!");
+      
+      if (CGI.OperandList[i].Rec != R)
+        I->error("Operand $" + OpName + " class mismatch!");
+      
+      // Okay, this one checks out.
+      SetDestinations.erase(OpName);
+    }
+    
+    if (!SetDestinations.empty())
+      I->error("'" + SetDestinations.begin()->first +
+               "' set but does not appear in operand list!");
 
     unsigned NumOperands = 0;
               






More information about the llvm-commits mailing list