More cleanups, preparing to revamp InstrForest to, among other things,
authorChris Lattner <sabre@nondot.org>
Wed, 12 Sep 2001 16:34:03 +0000 (16:34 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 12 Sep 2001 16:34:03 +0000 (16:34 +0000)
not leak all its allocated memory.

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

include/llvm/CodeGen/InstrForest.h
lib/CodeGen/InstrSelection/InstrForest.cpp
lib/CodeGen/InstrSelection/InstrSelection.cpp
lib/CodeGen/TargetMachine/Sparc/Sparc.burg
lib/Target/SparcV9/InstrSelection/InstrForest.cpp
lib/Target/SparcV9/InstrSelection/InstrSelection.cpp

index e987521ea0487f6310c79bbc97e3a6d7dae775eb..47a12ace6b7ebd40bc11ecb787219c62c89eed1f 100644 (file)
@@ -238,7 +238,7 @@ class InstrForest : private hash_map<const Instruction*, InstructionNode*> {
   hash_set<InstructionNode*> treeRoots;
   
 public:
-  void buildTreesForMethod(Method *M);
+  InstrForest(Method *M);
                                    
   inline InstructionNode *getTreeNodeForInstr(Instruction* instr) {
     return (*this)[instr];
index 50c4f98721776d834ced2ce700b58e14b05ed7e1..0ecf1c2fe99d2b8cdc10bf8f6e405d0f67529c37 100644 (file)
@@ -176,11 +176,6 @@ inline void InstrForest::setRightChild(InstrTreeNode *Par, InstrTreeNode *Chld){
 }
 
 
-void InstrForest::buildTreesForMethod(Method *M) {
-  for_each(M->inst_begin(), M->inst_end(),
-          bind_obj(this, &InstrForest::buildTreeForInstruction));
-}
-
 InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
   InstructionNode *treeNode = getTreeNodeForInstr(Inst);
   if (treeNode) {
@@ -210,8 +205,7 @@ InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
   static InstrTreeNode *fixedChildArray[MAX_CHILD];
   InstrTreeNode **childArray =
     (Inst->getNumOperands() > MAX_CHILD)
-    ? new (InstrTreeNode*)[Inst->getNumOperands()]
-    : fixedChildArray;
+    ? new (InstrTreeNode*)[Inst->getNumOperands()] : fixedChildArray;
   
   //
   // Walk the operands of the instruction
@@ -309,3 +303,8 @@ InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
   return treeNode;
 }
 
+
+InstrForest::InstrForest(Method *M) {
+  for_each(M->inst_begin(), M->inst_end(),
+          bind_obj(this, &InstrForest::buildTreeForInstruction));
+}
index 675e489e46071829866fb9b962fd3c20d1691c21..b77b5a8b4e5a94499441795ed24895503905c00d 100644 (file)
@@ -31,11 +31,11 @@ enum SelectDebugLevel_t {
 };
 
 // Enable Debug Options to be specified on the command line
-cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags, // cl::Hidden
+cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags,
    "enable instruction selection debugging information",
    clEnumValN(Select_NoDebugInfo,      "n", "disable debug output"),
    clEnumValN(Select_PrintMachineCode, "y", "print generated machine code"),
-   clEnumValN(Select_DebugInstTrees,   "i", "print instr. selection debugging info"),
+   clEnumValN(Select_DebugInstTrees,   "i", "print instruction selection debug info"),
    clEnumValN(Select_DebugBurgTrees,   "b", "print burg trees"), 0);
 
 
@@ -54,8 +54,7 @@ SelectInstructionsForMethod(Method* method,
   //
   // Build the instruction trees to be given as inputs to BURG.
   // 
-  InstrForest instrForest;
-  instrForest.buildTreesForMethod(method);
+  InstrForest instrForest(method);
   
   if (SelectDebugLevel >= Select_DebugInstTrees)
     {
index a40a9bb1fb86d1b533e4b22ef378991183d3d309..c554f2fff3131dc3b8e4cc63b3b21ec8639e6afb 100644 (file)
@@ -220,8 +220,6 @@ reg:        Constant                =   72 (3);     /* prefer direct use */
  * This code was taken from sample.gr provided with BURG.
  *-----------------------------------------------------------------------*/
 
-static char rcsid[] = "$Id$";
-
 void printcover(NODEPTR_TYPE p, int goalnt, int indent) {
        int eruleno = burm_rule(STATE_LABEL(p), goalnt);
        short *nts = burm_nts[eruleno];
index 50c4f98721776d834ced2ce700b58e14b05ed7e1..0ecf1c2fe99d2b8cdc10bf8f6e405d0f67529c37 100644 (file)
@@ -176,11 +176,6 @@ inline void InstrForest::setRightChild(InstrTreeNode *Par, InstrTreeNode *Chld){
 }
 
 
-void InstrForest::buildTreesForMethod(Method *M) {
-  for_each(M->inst_begin(), M->inst_end(),
-          bind_obj(this, &InstrForest::buildTreeForInstruction));
-}
-
 InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
   InstructionNode *treeNode = getTreeNodeForInstr(Inst);
   if (treeNode) {
@@ -210,8 +205,7 @@ InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
   static InstrTreeNode *fixedChildArray[MAX_CHILD];
   InstrTreeNode **childArray =
     (Inst->getNumOperands() > MAX_CHILD)
-    ? new (InstrTreeNode*)[Inst->getNumOperands()]
-    : fixedChildArray;
+    ? new (InstrTreeNode*)[Inst->getNumOperands()] : fixedChildArray;
   
   //
   // Walk the operands of the instruction
@@ -309,3 +303,8 @@ InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
   return treeNode;
 }
 
+
+InstrForest::InstrForest(Method *M) {
+  for_each(M->inst_begin(), M->inst_end(),
+          bind_obj(this, &InstrForest::buildTreeForInstruction));
+}
index 675e489e46071829866fb9b962fd3c20d1691c21..b77b5a8b4e5a94499441795ed24895503905c00d 100644 (file)
@@ -31,11 +31,11 @@ enum SelectDebugLevel_t {
 };
 
 // Enable Debug Options to be specified on the command line
-cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags, // cl::Hidden
+cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags,
    "enable instruction selection debugging information",
    clEnumValN(Select_NoDebugInfo,      "n", "disable debug output"),
    clEnumValN(Select_PrintMachineCode, "y", "print generated machine code"),
-   clEnumValN(Select_DebugInstTrees,   "i", "print instr. selection debugging info"),
+   clEnumValN(Select_DebugInstTrees,   "i", "print instruction selection debug info"),
    clEnumValN(Select_DebugBurgTrees,   "b", "print burg trees"), 0);
 
 
@@ -54,8 +54,7 @@ SelectInstructionsForMethod(Method* method,
   //
   // Build the instruction trees to be given as inputs to BURG.
   // 
-  InstrForest instrForest;
-  instrForest.buildTreesForMethod(method);
+  InstrForest instrForest(method);
   
   if (SelectDebugLevel >= Select_DebugInstTrees)
     {