Skip to content

Commit 5f22dd7

Browse files
committed
Add a subtarget hook: enablePostMachineScheduler.
As requested by AArch64 subtargets. Note that this will have no effect until the AArch64 target actually enables the pass like this: substitutePass(&PostRASchedulerID, &PostMachineSchedulerID); As soon as armv7 switches over, PostMachineScheduler will become the default postRA scheduler, so this won't be necessary any more. Targets using the old postRA schedule would then do: substitutePass(&PostMachineSchedulerID, &PostRASchedulerID); git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210167 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 0c83424 commit 5f22dd7

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

include/llvm/Target/TargetSubtargetInfo.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ class TargetSubtargetInfo : public MCSubtargetInfo {
6666
/// scheduler. It does not yet disable the postRA scheduler.
6767
virtual bool enableMachineScheduler() const;
6868

69+
/// \brief True if the subtarget should run PostMachineScheduler.
70+
///
71+
/// This only takes effect if the target has configured the
72+
/// PostMachineScheduler pass to run, or if the global cl::opt flag,
73+
/// MISchedPostRA, is set.
74+
virtual bool enablePostMachineScheduler() const;
75+
6976
/// \brief Override generic scheduling policy within a region.
7077
///
7178
/// This is a convenient way for targets that don't provide any custom

lib/CodeGen/MachineScheduler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ bool PostMachineScheduler::runOnMachineFunction(MachineFunction &mf) {
333333
if (skipOptnoneFunction(*mf.getFunction()))
334334
return false;
335335

336+
const TargetSubtargetInfo &ST =
337+
mf.getTarget().getSubtarget<TargetSubtargetInfo>();
338+
if (!ST.enablePostMachineScheduler()) {
339+
DEBUG(dbgs() << "Subtarget disables post-MI-sched.\n");
340+
return false;
341+
}
336342
DEBUG(dbgs() << "Before post-MI-sched:\n"; mf.print(dbgs()));
337343

338344
// Initialize the context of the pass.

lib/CodeGen/Passes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ PrintMachineInstrs("print-machineinstrs", cl::ValueOptional,
9292

9393
// Temporary option to allow experimenting with MachineScheduler as a post-RA
9494
// scheduler. Targets can "properly" enable this with
95-
// substitutePass(&PostRASchedulerID, &MachineSchedulerID); Ideally it wouldn't
96-
// be part of the standard pass pipeline, and the target would just add a PostRA
97-
// scheduling pass wherever it wants.
95+
// substitutePass(&PostRASchedulerID, &PostMachineSchedulerID); Ideally it
96+
// wouldn't be part of the standard pass pipeline, and the target would just add
97+
// a PostRA scheduling pass wherever it wants.
9898
static cl::opt<bool> MISchedPostRA("misched-postra", cl::Hidden,
9999
cl::desc("Run MachineScheduler post regalloc (independent of preRA sched)"));
100100

lib/Target/ARM/ARMSubtarget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ bool ARMSubtarget::hasSinCos() const {
352352
!getTargetTriple().isOSVersionLT(7, 0);
353353
}
354354

355+
// Enable the PostMachineScheduler if the target selects it instead of
356+
// PostRAScheduler. Currently only available on the command line via
357+
// -misched-postra.
358+
bool ARMSubtarget::enablePostMachineScheduler() const {
359+
return PostRAScheduler;
360+
}
361+
355362
bool ARMSubtarget::enablePostRAScheduler(
356363
CodeGenOpt::Level OptLevel,
357364
TargetSubtargetInfo::AntiDepBreakMode& Mode,

lib/Target/ARM/ARMSubtarget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
396396
/// compiler runtime or math libraries.
397397
bool hasSinCos() const;
398398

399+
/// True for some subtargets at > -O0.
400+
bool enablePostMachineScheduler() const;
401+
399402
/// enablePostRAScheduler - True at 'More' optimization.
400403
bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
401404
TargetSubtargetInfo::AntiDepBreakMode& Mode,

lib/Target/TargetSubtargetInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ bool TargetSubtargetInfo::enableMachineScheduler() const {
4343
return false;
4444
}
4545

46+
bool TargetSubtargetInfo::enablePostMachineScheduler() const {
47+
return false;
48+
}
49+
4650
bool TargetSubtargetInfo::enablePostRAScheduler(
4751
CodeGenOpt::Level OptLevel,
4852
AntiDepBreakMode& Mode,

0 commit comments

Comments
 (0)