Print register in LiveInterval::print()

llvm-svn: 192398
This commit is contained in:
Matthias Braun 2013-10-10 21:29:05 +00:00
parent 34e1be9451
commit f6fe6bfffe
7 changed files with 28 additions and 23 deletions

View File

@ -527,6 +527,8 @@ namespace llvm {
/// or stack slot. /// or stack slot.
class LiveInterval : public LiveRange { class LiveInterval : public LiveRange {
public: public:
typedef LiveRange super;
const unsigned reg; // the register or stack slot of this interval. const unsigned reg; // the register or stack slot of this interval.
float weight; // weight of this interval float weight; // weight of this interval
@ -554,6 +556,9 @@ namespace llvm {
(thisIndex == otherIndex && reg < other.reg); (thisIndex == otherIndex && reg < other.reg);
} }
void print(raw_ostream &OS) const;
void dump() const;
private: private:
LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION; LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION;

View File

@ -1337,7 +1337,7 @@ void InlineSpiller::spill(LiveRangeEdit &edit) {
DEBUG(dbgs() << "Inline spilling " DEBUG(dbgs() << "Inline spilling "
<< MRI.getRegClass(edit.getReg())->getName() << MRI.getRegClass(edit.getReg())->getName()
<< ':' << PrintReg(edit.getReg()) << ' ' << edit.getParent() << ':' << edit.getParent()
<< "\nFrom original " << PrintReg(Original) << '\n'); << "\nFrom original " << PrintReg(Original) << '\n');
assert(edit.getParent().isSpillable() && assert(edit.getParent().isSpillable() &&
"Attempting to spill already spilled value."); "Attempting to spill already spilled value.");

View File

@ -617,10 +617,19 @@ void LiveRange::print(raw_ostream &OS) const {
} }
} }
void LiveInterval::print(raw_ostream &OS) const {
OS << PrintReg(reg) << ' ';
super::print(OS);
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void LiveRange::dump() const { void LiveRange::dump() const {
dbgs() << *this << "\n"; dbgs() << *this << "\n";
} }
void LiveInterval::dump() const {
dbgs() << *this << "\n";
}
#endif #endif
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -141,13 +141,13 @@ void LiveIntervals::print(raw_ostream &OS, const Module* ) const {
// Dump the regunits. // Dump the regunits.
for (unsigned i = 0, e = RegUnitRanges.size(); i != e; ++i) for (unsigned i = 0, e = RegUnitRanges.size(); i != e; ++i)
if (LiveRange *LR = RegUnitRanges[i]) if (LiveRange *LR = RegUnitRanges[i])
OS << PrintRegUnit(i, TRI) << " = " << *LR << '\n'; OS << PrintRegUnit(i, TRI) << ' ' << *LR << '\n';
// Dump the virtregs. // Dump the virtregs.
for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) { for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
unsigned Reg = TargetRegisterInfo::index2VirtReg(i); unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
if (hasInterval(Reg)) if (hasInterval(Reg))
OS << PrintReg(Reg) << " = " << getInterval(Reg) << '\n'; OS << getInterval(Reg) << '\n';
} }
OS << "RegMasks:"; OS << "RegMasks:";

View File

