mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
Move pass configuration out of pass constructors: BranchFolderPass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150095 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1df91b0e54
commit
61f1e3db43
@ -42,9 +42,13 @@ protected:
|
||||
bool Initialized; // Flagged after all passes are configured.
|
||||
|
||||
// Target Pass Options
|
||||
// Targets provide a default setting, user flags override.
|
||||
//
|
||||
bool DisableVerify;
|
||||
|
||||
/// Default setting for -enable-tail-merge on this target.
|
||||
bool EnableTailMerge;
|
||||
|
||||
public:
|
||||
TargetPassConfig(TargetMachine *tm, PassManagerBase &pm);
|
||||
// Dummy constructor.
|
||||
@ -67,7 +71,10 @@ public:
|
||||
|
||||
CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); }
|
||||
|
||||
void setDisableVerify(bool disable) { DisableVerify = disable; }
|
||||
void setDisableVerify(bool Disable) { setOpt(DisableVerify, Disable); }
|
||||
|
||||
bool getEnableTailMerge() const { return EnableTailMerge; }
|
||||
void setEnableTailMerge(bool Enable) { setOpt(EnableTailMerge, Enable); }
|
||||
|
||||
/// Add common target configurable passes that perform LLVM IR to IR
|
||||
/// transforms following machine independent optimization.
|
||||
@ -118,10 +125,6 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
/// getEnableTailMergeDefault - the default setting for -enable-tail-merge
|
||||
/// on this target. User flag overrides.
|
||||
virtual bool getEnableTailMergeDefault() const { return true; }
|
||||
|
||||
/// addPreSched2 - This method may be implemented by targets that want to
|
||||
/// run passes after prolog-epilog insertion and before the second instruction
|
||||
/// scheduling pass. This should return true if -print-machineinstrs should
|
||||
@ -274,7 +277,7 @@ namespace llvm {
|
||||
/// optimizations to delete branches to branches, eliminate branches to
|
||||
/// successor blocks (creating fall throughs), and eliminating branches over
|
||||
/// branches.
|
||||
FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
|
||||
extern char &BranchFolderPassID;
|
||||
|
||||
/// TailDuplicate Pass - Duplicate blocks with unconditional branches
|
||||
/// into tails of their predecessors.
|
||||
|
@ -71,6 +71,7 @@ void initializeBasicCallGraphPass(PassRegistry&);
|
||||
void initializeBlockExtractorPassPass(PassRegistry&);
|
||||
void initializeBlockFrequencyInfoPass(PassRegistry&);
|
||||
void initializeBlockPlacementPass(PassRegistry&);
|
||||
void initializeBranchFolderPassPass(PassRegistry&);
|
||||
void initializeBranchProbabilityInfoPass(PassRegistry&);
|
||||
void initializeBreakCriticalEdgesPass(PassRegistry&);
|
||||
void initializeCFGOnlyPrinterPass(PassRegistry&);
|
||||
|
@ -61,29 +61,33 @@ TailMergeSize("tail-merge-size",
|
||||
|
||||
namespace {
|
||||
/// BranchFolderPass - Wrap branch folder in a machine function pass.
|
||||
class BranchFolderPass : public MachineFunctionPass,
|
||||
public BranchFolder {
|
||||
class BranchFolderPass : public MachineFunctionPass {
|
||||
public:
|
||||
static char ID;
|
||||
explicit BranchFolderPass(bool defaultEnableTailMerge)
|
||||
: MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {}
|
||||
explicit BranchFolderPass(): MachineFunctionPass(ID) {}
|
||||
|
||||
virtual bool runOnMachineFunction(MachineFunction &MF);
|
||||
virtual const char *getPassName() const { return "Control Flow Optimizer"; }
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<TargetPassConfig>();
|
||||
MachineFunctionPass::getAnalysisUsage(AU);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
char BranchFolderPass::ID = 0;
|
||||
char &llvm::BranchFolderPassID = BranchFolderPass::ID;
|
||||
|
||||
FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) {
|
||||
return new BranchFolderPass(DefaultEnableTailMerge);
|
||||
}
|
||||
INITIALIZE_PASS(BranchFolderPass, "branch-folder",
|
||||
"Control Flow Optimizer", false, false)
|
||||
|
||||
bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
return OptimizeFunction(MF,
|
||||
MF.getTarget().getInstrInfo(),
|
||||
MF.getTarget().getRegisterInfo(),
|
||||
getAnalysisIfAvailable<MachineModuleInfo>());
|
||||
TargetPassConfig *PassConfig = &getAnalysis<TargetPassConfig>();
|
||||
BranchFolder Folder(PassConfig->getEnableTailMerge(), /*CommonHoist=*/true);
|
||||
return Folder.OptimizeFunction(MF,
|
||||
MF.getTarget().getInstrInfo(),
|
||||
MF.getTarget().getRegisterInfo(),
|
||||
getAnalysisIfAvailable<MachineModuleInfo>());
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@ using namespace llvm;
|
||||
|
||||
/// initializeCodeGen - Initialize all passes linked into the CodeGen library.
|
||||
void llvm::initializeCodeGen(PassRegistry &Registry) {
|
||||
initializeBranchFolderPassPass(Registry);
|
||||
initializeCalculateSpillWeightsPass(Registry);
|
||||
initializeDeadMachineInstructionElimPass(Registry);
|
||||
initializeGCModuleInfoPass(Registry);
|
||||
|
@ -83,6 +83,8 @@ char TargetPassConfig::ID = 0;
|
||||
// Out of line virtual method.
|
||||
TargetPassConfig::~TargetPassConfig() {}
|
||||
|
||||
// Out of line constructor provides default values for pass options and
|
||||
// registers all common codegen passes.
|
||||
TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm)
|
||||
: ImmutablePass(ID), TM(tm), PM(pm), Initialized(false),
|
||||
DisableVerify(false),
|
||||
@ -257,7 +259,7 @@ void TargetPassConfig::addMachinePasses() {
|
||||
|
||||
// Branch folding must be run after regalloc and prolog/epilog insertion.
|
||||
if (getOptLevel() != CodeGenOpt::None && !DisableBranchFold) {
|
||||
PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
|
||||
addPass(BranchFolderPassID);
|
||||
printNoVerify("After BranchFolding");
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ bool PTXPassConfig::addCodeGenPasses(MCContext *&OutContext) {
|
||||
|
||||
// Branch folding must be run after regalloc and prolog/epilog insertion.
|
||||
if (getOptLevel() != CodeGenOpt::None) {
|
||||
PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
|
||||
addPass(BranchFolderPassID);
|
||||
printNoVerify("After BranchFolding");
|
||||
}
|
||||
|
||||
|
@ -78,13 +78,18 @@ public:
|
||||
}
|
||||
|
||||
virtual bool addInstSelector();
|
||||
virtual bool getEnableTailMergeDefault() const;
|
||||
virtual bool addPreEmitPass();
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TargetPassConfig *PPCTargetMachine::createPassConfig(PassManagerBase &PM) {
|
||||
return new PPCPassConfig(this, PM);
|
||||
TargetPassConfig *PassConfig = new PPCPassConfig(this, PM);
|
||||
|
||||
// Override this for PowerPC. Tail merging happily breaks up instruction issue
|
||||
// groups, which typically degrades performance.
|
||||
PassConfig->setEnableTailMerge(false);
|
||||
|
||||
return PassConfig;
|
||||
}
|
||||
|
||||
bool PPCPassConfig::addInstSelector() {
|
||||
@ -93,10 +98,6 @@ bool PPCPassConfig::addInstSelector() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Override this for PowerPC. Tail merging happily breaks up instruction issue
|
||||
/// groups, which typically degrades performance.
|
||||
bool PPCPassConfig::getEnableTailMergeDefault() const { return false; }
|
||||
|
||||
bool PPCPassConfig::addPreEmitPass() {
|
||||
// Must run branch selection immediately preceding the asm printer.
|
||||
PM.add(createPPCBranchSelectionPass());
|
||||
|
Loading…
Reference in New Issue
Block a user