Simplify LiveInterval::print().

Don't print out the register number and spill weight, making the TRI
argument unnecessary.

This allows callers to interpret the reg field. It can currently be a
virtual register, a physical register, a spill slot, or a register unit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158031 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2012-06-05 22:51:54 +00:00
parent 34c6f98034
commit b77ec7d264
5 changed files with 20 additions and 49 deletions

View File

@ -486,7 +486,7 @@ namespace llvm {
(thisIndex == otherIndex && reg < other.reg)); (thisIndex == otherIndex && reg < other.reg));
} }
void print(raw_ostream &OS, const TargetRegisterInfo *TRI = 0) const; void print(raw_ostream &OS) const;
void dump() const; void dump() const;
private: private:

View File

@ -592,15 +592,10 @@ void LiveRange::dump() const {
dbgs() << *this << "\n"; dbgs() << *this << "\n";
} }
void LiveInterval::print(raw_ostream &OS, const TargetRegisterInfo *TRI) const { void LiveInterval::print(raw_ostream &OS) const {
OS << PrintReg(reg, TRI);
if (weight != 0)
OS << ',' << weight;
if (empty()) if (empty())
OS << "EMPTY"; OS << "EMPTY";
else { else {
OS << " = ";
for (LiveInterval::Ranges::const_iterator I = ranges.begin(), for (LiveInterval::Ranges::const_iterator I = ranges.begin(),
E = ranges.end(); I != E; ++I) { E = ranges.end(); I != E; ++I) {
OS << *I; OS << *I;

View File

@ -138,10 +138,8 @@ void LiveIntervals::print(raw_ostream &OS, const Module* ) const {
// Dump the physregs. // Dump the physregs.
for (unsigned Reg = 1, RegE = TRI->getNumRegs(); Reg != RegE; ++Reg) for (unsigned Reg = 1, RegE = TRI->getNumRegs(); Reg != RegE; ++Reg)
if (const LiveInterval *LI = R2IMap.lookup(Reg)) { if (const LiveInterval *LI = R2IMap.lookup(Reg))
LI->print(OS, TRI); OS << PrintReg(Reg, TRI) << '\t' << *LI << '\n';
OS << '\n';
}
// Dump the regunits. // Dump the regunits.
for (unsigned i = 0, e = RegUnitIntervals.size(); i != e; ++i) for (unsigned i = 0, e = RegUnitIntervals.size(); i != e; ++i)
@ -151,10 +149,8 @@ void LiveIntervals::print(raw_ostream &OS, const Module* ) const {
// Dump the virtregs. // Dump the virtregs.
for (unsigned Reg = 0, RegE = MRI->getNumVirtRegs(); Reg != RegE; ++Reg) for (unsigned Reg = 0, RegE = MRI->getNumVirtRegs(); Reg != RegE; ++Reg)
if (const LiveInterval *LI = if (const LiveInterval *LI =
R2IMap.lookup(TargetRegisterInfo::index2VirtReg(Reg))) { R2IMap.lookup(TargetRegisterInfo::index2VirtReg(Reg)))
LI->print(OS, TRI); OS << PrintReg(LI->reg) << '\t' << *LI << '\n';
OS << '\n';
}
printInstrs(OS); printInstrs(OS);
} }
@ -352,10 +348,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
interval.addRange(LiveRange(RedefIndex, RedefIndex.getDeadSlot(), interval.addRange(LiveRange(RedefIndex, RedefIndex.getDeadSlot(),
OldValNo)); OldValNo));
DEBUG({ DEBUG(dbgs() << " RESULT: " << interval);
dbgs() << " RESULT: ";
interval.print(dbgs(), TRI);
});
} else if (LV->isPHIJoin(interval.reg)) { } else if (LV->isPHIJoin(interval.reg)) {
// In the case of PHI elimination, each variable definition is only // In the case of PHI elimination, each variable definition is only
// live until the end of the block. We've already taken care of the // live until the end of the block. We've already taken care of the

View File

@ -189,7 +189,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()
<< ':' << *VirtReg << '\n'); << ':' << PrintReg(VirtReg->reg) << ' ' << *VirtReg << '\n');
typedef SmallVector<LiveInterval*, 4> VirtRegVec; typedef SmallVector<LiveInterval*, 4> VirtRegVec;
VirtRegVec SplitVRegs; VirtRegVec SplitVRegs;
unsigned AvailablePhysReg = selectOrSplit(*VirtReg, SplitVRegs); unsigned AvailablePhysReg = selectOrSplit(*VirtReg, SplitVRegs);

View File

@ -451,10 +451,7 @@ bool RegisterCoalescer::adjustCopiesBackFrom(const CoalescerPair &CP,
// IntB, we can merge them. // IntB, we can merge them.
if (ValLR+1 != BLR) return false; if (ValLR+1 != BLR) return false;
DEBUG({ DEBUG(dbgs() << "Extending: " << PrintReg(IntB.reg, TRI));
dbgs() << "Extending: ";
IntB.print(dbgs(), TRI);
});
SlotIndex FillerStart = ValLR->end, FillerEnd = BLR->start; SlotIndex FillerStart = ValLR->end, FillerEnd = BLR->start;
// We are about to delete CopyMI, so need to remove it as the 'instruction // We are about to delete CopyMI, so need to remove it as the 'instruction
@ -489,11 +486,7 @@ bool RegisterCoalescer::adjustCopiesBackFrom(const CoalescerPair &CP,
if (HasPHIKill) if (HasPHIKill)
ValLR->valno->setHasPHIKill(true); ValLR->valno->setHasPHIKill(true);
} }
DEBUG({ DEBUG(dbgs() << " result = " << IntB << '\n');
dbgs() << " result = ";
IntB.print(dbgs(), TRI);
dbgs() << "\n";
});
// If the source instruction was killing the source register before the // If the source instruction was killing the source register before the
// merge, unset the isKill marker given the live range has been extended. // merge, unset the isKill marker given the live range has been extended.
@ -1084,12 +1077,8 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
// Update regalloc hint. // Update regalloc hint.
TRI->UpdateRegAllocHint(CP.getSrcReg(), CP.getDstReg(), *MF); TRI->UpdateRegAllocHint(CP.getSrcReg(), CP.getDstReg(), *MF);
DEBUG({ DEBUG(dbgs() << "\tJoined. Result = " << PrintReg(CP.getDstReg(), TRI)
LiveInterval &DstInt = LIS->getInterval(CP.getDstReg()); << ' ' << LIS->getInterval(CP.getDstReg()) << '\n');
dbgs() << "\tJoined. Result = ";
DstInt.print(dbgs(), TRI);
dbgs() << "\n";
});
++numJoins; ++numJoins;
return true; return true;
@ -1100,7 +1089,8 @@ bool RegisterCoalescer::joinReservedPhysReg(CoalescerPair &CP) {
assert(CP.isPhys() && "Must be a physreg copy"); assert(CP.isPhys() && "Must be a physreg copy");
assert(RegClassInfo.isReserved(CP.getDstReg()) && "Not a reserved register"); assert(RegClassInfo.isReserved(CP.getDstReg()) && "Not a reserved register");
LiveInterval &RHS = LIS->getInterval(CP.getSrcReg()); LiveInterval &RHS = LIS->getInterval(CP.getSrcReg());
DEBUG({ dbgs() << "\t\tRHS = "; RHS.print(dbgs(), TRI); dbgs() << "\n"; }); DEBUG(dbgs() << "\t\tRHS = " << PrintReg(CP.getSrcReg()) << ' ' << RHS
<< '\n');
assert(CP.isFlipped() && RHS.containsOneValue() && assert(CP.isFlipped() && RHS.containsOneValue() &&
"Invalid join with reserved register"); "Invalid join with reserved register");
@ -1263,7 +1253,8 @@ bool RegisterCoalescer::joinIntervals(CoalescerPair &CP) {
return joinReservedPhysReg(CP); return joinReservedPhysReg(CP);
LiveInterval &RHS = LIS->getInterval(CP.getSrcReg()); LiveInterval &RHS = LIS->getInterval(CP.getSrcReg());
DEBUG({ dbgs() << "\t\tRHS = "; RHS.print(dbgs(), TRI); dbgs() << "\n"; }); DEBUG(dbgs() << "\t\tRHS = " << PrintReg(CP.getSrcReg()) << ' ' << RHS
<< '\n');
// Compute the final value assignment, assuming that the live ranges can be // Compute the final value assignment, assuming that the live ranges can be
// coalesced. // coalesced.
@ -1277,7 +1268,8 @@ bool RegisterCoalescer::joinIntervals(CoalescerPair &CP) {
SmallVector<MachineInstr*, 8> DeadCopies; SmallVector<MachineInstr*, 8> DeadCopies;
LiveInterval &LHS = LIS->getOrCreateInterval(CP.getDstReg()); LiveInterval &LHS = LIS->getOrCreateInterval(CP.getDstReg());
DEBUG({ dbgs() << "\t\tLHS = "; LHS.print(dbgs(), TRI); dbgs() << "\n"; }); DEBUG(dbgs() << "\t\tLHS = " << PrintReg(CP.getDstReg(), TRI) << ' ' << LHS
<< '\n');
// Loop over the value numbers of the LHS, seeing if any are defined from // Loop over the value numbers of the LHS, seeing if any are defined from
// the RHS. // the RHS.
@ -1619,17 +1611,8 @@ bool RegisterCoalescer::runOnMachineFunction(MachineFunction &fn) {
RegClassInfo.runOnMachineFunction(fn); RegClassInfo.runOnMachineFunction(fn);
// Join (coalesce) intervals if requested. // Join (coalesce) intervals if requested.
if (EnableJoining) { if (EnableJoining)
joinAllIntervals(); joinAllIntervals();
DEBUG({
dbgs() << "********** INTERVALS POST JOINING **********\n";
for (LiveIntervals::iterator I = LIS->begin(), E = LIS->end();
I != E; ++I){
I->second->print(dbgs(), TRI);
dbgs() << "\n";
}
});
}
// After deleting a lot of copies, register classes may be less constrained. // After deleting a lot of copies, register classes may be less constrained.
// Removing sub-register operands may allow GR32_ABCD -> GR32 and DPR_VFP2 -> // Removing sub-register operands may allow GR32_ABCD -> GR32 and DPR_VFP2 ->