/// print - Implement the dump method.
void LiveIntervals::print(raw_ostream &OS, const Module* ) const {
OS << "********** INTERVALS **********\n";
- for (const_iterator I = begin(), E = end(); I != E; ++I) {
- I->second->print(OS, tri_);
- OS << "\n";
- }
+
+ // Dump the physregs.
+ for (unsigned Reg = 1, RegE = tri_->getNumRegs(); Reg != RegE; ++Reg)
+ if (const LiveInterval *LI = r2iMap_.lookup(Reg)) {
+ LI->print(OS, tri_);
+ OS << '\n';
+ }
+
+ // Dump the virtregs.
+ for (unsigned Reg = 0, RegE = mri_->getNumVirtRegs(); Reg != RegE; ++Reg)
+ if (const LiveInterval *LI =
+ r2iMap_.lookup(TargetRegisterInfo::index2VirtReg(Reg))) {
+ LI->print(OS, tri_);
+ OS << '\n';
+ }
printInstrs(OS);
}
// FIXME: We need saner rules for reserved regs.
if (isReserved(interval.reg)) {
- assert(!isRegLiveOutOf(MBB, interval.reg) && "Reserved reg live-out?");
end = start.getDeadSlot();
} else {
// Unreserved, unallocable registers like EFLAGS can be live across basic
end = baseIndex.getRegSlot();
SeenDefUse = true;
break;
- } else if (mi->definesRegister(interval.reg, tri_)) {
+ } else if (mi->modifiesRegister(interval.reg, tri_)) {
// Another instruction redefines the register before it is ever read.
// Then the register is essentially dead at the instruction that defines
// it. Hence its interval is:
if (!SeenDefUse) {
if (isAllocatable(interval.reg) || isReserved(interval.reg)) {
// This must be an entry block or landing pad - we asserted so on entry
- // to the function. For these blocks the interval is dead on entry.
+ // to the function. For these blocks the interval is dead on entry, so
+ // we won't emit a live-range for it.
DEBUG(dbgs() << " dead");
- end = start.getDeadSlot();
+ return;
} else {
assert(isRegLiveOutOf(MBB, interval.reg) &&
"Live in reg untouched in block should be be live through.");
}
}
-void LiveIntervals::moveInstr(MachineBasicBlock::iterator insertPt,
- MachineInstr *mi) {
- MachineBasicBlock* mbb = mi->getParent();
- assert((insertPt == mbb->end() || insertPt->getParent() == mbb) &&
- "Cannot handle moves across basic block boundaries.");
- assert(&*insertPt != mi && "No-op move requested?");
- assert(!mi->isBundled() && "Can't handle bundled instructions yet.");
- // Grab the original instruction index.
- SlotIndex origIdx = indexes_->getInstructionIndex(mi);
- // Move the machine instr and obtain its new index.
+void LiveIntervals::handleMove(MachineInstr* mi) {
+ SlotIndex origIdx = indexes_->getInstructionIndex(mi);
indexes_->removeMachineInstrFromMaps(mi);
- mbb->splice(insertPt, mbb, mi);
- SlotIndex miIdx = indexes_->insertMachineInstrInMaps(mi);
+ SlotIndex miIdx = mi->isInsideBundle() ?
+ indexes_->getInstructionIndex(mi->getBundleStart()) :
+ indexes_->insertMachineInstrInMaps(mi);
+ MachineBasicBlock* mbb = mi->getParent();
+ assert(getMBBStartIdx(mbb) <= origIdx && origIdx < getMBBEndIdx(mbb) &&
+ "Cannot handle moves across basic block boundaries.");
+ assert(!mi->isBundled() && "Can't handle bundled instructions yet.");
// Pick the direction.
bool movingUp = miIdx < origIdx;