diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2016-02-23 13:42:47 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2016-03-03 13:09:18 +0000 |
commit | c1c9beadde2b017c37751bb94d9e679f38fd0d25 (patch) | |
tree | cdbe18b9c3fa74dc993f7a0de089694de5e2f9ac /src/qml/jit/qv4regalloc.cpp | |
parent | ba1491488e02dfb4de734b4f2755c4899db0a815 (diff) |
V4: Replace foreach loops with range-based for loops.
Also replaced some QVectors with std::vectors so calls to clear() will
re-use the storage instead of re-allocating it.
Change-Id: Ibe7d8509af8d264ea93376288cec15fec7c38f70
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/qml/jit/qv4regalloc.cpp')
-rw-r--r-- | src/qml/jit/qv4regalloc.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/qml/jit/qv4regalloc.cpp b/src/qml/jit/qv4regalloc.cpp index a6e085a913..6741529245 100644 --- a/src/qml/jit/qv4regalloc.cpp +++ b/src/qml/jit/qv4regalloc.cpp @@ -180,9 +180,9 @@ public: _calls.reserve(function->statementCount() / 3); _hints.resize(function->tempCount); - foreach (BasicBlock *bb, function->basicBlocks()) { + for (BasicBlock *bb : function->basicBlocks()) { _currentBB = bb; - foreach (Stmt *s, bb->statements()) { + for (Stmt *s : bb->statements()) { _currentStmt = s; s->accept(this); } @@ -821,8 +821,8 @@ class ResolutionPhase: protected StmtVisitor, protected ExprVisitor { const QVector<const RegisterInfo *> &_fpRegs; Stmt *_currentStmt; - QVector<Move *> _loads; - QVector<Move *> _stores; + std::vector<Move *> _loads; + std::vector<Move *> _stores; QHash<BasicBlock *, QList<const LifeTimeInterval *> > _liveAtStart; QHash<BasicBlock *, QList<const LifeTimeInterval *> > _liveAtEnd; @@ -872,7 +872,7 @@ private: { QVector<Stmt *> newStatements; - foreach (BasicBlock *bb, _function->basicBlocks()) { + for (BasicBlock *bb : _function->basicBlocks()) { _currentStmt = 0; QVector<Stmt *> statements = bb->statements(); @@ -892,13 +892,13 @@ private: else addNewIntervals(defPosition(_currentStmt)); _currentStmt->accept(this); - foreach (Move *load, _loads) + for (Move *load : _loads) newStatements.append(load); if (_currentStmt->asPhi()) newStatements.prepend(_currentStmt); else newStatements.append(_currentStmt); - foreach (Move *store, _stores) + for (Move *store : _stores) newStatements.append(store); } @@ -912,7 +912,7 @@ private: os << "Intervals live at the start of L" << bb->index() << ":" << endl; if (_liveAtStart[bb].isEmpty()) os << "\t(none)" << endl; - foreach (const LifeTimeInterval *i, _liveAtStart[bb]) { + for (const LifeTimeInterval *i : _liveAtStart.value(bb)) { os << "\t"; i->dump(os); os << endl; @@ -920,7 +920,7 @@ private: os << "Intervals live at the end of L" << bb->index() << ":" << endl; if (_liveAtEnd[bb].isEmpty()) os << "\t(none)" << endl; - foreach (const LifeTimeInterval *i, _liveAtEnd[bb]) { + for (const LifeTimeInterval *i : _liveAtEnd.value(bb)) { os << "\t"; i->dump(os); os << endl; @@ -943,7 +943,7 @@ private: Q_ASSERT(pReg); int spillSlot = _assignedSpillSlots[i->temp().index]; if (spillSlot != RegisterAllocator::InvalidSpillSlot) - _stores.append(generateSpill(spillSlot, i->temp().type, pReg->reg<int>())); + _stores.push_back(generateSpill(spillSlot, i->temp().type, pReg->reg<int>())); } void addNewIntervals(int position) @@ -976,15 +976,15 @@ private: void resolve() { - foreach (BasicBlock *bb, _function->basicBlocks()) { - foreach (BasicBlock *bbOut, bb->out) + for (BasicBlock *bb : _function->basicBlocks()) { + for (BasicBlock *bbOut : bb->out) resolveEdge(bb, bbOut); } } Phi *findDefPhi(const Temp &t, BasicBlock *bb) const { - foreach (Stmt *s, bb->statements()) { + for (Stmt *s : bb->statements()) { Phi *phi = s->asPhi(); if (!phi) return 0; @@ -1017,7 +1017,7 @@ private: int successorStart = _intervals->startPosition(successor); Q_ASSERT(successorStart > 0); - foreach (const LifeTimeInterval *it, _liveAtStart[successor]) { + for (const LifeTimeInterval *it : _liveAtStart.value(successor)) { bool isPhiTarget = false; Expr *moveFrom = 0; @@ -1031,7 +1031,7 @@ private: Temp *t = opd->asTemp(); Q_ASSERT(t); - foreach (const LifeTimeInterval *it2, _liveAtEnd[predecessor]) { + for (const LifeTimeInterval *it2 : _liveAtEnd.value(predecessor)) { if (it2->temp() == *t && it2->reg() != LifeTimeInterval::InvalidRegister && it2->covers(predecessorEnd)) { @@ -1046,7 +1046,7 @@ private: } } } else { - foreach (const LifeTimeInterval *predIt, _liveAtEnd[predecessor]) { + for (const LifeTimeInterval *predIt : _liveAtEnd.value(predecessor)) { if (predIt->temp() == it->temp()) { if (predIt->reg() != LifeTimeInterval::InvalidRegister && predIt->covers(predecessorEnd)) { @@ -1191,7 +1191,7 @@ protected: Q_ASSERT(i->isSplitFromInterval()); const RegisterInfo *pReg = platformRegister(*i); Q_ASSERT(pReg); - _loads.append(generateUnspill(i->temp(), pReg->reg<int>())); + _loads.push_back(generateUnspill(i->temp(), pReg->reg<int>())); } if (i->reg() != LifeTimeInterval::InvalidRegister && @@ -1303,7 +1303,7 @@ void RegisterAllocator::run(IR::Function *function, const Optimizer &opt) qout << "Ranges:" << endl; QVector<LifeTimeInterval *> intervals = _unhandled; std::reverse(intervals.begin(), intervals.end()); - foreach (const LifeTimeInterval *r, intervals) { + for (const LifeTimeInterval *r : qAsConst(intervals)) { r->dump(qout); qout << endl; } @@ -1490,11 +1490,11 @@ void RegisterAllocator::linearScan() } } - foreach (LifeTimeInterval *r, _active) + for (LifeTimeInterval *r : qAsConst(_active)) if (!r->isFixedInterval()) _handled.append(r); _active.clear(); - foreach (LifeTimeInterval *r, _inactive) + for (LifeTimeInterval *r : qAsConst(_inactive)) if (!r->isFixedInterval()) _handled.append(r); _inactive.clear(); @@ -1922,7 +1922,7 @@ void RegisterAllocator::dump(IR::Function *function) const qout << "Ranges:" << endl; QVector<LifeTimeInterval *> handled = _handled; std::sort(handled.begin(), handled.end(), LifeTimeInterval::lessThanForTemp); - foreach (const LifeTimeInterval *r, handled) { + for (const LifeTimeInterval *r : qAsConst(handled)) { r->dump(qout); qout << endl; } |