mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 23:31:37 +00:00
Added -misched-regpressure option.
Register pressure tracking is half the complexity of the scheduler. It's useful to be able to turn it off for compile time and performance comparisons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189987 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b4b7a52ec5
commit
42ebb3ad41
@ -227,6 +227,7 @@ protected:
|
|||||||
PressureDiffs SUPressureDiffs;
|
PressureDiffs SUPressureDiffs;
|
||||||
|
|
||||||
/// Register pressure in this region computed by initRegPressure.
|
/// Register pressure in this region computed by initRegPressure.
|
||||||
|
bool ShouldTrackPressure;
|
||||||
IntervalPressure RegPressure;
|
IntervalPressure RegPressure;
|
||||||
RegPressureTracker RPTracker;
|
RegPressureTracker RPTracker;
|
||||||
|
|
||||||
@ -259,8 +260,9 @@ public:
|
|||||||
ScheduleDAGMI(MachineSchedContext *C, MachineSchedStrategy *S):
|
ScheduleDAGMI(MachineSchedContext *C, MachineSchedStrategy *S):
|
||||||
ScheduleDAGInstrs(*C->MF, *C->MLI, *C->MDT, /*IsPostRA=*/false, C->LIS),
|
ScheduleDAGInstrs(*C->MF, *C->MLI, *C->MDT, /*IsPostRA=*/false, C->LIS),
|
||||||
AA(C->AA), RegClassInfo(C->RegClassInfo), SchedImpl(S), DFSResult(0),
|
AA(C->AA), RegClassInfo(C->RegClassInfo), SchedImpl(S), DFSResult(0),
|
||||||
Topo(SUnits, &ExitSU), RPTracker(RegPressure), CurrentTop(),
|
Topo(SUnits, &ExitSU), ShouldTrackPressure(false),
|
||||||
TopRPTracker(TopPressure), CurrentBottom(), BotRPTracker(BotPressure),
|
RPTracker(RegPressure), CurrentTop(), TopRPTracker(TopPressure),
|
||||||
|
CurrentBottom(), BotRPTracker(BotPressure),
|
||||||
NextClusterPred(NULL), NextClusterSucc(NULL) {
|
NextClusterPred(NULL), NextClusterSucc(NULL) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
NumInstrsScheduled = 0;
|
NumInstrsScheduled = 0;
|
||||||
|
@ -288,6 +288,8 @@ public:
|
|||||||
MF(0), TRI(0), RCI(0), LIS(0), MBB(0), P(rp), RequireIntervals(false),
|
MF(0), TRI(0), RCI(0), LIS(0), MBB(0), P(rp), RequireIntervals(false),
|
||||||
TrackUntiedDefs(false) {}
|
TrackUntiedDefs(false) {}
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
void init(const MachineFunction *mf, const RegisterClassInfo *rci,
|
void init(const MachineFunction *mf, const RegisterClassInfo *rci,
|
||||||
const LiveIntervals *lis, const MachineBasicBlock *mbb,
|
const LiveIntervals *lis, const MachineBasicBlock *mbb,
|
||||||
MachineBasicBlock::const_iterator pos,
|
MachineBasicBlock::const_iterator pos,
|
||||||
|
@ -53,6 +53,9 @@ static cl::opt<unsigned> MISchedCutoff("misched-cutoff", cl::Hidden,
|
|||||||
static bool ViewMISchedDAGs = false;
|
static bool ViewMISchedDAGs = false;
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
|
|
||||||
|
static cl::opt<bool> EnableRegPressure("misched-regpressure", cl::Hidden,
|
||||||
|
cl::desc("Enable register pressure scheduling."), cl::init(true));
|
||||||
|
|
||||||
static cl::opt<bool> EnableCyclicPath("misched-cyclicpath", cl::Hidden,
|
static cl::opt<bool> EnableCyclicPath("misched-cyclicpath", cl::Hidden,
|
||||||
cl::desc("Enable cyclic critical path analysis."), cl::init(false));
|
cl::desc("Enable cyclic critical path analysis."), cl::init(false));
|
||||||
|
|
||||||
@ -477,6 +480,8 @@ void ScheduleDAGMI::enterRegion(MachineBasicBlock *bb,
|
|||||||
{
|
{
|
||||||
ScheduleDAGInstrs::enterRegion(bb, begin, end, regioninstrs);
|
ScheduleDAGInstrs::enterRegion(bb, begin, end, regioninstrs);
|
||||||
|
|
||||||
|
ShouldTrackPressure = EnableRegPressure;
|
||||||
|
|
||||||
// For convenience remember the end of the liveness region.
|
// For convenience remember the end of the liveness region.
|
||||||
LiveRegionEnd =
|
LiveRegionEnd =
|
||||||
(RegionEnd == bb->end()) ? RegionEnd : llvm::next(RegionEnd);
|
(RegionEnd == bb->end()) ? RegionEnd : llvm::next(RegionEnd);
|
||||||
@ -657,6 +662,13 @@ void ScheduleDAGMI::schedule() {
|
|||||||
|
|
||||||
/// Build the DAG and setup three register pressure trackers.
|
/// Build the DAG and setup three register pressure trackers.
|
||||||
void ScheduleDAGMI::buildDAGWithRegPressure() {
|
void ScheduleDAGMI::buildDAGWithRegPressure() {
|
||||||
|
if (!ShouldTrackPressure) {
|
||||||
|
RPTracker.reset();
|
||||||
|
RegionCriticalPSets.clear();
|
||||||
|
buildSchedGraph(AA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the register pressure tracker used by buildSchedGraph.
|
// Initialize the register pressure tracker used by buildSchedGraph.
|
||||||
RPTracker.init(&MF, RegClassInfo, LIS, BB, LiveRegionEnd,
|
RPTracker.init(&MF, RegClassInfo, LIS, BB, LiveRegionEnd,
|
||||||
/*TrackUntiedDefs=*/true);
|
/*TrackUntiedDefs=*/true);
|
||||||
@ -820,11 +832,13 @@ void ScheduleDAGMI::initQueues(ArrayRef<SUnit*> TopRoots,
|
|||||||
SchedImpl->registerRoots();
|
SchedImpl->registerRoots();
|
||||||
|
|
||||||
// Advance past initial DebugValues.
|
// Advance past initial DebugValues.
|
||||||
assert(TopRPTracker.getPos() == RegionBegin && "bad initial Top tracker");
|
|
||||||
CurrentTop = nextIfDebug(RegionBegin, RegionEnd);
|
CurrentTop = nextIfDebug(RegionBegin, RegionEnd);
|
||||||
TopRPTracker.setPos(CurrentTop);
|
|
||||||
|
|
||||||
CurrentBottom = RegionEnd;
|
CurrentBottom = RegionEnd;
|
||||||
|
|
||||||
|
if (ShouldTrackPressure) {
|
||||||
|
assert(TopRPTracker.getPos() == RegionBegin && "bad initial Top tracker");
|
||||||
|
TopRPTracker.setPos(CurrentTop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Move an instruction and update register pressure.
|
/// Move an instruction and update register pressure.
|
||||||
@ -841,10 +855,12 @@ void ScheduleDAGMI::scheduleMI(SUnit *SU, bool IsTopNode) {
|
|||||||
TopRPTracker.setPos(MI);
|
TopRPTracker.setPos(MI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update top scheduled pressure.
|
if (ShouldTrackPressure) {
|
||||||
TopRPTracker.advance();
|
// Update top scheduled pressure.
|
||||||
assert(TopRPTracker.getPos() == CurrentTop && "out of sync");
|
TopRPTracker.advance();
|
||||||
updateScheduledPressure(TopRPTracker.getPressure().MaxSetPressure);
|
assert(TopRPTracker.getPos() == CurrentTop && "out of sync");
|
||||||
|
updateScheduledPressure(TopRPTracker.getPressure().MaxSetPressure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(SU->isBottomReady() && "node still has unscheduled dependencies");
|
assert(SU->isBottomReady() && "node still has unscheduled dependencies");
|
||||||
@ -860,12 +876,14 @@ void ScheduleDAGMI::scheduleMI(SUnit *SU, bool IsTopNode) {
|
|||||||
moveInstruction(MI, CurrentBottom);
|
moveInstruction(MI, CurrentBottom);
|
||||||
CurrentBottom = MI;
|
CurrentBottom = MI;
|
||||||
}
|
}
|
||||||
// Update bottom scheduled pressure.
|
if (ShouldTrackPressure) {
|
||||||
SmallVector<unsigned, 8> LiveUses;
|
// Update bottom scheduled pressure.
|
||||||
BotRPTracker.recede(&LiveUses);
|
SmallVector<unsigned, 8> LiveUses;
|
||||||
assert(BotRPTracker.getPos() == CurrentBottom && "out of sync");
|
BotRPTracker.recede(&LiveUses);
|
||||||
updatePressureDiffs(LiveUses);
|
assert(BotRPTracker.getPos() == CurrentBottom && "out of sync");
|
||||||
updateScheduledPressure(BotRPTracker.getPressure().MaxSetPressure);
|
updatePressureDiffs(LiveUses);
|
||||||
|
updateScheduledPressure(BotRPTracker.getPressure().MaxSetPressure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +153,24 @@ const LiveInterval *RegPressureTracker::getInterval(unsigned Reg) const {
|
|||||||
return LIS->getCachedRegUnit(Reg);
|
return LIS->getCachedRegUnit(Reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RegPressureTracker::reset() {
|
||||||
|
MBB = 0;
|
||||||
|
LIS = 0;
|
||||||
|
|
||||||
|
CurrSetPressure.clear();
|
||||||
|
LiveThruPressure.clear();
|
||||||
|
P.MaxSetPressure.clear();
|
||||||
|
|
||||||
|
if (RequireIntervals)
|
||||||
|
static_cast<IntervalPressure&>(P).reset();
|
||||||
|
else
|
||||||
|
static_cast<RegionPressure&>(P).reset();
|
||||||
|
|
||||||
|
LiveRegs.PhysRegs.clear();
|
||||||
|
LiveRegs.VirtRegs.clear();
|
||||||
|
UntiedDefs.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/// Setup the RegPressureTracker.
|
/// Setup the RegPressureTracker.
|
||||||
///
|
///
|
||||||
/// TODO: Add support for pressure without LiveIntervals.
|
/// TODO: Add support for pressure without LiveIntervals.
|
||||||
@ -163,6 +181,8 @@ void RegPressureTracker::init(const MachineFunction *mf,
|
|||||||
MachineBasicBlock::const_iterator pos,
|
MachineBasicBlock::const_iterator pos,
|
||||||
bool ShouldTrackUntiedDefs)
|
bool ShouldTrackUntiedDefs)
|
||||||
{
|
{
|
||||||
|
reset();
|
||||||
|
|
||||||
MF = mf;
|
MF = mf;
|
||||||
TRI = MF->getTarget().getRegisterInfo();
|
TRI = MF->getTarget().getRegisterInfo();
|
||||||
RCI = rci;
|
RCI = rci;
|
||||||
@ -177,19 +197,11 @@ void RegPressureTracker::init(const MachineFunction *mf,
|
|||||||
|
|
||||||
CurrPos = pos;
|
CurrPos = pos;
|
||||||
CurrSetPressure.assign(TRI->getNumRegPressureSets(), 0);
|
CurrSetPressure.assign(TRI->getNumRegPressureSets(), 0);
|
||||||
LiveThruPressure.clear();
|
|
||||||
|
|
||||||
if (RequireIntervals)
|
|
||||||
static_cast<IntervalPressure&>(P).reset();
|
|
||||||
else
|
|
||||||
static_cast<RegionPressure&>(P).reset();
|
|
||||||
P.MaxSetPressure = CurrSetPressure;
|
P.MaxSetPressure = CurrSetPressure;
|
||||||
|
|
||||||
LiveRegs.PhysRegs.clear();
|
|
||||||
LiveRegs.PhysRegs.setUniverse(TRI->getNumRegs());
|
LiveRegs.PhysRegs.setUniverse(TRI->getNumRegs());
|
||||||
LiveRegs.VirtRegs.clear();
|
|
||||||
LiveRegs.VirtRegs.setUniverse(MRI->getNumVirtRegs());
|
LiveRegs.VirtRegs.setUniverse(MRI->getNumVirtRegs());
|
||||||
UntiedDefs.clear();
|
|
||||||
if (TrackUntiedDefs)
|
if (TrackUntiedDefs)
|
||||||
UntiedDefs.setUniverse(MRI->getNumVirtRegs());
|
UntiedDefs.setUniverse(MRI->getNumVirtRegs());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user