From: Francisco Jerez Date: Mon, 9 Apr 2012 19:18:31 +0000 (+0200) Subject: nv50/ir: Scan program functions in DFS-postorder. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d32ebb8c304725fa6bb7ec2d3d40ce828c713917;p=mesa.git 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. --- diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp index cbab1ec1406..357d6d9e2cc 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp @@ -977,6 +977,7 @@ Program::Program(Type type, Target *arch) maxGPR = -1; main = new Function(this, "MAIN"); + calls.insert(&main->call); dbgFlags = 0; } diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.h b/src/gallium/drivers/nv50/codegen/nv50_ir.h index 74692d8251a..e803a8b7b7a 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir.h @@ -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; } diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp index 991341b3f86..5a76558863c 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp @@ -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(fi.get()); - if (!doRun(fn, ordered, skipPhi)) + for (IteratorRef it = prog->calls.iteratorDFS(false); + !it->end(); it->next()) { + Graph::Node *n = reinterpret_cast(it->get()); + if (!doRun(Function::get(n), ordered, skipPhi)) return false; } return !err; diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h b/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h index 4aec6ea6723..b06f217ba30 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h @@ -358,6 +358,12 @@ BasicBlock *BasicBlock::get(Graph::Node *node) return reinterpret_cast(node->data); } +Function *Function::get(Graph::Node *node) +{ + assert(node); + return reinterpret_cast(node->data); +} + LValue *Function::getLValue(int id) { assert((unsigned int)id < (unsigned int)allLValues.getSize()); diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp index 43c29d5926a..a91a088353e 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp @@ -724,9 +724,9 @@ RegAlloc::linearScan() bool RegAlloc::exec() { - for (ArrayList::Iterator fi = prog->allFuncs.iterator(); - !fi.end(); fi.next()) { - func = reinterpret_cast(fi.get()); + for (IteratorRef it = prog->calls.iteratorDFS(false); + !it->end(); it->next()) { + func = Function::get(reinterpret_cast(it->get())); if (!execFunc()) return false; }