summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2012-04-09 21:18:31 +0200
committerChristoph Bumiller <[email protected]>2012-04-14 21:54:01 +0200
commitd32ebb8c304725fa6bb7ec2d3d40ce828c713917 (patch)
treeb519847487de56fa05b7de9f3bd5af2c2972ae6f /src
parent78de8c8ab54c50c96bc3fae2fe0976054e0acd14 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir.cpp1
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir.h2
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp8
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h6
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp6
5 files changed, 16 insertions, 7 deletions
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<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;
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<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());
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<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;
}