Skip to content

Commit

Permalink
MachineScheduler: Add constructor functions for the DAGMutations
Browse files Browse the repository at this point in the history
Summary: This way they can be re-used by target-specific schedulers.

Reviewers: atrick, MatzeB, kparzysz

Subscribers: kparzysz, llvm-commits, MatzeB

Differential Revision: https://reviews.llvm.org/D23678

llvm-svn: 279305
  • Loading branch information
tstellarAMD committed Aug 19, 2016
1 parent 021151d commit 68726a5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
16 changes: 16 additions & 0 deletions llvm/include/llvm/CodeGen/MachineScheduler.h
Expand Up @@ -997,6 +997,22 @@ class PostGenericScheduler : public GenericSchedulerBase {
void pickNodeFromQueue(SchedCandidate &Cand);
};

std::unique_ptr<ScheduleDAGMutation>
createLoadClusterDAGMutation(const TargetInstrInfo *TII,
const TargetRegisterInfo *TRI);

std::unique_ptr<ScheduleDAGMutation>
createStoreClusterDAGMutation(const TargetInstrInfo *TII,
const TargetRegisterInfo *TRI);

std::unique_ptr<ScheduleDAGMutation>
createMacroFusionDAGMutation(const TargetInstrInfo *TII,
const TargetRegisterInfo *TRI);

std::unique_ptr<ScheduleDAGMutation>
createCopyConstrainDAGMutation(const TargetInstrInfo *TII,
const TargetRegisterInfo *TRI);

} // namespace llvm

#endif
44 changes: 40 additions & 4 deletions llvm/lib/CodeGen/MachineScheduler.cpp
Expand Up @@ -1392,6 +1392,22 @@ class LoadClusterMutation : public BaseMemOpClusterMutation {
};
} // anonymous

namespace llvm {

std::unique_ptr<ScheduleDAGMutation>
createLoadClusterDAGMutation(const TargetInstrInfo *TII,
const TargetRegisterInfo *TRI) {
return make_unique<LoadClusterMutation>(TII, TRI);
}

std::unique_ptr<ScheduleDAGMutation>
createStoreClusterDAGMutation(const TargetInstrInfo *TII,
const TargetRegisterInfo *TRI) {
return make_unique<StoreClusterMutation>(TII, TRI);
}

} // namespace llvm

void BaseMemOpClusterMutation::clusterNeighboringMemOps(
ArrayRef<SUnit *> MemOps, ScheduleDAGMI *DAG) {
SmallVector<MemOpInfo, 32> MemOpRecords;
Expand Down Expand Up @@ -1493,6 +1509,16 @@ class MacroFusion : public ScheduleDAGMutation {
};
} // anonymous

namespace llvm {

std::unique_ptr<ScheduleDAGMutation>
createMacroFusionDAGMutation(const TargetInstrInfo *TII,
const TargetRegisterInfo *TRI) {
return make_unique<MacroFusion>(*TII, *TRI);
}

} // namespace llvm

/// Returns true if \p MI reads a register written by \p Other.
static bool HasDataDep(const TargetRegisterInfo &TRI, const MachineInstr &MI,
const MachineInstr &Other) {
Expand Down Expand Up @@ -1569,6 +1595,16 @@ class CopyConstrain : public ScheduleDAGMutation {
};
} // anonymous

namespace llvm {

std::unique_ptr<ScheduleDAGMutation>
createCopyConstrainDAGMutation(const TargetInstrInfo *TII,
const TargetRegisterInfo *TRI) {
return make_unique<CopyConstrain>(TII, TRI);
}

} // namespace llvm

/// constrainLocalCopy handles two possibilities:
/// 1) Local src:
/// I0: = dst
Expand Down Expand Up @@ -3109,15 +3145,15 @@ static ScheduleDAGInstrs *createGenericSchedLive(MachineSchedContext *C) {
// FIXME: extend the mutation API to allow earlier mutations to instantiate
// data and pass it to later mutations. Have a single mutation that gathers
// the interesting nodes in one pass.
DAG->addMutation(make_unique<CopyConstrain>(DAG->TII, DAG->TRI));
DAG->addMutation(createCopyConstrainDAGMutation(DAG->TII, DAG->TRI));
if (EnableMemOpCluster) {
if (DAG->TII->enableClusterLoads())
DAG->addMutation(make_unique<LoadClusterMutation>(DAG->TII, DAG->TRI));
DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
if (DAG->TII->enableClusterStores())
DAG->addMutation(make_unique<StoreClusterMutation>(DAG->TII, DAG->TRI));
DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
}
if (EnableMacroFusion)
DAG->addMutation(make_unique<MacroFusion>(*DAG->TII, *DAG->TRI));
DAG->addMutation(createMacroFusionDAGMutation(DAG->TII, DAG->TRI));
return DAG;
}

Expand Down

0 comments on commit 68726a5

Please sign in to comment.