mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-16 11:24:39 +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:
@@ -42,9 +42,13 @@ protected:
|
|||||||
bool Initialized; // Flagged after all passes are configured.
|
bool Initialized; // Flagged after all passes are configured.
|
||||||
|
|
||||||
// Target Pass Options
|
// Target Pass Options
|
||||||
|
// Targets provide a default setting, user flags override.
|
||||||
//
|
//
|
||||||
bool DisableVerify;
|
bool DisableVerify;
|
||||||
|
|
||||||
|
/// Default setting for -enable-tail-merge on this target.
|
||||||
|
bool EnableTailMerge;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TargetPassConfig(TargetMachine *tm, PassManagerBase &pm);
|
TargetPassConfig(TargetMachine *tm, PassManagerBase &pm);
|
||||||
// Dummy constructor.
|
// Dummy constructor.
|
||||||
@@ -67,7 +71,10 @@ public:
|
|||||||
|
|
||||||
CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); }
|
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
|
/// Add common target configurable passes that perform LLVM IR to IR
|
||||||
/// transforms following machine independent optimization.
|
/// transforms following machine independent optimization.
|
||||||
@@ -118,10 +125,6 @@ protected:
|
|||||||
return false;
|
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
|
/// addPreSched2 - This method may be implemented by targets that want to
|
||||||
/// run passes after prolog-epilog insertion and before the second instruction
|
/// run passes after prolog-epilog insertion and before the second instruction
|
||||||
/// scheduling pass. This should return true if -print-machineinstrs should
|
/// 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
|
/// optimizations to delete branches to branches, eliminate branches to
|
||||||
/// successor blocks (creating fall throughs), and eliminating branches over
|
/// successor blocks (creating fall throughs), and eliminating branches over
|
||||||
/// branches.
|
/// branches.
|
||||||
FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
|
extern char &BranchFolderPassID;
|
||||||
|
|
||||||
/// TailDuplicate Pass - Duplicate blocks with unconditional branches
|
/// TailDuplicate Pass - Duplicate blocks with unconditional branches
|
||||||
/// into tails of their predecessors.
|
/// into tails of their predecessors.
|
||||||
|
@@ -71,6 +71,7 @@ void initializeBasicCallGraphPass(PassRegistry&);
|
|||||||
void initializeBlockExtractorPassPass(PassRegistry&);
|
void initializeBlockExtractorPassPass(PassRegistry&);
|
||||||
void initializeBlockFrequencyInfoPass(PassRegistry&);
|
void initializeBlockFrequencyInfoPass(PassRegistry&);
|
||||||
void initializeBlockPlacementPass(PassRegistry&);
|
void initializeBlockPlacementPass(PassRegistry&);
|
||||||
|
void initializeBranchFolderPassPass(PassRegistry&);
|
||||||
void initializeBranchProbabilityInfoPass(PassRegistry&);
|
void initializeBranchProbabilityInfoPass(PassRegistry&);
|
||||||
void initializeBreakCriticalEdgesPass(PassRegistry&);
|
void initializeBreakCriticalEdgesPass(PassRegistry&);
|
||||||
void initializeCFGOnlyPrinterPass(PassRegistry&);
|
void initializeCFGOnlyPrinterPass(PassRegistry&);
|
||||||
|
@@ -61,29 +61,33 @@ TailMergeSize("tail-merge-size",
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
/// BranchFolderPass - Wrap branch folder in a machine function pass.
|
/// BranchFolderPass - Wrap branch folder in a machine function pass.
|
||||||
class BranchFolderPass : public MachineFunctionPass,
|
class BranchFolderPass : public MachineFunctionPass {
|
||||||
public BranchFolder {
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
explicit BranchFolderPass(bool defaultEnableTailMerge)
|
explicit BranchFolderPass(): MachineFunctionPass(ID) {}
|
||||||
: MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {}
|
|
||||||
|
|
||||||
virtual bool runOnMachineFunction(MachineFunction &MF);
|
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 BranchFolderPass::ID = 0;
|
||||||
|
char &llvm::BranchFolderPassID = BranchFolderPass::ID;
|
||||||
|
|
||||||
FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) {
|
INITIALIZE_PASS(BranchFolderPass, "branch-folder",
|
||||||
return new BranchFolderPass(DefaultEnableTailMerge);
|
"Control Flow Optimizer", false, false)
|
||||||
}
|
|
||||||
|
|
||||||
bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
||||||
return OptimizeFunction(MF,
|
TargetPassConfig *PassConfig = &getAnalysis<TargetPassConfig>();
|
||||||
MF.getTarget().getInstrInfo(),
|
BranchFolder Folder(PassConfig->getEnableTailMerge(), /*CommonHoist=*/true);
|
||||||
MF.getTarget().getRegisterInfo(),
|
return Folder.OptimizeFunction(MF,
|
||||||
getAnalysisIfAvailable<MachineModuleInfo>());
|
MF.getTarget().getInstrInfo(),
|
||||||
|
MF.getTarget().getRegisterInfo(),
|
||||||
|
getAnalysisIfAvailable<MachineModuleInfo>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ using namespace llvm;
|
|||||||
|
|
||||||
/// initializeCodeGen - Initialize all passes linked into the CodeGen library.
|
/// initializeCodeGen - Initialize all passes linked into the CodeGen library.
|
||||||
void llvm::initializeCodeGen(PassRegistry &Registry) {
|
void llvm::initializeCodeGen(PassRegistry &Registry) {
|
||||||
|
initializeBranchFolderPassPass(Registry);
|
||||||
initializeCalculateSpillWeightsPass(Registry);
|
initializeCalculateSpillWeightsPass(Registry);
|
||||||
initializeDeadMachineInstructionElimPass(Registry);
|
initializeDeadMachineInstructionElimPass(Registry);
|
||||||
initializeGCModuleInfoPass(Registry);
|
initializeGCModuleInfoPass(Registry);
|
||||||
|
@@ -83,6 +83,8 @@ char TargetPassConfig::ID = 0;
|
|||||||
// Out of line virtual method.
|
// Out of line virtual method.
|
||||||
TargetPassConfig::~TargetPassConfig() {}
|
TargetPassConfig::~TargetPassConfig() {}
|
||||||
|
|
||||||
|
// Out of line constructor provides default values for pass options and
|
||||||
|
// registers all common codegen passes.
|
||||||
TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm)
|
TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm)
|
||||||
: ImmutablePass(ID), TM(tm), PM(pm), Initialized(false),
|
: ImmutablePass(ID), TM(tm), PM(pm), Initialized(false),
|
||||||
DisableVerify(false),
|
DisableVerify(false),
|
||||||
@@ -257,7 +259,7 @@ void TargetPassConfig::addMachinePasses() {
|
|||||||
|
|
||||||
// Branch folding must be run after regalloc and prolog/epilog insertion.
|
// Branch folding must be run after regalloc and prolog/epilog insertion.
|
||||||
if (getOptLevel() != CodeGenOpt::None && !DisableBranchFold) {
|
if (getOptLevel() != CodeGenOpt::None && !DisableBranchFold) {
|
||||||
PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
|
addPass(BranchFolderPassID);
|
||||||
printNoVerify("After BranchFolding");
|
printNoVerify("After BranchFolding");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -359,7 +359,7 @@ bool PTXPassConfig::addCodeGenPasses(MCContext *&OutContext) {
|
|||||||
|
|
||||||
// Branch folding must be run after regalloc and prolog/epilog insertion.
|
// Branch folding must be run after regalloc and prolog/epilog insertion.
|
||||||
if (getOptLevel() != CodeGenOpt::None) {
|
if (getOptLevel() != CodeGenOpt::None) {
|
||||||
PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
|
addPass(BranchFolderPassID);
|
||||||
printNoVerify("After BranchFolding");
|
printNoVerify("After BranchFolding");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,13 +78,18 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual bool addInstSelector();
|
virtual bool addInstSelector();
|
||||||
virtual bool getEnableTailMergeDefault() const;
|
|
||||||
virtual bool addPreEmitPass();
|
virtual bool addPreEmitPass();
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TargetPassConfig *PPCTargetMachine::createPassConfig(PassManagerBase &PM) {
|
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() {
|
bool PPCPassConfig::addInstSelector() {
|
||||||
@@ -93,10 +98,6 @@ bool PPCPassConfig::addInstSelector() {
|
|||||||
return false;
|
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() {
|
bool PPCPassConfig::addPreEmitPass() {
|
||||||
// Must run branch selection immediately preceding the asm printer.
|
// Must run branch selection immediately preceding the asm printer.
|
||||||
PM.add(createPPCBranchSelectionPass());
|
PM.add(createPPCBranchSelectionPass());
|
||||||
|
Reference in New Issue
Block a user