mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
misched: add a hook for custom DAG postprocessing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163915 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -179,6 +179,14 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Mutate the DAG as a postpass after normal DAG building.
|
||||||
|
class ScheduleDAGMutation {
|
||||||
|
public:
|
||||||
|
virtual ~ScheduleDAGMutation() {}
|
||||||
|
|
||||||
|
virtual void apply(ScheduleDAGMI *DAG) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/// ScheduleDAGMI is an implementation of ScheduleDAGInstrs that schedules
|
/// ScheduleDAGMI is an implementation of ScheduleDAGInstrs that schedules
|
||||||
/// machine instructions while updating LiveIntervals and tracking regpressure.
|
/// machine instructions while updating LiveIntervals and tracking regpressure.
|
||||||
class ScheduleDAGMI : public ScheduleDAGInstrs {
|
class ScheduleDAGMI : public ScheduleDAGInstrs {
|
||||||
@ -187,6 +195,9 @@ protected:
|
|||||||
RegisterClassInfo *RegClassInfo;
|
RegisterClassInfo *RegClassInfo;
|
||||||
MachineSchedStrategy *SchedImpl;
|
MachineSchedStrategy *SchedImpl;
|
||||||
|
|
||||||
|
/// Ordered list of DAG postprocessing steps.
|
||||||
|
std::vector<ScheduleDAGMutation*> Mutations;
|
||||||
|
|
||||||
MachineBasicBlock::iterator LiveRegionEnd;
|
MachineBasicBlock::iterator LiveRegionEnd;
|
||||||
|
|
||||||
/// Register pressure in this region computed by buildSchedGraph.
|
/// Register pressure in this region computed by buildSchedGraph.
|
||||||
@ -229,6 +240,13 @@ public:
|
|||||||
delete SchedImpl;
|
delete SchedImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a postprocessing step to the DAG builder.
|
||||||
|
/// Mutations are applied in the order that they are added after normal DAG
|
||||||
|
/// building and before MachineSchedStrategy initialization.
|
||||||
|
void addMutation(ScheduleDAGMutation *Mutation) {
|
||||||
|
Mutations.push_back(Mutation);
|
||||||
|
}
|
||||||
|
|
||||||
MachineBasicBlock::iterator top() const { return CurrentTop; }
|
MachineBasicBlock::iterator top() const { return CurrentTop; }
|
||||||
MachineBasicBlock::iterator bottom() const { return CurrentBottom; }
|
MachineBasicBlock::iterator bottom() const { return CurrentBottom; }
|
||||||
|
|
||||||
@ -282,6 +300,10 @@ protected:
|
|||||||
/// bottom of the DAG region without covereing any unscheduled instruction.
|
/// bottom of the DAG region without covereing any unscheduled instruction.
|
||||||
void buildDAGWithRegPressure();
|
void buildDAGWithRegPressure();
|
||||||
|
|
||||||
|
/// Apply each ScheduleDAGMutation step in order. This allows different
|
||||||
|
/// instances of ScheduleDAGMI to perform custom DAG postprocessing.
|
||||||
|
void postprocessDAG();
|
||||||
|
|
||||||
/// Identify DAG roots and setup scheduler queues.
|
/// Identify DAG roots and setup scheduler queues.
|
||||||
void initQueues();
|
void initQueues();
|
||||||
|
|
||||||
|
@ -484,6 +484,8 @@ void ScheduleDAGMI::releaseRoots() {
|
|||||||
void ScheduleDAGMI::schedule() {
|
void ScheduleDAGMI::schedule() {
|
||||||
buildDAGWithRegPressure();
|
buildDAGWithRegPressure();
|
||||||
|
|
||||||
|
postprocessDAG();
|
||||||
|
|
||||||
DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
|
DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
|
||||||
SUnits[su].dumpAll(this));
|
SUnits[su].dumpAll(this));
|
||||||
|
|
||||||
@ -522,6 +524,13 @@ void ScheduleDAGMI::buildDAGWithRegPressure() {
|
|||||||
initRegPressure();
|
initRegPressure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Apply each ScheduleDAGMutation step in order.
|
||||||
|
void ScheduleDAGMI::postprocessDAG() {
|
||||||
|
for (unsigned i = 0, e = Mutations.size(); i < e; ++i) {
|
||||||
|
Mutations[i]->apply(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Identify DAG roots and setup scheduler queues.
|
/// Identify DAG roots and setup scheduler queues.
|
||||||
void ScheduleDAGMI::initQueues() {
|
void ScheduleDAGMI::initQueues() {
|
||||||
// Initialize the strategy before modifying the DAG.
|
// Initialize the strategy before modifying the DAG.
|
||||||
|
Reference in New Issue
Block a user