nv50/ir: Scan program functions in DFS-postorder.
The reason is that several passes (regalloc, function argument binding, inlining) are going to require the callees of a function to be processed before the caller.
This commit is contained in:
parent
78de8c8ab5
commit
d32ebb8c30
|
@ -977,6 +977,7 @@ Program::Program(Type type, Target *arch)
|
|||
maxGPR = -1;
|
||||
|
||||
main = new Function(this, "MAIN");
|
||||
calls.insert(&main->call);
|
||||
|
||||
dbgFlags = 0;
|
||||
}
|
||||
|
|
|
@ -919,6 +919,8 @@ public:
|
|||
Function(Program *, const char *name);
|
||||
~Function();
|
||||
|
||||
static inline Function *get(Graph::Node *node);
|
||||
|
||||
inline Program *getProgram() const { return prog; }
|
||||
inline const char *getName() const { return name; }
|
||||
inline int getId() const { return id; }
|
||||
|
|
|
@ -444,10 +444,10 @@ Pass::run(Program *prog, bool ordered, bool skipPhi)
|
|||
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;
|
||||
|
|
|
@ -358,6 +358,12 @@ BasicBlock *BasicBlock::get(Graph::Node *node)
|
|||
return reinterpret_cast<BasicBlock *>(node->data);
|
||||
}
|
||||
|
||||
Function *Function::get(Graph::Node *node)
|
||||
{
|
||||
assert(node);
|
||||
return reinterpret_cast<Function *>(node->data);
|
||||
}
|
||||
|
||||
LValue *Function::getLValue(int id)
|
||||
{
|
||||
assert((unsigned int)id < (unsigned int)allLValues.getSize());
|
||||
|
|
|
@ -724,9 +724,9 @@ RegAlloc::linearScan()
|
|||
bool
|
||||
RegAlloc::exec()
|
||||
{
|
||||
for (ArrayList::Iterator fi = prog->allFuncs.iterator();
|
||||
!fi.end(); fi.next()) {
|
||||
func = reinterpret_cast<Function *>(fi.get());
|
||||
for (IteratorRef it = prog->calls.iteratorDFS(false);
|
||||
!it->end(); it->next()) {
|
||||
func = Function::get(reinterpret_cast<Graph::Node *>(it->get()));
|
||||
if (!execFunc())
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue