mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-03-05 02:49:18 +00:00
Switched to rendering after allocation (but before rewriting) in PBQP.
Updated renderer to use allocation information from VirtRegMap (if available) to render spilled intervals differently. llvm-svn: 108815
This commit is contained in:
parent
71a1a1a937
commit
7be6158391
@ -865,11 +865,10 @@ bool PBQPRegAlloc::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
lis = &getAnalysis<LiveIntervals>();
|
lis = &getAnalysis<LiveIntervals>();
|
||||||
lss = &getAnalysis<LiveStacks>();
|
lss = &getAnalysis<LiveStacks>();
|
||||||
loopInfo = &getAnalysis<MachineLoopInfo>();
|
loopInfo = &getAnalysis<MachineLoopInfo>();
|
||||||
|
RenderMachineFunction *rmf = &getAnalysis<RenderMachineFunction>();
|
||||||
|
|
||||||
vrm = &getAnalysis<VirtRegMap>();
|
vrm = &getAnalysis<VirtRegMap>();
|
||||||
|
|
||||||
RenderMachineFunction *rmf = &getAnalysis<RenderMachineFunction>();
|
|
||||||
rmf->renderMachineFunction("Prior to PBQP register allocation.");
|
|
||||||
|
|
||||||
DEBUG(dbgs() << "PBQP Register Allocating for " << mf->getFunction()->getName() << "\n");
|
DEBUG(dbgs() << "PBQP Register Allocating for " << mf->getFunction()->getName() << "\n");
|
||||||
|
|
||||||
@ -907,6 +906,8 @@ bool PBQPRegAlloc::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// Finalise allocation, allocate empty ranges.
|
// Finalise allocation, allocate empty ranges.
|
||||||
finalizeAlloc();
|
finalizeAlloc();
|
||||||
|
|
||||||
|
rmf->renderMachineFunction("After PBQP register allocation.", vrm);
|
||||||
|
|
||||||
vregIntervalsToAlloc.clear();
|
vregIntervalsToAlloc.clear();
|
||||||
emptyVRegIntervals.clear();
|
emptyVRegIntervals.clear();
|
||||||
li2Node.clear();
|
li2Node.clear();
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include "RenderMachineFunction.h"
|
#include "RenderMachineFunction.h"
|
||||||
|
|
||||||
|
#include "VirtRegMap.h"
|
||||||
|
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
@ -511,6 +513,50 @@ namespace llvm {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RenderMachineFunction::LiveState
|
||||||
|
RenderMachineFunction::getLiveStateAt(const LiveInterval *li,
|
||||||
|
SlotIndex i) const {
|
||||||
|
const MachineInstr *mi = sis->getInstructionFromIndex(i);
|
||||||
|
|
||||||
|
if (li->liveAt(i)) {
|
||||||
|
if (mi == 0) {
|
||||||
|
if (vrm == 0 ||
|
||||||
|
(vrm->getStackSlot(li->reg) == VirtRegMap::NO_STACK_SLOT)) {
|
||||||
|
return AliveReg;
|
||||||
|
} else {
|
||||||
|
return AliveStack;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (i.getSlot() == SlotIndex::DEF &&
|
||||||
|
mi->definesRegister(li->reg, tri)) {
|
||||||
|
return Defined;
|
||||||
|
} else if (i.getSlot() == SlotIndex::USE &&
|
||||||
|
mi->readsRegister(li->reg)) {
|
||||||
|
return Used;
|
||||||
|
} else {
|
||||||
|
if (vrm == 0 ||
|
||||||
|
(vrm->getStackSlot(li->reg) == VirtRegMap::NO_STACK_SLOT)) {
|
||||||
|
return AliveReg;
|
||||||
|
} else {
|
||||||
|
return AliveStack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Dead;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Render a machine instruction.
|
||||||
|
template <typename OStream>
|
||||||
|
void RenderMachineFunction::renderMachineInstr(OStream &os,
|
||||||
|
const MachineInstr *mi) const {
|
||||||
|
std::string s;
|
||||||
|
raw_string_ostream oss(s);
|
||||||
|
oss << *mi;
|
||||||
|
|
||||||
|
os << escapeChars(oss.str());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename OStream, typename T>
|
template <typename OStream, typename T>
|
||||||
void RenderMachineFunction::renderVertical(const std::string &indent,
|
void RenderMachineFunction::renderVertical(const std::string &indent,
|
||||||
OStream &os,
|
OStream &os,
|
||||||
@ -557,7 +603,8 @@ namespace llvm {
|
|||||||
<< indent << " table.code td.l-na { background-color: #ffffff; }\n"
|
<< indent << " table.code td.l-na { background-color: #ffffff; }\n"
|
||||||
<< indent << " table.code td.l-def { background-color: #ff0000; }\n"
|
<< indent << " table.code td.l-def { background-color: #ff0000; }\n"
|
||||||
<< indent << " table.code td.l-use { background-color: #ffff00; }\n"
|
<< indent << " table.code td.l-use { background-color: #ffff00; }\n"
|
||||||
<< indent << " table.code td.l-sa { background-color: #000000; }\n"
|
<< indent << " table.code td.l-sar { background-color: #000000; }\n"
|
||||||
|
<< indent << " table.code td.l-sas { background-color: #770000; }\n"
|
||||||
<< indent << " table.code th { border-width: 0px; "
|
<< indent << " table.code th { border-width: 0px; "
|
||||||
"border-style: solid; }\n"
|
"border-style: solid; }\n"
|
||||||
<< indent << "</style>\n";
|
<< indent << "</style>\n";
|
||||||
@ -663,7 +710,9 @@ namespace llvm {
|
|||||||
if (i == sis->getMBBStartIdx(mbb)) {
|
if (i == sis->getMBBStartIdx(mbb)) {
|
||||||
os << indent << " BB#" << mbb->getNumber() << ": \n";
|
os << indent << " BB#" << mbb->getNumber() << ": \n";
|
||||||
} else if (mi != 0) {
|
} else if (mi != 0) {
|
||||||
os << indent << " " << escapeChars(mi) << "\n";
|
os << indent << " ";
|
||||||
|
renderMachineInstr(os, mi);
|
||||||
|
os << "\n";
|
||||||
} else {
|
} else {
|
||||||
os << indent << " \n";
|
os << indent << " \n";
|
||||||
}
|
}
|
||||||
@ -706,22 +755,13 @@ namespace llvm {
|
|||||||
liItr != liEnd; ++liItr) {
|
liItr != liEnd; ++liItr) {
|
||||||
const LiveInterval *li = *liItr;
|
const LiveInterval *li = *liItr;
|
||||||
os << indent << " <td class=\"";
|
os << indent << " <td class=\"";
|
||||||
if (li->liveAt(i)) {
|
switch (getLiveStateAt(li, i)) {
|
||||||
if (mi == 0) {
|
case Dead: os << "l-na"; break;
|
||||||
os << "l-sa";
|
case Defined: os << "l-def"; break;
|
||||||
} else {
|
case Used: os << "l-use"; break;
|
||||||
if (i.getSlot() == SlotIndex::DEF &&
|
case AliveReg: os << "l-sar"; break;
|
||||||
mi->definesRegister(li->reg, tri)) {
|
case AliveStack: os << "l-sas"; break;
|
||||||
os << "l-def";
|
default: assert(false && "Unrecognised live state."); break;
|
||||||
} else if (i.getSlot() == SlotIndex::USE &&
|
|
||||||
mi->readsRegister(li->reg)) {
|
|
||||||
os << "l-use";
|
|
||||||
} else {
|
|
||||||
os << "l-sa";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
os << "l-na";
|
|
||||||
}
|
}
|
||||||
os << "\"></td>\n";
|
os << "\"></td>\n";
|
||||||
}
|
}
|
||||||
@ -797,10 +837,12 @@ namespace llvm {
|
|||||||
|
|
||||||
void RenderMachineFunction::renderMachineFunction(
|
void RenderMachineFunction::renderMachineFunction(
|
||||||
const char *renderContextStr,
|
const char *renderContextStr,
|
||||||
|
const VirtRegMap *vrm,
|
||||||
const char *renderSuffix) {
|
const char *renderSuffix) {
|
||||||
if (!ro.shouldRenderCurrentMachineFunction())
|
if (!ro.shouldRenderCurrentMachineFunction())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this->vrm = vrm;
|
||||||
trei.reset();
|
trei.reset();
|
||||||
|
|
||||||
std::string rpFileName(mf->getFunction()->getName().str() +
|
std::string rpFileName(mf->getFunction()->getName().str() +
|
||||||
@ -815,20 +857,8 @@ namespace llvm {
|
|||||||
ro.resetRenderSpecificOptions();
|
ro.resetRenderSpecificOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderMachineFunction::setupRenderingOptions() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string RenderMachineFunction::escapeChars(const std::string &s) const {
|
std::string RenderMachineFunction::escapeChars(const std::string &s) const {
|
||||||
return escapeChars(s.begin(), s.end());
|
return escapeChars(s.begin(), s.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RenderMachineFunction::escapeChars(const MachineInstr *mi) const {
|
|
||||||
std::string s;
|
|
||||||
raw_string_ostream os(s);
|
|
||||||
os << *mi;
|
|
||||||
std::string s2 = os.str();
|
|
||||||
return escapeChars(s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace llvm {
|
|||||||
class MachineRegisterInfo;
|
class MachineRegisterInfo;
|
||||||
class TargetRegisterClass;
|
class TargetRegisterClass;
|
||||||
class TargetRegisterInfo;
|
class TargetRegisterInfo;
|
||||||
|
class VirtRegMap;
|
||||||
|
|
||||||
/// \brief Provide extra information about the physical and virtual registers
|
/// \brief Provide extra information about the physical and virtual registers
|
||||||
/// in the function being compiled.
|
/// in the function being compiled.
|
||||||
@ -212,10 +212,14 @@ namespace llvm {
|
|||||||
/// codegen pipeline) this function was rendered
|
/// codegen pipeline) this function was rendered
|
||||||
/// from. Set it to something like
|
/// from. Set it to something like
|
||||||
/// "Pre-register-allocation".
|
/// "Pre-register-allocation".
|
||||||
|
/// @param vrm If non-null the VRM will be queried to determine
|
||||||
|
/// whether a virtual register was allocated to a
|
||||||
|
/// physical register or spilled.
|
||||||
/// @param renderFilePrefix This string will be appended to the function
|
/// @param renderFilePrefix This string will be appended to the function
|
||||||
/// name (before the output file suffix) to enable
|
/// name (before the output file suffix) to enable
|
||||||
/// multiple renderings from the same function.
|
/// multiple renderings from the same function.
|
||||||
void renderMachineFunction(const char *renderContextStr,
|
void renderMachineFunction(const char *renderContextStr,
|
||||||
|
const VirtRegMap *vrm = 0,
|
||||||
const char *renderSuffix = 0);
|
const char *renderSuffix = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -227,19 +231,26 @@ namespace llvm {
|
|||||||
const TargetRegisterInfo *tri;
|
const TargetRegisterInfo *tri;
|
||||||
LiveIntervals *lis;
|
LiveIntervals *lis;
|
||||||
SlotIndexes *sis;
|
SlotIndexes *sis;
|
||||||
|
const VirtRegMap *vrm;
|
||||||
|
|
||||||
TargetRegisterExtraInfo trei;
|
TargetRegisterExtraInfo trei;
|
||||||
MFRenderingOptions ro;
|
MFRenderingOptions ro;
|
||||||
|
|
||||||
// ---------- Utility functions ----------
|
// Utilities.
|
||||||
|
typedef enum { Dead, Defined, Used, AliveReg, AliveStack } LiveState;
|
||||||
|
|
||||||
void setupRenderingOptions();
|
LiveState getLiveStateAt(const LiveInterval *li, SlotIndex i) const;
|
||||||
|
|
||||||
// ---------- Rendering methods ----------
|
// ---------- Rendering methods ----------
|
||||||
|
|
||||||
template <typename Iterator>
|
template <typename Iterator>
|
||||||
std::string escapeChars(Iterator sBegin, Iterator sEnd) const;
|
std::string escapeChars(Iterator sBegin, Iterator sEnd) const;
|
||||||
|
|
||||||
|
/// \brief Render a machine instruction.
|
||||||
|
template <typename OStream>
|
||||||
|
void renderMachineInstr(OStream &os,
|
||||||
|
const MachineInstr *mi) const;
|
||||||
|
|
||||||
/// \brief Render vertical text.
|
/// \brief Render vertical text.
|
||||||
template <typename OStream, typename T>
|
template <typename OStream, typename T>
|
||||||
void renderVertical(const std::string &indent,
|
void renderVertical(const std::string &indent,
|
||||||
@ -282,9 +293,6 @@ namespace llvm {
|
|||||||
const char * const renderContextStr) const;
|
const char * const renderContextStr) const;
|
||||||
|
|
||||||
std::string escapeChars(const std::string &s) const;
|
std::string escapeChars(const std::string &s) const;
|
||||||
|
|
||||||
std::string escapeChars(const MachineInstr *mi) const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user