Eliminate 'BasicNode' from InstrForest.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@551 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp
index 181c1a1..1ff4c88 100644
--- a/lib/CodeGen/InstrSelection/InstrForest.cpp
+++ b/lib/CodeGen/InstrSelection/InstrForest.cpp
@@ -38,23 +38,16 @@
 //------------------------------------------------------------------------ 
 
 
-InstrTreeNode::InstrTreeNode(InstrTreeNodeType nodeType,
-			     Value* _val)
-  : treeNodeType(nodeType),
-    val(_val)
-{
-  basicNode.leftChild = NULL;
-  basicNode.rightChild = NULL;
-  basicNode.parent = NULL;
-  basicNode.opLabel = InvalidOp;
-  basicNode.treeNodePtr = this;
+InstrTreeNode::InstrTreeNode(InstrTreeNodeType nodeType, Value* _val)
+  : treeNodeType(nodeType), val(_val) {
+  LeftChild   = 0;
+  RightChild  = 0;
+  Parent      = 0;
+  opLabel     = InvalidOp;
 }
 
-void
-InstrTreeNode::dump(int dumpChildren,
-		    int indent) const
-{
-  this->dumpNode(indent);
+void InstrTreeNode::dump(int dumpChildren, int indent) const {
+  dumpNode(indent);
   
   if (dumpChildren)
     {
@@ -122,7 +115,7 @@
 	}
     }
   
-  basicNode.opLabel = opLabel;
+  this->opLabel = opLabel;
 }
 
 
@@ -148,10 +141,8 @@
 }
 
 
-VRegListNode::VRegListNode()
-  : InstrTreeNode(NTVRegListNode, NULL)
-{
-  basicNode.opLabel = VRegListOp;
+VRegListNode::VRegListNode() : InstrTreeNode(NTVRegListNode, 0) {
+  opLabel = VRegListOp;
 }
 
 void
@@ -164,10 +155,8 @@
 }
 
 
-VRegNode::VRegNode(Value* _val)
-  : InstrTreeNode(NTVRegNode, _val)
-{
-  basicNode.opLabel = VRegNodeOp;
+VRegNode::VRegNode(Value* _val) : InstrTreeNode(NTVRegNode, _val) {
+  opLabel = VRegNodeOp;
 }
 
 void
@@ -181,10 +170,9 @@
 }
 
 
-ConstantNode::ConstantNode(ConstPoolVal* constVal)
-  : InstrTreeNode(NTConstNode, constVal)
-{
-  basicNode.opLabel = ConstantNodeOp;
+ConstantNode::ConstantNode(ConstPoolVal *constVal)
+  : InstrTreeNode(NTConstNode, constVal) {
+  opLabel = ConstantNodeOp;
 }
 
 void
@@ -198,10 +186,8 @@
 }
 
 
