[PATCH] D11538: Move the Target way of overriding DAG Scheduler to a target hook

Mehdi AMINI mehdi.amini at apple.com
Mon Jul 27 13:47:08 PDT 2015


joker.eph created this revision.
joker.eph added reviewers: echristo, atrick.
joker.eph added a subscriber: llvm-commits.

The previous way of overriding it was relying on calling "setDefault"
on the global registry, which implies global mutable state.

http://reviews.llvm.org/D11538

Files:
  include/llvm/CodeGen/SchedulerRegistry.h
  include/llvm/Target/TargetSubtargetInfo.h
  lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -55,6 +55,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetRegisterInfo.h"
+#include "llvm/Target/TargetSelectionDAGInfo.h"
 #include "llvm/Target/TargetSubtargetInfo.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include <algorithm>
@@ -1643,11 +1644,11 @@
 /// one preferred by the target.
 ///
 ScheduleDAGSDNodes *SelectionDAGISel::CreateScheduler() {
-  RegisterScheduler::FunctionPassCtor Ctor = RegisterScheduler::getDefault();
+  RegisterScheduler::FunctionPassCtor Ctor =
+      CurDAG->getSubtarget().getDefaultDAGScheduler();
 
   if (!Ctor) {
     Ctor = ISHeuristic;
-    RegisterScheduler::setDefault(Ctor);
   }
 
   return Ctor(this, OptLevel);
Index: include/llvm/Target/TargetSubtargetInfo.h
===================================================================
--- include/llvm/Target/TargetSubtargetInfo.h
+++ include/llvm/Target/TargetSubtargetInfo.h
@@ -17,6 +17,7 @@
 #include "llvm/CodeGen/PBQPRAConstraint.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/Support/CodeGen.h"
+#include "llvm/Target/TargetSelectionDAGInfo.h"
 
 namespace llvm {
 
@@ -81,6 +82,10 @@
   virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
     return nullptr;
   }
+  /// Target can subclass this hook to select a different DAG scheduler.
+  virtual RegisterScheduler::FunctionPassCtor getDefaultDAGScheduler() const {
+    return nullptr;
+  }
 
   /// getRegisterInfo - If register information is available, return it.  If
   /// not, return null.  This is kept separate from RegInfo until RegInfo has
Index: include/llvm/CodeGen/SchedulerRegistry.h
===================================================================
--- include/llvm/CodeGen/SchedulerRegistry.h
+++ include/llvm/CodeGen/SchedulerRegistry.h
@@ -52,12 +52,6 @@
   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);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11538.30731.patch
Type: text/x-patch
Size: 2449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150727/3f4d7914/attachment.bin>


More information about the llvm-commits mailing list