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

Chris Lattner lattner at cs.uiuc.edu
Tue Sep 13 21:03:27 PDT 2005



Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.16 -> 1.17
DAGISelEmitter.h updated: 1.12 -> 1.13
---
Log message:

Switch to a slightly more structured representation for instructions


---
Diffs of the changes:  (+24 -8)

 DAGISelEmitter.cpp |   11 +++++------
 DAGISelEmitter.h   |   21 +++++++++++++++++++--
 2 files changed, 24 insertions(+), 8 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.16 llvm/utils/TableGen/DAGISelEmitter.cpp:1.17
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.16	Tue Sep 13 21:11:12 2005
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Tue Sep 13 23:03:15 2005
@@ -700,18 +700,19 @@
     // Now that we have operands that are sets, inspect the operands list for
     // the instruction.  This determines the order that operands are added to
     // the machine instruction the node corresponds to.
-    assert(SetDestinations.size() == 1 &&
+    unsigned NumResults = SetDestinations.size();
+    assert(NumResults == 1 &&
            "This code only handles a single set right now!");
 
-
+    unsigned NumOperands = 0;
               
     DEBUG(I->dump());
-    Instructions.push_back(I);
+    Instructions.push_back(DAGInstruction(I, NumResults, NumOperands));
   }
    
   // If we can, convert the instructions to be a patterns that are matched!
   for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
-    TreePattern *I = Instructions[i];
+    TreePattern *I = Instructions[i].getPattern();
     
     if (I->getNumTrees() != 1) {
       std::cerr << "CANNOT HANDLE: " << I->getRecord()->getName() << " yet!";
@@ -780,7 +781,5 @@
     delete I->second;
   PatternFragments.clear();
 
-  for (unsigned i = 0, e = Instructions.size(); i != e; ++i)
-    delete Instructions[i];
   Instructions.clear();
 }


Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.12 llvm/utils/TableGen/DAGISelEmitter.h:1.13
--- llvm/utils/TableGen/DAGISelEmitter.h:1.12	Tue Sep 13 19:09:24 2005
+++ llvm/utils/TableGen/DAGISelEmitter.h	Tue Sep 13 23:03:16 2005
@@ -272,7 +272,24 @@
     MVT::ValueType getIntrinsicType(Record *R) const;
     TreePatternNode *ParseTreePattern(DagInit *DI);
   };
-  
+
+
+  class DAGInstruction {
+    TreePattern *Pattern;
+    unsigned NumResults;
+    unsigned NumOperands;
+  public:
+    DAGInstruction(TreePattern *TP, unsigned results, unsigned ops)
+      : Pattern(TP), NumResults(results), NumOperands(ops) {}
+
+    ~DAGInstruction() {
+      delete Pattern;
+    }
+
+    TreePattern *getPattern() const { return Pattern; }
+    unsigned getNumResults() const { return NumResults; }
+    unsigned getNumOperands() const { return NumOperands; }
+  };
   
   
 /// InstrSelectorEmitter - The top-level class which coordinates construction
@@ -285,7 +302,7 @@
   std::map<Record*, SDNodeInfo> SDNodes;
   std::map<Record*, std::pair<Record*, std::string> > SDNodeXForms;
   std::map<Record*, TreePattern*> PatternFragments;
-  std::vector<TreePattern*> Instructions;
+  std::vector<DAGInstruction> Instructions;
   
   /// PatternsToMatch - All of the things we are matching on the DAG.  The first
   /// value is the pattern to match, the second pattern is the result to






More information about the llvm-commits mailing list