mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Respect src register allocation requirements when breaking anti-dependencies. Remove some dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84691 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -209,8 +209,7 @@ namespace {
|
|||||||
void PrescanInstruction(MachineInstr *MI, unsigned Count);
|
void PrescanInstruction(MachineInstr *MI, unsigned Count);
|
||||||
void ScanInstruction(MachineInstr *MI, unsigned Count);
|
void ScanInstruction(MachineInstr *MI, unsigned Count);
|
||||||
bool BreakAntiDependencies(bool CriticalPathOnly);
|
bool BreakAntiDependencies(bool CriticalPathOnly);
|
||||||
unsigned FindSuitableFreeRegister(unsigned AntiDepReg,
|
unsigned FindSuitableFreeRegister(unsigned AntiDepReg);
|
||||||
unsigned LastNewReg);
|
|
||||||
|
|
||||||
void ReleaseSucc(SUnit *SU, SDep *SuccEdge);
|
void ReleaseSucc(SUnit *SU, SDep *SuccEdge);
|
||||||
void ReleaseSuccessors(SUnit *SU);
|
void ReleaseSuccessors(SUnit *SU);
|
||||||
@@ -595,7 +594,7 @@ void SchedulePostRATDList::PrescanInstruction(MachineInstr *MI, unsigned Count)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(errs() << "\tGroups:");
|
DEBUG(errs() << "\tDef Groups:");
|
||||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||||
MachineOperand &MO = MI->getOperand(i);
|
MachineOperand &MO = MI->getOperand(i);
|
||||||
if (!MO.isReg() || !MO.isDef()) continue;
|
if (!MO.isReg() || !MO.isDef()) continue;
|
||||||
@@ -637,6 +636,8 @@ void SchedulePostRATDList::PrescanInstruction(MachineInstr *MI, unsigned Count)
|
|||||||
|
|
||||||
void SchedulePostRATDList::ScanInstruction(MachineInstr *MI,
|
void SchedulePostRATDList::ScanInstruction(MachineInstr *MI,
|
||||||
unsigned Count) {
|
unsigned Count) {
|
||||||
|
DEBUG(errs() << "\tUse Groups:");
|
||||||
|
|
||||||
// Scan the register uses for this instruction and update
|
// Scan the register uses for this instruction and update
|
||||||
// live-ranges, groups and RegRefs.
|
// live-ranges, groups and RegRefs.
|
||||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||||
@@ -645,6 +646,8 @@ void SchedulePostRATDList::ScanInstruction(MachineInstr *MI,
|
|||||||
unsigned Reg = MO.getReg();
|
unsigned Reg = MO.getReg();
|
||||||
if (Reg == 0) continue;
|
if (Reg == 0) continue;
|
||||||
|
|
||||||
|
DEBUG(errs() << " " << TRI->getName(Reg) << "=g" << GetGroup(Reg));
|
||||||
|
|
||||||
// It wasn't previously live but now it is, this is a kill. Forget
|
// It wasn't previously live but now it is, this is a kill. Forget
|
||||||
// the previous live-range information and start a new live-range
|
// the previous live-range information and start a new live-range
|
||||||
// for the register.
|
// for the register.
|
||||||
@@ -653,6 +656,7 @@ void SchedulePostRATDList::ScanInstruction(MachineInstr *MI,
|
|||||||
DefIndices[Reg] = ~0u;
|
DefIndices[Reg] = ~0u;
|
||||||
RegRefs.erase(Reg);
|
RegRefs.erase(Reg);
|
||||||
LeaveGroup(Reg);
|
LeaveGroup(Reg);
|
||||||
|
DEBUG(errs() << "->g" << GetGroup(Reg) << "(last-use)");
|
||||||
}
|
}
|
||||||
// Repeat, for subregisters.
|
// Repeat, for subregisters.
|
||||||
for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
|
for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
|
||||||
@@ -663,9 +667,18 @@ void SchedulePostRATDList::ScanInstruction(MachineInstr *MI,
|
|||||||
DefIndices[SubregReg] = ~0u;
|
DefIndices[SubregReg] = ~0u;
|
||||||
RegRefs.erase(SubregReg);
|
RegRefs.erase(SubregReg);
|
||||||
LeaveGroup(SubregReg);
|
LeaveGroup(SubregReg);
|
||||||
|
DEBUG(errs() << "->g" << GetGroup(SubregReg) << "(last-use)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If MI's uses have special allocation requirement, don't allow
|
||||||
|
// any use registers to be changed. Also assume all registers
|
||||||
|
// used in a call must not be changed (ABI).
|
||||||
|
if (MI->getDesc().isCall() || MI->getDesc().hasExtraSrcRegAllocReq()) {
|
||||||
|
DEBUG(if (GetGroup(Reg) != 0) errs() << "->g0(alloc-req)");
|
||||||
|
UnionGroups(Reg, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Note register reference...
|
// Note register reference...
|
||||||
const TargetRegisterClass *RC = NULL;
|
const TargetRegisterClass *RC = NULL;
|
||||||
if (i < MI->getDesc().getNumOperands())
|
if (i < MI->getDesc().getNumOperands())
|
||||||
@@ -674,6 +687,8 @@ void SchedulePostRATDList::ScanInstruction(MachineInstr *MI,
|
|||||||
RegRefs.insert(std::make_pair(Reg, RR));
|
RegRefs.insert(std::make_pair(Reg, RR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG(errs() << '\n');
|
||||||
|
|
||||||
// Form a group of all defs and uses of a KILL instruction to ensure
|
// Form a group of all defs and uses of a KILL instruction to ensure
|
||||||
// that all registers are renamed as a group.
|
// that all registers are renamed as a group.
|
||||||
if (MI->getOpcode() == TargetInstrInfo::KILL) {
|
if (MI->getOpcode() == TargetInstrInfo::KILL) {
|
||||||
@@ -694,8 +709,7 @@ void SchedulePostRATDList::ScanInstruction(MachineInstr *MI,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned SchedulePostRATDList::FindSuitableFreeRegister(unsigned AntiDepReg,
|
unsigned SchedulePostRATDList::FindSuitableFreeRegister(unsigned AntiDepReg) {
|
||||||
unsigned LastNewReg) {
|
|
||||||
// Collect all registers in the same group as AntiDepReg. These all
|
// Collect all registers in the same group as AntiDepReg. These all
|
||||||
// need to be renamed together if we are to break the
|
// need to be renamed together if we are to break the
|
||||||
// anti-dependence.
|
// anti-dependence.
|
||||||
@@ -846,12 +860,6 @@ bool SchedulePostRATDList::BreakAntiDependencies(bool CriticalPathOnly) {
|
|||||||
std::string dbgStr;
|
std::string dbgStr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: If we tracked more than one register here, we could potentially
|
|
||||||
// fix that remaining critical edge too. This is a little more involved,
|
|
||||||
// because unlike the most recent register, less recent registers should
|
|
||||||
// still be considered, though only if no other registers are available.
|
|
||||||
unsigned LastNewReg[TargetRegisterInfo::FirstVirtualRegister] = {};
|
|
||||||
|
|
||||||
// Attempt to break anti-dependence edges. Walk the instructions
|
// Attempt to break anti-dependence edges. Walk the instructions
|
||||||
// from the bottom up, tracking information about liveness as we go
|
// from the bottom up, tracking information about liveness as we go
|
||||||
// to help determine which registers are available.
|
// to help determine which registers are available.
|
||||||
@@ -969,12 +977,8 @@ bool SchedulePostRATDList::BreakAntiDependencies(bool CriticalPathOnly) {
|
|||||||
DEBUG(if (!dbgStr.empty()) errs() << dbgStr << '\n');
|
DEBUG(if (!dbgStr.empty()) errs() << dbgStr << '\n');
|
||||||
|
|
||||||
// Look for a suitable register to use to break the anti-dependence.
|
// Look for a suitable register to use to break the anti-dependence.
|
||||||
//
|
|
||||||
// TODO: Instead of picking the first free register, consider which might
|
|
||||||
// be the best.
|
|
||||||
if (AntiDepReg != 0) {
|
if (AntiDepReg != 0) {
|
||||||
if (unsigned NewReg = FindSuitableFreeRegister(AntiDepReg,
|
if (unsigned NewReg = FindSuitableFreeRegister(AntiDepReg)) {
|
||||||
LastNewReg[AntiDepReg])) {
|
|
||||||
DEBUG(errs() << "\tBreaking anti-dependence edge on "
|
DEBUG(errs() << "\tBreaking anti-dependence edge on "
|
||||||
<< TRI->getName(AntiDepReg)
|
<< TRI->getName(AntiDepReg)
|
||||||
<< " with " << RegRefs.count(AntiDepReg) << " references"
|
<< " with " << RegRefs.count(AntiDepReg) << " references"
|
||||||
@@ -1008,7 +1012,6 @@ bool SchedulePostRATDList::BreakAntiDependencies(bool CriticalPathOnly) {
|
|||||||
"Kill and Def maps aren't consistent for AntiDepReg!");
|
"Kill and Def maps aren't consistent for AntiDepReg!");
|
||||||
|
|
||||||
Changed = true;
|
Changed = true;
|
||||||
LastNewReg[AntiDepReg] = NewReg;
|
|
||||||
++NumFixedAnti;
|
++NumFixedAnti;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user