diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-05-23 15:52:08 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-06-24 09:51:10 +0200 |
commit | 8eafef976f2a53b5c05967de8b4fb8f01b8e9e7b (patch) | |
tree | 67e888024b546136de764a11e3592245b927de64 /src/qml/jit/qv4regalloc.cpp | |
parent | 01660fd569f78ce48364e1b9d9df3137f35a9a57 (diff) |
V4 JIT: add IR printer that uses platform register names.
After running register allocation, the IR is printed one last time (when
the environment variable QV4_SHOW_IR is set). This will now use the
platform defined register names, e.g. "ebx" or "d2".
Change-Id: I2f2f4536d1de940a69690056e5165d38fa7910bb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jit/qv4regalloc.cpp')
-rw-r--r-- | src/qml/jit/qv4regalloc.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/qml/jit/qv4regalloc.cpp b/src/qml/jit/qv4regalloc.cpp index cb24db36b9..a673cd308a 100644 --- a/src/qml/jit/qv4regalloc.cpp +++ b/src/qml/jit/qv4regalloc.cpp @@ -95,6 +95,41 @@ protected: *out << ": "; } }; + +class IRPrinterWithRegisters: public IRPrinterWithPositions +{ + const RegisterInformation &_registerInformation; + QHash<int, const RegisterInfo *> _infoForRegister; + +public: + IRPrinterWithRegisters(QTextStream *out, const LifeTimeIntervals::Ptr &intervals, + const RegisterInformation ®isterInformation) + : IRPrinterWithPositions(out, intervals) + , _registerInformation(registerInformation) + { + for (int i = 0, ei = _registerInformation.size(); i != ei; ++i) + _infoForRegister.insert(_registerInformation.at(i).reg<int>(), + &_registerInformation.at(i)); + } + +protected: + void visitTemp(Temp *e) + { + switch (e->kind) { + case Temp::PhysicalRegister: { + const RegisterInfo *ri = _infoForRegister.value(e->index, 0); + if (ri) { + *out << dumpStart(e); + *out << ri->prettyName(); + *out << dumpEnd(e); + break; + } + } + default: + IRPrinterWithPositions::visitTemp(e); + } + } +}; } class RegAllocInfo: public IRDecoder @@ -1237,10 +1272,13 @@ void RegisterAllocator::run(IR::Function *function, const Optimizer &opt) function->tempCount = *std::max_element(_assignedSpillSlots.begin(), _assignedSpillSlots.end()) + 1; - if (DebugRegAlloc) { + if (DebugRegAlloc) qDebug() << "*** Finished regalloc , result:"; + + static bool showCode = !qgetenv("QV4_SHOW_IR").isNull(); + if (showCode) { QTextStream qout(stdout, QIODevice::WriteOnly); - IRPrinterWithPositions(&qout, _lifeTimeIntervals).print(function); + IRPrinterWithRegisters(&qout, _lifeTimeIntervals, _registerInformation).print(function); } } |