mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
Add more comments... err debug statements to the fast allocator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2a2bc5ccee
commit
0b756349a7
@ -420,20 +420,25 @@ void RAFast::definePhysReg(MachineInstr *MI, unsigned PhysReg,
|
|||||||
// can be allocated directly.
|
// can be allocated directly.
|
||||||
// Returns spillImpossible when PhysReg or an alias can't be spilled.
|
// Returns spillImpossible when PhysReg or an alias can't be spilled.
|
||||||
unsigned RAFast::calcSpillCost(unsigned PhysReg) const {
|
unsigned RAFast::calcSpillCost(unsigned PhysReg) const {
|
||||||
if (UsedInInstr.test(PhysReg))
|
if (UsedInInstr.test(PhysReg)) {
|
||||||
|
DEBUG(dbgs() << "PhysReg: " << PhysReg << " is already used in instr.\n");
|
||||||
return spillImpossible;
|
return spillImpossible;
|
||||||
|
}
|
||||||
switch (unsigned VirtReg = PhysRegState[PhysReg]) {
|
switch (unsigned VirtReg = PhysRegState[PhysReg]) {
|
||||||
case regDisabled:
|
case regDisabled:
|
||||||
break;
|
break;
|
||||||
case regFree:
|
case regFree:
|
||||||
return 0;
|
return 0;
|
||||||
case regReserved:
|
case regReserved:
|
||||||
|
DEBUG(dbgs() << "VirtReg: " << VirtReg << " corresponding to PhysReg: "
|
||||||
|
<< PhysReg << " is reserved already.\n");
|
||||||
return spillImpossible;
|
return spillImpossible;
|
||||||
default:
|
default:
|
||||||
return LiveVirtRegs.lookup(VirtReg).Dirty ? spillDirty : spillClean;
|
return LiveVirtRegs.lookup(VirtReg).Dirty ? spillDirty : spillClean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a disabled register, add up cost of aliases.
|
// This is a disabled register, add up cost of aliases.
|
||||||
|
DEBUG(dbgs() << "\tRegister: " << PhysReg << " is disabled.\n");
|
||||||
unsigned Cost = 0;
|
unsigned Cost = 0;
|
||||||
for (const unsigned *AS = TRI->getAliasSet(PhysReg);
|
for (const unsigned *AS = TRI->getAliasSet(PhysReg);
|
||||||
unsigned Alias = *AS; ++AS) {
|
unsigned Alias = *AS; ++AS) {
|
||||||
@ -511,9 +516,14 @@ void RAFast::allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint) {
|
|||||||
|
|
||||||
unsigned BestReg = 0, BestCost = spillImpossible;
|
unsigned BestReg = 0, BestCost = spillImpossible;
|
||||||
for (TargetRegisterClass::iterator I = AOB; I != AOE; ++I) {
|
for (TargetRegisterClass::iterator I = AOB; I != AOE; ++I) {
|
||||||
if (!Allocatable.test(*I))
|
if (!Allocatable.test(*I)) {
|
||||||
|
DEBUG(dbgs() << "\tRegister " << *I << " is not allocatable.\n");
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
unsigned Cost = calcSpillCost(*I);
|
unsigned Cost = calcSpillCost(*I);
|
||||||
|
DEBUG(dbgs() << "\tRegister: " << *I << "\n");
|
||||||
|
DEBUG(dbgs() << "\tCost: " << Cost << "\n");
|
||||||
|
DEBUG(dbgs() << "\tBestCost: " << BestCost << "\n");
|
||||||
// Cost is 0 when all aliases are already disabled.
|
// Cost is 0 when all aliases are already disabled.
|
||||||
if (Cost == 0)
|
if (Cost == 0)
|
||||||
return assignVirtToPhysReg(LRE, *I);
|
return assignVirtToPhysReg(LRE, *I);
|
||||||
@ -722,9 +732,12 @@ void RAFast::handleThroughOperands(MachineInstr *MI,
|
|||||||
if (!MO.isReg() || (MO.isDef() && !MO.isEarlyClobber())) continue;
|
if (!MO.isReg() || (MO.isDef() && !MO.isEarlyClobber())) continue;
|
||||||
unsigned Reg = MO.getReg();
|
unsigned Reg = MO.getReg();
|
||||||
if (!Reg || !TargetRegisterInfo::isPhysicalRegister(Reg)) continue;
|
if (!Reg || !TargetRegisterInfo::isPhysicalRegister(Reg)) continue;
|
||||||
|
DEBUG(dbgs() << "\tSetting reg " << Reg << " as used in instr\n");
|
||||||
UsedInInstr.set(Reg);
|
UsedInInstr.set(Reg);
|
||||||
for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS)
|
for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) {
|
||||||
|
DEBUG(dbgs() << "\tSetting alias reg " << *AS << " as used in instr\n");
|
||||||
UsedInInstr.set(*AS);
|
UsedInInstr.set(*AS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also mark PartialDefs as used to avoid reallocation.
|
// Also mark PartialDefs as used to avoid reallocation.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user