mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 06:24:57 +00:00
More cleanups, preparing to revamp InstrForest to, among other things,
not leak all its allocated memory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@553 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -238,7 +238,7 @@ class InstrForest : private hash_map<const Instruction*, InstructionNode*> {
|
|||||||
hash_set<InstructionNode*> treeRoots;
|
hash_set<InstructionNode*> treeRoots;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void buildTreesForMethod(Method *M);
|
InstrForest(Method *M);
|
||||||
|
|
||||||
inline InstructionNode *getTreeNodeForInstr(Instruction* instr) {
|
inline InstructionNode *getTreeNodeForInstr(Instruction* instr) {
|
||||||
return (*this)[instr];
|
return (*this)[instr];
|
||||||
|
@ -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 *InstrForest::buildTreeForInstruction(Instruction *Inst) {
|
||||||
InstructionNode *treeNode = getTreeNodeForInstr(Inst);
|
InstructionNode *treeNode = getTreeNodeForInstr(Inst);
|
||||||
if (treeNode) {
|
if (treeNode) {
|
||||||
@ -210,8 +205,7 @@ InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
|
|||||||
static InstrTreeNode *fixedChildArray[MAX_CHILD];
|
static InstrTreeNode *fixedChildArray[MAX_CHILD];
|
||||||
InstrTreeNode **childArray =
|
InstrTreeNode **childArray =
|
||||||
(Inst->getNumOperands() > MAX_CHILD)
|
(Inst->getNumOperands() > MAX_CHILD)
|
||||||
? new (InstrTreeNode*)[Inst->getNumOperands()]
|
? new (InstrTreeNode*)[Inst->getNumOperands()] : fixedChildArray;
|
||||||
: fixedChildArray;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Walk the operands of the instruction
|
// Walk the operands of the instruction
|
||||||
@ -309,3 +303,8 @@ InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
|
|||||||
return treeNode;
|
return treeNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InstrForest::InstrForest(Method *M) {
|
||||||
|
for_each(M->inst_begin(), M->inst_end(),
|
||||||
|
bind_obj(this, &InstrForest::buildTreeForInstruction));
|
||||||
|
}
|
||||||
|
@ -31,11 +31,11 @@ enum SelectDebugLevel_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Enable Debug Options to be specified on the command line
|
// 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",
|
"enable instruction selection debugging information",
|
||||||
clEnumValN(Select_NoDebugInfo, "n", "disable debug output"),
|
clEnumValN(Select_NoDebugInfo, "n", "disable debug output"),
|
||||||
clEnumValN(Select_PrintMachineCode, "y", "print generated machine code"),
|
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);
|
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.
|
// Build the instruction trees to be given as inputs to BURG.
|
||||||
//
|
//
|
||||||
InstrForest instrForest;
|
InstrForest instrForest(method);
|
||||||
instrForest.buildTreesForMethod(method);
|
|
||||||
|
|
||||||
if (SelectDebugLevel >= Select_DebugInstTrees)
|
if (SelectDebugLevel >= Select_DebugInstTrees)
|
||||||
{
|
{
|
||||||
|
@ -220,8 +220,6 @@ reg: Constant = 72 (3); /* prefer direct use */
|
|||||||
* This code was taken from sample.gr provided with BURG.
|
* This code was taken from sample.gr provided with BURG.
|
||||||
*-----------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static char rcsid[] = "$Id$";
|
|
||||||
|
|
||||||
void printcover(NODEPTR_TYPE p, int goalnt, int indent) {
|
void printcover(NODEPTR_TYPE p, int goalnt, int indent) {
|
||||||
int eruleno = burm_rule(STATE_LABEL(p), goalnt);
|
int eruleno = burm_rule(STATE_LABEL(p), goalnt);
|
||||||
short *nts = burm_nts[eruleno];
|
short *nts = burm_nts[eruleno];
|
||||||
|
@ -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 *InstrForest::buildTreeForInstruction(Instruction *Inst) {
|
||||||
InstructionNode *treeNode = getTreeNodeForInstr(Inst);
|
InstructionNode *treeNode = getTreeNodeForInstr(Inst);
|
||||||
if (treeNode) {
|
if (treeNode) {
|
||||||
@ -210,8 +205,7 @@ InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
|
|||||||
static InstrTreeNode *fixedChildArray[MAX_CHILD];
|
static InstrTreeNode *fixedChildArray[MAX_CHILD];
|
||||||
InstrTreeNode **childArray =
|
InstrTreeNode **childArray =
|
||||||
(Inst->getNumOperands() > MAX_CHILD)
|
(Inst->getNumOperands() > MAX_CHILD)
|
||||||
? new (InstrTreeNode*)[Inst->getNumOperands()]
|
? new (InstrTreeNode*)[Inst->getNumOperands()] : fixedChildArray;
|
||||||
: fixedChildArray;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Walk the operands of the instruction
|
// Walk the operands of the instruction
|
||||||
@ -309,3 +303,8 @@ InstructionNode *InstrForest::buildTreeForInstruction(Instruction *Inst) {
|
|||||||
return treeNode;
|
return treeNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InstrForest::InstrForest(Method *M) {
|
||||||
|
for_each(M->inst_begin(), M->inst_end(),
|
||||||
|
bind_obj(this, &InstrForest::buildTreeForInstruction));
|
||||||
|
}
|
||||||
|
@ -31,11 +31,11 @@ enum SelectDebugLevel_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Enable Debug Options to be specified on the command line
|
// 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",
|
"enable instruction selection debugging information",
|
||||||
clEnumValN(Select_NoDebugInfo, "n", "disable debug output"),
|
clEnumValN(Select_NoDebugInfo, "n", "disable debug output"),
|
||||||
clEnumValN(Select_PrintMachineCode, "y", "print generated machine code"),
|
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);
|
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.
|
// Build the instruction trees to be given as inputs to BURG.
|
||||||
//
|
//
|
||||||
InstrForest instrForest;
|
InstrForest instrForest(method);
|
||||||
instrForest.buildTreesForMethod(method);
|
|
||||||
|
|
||||||
if (SelectDebugLevel >= Select_DebugInstTrees)
|
if (SelectDebugLevel >= Select_DebugInstTrees)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user