diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-03-21 10:56:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-15 15:31:23 +0200 |
commit | 377aeea46cb90f84e5a0e867e5f68cd9f89f56b1 (patch) | |
tree | 6e5990fe8b64024c9e943693897d58877f9e5888 /src/qml/jit/qv4regalloc.cpp | |
parent | 63f757faea7008e478e0a1edea4f0ae79aaba5f7 (diff) |
V4 IR: clean up basic-block management and statement access.
BasicBlocks have an index property which points to the index of that
basic block in the container array in Function. This property can be
used to store calculated information about basic blocks in a vector,
where the vector index corresponds to the basic block index. This is
a lot cheaper than storing any information in a
QHash<BasicBlock *, ....>.
However, this numbering requires that no re-ordering or deletion of
blocks happens. This change cleans up all that handling which was
scattered over a number of places.
Change-Id: I337abd39c030b9d30c82b7bbcf2ba89e50a08e63
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jit/qv4regalloc.cpp')
-rw-r--r-- | src/qml/jit/qv4regalloc.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/qml/jit/qv4regalloc.cpp b/src/qml/jit/qv4regalloc.cpp index 506fd8df6d..a42408890b 100644 --- a/src/qml/jit/qv4regalloc.cpp +++ b/src/qml/jit/qv4regalloc.cpp @@ -97,8 +97,8 @@ public: void collect(IR::Function *function) { - foreach (BasicBlock *bb, function->basicBlocks) { - foreach (Stmt *s, bb->statements) { + foreach (BasicBlock *bb, function->basicBlocks()) { + foreach (Stmt *s, bb->statements()) { Q_ASSERT(s->id > 0); _currentStmt = s; s->accept(this); @@ -705,8 +705,8 @@ public: for (int i = 0, ei = _intervals.size(); i != ei; ++i) _unprocessed[i] = &_intervals[i]; - _liveAtStart.reserve(function->basicBlocks.size()); - _liveAtEnd.reserve(function->basicBlocks.size()); + _liveAtStart.reserve(function->basicBlockCount()); + _liveAtEnd.reserve(function->basicBlockCount()); } void run() { @@ -718,13 +718,14 @@ public: private: void renumber() { - foreach (BasicBlock *bb, _function->basicBlocks) { + foreach (BasicBlock *bb, _function->basicBlocks()) { + QVector<Stmt *> statements = bb->statements(); QVector<Stmt *> newStatements; - newStatements.reserve(bb->statements.size() + 7); + newStatements.reserve(bb->statements().size() + 7); bool seenFirstNonPhiStmt = false; - for (int i = 0, ei = bb->statements.size(); i != ei; ++i) { - _currentStmt = bb->statements[i]; + for (int i = 0, ei = statements.size(); i != ei; ++i) { + _currentStmt = statements[i]; _loads.clear(); _stores.clear(); addNewIntervals(); @@ -766,7 +767,7 @@ private: } #endif - bb->statements = newStatements; + bb->setStatements(newStatements); } } @@ -833,7 +834,7 @@ private: void resolve() { - foreach (BasicBlock *bb, _function->basicBlocks) { + foreach (BasicBlock *bb, _function->basicBlocks()) { foreach (BasicBlock *bbOut, bb->out) resolveEdge(bb, bbOut); } @@ -848,11 +849,11 @@ private: MoveMapping mapping; - const int predecessorEnd = predecessor->statements.last()->id; // the terminator is always last and always has an id set... + const int predecessorEnd = predecessor->terminator()->id; // the terminator is always last and always has an id set... Q_ASSERT(predecessorEnd > 0); // ... but we verify it anyway for good measure. int successorStart = -1; - foreach (Stmt *s, successor->statements) { + foreach (Stmt *s, successor->statements()) { if (s && s->id > 0) { successorStart = s->id; break; @@ -869,7 +870,7 @@ private: Expr *moveFrom = 0; if (it->start() == successorStart) { - foreach (Stmt *s, successor->statements) { + foreach (Stmt *s, successor->statements()) { if (!s || s->id < 1) continue; if (Phi *phi = s->asPhi()) { @@ -925,14 +926,14 @@ private: Q_ASSERT(!_info->isPhiTarget(it->temp()) || it->isSplitFromInterval() || lifeTimeHole); if (_info->def(it->temp()) != successorStart && !it->isSplitFromInterval()) { - const int successorEnd = successor->statements.last()->id; + const int successorEnd = successor->terminator()->id; const int idx = successor->in.indexOf(predecessor); foreach (const Use &use, _info->uses(it->temp())) { if (use.pos == static_cast<unsigned>(successorStart)) { // only check the current edge, not all other possible ones. This is // important for phi nodes: they have uses that are only valid when // coming in over a specific edge. - foreach (Stmt *s, successor->statements) { + foreach (Stmt *s, successor->statements()) { if (Phi *phi = s->asPhi()) { Q_ASSERT(it->temp().index != phi->targetTemp->index); Q_ASSERT(phi->d->incoming[idx]->asTemp() == 0 |