diff options
| author | Mehdi Amini <mehdi.amini@apple.com> | 2015-07-28 06:18:04 +0000 |
|---|---|---|
| committer | Mehdi Amini <mehdi.amini@apple.com> | 2015-07-28 06:18:04 +0000 |
| commit | b58f8137c12abd8ab2cc3407ac835e38c1447a66 (patch) | |
| tree | caa6457ca107e8fcce239b23ec082093c9b7cbe3 | |
| parent | c2a589169cf1bd9a999da67ac6ed9a3f78b919fa (diff) | |
| download | bcm5719-llvm-b58f8137c12abd8ab2cc3407ac835e38c1447a66.tar.gz bcm5719-llvm-b58f8137c12abd8ab2cc3407ac835e38c1447a66.zip | |
Move the Target way of overriding DAG Scheduler to a target hook
Summary:
The previous way of overriding it was relying on calling "setDefault"
on the global registry, which implies global mutable state.
Reviewers: echristo, atrick
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11538
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 243388
| -rw-r--r-- | llvm/include/llvm/CodeGen/SchedulerRegistry.h | 6 | ||||
| -rw-r--r-- | llvm/include/llvm/Target/TargetSubtargetInfo.h | 6 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 14 |
3 files changed, 12 insertions, 14 deletions
diff --git a/llvm/include/llvm/CodeGen/SchedulerRegistry.h b/llvm/include/llvm/CodeGen/SchedulerRegistry.h index 51ac7f28527..a7a6227664d 100644 --- a/llvm/include/llvm/CodeGen/SchedulerRegistry.h +++ b/llvm/include/llvm/CodeGen/SchedulerRegistry.h @@ -52,12 +52,6 @@ public: static RegisterScheduler *getList() { return (RegisterScheduler *)Registry.getList(); } - static FunctionPassCtor getDefault() { - return (FunctionPassCtor)Registry.getDefault(); - } - static void setDefault(FunctionPassCtor C) { - Registry.setDefault((MachinePassCtor)C); - } static void setListener(MachinePassRegistryListener *L) { Registry.setListener(L); } diff --git a/llvm/include/llvm/Target/TargetSubtargetInfo.h b/llvm/include/llvm/Target/TargetSubtargetInfo.h index 07c0c66bfa1..d50aa4932f8 100644 --- a/llvm/include/llvm/Target/TargetSubtargetInfo.h +++ b/llvm/include/llvm/Target/TargetSubtargetInfo.h @@ -15,6 +15,7 @@ #define LLVM_TARGET_TARGETSUBTARGETINFO_H #include "llvm/CodeGen/PBQPRAConstraint.h" +#include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/CodeGen.h" @@ -81,6 +82,11 @@ public: virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const { return nullptr; } + /// Target can subclass this hook to select a different DAG scheduler. + virtual RegisterScheduler::FunctionPassCtor + getDAGScheduler(CodeGenOpt::Level) const { + return nullptr; + } /// getRegisterInfo - If register information is available, return it. If /// not, return null. This is kept separate from RegInfo until RegInfo has diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index c3dab9cc293..6b5fcb095e2 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -293,6 +293,11 @@ namespace llvm { const TargetLowering *TLI = IS->TLI; const TargetSubtargetInfo &ST = IS->MF->getSubtarget(); + // Try first to see if the Target has its own way of selecting a scheduler + if (auto *SchedulerCtor = ST.getDAGScheduler(OptLevel)) { + return SchedulerCtor(IS, OptLevel); + } + if (OptLevel == CodeGenOpt::None || (ST.enableMachineScheduler() && ST.enableMachineSchedDefaultSched()) || TLI->getSchedulingPreference() == Sched::Source) @@ -1643,14 +1648,7 @@ SelectionDAGISel::FinishBasicBlock() { /// one preferred by the target. /// ScheduleDAGSDNodes *SelectionDAGISel::CreateScheduler() { - RegisterScheduler::FunctionPassCtor Ctor = RegisterScheduler::getDefault(); - - if (!Ctor) { - Ctor = ISHeuristic; - RegisterScheduler::setDefault(Ctor); - } - - return Ctor(this, OptLevel); + return ISHeuristic(this, OptLevel); } //===----------------------------------------------------------------------===// |

