mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Enable opportunistic coalescing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103764 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
22c687b642
commit
7ff82e1501
@ -603,6 +603,7 @@ void RAFast::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||||||
reservePhysReg(MBB, MII, *I);
|
reservePhysReg(MBB, MII, *I);
|
||||||
|
|
||||||
SmallVector<unsigned, 8> VirtKills, PhysKills, PhysDefs;
|
SmallVector<unsigned, 8> VirtKills, PhysKills, PhysDefs;
|
||||||
|
SmallVector<MachineInstr*, 32> Coalesced;
|
||||||
|
|
||||||
// Otherwise, sequentially allocate each instruction in the MBB.
|
// Otherwise, sequentially allocate each instruction in the MBB.
|
||||||
while (MII != MBB.end()) {
|
while (MII != MBB.end()) {
|
||||||
@ -706,8 +707,7 @@ void RAFast::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) continue;
|
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) continue;
|
||||||
if (MO.isUse()) {
|
if (MO.isUse()) {
|
||||||
unsigned PhysReg = reloadVirtReg(MBB, MI, i, Reg, CopyDst);
|
unsigned PhysReg = reloadVirtReg(MBB, MI, i, Reg, CopyDst);
|
||||||
if (CopySrc == Reg)
|
CopySrc = (CopySrc == Reg || CopySrc == PhysReg) ? PhysReg : 0;
|
||||||
CopySrc = PhysReg;
|
|
||||||
setPhysReg(MO, PhysReg);
|
setPhysReg(MO, PhysReg);
|
||||||
if (MO.isKill())
|
if (MO.isKill())
|
||||||
VirtKills.push_back(Reg);
|
VirtKills.push_back(Reg);
|
||||||
@ -757,11 +757,12 @@ void RAFast::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||||||
PhysKills.push_back(Reg);
|
PhysKills.push_back(Reg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MO.isDead())
|
|
||||||
VirtKills.push_back(Reg);
|
|
||||||
unsigned PhysReg = defineVirtReg(MBB, MI, i, Reg, CopySrc);
|
unsigned PhysReg = defineVirtReg(MBB, MI, i, Reg, CopySrc);
|
||||||
if (CopyDst == Reg)
|
if (MO.isDead()) {
|
||||||
CopyDst = PhysReg;
|
VirtKills.push_back(Reg);
|
||||||
|
CopyDst = 0; // cancel coalescing;
|
||||||
|
} else
|
||||||
|
CopyDst = (CopyDst == Reg || CopyDst == PhysReg) ? PhysReg : 0;
|
||||||
setPhysReg(MO, PhysReg);
|
setPhysReg(MO, PhysReg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,7 +784,12 @@ void RAFast::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||||||
|
|
||||||
MRI->addPhysRegsUsed(UsedInInstr);
|
MRI->addPhysRegsUsed(UsedInInstr);
|
||||||
|
|
||||||
DEBUG(dbgs() << "<< " << *MI);
|
if (CopyDst && CopyDst == CopySrc && CopyDstSub == CopySrcSub) {
|
||||||
|
DEBUG(dbgs() << "-- coalescing: " << *MI);
|
||||||
|
Coalesced.push_back(MI);
|
||||||
|
} else {
|
||||||
|
DEBUG(dbgs() << "<< " << *MI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spill all physical registers holding virtual registers now.
|
// Spill all physical registers holding virtual registers now.
|
||||||
@ -795,6 +801,11 @@ void RAFast::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||||||
spillVirtReg(MBB, MI, i, true);
|
spillVirtReg(MBB, MI, i, true);
|
||||||
LiveVirtRegs.clear();
|
LiveVirtRegs.clear();
|
||||||
|
|
||||||
|
// Erase all the coalesced copies. We are delaying it until now because
|
||||||
|
// LiveVirtsRegs might refer to the instrs.
|
||||||
|
for (unsigned i = 0, e = Coalesced.size(); i != e; ++i)
|
||||||
|
MBB.erase(Coalesced[i]);
|
||||||
|
|
||||||
DEBUG(MBB.dump());
|
DEBUG(MBB.dump());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user