mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-19 04:32:19 +00:00
Create our own block initializer for kill fixups as the scheduling one wasn't doing the right thing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80958 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e8d82c0e4f
commit
5e41178a6e
@ -54,7 +54,7 @@ EnableAntiDepBreaking("break-anti-dependencies",
|
|||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
EnablePostRAHazardAvoidance("avoid-hazards",
|
EnablePostRAHazardAvoidance("avoid-hazards",
|
||||||
cl::desc("Enable exact hazard avoidance"),
|
cl::desc("Enable exact hazard avoidance"),
|
||||||
cl::init(false), cl::Hidden);
|
cl::init(true), cl::Hidden);
|
||||||
|
|
||||||
// If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
|
// If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
|
||||||
static cl::opt<int>
|
static cl::opt<int>
|
||||||
@ -166,11 +166,6 @@ namespace {
|
|||||||
///
|
///
|
||||||
void FinishBlock();
|
void FinishBlock();
|
||||||
|
|
||||||
/// GenerateLivenessForKills - If true then generate Def/Kill
|
|
||||||
/// information for use in updating register kill. If false then
|
|
||||||
/// generate Def/Kill information for anti-dependence breaking.
|
|
||||||
bool GenerateLivenessForKills;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PrescanInstruction(MachineInstr *MI);
|
void PrescanInstruction(MachineInstr *MI);
|
||||||
void ScanInstruction(MachineInstr *MI, unsigned Count);
|
void ScanInstruction(MachineInstr *MI, unsigned Count);
|
||||||
@ -182,6 +177,7 @@ namespace {
|
|||||||
unsigned findSuitableFreeRegister(unsigned AntiDepReg,
|
unsigned findSuitableFreeRegister(unsigned AntiDepReg,
|
||||||
unsigned LastNewReg,
|
unsigned LastNewReg,
|
||||||
const TargetRegisterClass *);
|
const TargetRegisterClass *);
|
||||||
|
void StartBlockForKills(MachineBasicBlock *BB);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +230,6 @@ bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize register live-range state for scheduling in this block.
|
// Initialize register live-range state for scheduling in this block.
|
||||||
Scheduler.GenerateLivenessForKills = false;
|
|
||||||
Scheduler.StartBlock(MBB);
|
Scheduler.StartBlock(MBB);
|
||||||
|
|
||||||
// Schedule each sequence of instructions not interrupted by a label
|
// Schedule each sequence of instructions not interrupted by a label
|
||||||
@ -262,11 +257,8 @@ bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
// Clean up register live-range state.
|
// Clean up register live-range state.
|
||||||
Scheduler.FinishBlock();
|
Scheduler.FinishBlock();
|
||||||
|
|
||||||
// Initialize register live-range state again and update register kills
|
// Update register kills
|
||||||
Scheduler.GenerateLivenessForKills = true;
|
|
||||||
Scheduler.StartBlock(MBB);
|
|
||||||
Scheduler.FixupKills(MBB);
|
Scheduler.FixupKills(MBB);
|
||||||
Scheduler.FinishBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -326,7 +318,6 @@ void SchedulePostRATDList::StartBlock(MachineBasicBlock *BB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GenerateLivenessForKills) {
|
|
||||||
// Consider callee-saved registers as live-out, since we're running after
|
// Consider callee-saved registers as live-out, since we're running after
|
||||||
// prologue/epilogue insertion so there's no way to add additional
|
// prologue/epilogue insertion so there's no way to add additional
|
||||||
// saved registers.
|
// saved registers.
|
||||||
@ -349,7 +340,6 @@ void SchedulePostRATDList::StartBlock(MachineBasicBlock *BB) {
|
|||||||
DefIndices[AliasReg] = ~0u;
|
DefIndices[AliasReg] = ~0u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Schedule - Schedule the instruction range using list scheduling.
|
/// Schedule - Schedule the instruction range using list scheduling.
|
||||||
@ -794,6 +784,44 @@ bool SchedulePostRATDList::BreakAntiDependencies() {
|
|||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// StartBlockForKills - Initialize register live-range state for updating kills
|
||||||
|
///
|
||||||
|
void SchedulePostRATDList::StartBlockForKills(MachineBasicBlock *BB) {
|
||||||
|
// Initialize the indices to indicate that no registers are live.
|
||||||
|
std::fill(KillIndices, array_endof(KillIndices), ~0u);
|
||||||
|
|
||||||
|
// Determine the live-out physregs for this block.
|
||||||
|
if (!BB->empty() && BB->back().getDesc().isReturn()) {
|
||||||
|
// In a return block, examine the function live-out regs.
|
||||||
|
for (MachineRegisterInfo::liveout_iterator I = MRI.liveout_begin(),
|
||||||
|
E = MRI.liveout_end(); I != E; ++I) {
|
||||||
|
unsigned Reg = *I;
|
||||||
|
KillIndices[Reg] = BB->size();
|
||||||
|
// Repeat, for all subregs.
|
||||||
|
for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
|
||||||
|
*Subreg; ++Subreg) {
|
||||||
|
KillIndices[*Subreg] = BB->size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// In a non-return block, examine the live-in regs of all successors.
|
||||||
|
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
|
||||||
|
SE = BB->succ_end(); SI != SE; ++SI) {
|
||||||
|
for (MachineBasicBlock::livein_iterator I = (*SI)->livein_begin(),
|
||||||
|
E = (*SI)->livein_end(); I != E; ++I) {
|
||||||
|
unsigned Reg = *I;
|
||||||
|
KillIndices[Reg] = BB->size();
|
||||||
|
// Repeat, for all subregs.
|
||||||
|
for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
|
||||||
|
*Subreg; ++Subreg) {
|
||||||
|
KillIndices[*Subreg] = BB->size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// FixupKills - Fix the register kill flags, they may have been made
|
/// FixupKills - Fix the register kill flags, they may have been made
|
||||||
/// incorrect by instruction reordering.
|
/// incorrect by instruction reordering.
|
||||||
///
|
///
|
||||||
@ -803,6 +831,8 @@ void SchedulePostRATDList::FixupKills(MachineBasicBlock *MBB) {
|
|||||||
std::set<unsigned> killedRegs;
|
std::set<unsigned> killedRegs;
|
||||||
BitVector ReservedRegs = TRI->getReservedRegs(MF);
|
BitVector ReservedRegs = TRI->getReservedRegs(MF);
|
||||||
|
|
||||||
|
StartBlockForKills(MBB);
|
||||||
|
|
||||||
// Examine block from end to start...
|
// Examine block from end to start...
|
||||||
unsigned Count = MBB->size();
|
unsigned Count = MBB->size();
|
||||||
for (MachineBasicBlock::iterator I = MBB->end(), E = MBB->begin();
|
for (MachineBasicBlock::iterator I = MBB->end(), E = MBB->begin();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user