mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
misched: allow the default scheduler to be one chosen by the target.
llvm-svn: 152360
This commit is contained in:
parent
d214a5ef98
commit
71ba4d00f2
@ -15,8 +15,12 @@
|
|||||||
// return new CustomMachineScheduler(C);
|
// return new CustomMachineScheduler(C);
|
||||||
// }
|
// }
|
||||||
// static MachineSchedRegistry
|
// static MachineSchedRegistry
|
||||||
// SchedDefaultRegistry("custom", "Run my target's custom scheduler",
|
// SchedCustomRegistry("custom", "Run my target's custom scheduler",
|
||||||
// createCustomMachineSched);
|
// createCustomMachineSched);
|
||||||
|
//
|
||||||
|
// Inside <Target>PassConfig:
|
||||||
|
// enablePass(MachineSchedulerID);
|
||||||
|
// MachineSchedRegistry::setDefault(createCustomMachineSched);
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
@ -39,10 +43,11 @@ struct MachineSchedContext {
|
|||||||
MachineFunction *MF;
|
MachineFunction *MF;
|
||||||
const MachineLoopInfo *MLI;
|
const MachineLoopInfo *MLI;
|
||||||
const MachineDominatorTree *MDT;
|
const MachineDominatorTree *MDT;
|
||||||
|
const TargetPassConfig *PassConfig;
|
||||||
AliasAnalysis *AA;
|
AliasAnalysis *AA;
|
||||||
LiveIntervals *LIS;
|
LiveIntervals *LIS;
|
||||||
|
|
||||||
MachineSchedContext(): MF(0), MLI(0), MDT(0), AA(0), LIS(0) {}
|
MachineSchedContext(): MF(0), MLI(0), MDT(0), PassConfig(0), AA(0), LIS(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// MachineSchedRegistry provides a selection of available machine instruction
|
/// MachineSchedRegistry provides a selection of available machine instruction
|
||||||
|
@ -82,7 +82,7 @@ void MachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
AU.addRequiredID(MachineDominatorsID);
|
AU.addRequiredID(MachineDominatorsID);
|
||||||
AU.addRequired<MachineLoopInfo>();
|
AU.addRequired<MachineLoopInfo>();
|
||||||
AU.addRequired<AliasAnalysis>();
|
AU.addRequired<AliasAnalysis>();
|
||||||
AU.addPreserved<AliasAnalysis>();
|
AU.addRequired<TargetPassConfig>();
|
||||||
AU.addRequired<SlotIndexes>();
|
AU.addRequired<SlotIndexes>();
|
||||||
AU.addPreserved<SlotIndexes>();
|
AU.addPreserved<SlotIndexes>();
|
||||||
AU.addRequired<LiveIntervals>();
|
AU.addRequired<LiveIntervals>();
|
||||||
@ -92,31 +92,47 @@ void MachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
|
|
||||||
MachinePassRegistry MachineSchedRegistry::Registry;
|
MachinePassRegistry MachineSchedRegistry::Registry;
|
||||||
|
|
||||||
static ScheduleDAGInstrs *createDefaultMachineSched(MachineSchedContext *C);
|
/// A dummy default scheduler factory indicates whether the scheduler
|
||||||
|
/// is overridden on the command line.
|
||||||
|
static ScheduleDAGInstrs *useDefaultMachineSched(MachineSchedContext *C) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// MachineSchedOpt allows command line selection of the scheduler.
|
/// MachineSchedOpt allows command line selection of the scheduler.
|
||||||
static cl::opt<MachineSchedRegistry::ScheduleDAGCtor, false,
|
static cl::opt<MachineSchedRegistry::ScheduleDAGCtor, false,
|
||||||
RegisterPassParser<MachineSchedRegistry> >
|
RegisterPassParser<MachineSchedRegistry> >
|
||||||
MachineSchedOpt("misched",
|
MachineSchedOpt("misched",
|
||||||
cl::init(&createDefaultMachineSched), cl::Hidden,
|
cl::init(&useDefaultMachineSched), cl::Hidden,
|
||||||
cl::desc("Machine instruction scheduler to use"));
|
cl::desc("Machine instruction scheduler to use"));
|
||||||
|
|
||||||
|
static MachineSchedRegistry
|
||||||
|
SchedDefaultRegistry("default", "Use the target's default scheduler choice.",
|
||||||
|
useDefaultMachineSched);
|
||||||
|
|
||||||
|
/// Forward declare the common machine scheduler. This will be used as the
|
||||||
|
/// default scheduler if the target does not set a default.
|
||||||
|
static ScheduleDAGInstrs *createCommonMachineSched(MachineSchedContext *C);
|
||||||
|
|
||||||
bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
|
bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
|
||||||
// Initialize the context of the pass.
|
// Initialize the context of the pass.
|
||||||
MF = &mf;
|
MF = &mf;
|
||||||
MLI = &getAnalysis<MachineLoopInfo>();
|
MLI = &getAnalysis<MachineLoopInfo>();
|
||||||
MDT = &getAnalysis<MachineDominatorTree>();
|
MDT = &getAnalysis<MachineDominatorTree>();
|
||||||
|
PassConfig = &getAnalysis<TargetPassConfig>();
|
||||||
AA = &getAnalysis<AliasAnalysis>();
|
AA = &getAnalysis<AliasAnalysis>();
|
||||||
|
|
||||||
LIS = &getAnalysis<LiveIntervals>();
|
LIS = &getAnalysis<LiveIntervals>();
|
||||||
const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
|
const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
|
||||||
|
|
||||||
// Select the scheduler, or set the default.
|
// Select the scheduler, or set the default.
|
||||||
MachineSchedRegistry::ScheduleDAGCtor Ctor =
|
MachineSchedRegistry::ScheduleDAGCtor Ctor = MachineSchedOpt;
|
||||||
MachineSchedRegistry::getDefault();
|
if (Ctor == useDefaultMachineSched) {
|
||||||
if (!Ctor) {
|
// Get the default scheduler set by the target.
|
||||||
Ctor = MachineSchedOpt;
|
Ctor = MachineSchedRegistry::getDefault();
|
||||||
MachineSchedRegistry::setDefault(Ctor);
|
if (!Ctor) {
|
||||||
|
Ctor = createCommonMachineSched;
|
||||||
|
MachineSchedRegistry::setDefault(Ctor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Instantiate the selected scheduler.
|
// Instantiate the selected scheduler.
|
||||||
OwningPtr<ScheduleDAGInstrs> Scheduler(Ctor(this));
|
OwningPtr<ScheduleDAGInstrs> Scheduler(Ctor(this));
|
||||||
@ -283,10 +299,10 @@ void ScheduleTopDownLive::schedule() {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class DefaultMachineScheduler : public ScheduleDAGInstrs {
|
class CommonMachineScheduler : public ScheduleDAGInstrs {
|
||||||
AliasAnalysis *AA;
|
AliasAnalysis *AA;
|
||||||
public:
|
public:
|
||||||
DefaultMachineScheduler(MachineSchedContext *C):
|
CommonMachineScheduler(MachineSchedContext *C):
|
||||||
ScheduleDAGInstrs(*C->MF, *C->MLI, *C->MDT, /*IsPostRA=*/false, C->LIS),
|
ScheduleDAGInstrs(*C->MF, *C->MLI, *C->MDT, /*IsPostRA=*/false, C->LIS),
|
||||||
AA(C->AA) {}
|
AA(C->AA) {}
|
||||||
|
|
||||||
@ -296,17 +312,18 @@ public:
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
static ScheduleDAGInstrs *createDefaultMachineSched(MachineSchedContext *C) {
|
/// The common machine scheduler will be used as the default scheduler if the
|
||||||
return new DefaultMachineScheduler(C);
|
/// target does not set a default.
|
||||||
|
static ScheduleDAGInstrs *createCommonMachineSched(MachineSchedContext *C) {
|
||||||
|
return new CommonMachineScheduler(C);
|
||||||
}
|
}
|
||||||
static MachineSchedRegistry
|
static MachineSchedRegistry
|
||||||
SchedDefaultRegistry("default", "Activate the scheduler pass, "
|
SchedCommonRegistry("common", "Use the target's default scheduler choice.",
|
||||||
"but don't reorder instructions",
|
createCommonMachineSched);
|
||||||
createDefaultMachineSched);
|
|
||||||
|
|
||||||
/// Schedule - This is called back from ScheduleDAGInstrs::Run() when it's
|
/// Schedule - This is called back from ScheduleDAGInstrs::Run() when it's
|
||||||
/// time to do some work.
|
/// time to do some work.
|
||||||
void DefaultMachineScheduler::schedule() {
|
void CommonMachineScheduler::schedule() {
|
||||||
buildSchedGraph(AA);
|
buildSchedGraph(AA);
|
||||||
|
|
||||||
DEBUG(dbgs() << "********** MI Scheduling **********\n");
|
DEBUG(dbgs() << "********** MI Scheduling **********\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user