-LabelNode::LabelNode(BasicBlock* _bblock)
-  : InstrTreeNode(NTLabelNode, _bblock)
-{
-  basicNode.opLabel = LabelNodeOp;
+LabelNode::LabelNode(BasicBlock *BB) : InstrTreeNode(NTLabelNode, BB) {
+  opLabel = LabelNodeOp;
 }
 
 void
@@ -255,10 +241,9 @@
 
 
 inline void
-InstrForest::setLeftChild(InstrTreeNode* parent, InstrTreeNode* child)
-{
-  parent->basicNode.leftChild = & child->basicNode;
-  child->basicNode.parent = & parent->basicNode;
+InstrForest::setLeftChild(InstrTreeNode* parent, InstrTreeNode* child) {
+  parent->LeftChild = child;
+  child->Parent = parent;
   if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
     treeRoots.erase((InstructionNode*) child);	// no longer a tree root
 }
@@ -267,8 +252,8 @@
 inline void
 InstrForest::setRightChild(InstrTreeNode* parent, InstrTreeNode* child)
 {
-  parent->basicNode.rightChild = & child->basicNode;
-  child->basicNode.parent = & parent->basicNode;
+  parent->RightChild = child;
+  child->Parent = parent;
   if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
     treeRoots.erase((InstructionNode*) child);	// no longer a tree root
 }
diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp
index e6884ab..675e489 100644
--- a/lib/CodeGen/InstrSelection/InstrSelection.cpp
+++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp
@@ -10,30 +10,19 @@
 //**************************************************************************/
 
 
-//************************** System Include Files ***************************/
-
-
-//*************************** User Include Files ***************************/
-
 #include "llvm/CodeGen/InstrSelection.h"
+#include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Type.h"
 #include "llvm/iMemory.h"
 #include "llvm/Instruction.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
-#include "llvm/CodeGen/MachineInstr.h"
 
-
-//************************* Forward Declarations ***************************/
-
-static bool SelectInstructionsForTree(BasicTreeNode* treeRoot,
-				      int goalnt,
+static bool SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
 				      TargetMachine &Target);
 
 
-//************************* Internal Data Types *****************************/
-
 enum SelectDebugLevel_t {
   Select_NoDebugInfo,
   Select_PrintMachineCode, 
@@ -50,8 +39,6 @@
    clEnumValN(Select_DebugBurgTrees,   "b", "print burg trees"), 0);
 
 
-//************************** External Functions ****************************/
-
 
 //---------------------------------------------------------------------------
 // Entry point for instruction selection using BURG.
@@ -87,7 +74,7 @@
        treeRootIter != treeRoots.end();
        ++treeRootIter)
     {
-      BasicTreeNode* basicNode = (*treeRootIter)->getBasicNode();
+      InstrTreeNode* basicNode = *treeRootIter;
       
       // Invoke BURM to label each tree node with a state
       (void) burm_label(basicNode);
@@ -192,8 +179,7 @@
 //---------------------------------------------------------------------------
 
 bool
-SelectInstructionsForTree(BasicTreeNode* treeRoot,
-			  int goalnt,
+SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
 			  TargetMachine &Target)
 {
   // Use a static vector to avoid allocating a new one per VM instruction
@@ -220,7 +206,7 @@
   // 
   if (treeRoot->opLabel != VRegListOp)
     {
-      InstructionNode* instrNode = (InstructionNode*)treeRoot->treeNodePtr;
+      InstructionNode* instrNode = (InstructionNode*)treeRoot;
       assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
       
       unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, Target,
@@ -238,7 +224,7 @@
   if (nts[0])
     { // i.e., there is at least one kid
 
-      BasicTreeNode* kids[2];
+      InstrTreeNode* kids[2];
       int currentRule = ruleForNode;
       burm_kids(treeRoot, currentRule, kids);
       
@@ -258,8 +244,7 @@
       for (int i = 0; nts[i]; i++)
 	{
 	  assert(i < 2);
-	  InstrTreeNode::InstrTreeNodeType
-	    nodeType = kids[i]->treeNodePtr->getNodeType();
+	  InstrTreeNode::InstrTreeNodeType nodeType = kids[i]->getNodeType();
 	  if (nodeType == InstrTreeNode::NTVRegListNode ||
 	      nodeType == InstrTreeNode::NTInstructionNode)
 	    {
diff --git a/lib/CodeGen/TargetMachine/Sparc/Sparc.burg b/lib/CodeGen/TargetMachine/Sparc/Sparc.burg
index b211b54..a40a9bb 100644
--- a/lib/CodeGen/TargetMachine/Sparc/Sparc.burg
+++ b/lib/CodeGen/TargetMachine/Sparc/Sparc.burg
@@ -2,10 +2,10 @@
 #include <stdio.h>
 #include <llvm/CodeGen/InstrForest.h>
 
-typedef BasicTreeNode* NODEPTR_TYPE;
+typedef InstrTreeNode* NODEPTR_TYPE;
 #define OP_LABEL(p)	((p)->opLabel)
-#define LEFT_CHILD(p)	((p)->leftChild)
-#define RIGHT_CHILD(p)	((p)->rightChild)
+#define LEFT_CHILD(p)	((p)->LeftChild)
+#define RIGHT_CHILD(p)	((p)->RightChild)
 #define STATE_LABEL(p)	((p)->state)
 #define PANIC		printf
 %}
diff --git a/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp b/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp
index 492a52f..ca2bca6 100644
--- a/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp
+++ b/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp
@@ -9,23 +9,18 @@
 //	7/02/01	 -  Vikram Adve  -  Created
 //**************************************************************************/
 
+#include "llvm/CodeGen/Sparc.h"
+#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/InstrForest.h"
+#include "llvm/CodeGen/InstrSelection.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/Type.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/SymbolTable.h"
-#include "llvm/Value.h"
-#include "llvm/Instruction.h"
-#include "llvm/InstrTypes.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
 #include "llvm/iOther.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
 #include "llvm/ConstPoolVals.h"
-#include "llvm/CodeGen/Sparc.h"
-#include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/CodeGen/InstrForest.h"
-#include "llvm/CodeGen/InstrSelection.h"
 
 
 //******************** Internal Data Declarations ************************/
@@ -1982,7 +1977,7 @@
     assert(ThisIsAChainRule(ruleForNode));
     assert(nts[0] && ! nts[1]
 	   && "A chain rule should have only one RHS non-terminal!");
-    nextRule = burm_rule(subtreeRoot->getBasicNode()->state, nts[0]);
+    nextRule = burm_rule(subtreeRoot->state, nts[0]);
     nts = burm_nts[nextRule];
     numInstr = GetInstructionsByRule(subtreeRoot, nextRule, nts,target,mvec);
     break;