diff options
author | Pengcheng Wang <wangpengcheng.pp@bytedance.com> | 2025-06-03 11:37:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-03 11:37:40 +0800 |
commit | f393986b53b108457529213c1559346fdb8120ae (patch) | |
tree | c486b0e38c60c7b742dcce785f7f88797baca574 /llvm/lib/CodeGen/MachineScheduler.cpp | |
parent | 94011efe30c18505c09f7b588854e51b98cb2a71 (diff) | |
download | llvm-f393986b53b108457529213c1559346fdb8120ae.zip llvm-f393986b53b108457529213c1559346fdb8120ae.tar.gz llvm-f393986b53b108457529213c1559346fdb8120ae.tar.bz2 |
[MISched] Add templates for creating custom schedulers (#141935)
We rename `createGenericSchedLive` and `createGenericSchedPostRA`
to `createSchedLive` and `createSchedPostRA`, and add a template
parameter `Strategy` which is the generic implementation by default.
This can simplify some code for targets that have custom scheduler
strategy.
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineScheduler.cpp | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index 6e9a4a7..2cc7f54 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -547,7 +547,7 @@ ScheduleDAGInstrs *MachineSchedulerImpl::createMachineScheduler() { return Scheduler; // Default to GenericScheduler. - return createGenericSchedLive(this); + return createSchedLive(this); } bool MachineSchedulerImpl::run(MachineFunction &Func, const TargetMachine &TM, @@ -595,7 +595,7 @@ ScheduleDAGInstrs *PostMachineSchedulerImpl::createPostMachineScheduler() { return Scheduler; // Default to GenericScheduler. - return createGenericSchedPostRA(this); + return createSchedPostRA(this); } bool PostMachineSchedulerImpl::run(MachineFunction &Func, @@ -4273,28 +4273,8 @@ void GenericScheduler::schedNode(SUnit *SU, bool IsTopNode) { } } -/// Create the standard converging machine scheduler. This will be used as the -/// default scheduler if the target does not set a default. -ScheduleDAGMILive *llvm::createGenericSchedLive(MachineSchedContext *C) { - ScheduleDAGMILive *DAG = - new ScheduleDAGMILive(C, std::make_unique<GenericScheduler>(C)); - // Register DAG post-processors. - // - // 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(createCopyConstrainDAGMutation(DAG->TII, DAG->TRI)); - - const TargetSubtargetInfo &STI = C->MF->getSubtarget(); - // Add MacroFusion mutation if fusions are not empty. - const auto &MacroFusions = STI.getMacroFusions(); - if (!MacroFusions.empty()) - DAG->addMutation(createMacroFusionDAGMutation(MacroFusions)); - return DAG; -} - static ScheduleDAGInstrs *createConvergingSched(MachineSchedContext *C) { - return createGenericSchedLive(C); + return createSchedLive(C); } static MachineSchedRegistry @@ -4598,18 +4578,6 @@ void PostGenericScheduler::schedNode(SUnit *SU, bool IsTopNode) { } } -ScheduleDAGMI *llvm::createGenericSchedPostRA(MachineSchedContext *C) { - ScheduleDAGMI *DAG = - new ScheduleDAGMI(C, std::make_unique<PostGenericScheduler>(C), - /*RemoveKillFlags=*/true); - const TargetSubtargetInfo &STI = C->MF->getSubtarget(); - // Add MacroFusion mutation if fusions are not empty. - const auto &MacroFusions = STI.getMacroFusions(); - if (!MacroFusions.empty()) - DAG->addMutation(createMacroFusionDAGMutation(MacroFusions)); - return DAG; -} - //===----------------------------------------------------------------------===// // ILP Scheduler. Currently for experimental analysis of heuristics. //===----------------------------------------------------------------------===// |