diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-05-07 11:02:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-28 15:34:45 +0200 |
commit | 4a2c3f319485dd1df008ec2d7e262d860952b3df (patch) | |
tree | d96433656c342855f0f98f24b51fd7723c73cfb1 /src/qml/compiler/qv4jsir.cpp | |
parent | cc1929da585664aa16c53e5c0cd624fe5e699345 (diff) |
V4 IR: make statement numbering fixed and clean up statement worklists.
Every statement in the IR now gets a fixed unique number. This number
can be used to store statements or information for a statement into an
array where the number is used as an index. This removes the need for
many hashes.
In the process of changing the code the two statement worklists in the
optimizer are merged into one. A single instance can be (and is) re-used
by the various algorithms.
Change-Id: I8f49ec7b1df79cf6914c5747f5d2c994dad110b2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4jsir.cpp')
-rw-r--r-- | src/qml/compiler/qv4jsir.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp index 80528f1007..8f2b2ca9e1 100644 --- a/src/qml/compiler/qv4jsir.cpp +++ b/src/qml/compiler/qv4jsir.cpp @@ -411,6 +411,7 @@ Function::Function(Module *module, Function *outer, const QString &name) , line(-1) , column(-1) , _allBasicBlocks(0) + , _statementCount(0) { this->name = newString(name); _basicBlocks.reserve(8); @@ -493,6 +494,21 @@ void Function::renumberBasicBlocks() basicBlock(i)->changeIndex(i); } +void Function::renumberForLifeRanges() +{ + //### TODO: check if this can be done in a more elegant way. + + int id = 0; + foreach (BasicBlock *bb, basicBlocks()) { + foreach (Stmt *s, bb->statements()) { + if (s->asPhi()) + s->_id = id + 1; + else + s->_id = ++id; + } + } +} + BasicBlock::~BasicBlock() { foreach (Stmt *s, _statements) @@ -665,7 +681,7 @@ Stmt *BasicBlock::EXP(Expr *expr) if (isTerminated()) return 0; - Exp *s = function->New<Exp>(); + Exp *s = function->NewStmt<Exp>(); s->init(expr); appendStatement(s); return s; @@ -677,7 +693,7 @@ Stmt *BasicBlock::MOVE(Expr *target, Expr *source) if (isTerminated()) return 0; - Move *s = function->New<Move>(); + Move *s = function->NewStmt<Move>(); s->init(target, source); appendStatement(s); return s; @@ -689,7 +705,7 @@ Stmt *BasicBlock::JUMP(BasicBlock *target) if (isTerminated()) return 0; - Jump *s = function->New<Jump>(); + Jump *s = function->NewStmt<Jump>(); s->init(target); appendStatement(s); @@ -713,7 +729,7 @@ Stmt *BasicBlock::CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse) return JUMP(iftrue); } - CJump *s = function->New<CJump>(); + CJump *s = function->NewStmt<CJump>(); s->init(cond, iftrue, iffalse); appendStatement(s); @@ -738,7 +754,7 @@ Stmt *BasicBlock::RET(Temp *expr) if (isTerminated()) return 0; - Ret *s = function->New<Ret>(); + Ret *s = function->NewStmt<Ret>(); s->init(expr); appendStatement(s); return s; @@ -955,8 +971,8 @@ void IRPrinter::print(BasicBlock *bb) QTextStream os(&buf); QTextStream *prevOut = &os; std::swap(out, prevOut); - if (s->id > 0) - *out << s->id << ": "; + if (s->id() >= 0) + *out << s->id() << ": "; s->accept(this); if (s->location.isValid()) { out->flush(); |