mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Code clean up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43026 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -100,7 +100,7 @@ namespace llvm {
|
|||||||
/// CopyCoalesceInMBB - Coalesce copies in the specified MBB, putting
|
/// CopyCoalesceInMBB - Coalesce copies in the specified MBB, putting
|
||||||
/// copies that cannot yet be coalesced into the "TryAgain" list.
|
/// copies that cannot yet be coalesced into the "TryAgain" list.
|
||||||
void CopyCoalesceInMBB(MachineBasicBlock *MBB,
|
void CopyCoalesceInMBB(MachineBasicBlock *MBB,
|
||||||
std::vector<CopyRec> *TryAgain, bool PhysOnly = false);
|
std::vector<CopyRec> &TryAgain);
|
||||||
|
|
||||||
/// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg,
|
/// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg,
|
||||||
/// which are the src/dst of the copy instruction CopyMI. This returns true
|
/// which are the src/dst of the copy instruction CopyMI. This returns true
|
||||||
@ -108,8 +108,7 @@ namespace llvm {
|
|||||||
/// to coalesce these this copy, due to register constraints. It returns
|
/// to coalesce these this copy, due to register constraints. It returns
|
||||||
/// false if it is not currently possible to coalesce this interval, but
|
/// false if it is not currently possible to coalesce this interval, but
|
||||||
/// it may be possible if other things get coalesced.
|
/// it may be possible if other things get coalesced.
|
||||||
bool JoinCopy(MachineInstr *CopyMI, unsigned SrcReg, unsigned DstReg,
|
bool JoinCopy(MachineInstr *CopyMI, unsigned SrcReg, unsigned DstReg);
|
||||||
bool PhysOnly = false);
|
|
||||||
|
|
||||||
/// JoinIntervals - Attempt to join these two intervals. On failure, this
|
/// JoinIntervals - Attempt to join these two intervals. On failure, this
|
||||||
/// returns false. Otherwise, if one of the intervals being joined is a
|
/// returns false. Otherwise, if one of the intervals being joined is a
|
||||||
|
@ -192,7 +192,7 @@ bool SimpleRegisterCoalescing::AdjustCopiesBackFrom(LiveInterval &IntA, LiveInte
|
|||||||
/// false if it is not currently possible to coalesce this interval, but
|
/// false if it is not currently possible to coalesce this interval, but
|
||||||
/// it may be possible if other things get coalesced.
|
/// it may be possible if other things get coalesced.
|
||||||
bool SimpleRegisterCoalescing::JoinCopy(MachineInstr *CopyMI,
|
bool SimpleRegisterCoalescing::JoinCopy(MachineInstr *CopyMI,
|
||||||
unsigned SrcReg, unsigned DstReg, bool PhysOnly) {
|
unsigned SrcReg, unsigned DstReg) {
|
||||||
DOUT << li_->getInstructionIndex(CopyMI) << '\t' << *CopyMI;
|
DOUT << li_->getInstructionIndex(CopyMI) << '\t' << *CopyMI;
|
||||||
|
|
||||||
// Get representative registers.
|
// Get representative registers.
|
||||||
@ -207,9 +207,6 @@ bool SimpleRegisterCoalescing::JoinCopy(MachineInstr *CopyMI,
|
|||||||
|
|
||||||
bool SrcIsPhys = MRegisterInfo::isPhysicalRegister(repSrcReg);
|
bool SrcIsPhys = MRegisterInfo::isPhysicalRegister(repSrcReg);
|
||||||
bool DstIsPhys = MRegisterInfo::isPhysicalRegister(repDstReg);
|
bool DstIsPhys = MRegisterInfo::isPhysicalRegister(repDstReg);
|
||||||
if (PhysOnly && !SrcIsPhys && !DstIsPhys)
|
|
||||||
// Only joining physical registers with virtual registers in this round.
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// If they are both physical registers, we cannot join them.
|
// If they are both physical registers, we cannot join them.
|
||||||
if (SrcIsPhys && DstIsPhys) {
|
if (SrcIsPhys && DstIsPhys) {
|
||||||
@ -932,9 +929,11 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRegisterCoalescing::CopyCoalesceInMBB(MachineBasicBlock *MBB,
|
void SimpleRegisterCoalescing::CopyCoalesceInMBB(MachineBasicBlock *MBB,
|
||||||
std::vector<CopyRec> *TryAgain, bool PhysOnly) {
|
std::vector<CopyRec> &TryAgain) {
|
||||||
DOUT << ((Value*)MBB->getBasicBlock())->getName() << ":\n";
|
DOUT << ((Value*)MBB->getBasicBlock())->getName() << ":\n";
|
||||||
|
|
||||||
|
std::vector<CopyRec> VirtCopies;
|
||||||
|
std::vector<CopyRec> PhysCopies;
|
||||||
for (MachineBasicBlock::iterator MII = MBB->begin(), E = MBB->end();
|
for (MachineBasicBlock::iterator MII = MBB->begin(), E = MBB->end();
|
||||||
MII != E;) {
|
MII != E;) {
|
||||||
MachineInstr *Inst = MII++;
|
MachineInstr *Inst = MII++;
|
||||||
@ -947,9 +946,26 @@ void SimpleRegisterCoalescing::CopyCoalesceInMBB(MachineBasicBlock *MBB,
|
|||||||
} else if (!tii_->isMoveInstr(*Inst, SrcReg, DstReg))
|
} else if (!tii_->isMoveInstr(*Inst, SrcReg, DstReg))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool Done = JoinCopy(Inst, SrcReg, DstReg, PhysOnly);
|
unsigned repSrcReg = rep(SrcReg);
|
||||||
if (TryAgain && !Done)
|
unsigned repDstReg = rep(DstReg);
|
||||||
TryAgain->push_back(getCopyRec(Inst, SrcReg, DstReg));
|
bool SrcIsPhys = MRegisterInfo::isPhysicalRegister(repSrcReg);
|
||||||
|
bool DstIsPhys = MRegisterInfo::isPhysicalRegister(repDstReg);
|
||||||
|
if (SrcIsPhys || DstIsPhys)
|
||||||
|
PhysCopies.push_back(getCopyRec(Inst, SrcReg, DstReg));
|
||||||
|
else
|
||||||
|
VirtCopies.push_back(getCopyRec(Inst, SrcReg, DstReg));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try coalescing physical register + virtual register first.
|
||||||
|
for (unsigned i = 0, e = PhysCopies.size(); i != e; ++i) {
|
||||||
|
CopyRec &TheCopy = PhysCopies[i];
|
||||||
|
if (!JoinCopy(TheCopy.MI, TheCopy.SrcReg, TheCopy.DstReg))
|
||||||
|
TryAgain.push_back(TheCopy);
|
||||||
|
}
|
||||||
|
for (unsigned i = 0, e = VirtCopies.size(); i != e; ++i) {
|
||||||
|
CopyRec &TheCopy = VirtCopies[i];
|
||||||
|
if (!JoinCopy(TheCopy.MI, TheCopy.SrcReg, TheCopy.DstReg))
|
||||||
|
TryAgain.push_back(TheCopy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,7 +981,7 @@ void SimpleRegisterCoalescing::joinIntervals() {
|
|||||||
// If there are no loops in the function, join intervals in function order.
|
// If there are no loops in the function, join intervals in function order.
|
||||||
for (MachineFunction::iterator I = mf_->begin(), E = mf_->end();
|
for (MachineFunction::iterator I = mf_->begin(), E = mf_->end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
CopyCoalesceInMBB(I, &TryAgainList);
|
CopyCoalesceInMBB(I, TryAgainList);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, join intervals in inner loops before other intervals.
|
// Otherwise, join intervals in inner loops before other intervals.
|
||||||
// Unfortunately we can't just iterate over loop hierarchy here because
|
// Unfortunately we can't just iterate over loop hierarchy here because
|
||||||
@ -982,9 +998,7 @@ void SimpleRegisterCoalescing::joinIntervals() {
|
|||||||
|
|
||||||
// Finally, join intervals in loop nest order.
|
// Finally, join intervals in loop nest order.
|
||||||
for (unsigned i = 0, e = MBBs.size(); i != e; ++i)
|
for (unsigned i = 0, e = MBBs.size(); i != e; ++i)
|
||||||
CopyCoalesceInMBB(MBBs[i].second, NULL, true);
|
CopyCoalesceInMBB(MBBs[i].second, TryAgainList);
|
||||||
for (unsigned i = 0, e = MBBs.size(); i != e; ++i)
|
|
||||||
CopyCoalesceInMBB(MBBs[i].second, &TryAgainList, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joining intervals can allow other intervals to be joined. Iteratively join
|
// Joining intervals can allow other intervals to be joined. Iteratively join
|
||||||
|
Reference in New Issue
Block a user