@ -419,23 +419,13 @@ void MachineVerifier::report(const char *msg,
void MachineVerifier::report(const char *msg, const MachineFunction *MF, void MachineVerifier::report(const char *msg, const MachineFunction *MF,
const LiveInterval &LI) { const LiveInterval &LI) {
report(msg, MF); report(msg, MF);
*OS << "- interval: "; *OS << "- interval: " << LI << '\n';
if (TargetRegisterInfo::isVirtualRegister(LI.reg))
*OS << PrintReg(LI.reg, TRI);
else
*OS << PrintRegUnit(LI.reg, TRI);
*OS << ' ' << LI << '\n';
} }
void MachineVerifier::report(const char *msg, const MachineBasicBlock *MBB, void MachineVerifier::report(const char *msg, const MachineBasicBlock *MBB,
const LiveInterval &LI) { const LiveInterval &LI) {
report(msg, MBB); report(msg, MBB);
*OS << "- interval: "; *OS << "- interval: " << LI << '\n';
if (TargetRegisterInfo::isVirtualRegister(LI.reg))
*OS << PrintReg(LI.reg, TRI);
else
*OS << PrintRegUnit(LI.reg, TRI);
*OS << ' ' << LI << '\n';
} }
void MachineVerifier::report(const char *msg, const MachineBasicBlock *MBB, void MachineVerifier::report(const char *msg, const MachineBasicBlock *MBB,

View File

@ -99,7 +99,7 @@ void RegAllocBase::allocatePhysRegs() {
// result from splitting. // result from splitting.
DEBUG(dbgs() << "\nselectOrSplit " DEBUG(dbgs() << "\nselectOrSplit "
<< MRI->getRegClass(VirtReg->reg)->getName() << MRI->getRegClass(VirtReg->reg)->getName()
<< ':' << PrintReg(VirtReg->reg) << ' ' << *VirtReg << '\n'); << ':' << *VirtReg << '\n');
typedef SmallVector<unsigned, 4> VirtRegVec; typedef SmallVector<unsigned, 4> VirtRegVec;
VirtRegVec SplitVRegs; VirtRegVec SplitVRegs;
unsigned AvailablePhysReg = selectOrSplit(*VirtReg, SplitVRegs); unsigned AvailablePhysReg = selectOrSplit(*VirtReg, SplitVRegs);

View File

@ -1156,10 +1156,12 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
TRI->UpdateRegAllocHint(CP.getSrcReg(), CP.getDstReg(), *MF); TRI->UpdateRegAllocHint(CP.getSrcReg(), CP.getDstReg(), *MF);
DEBUG({ DEBUG({
dbgs() << "\tJoined. Result = " << PrintReg(CP.getDstReg(), TRI); dbgs() << "\tJoined. Result = ";
if (!CP.isPhys()) if (CP.isPhys())
dbgs() << PrintReg(CP.getDstReg(), TRI);
else
dbgs() << LIS->getInterval(CP.getDstReg()); dbgs() << LIS->getInterval(CP.getDstReg());
dbgs() << '\n'; dbgs() << '\n';
}); });
++numJoins; ++numJoins;
@ -1171,8 +1173,7 @@ bool RegisterCoalescer::joinReservedPhysReg(CoalescerPair &CP) {
assert(CP.isPhys() && "Must be a physreg copy"); assert(CP.isPhys() && "Must be a physreg copy");
assert(MRI->isReserved(CP.getDstReg()) && "Not a reserved register"); assert(MRI->isReserved(CP.getDstReg()) && "Not a reserved register");
LiveInterval &RHS = LIS->getInterval(CP.getSrcReg()); LiveInterval &RHS = LIS->getInterval(CP.getSrcReg());
DEBUG(dbgs() << "\t\tRHS = " << PrintReg(CP.getSrcReg()) << ' ' << RHS DEBUG(dbgs() << "\t\tRHS = " << RHS << '\n');
<< '\n');
assert(CP.isFlipped() && RHS.containsOneValue() && assert(CP.isFlipped() && RHS.containsOneValue() &&
"Invalid join with reserved register"); "Invalid join with reserved register");
@ -1968,8 +1969,8 @@ bool RegisterCoalescer::joinVirtRegs(CoalescerPair &CP) {
JoinVals RHSVals(RHS, CP.getSrcIdx(), NewVNInfo, CP, LIS, TRI); JoinVals RHSVals(RHS, CP.getSrcIdx(), NewVNInfo, CP, LIS, TRI);
JoinVals LHSVals(LHS, CP.getDstIdx(), NewVNInfo, CP, LIS, TRI); JoinVals LHSVals(LHS, CP.getDstIdx(), NewVNInfo, CP, LIS, TRI);
DEBUG(dbgs() << "\t\tRHS = " << PrintReg(CP.getSrcReg()) << ' ' << RHS DEBUG(dbgs() << "\t\tRHS = " << RHS
<< "\n\t\tLHS = " << PrintReg(CP.getDstReg()) << ' ' << LHS << "\n\t\tLHS = " << LHS
<< '\n'); << '\n');
// First compute NewVNInfo and the simple value mappings. // First compute NewVNInfo and the simple value mappings.