mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Stub out a PostMachineScheduler pass.
Placeholder and boilerplate for a PostRA MachineScheduler pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198120 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a38b0de893
commit
c5443a90d8
@ -207,9 +207,9 @@ public:
|
|||||||
/// Fully developed targets will not generally override this.
|
/// Fully developed targets will not generally override this.
|
||||||
virtual void addMachinePasses();
|
virtual void addMachinePasses();
|
||||||
|
|
||||||
/// createTargetScheduler - Create an instance of ScheduleDAGInstrs to be run
|
/// Create an instance of ScheduleDAGInstrs to be run within the standard
|
||||||
/// within the standard MachineScheduler pass for this function and target at
|
/// MachineScheduler pass for this function and target at the current
|
||||||
/// the current optimization level.
|
/// optimization level.
|
||||||
///
|
///
|
||||||
/// This can also be used to plug a new MachineSchedStrategy into an instance
|
/// This can also be used to plug a new MachineSchedStrategy into an instance
|
||||||
/// of the standard ScheduleDAGMI:
|
/// of the standard ScheduleDAGMI:
|
||||||
@ -221,6 +221,13 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Similar to createMachineScheduler but used when postRA machine scheduling
|
||||||
|
/// is enabled.
|
||||||
|
virtual ScheduleDAGInstrs *
|
||||||
|
createPostMachineScheduler(MachineSchedContext *C) const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Helper to verify the analysis is really immutable.
|
// Helper to verify the analysis is really immutable.
|
||||||
void setOpt(bool &Opt, bool Val);
|
void setOpt(bool &Opt, bool Val);
|
||||||
@ -403,6 +410,9 @@ namespace llvm {
|
|||||||
/// MachineScheduler - This pass schedules machine instructions.
|
/// MachineScheduler - This pass schedules machine instructions.
|
||||||
extern char &MachineSchedulerID;
|
extern char &MachineSchedulerID;
|
||||||
|
|
||||||
|
/// PostMachineScheduler - This pass schedules machine instructions postRA.
|
||||||
|
extern char &PostMachineSchedulerID;
|
||||||
|
|
||||||
/// SpillPlacement analysis. Suggest optimal placement of spill code between
|
/// SpillPlacement analysis. Suggest optimal placement of spill code between
|
||||||
/// basic blocks.
|
/// basic blocks.
|
||||||
extern char &SpillPlacementID;
|
extern char &SpillPlacementID;
|
||||||
|
@ -210,6 +210,7 @@ void initializePostDomPrinterPass(PassRegistry&);
|
|||||||
void initializePostDomViewerPass(PassRegistry&);
|
void initializePostDomViewerPass(PassRegistry&);
|
||||||
void initializePostDominatorTreePass(PassRegistry&);
|
void initializePostDominatorTreePass(PassRegistry&);
|
||||||
void initializePostRASchedulerPass(PassRegistry&);
|
void initializePostRASchedulerPass(PassRegistry&);
|
||||||
|
void initializePostMachineSchedulerPass(PassRegistry&);
|
||||||
void initializePreVerifierPass(PassRegistry&);
|
void initializePreVerifierPass(PassRegistry&);
|
||||||
void initializePrintFunctionPassPass(PassRegistry&);
|
void initializePrintFunctionPassPass(PassRegistry&);
|
||||||
void initializePrintModulePassPass(PassRegistry&);
|
void initializePrintModulePassPass(PassRegistry&);
|
||||||
|
@ -51,6 +51,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
|
|||||||
initializeOptimizePHIsPass(Registry);
|
initializeOptimizePHIsPass(Registry);
|
||||||
initializePHIEliminationPass(Registry);
|
initializePHIEliminationPass(Registry);
|
||||||
initializePeepholeOptimizerPass(Registry);
|
initializePeepholeOptimizerPass(Registry);
|
||||||
|
initializePostMachineSchedulerPass(Registry);
|
||||||
initializePostRASchedulerPass(Registry);
|
initializePostRASchedulerPass(Registry);
|
||||||
initializeProcessImplicitDefsPass(Registry);
|
initializeProcessImplicitDefsPass(Registry);
|
||||||
initializePEIPass(Registry);
|
initializePEIPass(Registry);
|
||||||
|
@ -116,6 +116,21 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
ScheduleDAGInstrs *createMachineScheduler();
|
ScheduleDAGInstrs *createMachineScheduler();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// PostMachineScheduler runs after shortly before code emission.
|
||||||
|
class PostMachineScheduler : public MachineSchedulerBase {
|
||||||
|
public:
|
||||||
|
PostMachineScheduler();
|
||||||
|
|
||||||
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
||||||
|
|
||||||
|
virtual bool runOnMachineFunction(MachineFunction&);
|
||||||
|
|
||||||
|
static char ID; // Class identification, replacement for typeinfo
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ScheduleDAGInstrs *createPostMachineScheduler();
|
||||||
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
char MachineScheduler::ID = 0;
|
char MachineScheduler::ID = 0;
|
||||||
@ -148,6 +163,26 @@ void MachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char PostMachineScheduler::ID = 0;
|
||||||
|
|
||||||
|
char &llvm::PostMachineSchedulerID = PostMachineScheduler::ID;
|
||||||
|
|
||||||
|
INITIALIZE_PASS(PostMachineScheduler, "postmisched",
|
||||||
|
"PostRA Machine Instruction Scheduler", false, false);
|
||||||
|
|
||||||
|
PostMachineScheduler::PostMachineScheduler()
|
||||||
|
: MachineSchedulerBase(ID) {
|
||||||
|
initializePostMachineSchedulerPass(*PassRegistry::getPassRegistry());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PostMachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
|
AU.setPreservesCFG();
|
||||||
|
AU.addRequiredID(MachineDominatorsID);
|
||||||
|
AU.addRequired<MachineLoopInfo>();
|
||||||
|
AU.addRequired<TargetPassConfig>();
|
||||||
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
|
}
|
||||||
|
|
||||||
MachinePassRegistry MachineSchedRegistry::Registry;
|
MachinePassRegistry MachineSchedRegistry::Registry;
|
||||||
|
|
||||||
/// A dummy default scheduler factory indicates whether the scheduler
|
/// A dummy default scheduler factory indicates whether the scheduler
|
||||||
@ -232,6 +267,20 @@ ScheduleDAGInstrs *MachineScheduler::createMachineScheduler() {
|
|||||||
return createGenericSched(this);
|
return createGenericSched(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Instantiate a ScheduleDAGInstrs for PostRA scheduling that will be owned by
|
||||||
|
/// the caller. We don't have a command line option to override the postRA
|
||||||
|
/// scheduler. The Target must configure it.
|
||||||
|
ScheduleDAGInstrs *PostMachineScheduler::createPostMachineScheduler() {
|
||||||
|
// Get the postRA scheduler set by the target for this function.
|
||||||
|
ScheduleDAGInstrs *Scheduler = PassConfig->createPostMachineScheduler(this);
|
||||||
|
if (Scheduler)
|
||||||
|
return Scheduler;
|
||||||
|
|
||||||
|
// Default to GenericScheduler.
|
||||||
|
// return createRawGenericSched(this);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/// Top-level MachineScheduler pass driver.
|
/// Top-level MachineScheduler pass driver.
|
||||||
///
|
///
|
||||||
/// Visit blocks in function order. Divide each block into scheduling regions
|
/// Visit blocks in function order. Divide each block into scheduling regions
|
||||||
@ -277,6 +326,26 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PostMachineScheduler::runOnMachineFunction(MachineFunction &mf) {
|
||||||
|
DEBUG(dbgs() << "Before post-MI-sched:\n"; mf.print(dbgs()));
|
||||||
|
|
||||||
|
// Initialize the context of the pass.
|
||||||
|
MF = &mf;
|
||||||
|
PassConfig = &getAnalysis<TargetPassConfig>();
|
||||||
|
|
||||||
|
if (VerifyScheduling)
|
||||||
|
MF->verify(this, "Before post machine scheduling.");
|
||||||
|
|
||||||
|
// Instantiate the selected scheduler for this target, function, and
|
||||||
|
// optimization level.
|
||||||
|
OwningPtr<ScheduleDAGInstrs> Scheduler(createPostMachineScheduler());
|
||||||
|
scheduleRegions(*Scheduler);
|
||||||
|
|
||||||
|
if (VerifyScheduling)
|
||||||
|
MF->verify(this, "After post machine scheduling.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// Main driver for both MachineScheduler and PostMachineScheduler.
|
/// Main driver for both MachineScheduler and PostMachineScheduler.
|
||||||
void MachineSchedulerBase::scheduleRegions(ScheduleDAGInstrs &Scheduler) {
|
void MachineSchedulerBase::scheduleRegions(ScheduleDAGInstrs &Scheduler) {
|
||||||
const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
|
const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
|
||||||
|
@ -88,6 +88,14 @@ PrintMachineInstrs("print-machineinstrs", cl::ValueOptional,
|
|||||||
cl::desc("Print machine instrs"),
|
cl::desc("Print machine instrs"),
|
||||||
cl::value_desc("pass-name"), cl::init("option-unspecified"));
|
cl::value_desc("pass-name"), cl::init("option-unspecified"));
|
||||||
|
|
||||||
|
// Temporary option to allow experimenting with MachineScheduler as a post-RA
|
||||||
|
// scheduler. Targets can "properly" enable this with
|
||||||
|
// substitutePass(&PostRASchedulerID, &MachineSchedulerID); Ideally it wouldn't
|
||||||
|
// be part of the standard pass pipeline, and the target would just add a PostRA
|
||||||
|
// scheduling pass wherever it wants.
|
||||||
|
static cl::opt<bool> MISchedPostRA("misched-postra", cl::Hidden,
|
||||||
|
cl::desc("Run MachineScheduler post regalloc (independent of preRA sched)"));
|
||||||
|
|
||||||
// Experimental option to run live interval analysis early.
|
// Experimental option to run live interval analysis early.
|
||||||
static cl::opt<bool> EarlyLiveIntervals("early-live-intervals", cl::Hidden,
|
static cl::opt<bool> EarlyLiveIntervals("early-live-intervals", cl::Hidden,
|
||||||
cl::desc("Run live interval analysis earlier in the pipeline"));
|
cl::desc("Run live interval analysis earlier in the pipeline"));
|
||||||
@ -525,7 +533,10 @@ void TargetPassConfig::addMachinePasses() {
|
|||||||
|
|
||||||
// Second pass scheduler.
|
// Second pass scheduler.
|
||||||
if (getOptLevel() != CodeGenOpt::None) {
|
if (getOptLevel() != CodeGenOpt::None) {
|
||||||
addPass(&PostRASchedulerID);
|
if (MISchedPostRA)
|
||||||
|
addPass(&PostMachineSchedulerID);
|
||||||
|
else
|
||||||
|
addPass(&PostRASchedulerID);
|
||||||
printAndVerify("After PostRAScheduler");
|
printAndVerify("After PostRAScheduler");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user