hash_set<InstructionNode*> treeRoots;
public:
- void buildTreesForMethod(Method *M);
+ InstrForest(Method *M);
inline InstructionNode *getTreeNodeForInstr(Instruction* instr) {
return (*this)[instr];
}
-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) {
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
return treeNode;
}
+
+InstrForest::InstrForest(Method *M) {
+ for_each(M->inst_begin(), M->inst_end(),
+ bind_obj(this, &InstrForest::buildTreeForInstruction));
+}
};
// 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);
//
// Build the instruction trees to be given as inputs to BURG.
//
- InstrForest instrForest;
- instrForest.buildTreesForMethod(method);
+ InstrForest instrForest(method);
if (SelectDebugLevel >= Select_DebugInstTrees)
{
* 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];
}
-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) {
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
return treeNode;
}
+
+InstrForest::InstrForest(Method *M) {
+ for_each(M->inst_begin(), M->inst_end(),
+ bind_obj(this, &InstrForest::buildTreeForInstruction));
+}
};
// 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);
//
// Build the instruction trees to be given as inputs to BURG.
//
- InstrForest instrForest;
- instrForest.buildTreesForMethod(method);
+ InstrForest instrForest(method);
if (SelectDebugLevel >= Select_DebugInstTrees)
{