namespace nv50_ir {
-Function::Function(Program *p, const char *fnName)
+Function::Function(Program *p, const char *fnName, uint32_t label)
: call(this),
+ label(label),
name(fnName),
prog(p)
{
Function::~Function()
{
+ prog->del(this, id);
+
if (domTree)
delete domTree;
if (bbArray)
unsigned int
Function::orderInstructions(ArrayList &result)
{
- Iterator *iter;
- for (iter = cfg.iteratorCFG(); !iter->end(); iter->next()) {
+ for (IteratorRef it = cfg.iteratorCFG(); !it->end(); it->next()) {
BasicBlock *bb =
- BasicBlock::get(reinterpret_cast<Graph::Node *>(iter->get()));
+ BasicBlock::get(reinterpret_cast<Graph::Node *>(it->get()));
for (Instruction *insn = bb->getFirst(); insn; insn = insn->next)
result.insert(insn, insn->serial);
}
- cfg.putIterator(iter);
return result.getSize();
}
bool
Pass::doRun(Program *prog, bool ordered, bool skipPhi)
{
- for (ArrayList::Iterator fi = prog->allFuncs.iterator();
- !fi.end(); fi.next()) {
- Function *fn = reinterpret_cast<Function *>(fi.get());
- if (!doRun(fn, ordered, skipPhi))
+ for (IteratorRef it = prog->calls.iteratorDFS(false);
+ !it->end(); it->next()) {
+ Graph::Node *n = reinterpret_cast<Graph::Node *>(it->get());
+ if (!doRun(Function::get(n), ordered, skipPhi))
return false;
}
return !err;
bool
Pass::doRun(Function *func, bool ordered, bool skipPhi)
{
- Iterator *bbIter;
+ IteratorRef bbIter;
BasicBlock *bb;
Instruction *insn, *next;
break;
}
}
- func->cfg.putIterator(bbIter);
+
return !err;
}
fprintf(out, "digraph G {\n");
- Iterator *iter;
- for (iter = cfg.iteratorDFS(); !iter->end(); iter->next()) {
+ for (IteratorRef it = cfg.iteratorDFS(); !it->end(); it->next()) {
BasicBlock *bb = BasicBlock::get(
- reinterpret_cast<Graph::Node *>(iter->get()));
+ reinterpret_cast<Graph::Node *>(it->get()));
int idA = bb->getId();
for (Graph::EdgeIterator ei = bb->cfg.outgoing(); !ei.end(); ei.next()) {
int idB = BasicBlock::get(ei.getNode())->getId();
}
}
}
- cfg.putIterator(iter);
fprintf(out, "}\n");
fclose(out);