maxGPR = -1;
main = new Function(this, "MAIN");
+ calls.insert(&main->call);
dbgFlags = 0;
}
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; }
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;
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());
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;
}