aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jit/qv4regalloc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jit/qv4regalloc.cpp')
-rw-r--r--src/qml/jit/qv4regalloc.cpp84
1 files changed, 45 insertions, 39 deletions
diff --git a/src/qml/jit/qv4regalloc.cpp b/src/qml/jit/qv4regalloc.cpp
index 82ae60a8f0..c21f52ecd3 100644
--- a/src/qml/jit/qv4regalloc.cpp
+++ b/src/qml/jit/qv4regalloc.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the V4VM module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -174,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);
}
@@ -696,8 +702,8 @@ protected: // IRDecoder
virtual void visitPhi(IR::Phi *s)
{
addDef(s->targetTemp, true);
- for (int i = 0, ei = s->d->incoming.size(); i < ei; ++i) {
- Expr *e = s->d->incoming.at(i);
+ for (int i = 0, ei = s->incoming.size(); i < ei; ++i) {
+ Expr *e = s->incoming.at(i);
if (Temp *t = e->asTemp()) {
// The actual use of an incoming value in a phi node is right before the terminator
// of the other side of the incoming edge.
@@ -815,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;
@@ -867,7 +873,7 @@ private:
{
QVector<Stmt *> newStatements;
- foreach (BasicBlock *bb, _function->basicBlocks()) {
+ for (BasicBlock *bb : _function->basicBlocks()) {
_currentStmt = 0;
QVector<Stmt *> statements = bb->statements();
@@ -887,13 +893,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);
}
@@ -907,7 +913,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;
@@ -915,7 +921,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;
@@ -938,7 +944,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)
@@ -971,15 +977,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;
@@ -1012,21 +1018,21 @@ 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;
if (it->start() == successorStart) {
if (Phi *phi = findDefPhi(it->temp(), successor)) {
isPhiTarget = true;
- Expr *opd = phi->d->incoming[successor->in.indexOf(predecessor)];
+ Expr *opd = phi->incoming[successor->in.indexOf(predecessor)];
if (opd->asConst()) {
moveFrom = opd;
} else {
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)) {
@@ -1041,7 +1047,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)) {
@@ -1186,7 +1192,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 &&
@@ -1298,7 +1304,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;
}
@@ -1393,7 +1399,7 @@ LifeTimeInterval *RegisterAllocator::cloneFixedInterval(int reg, bool isFP, cons
void RegisterAllocator::prepareRanges()
{
LifeTimeInterval ltiWithCalls = createFixedInterval(int(_info->calls().size()));
- foreach (int callPosition, _info->calls())
+ for (int callPosition : _info->calls())
ltiWithCalls.addRange(callPosition, callPosition);
const int regCount = _normalRegisters.size();
@@ -1485,11 +1491,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();
@@ -1917,7 +1923,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;
}