#include "llvm/CodeGen/RegisterPressure.h"
#include "llvm/CodeGen/ScheduleDAG.h"
#include "llvm/CodeGen/ScheduleDAGInstrs.h"
+#include "llvm/CodeGen/ScheduleDAGMutation.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCInstrItineraries.h"
/// must be deleted when the pass is finished.
SmallPtrSet<MachineInstr *, 4> NewMIs;
+ /// Ordered list of DAG postprocessing steps.
+ std::vector<std::unique_ptr<ScheduleDAGMutation>> Mutations;
+
/// Helper class to implement Johnson's circuit finding algorithm.
class Circuits {
std::vector<SUnit> &SUnits;
const RegisterClassInfo &rci)
: ScheduleDAGInstrs(*P.MF, P.MLI, false), Pass(P), MII(0),
Scheduled(false), Loop(L), LIS(lis), RegClassInfo(rci),
- Topo(SUnits, &ExitSU) {}
+ Topo(SUnits, &ExitSU) {
+ P.MF->getSubtarget().getSMSMutations(Mutations);
+ }
void schedule() override;
void finishBlock() override;
return 0;
}
+ void addMutation(std::unique_ptr<ScheduleDAGMutation> Mutation) {
+ Mutations.push_back(std::move(Mutation));
+ }
+
private:
void addLoopCarriedDependences(AliasAnalysis *AA);
void updatePhiDependences();
bool canUseLastOffsetValue(MachineInstr *MI, unsigned &BasePos,
unsigned &OffsetPos, unsigned &NewBase,
int64_t &NewOffset);
+ void postprocessDAG();
};
/// A NodeSet contains a set of SUnit DAG nodes with additional information
addLoopCarriedDependences(AA);
updatePhiDependences();
Topo.InitDAGTopologicalSorting();
+ postprocessDAG();
changeDependences();
DEBUG({
for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
return true;
}
+void SwingSchedulerDAG::postprocessDAG() {
+ for (auto &M : Mutations)
+ M->apply(this);
+}
+
/// Try to schedule the node at the specified StartCycle and continue
/// until the node is schedule or the EndCycle is reached. This function
/// returns true if the node is scheduled. This routine may search either