Added TargetPassConfig::setOpt

llvm-svn: 150093
This commit is contained in:
Andrew Trick 2012-02-08 21:22:39 +00:00
parent 3a61b7862b
commit dd37d52f95
4 changed files with 20 additions and 1 deletions

View File

@ -39,6 +39,7 @@ class TargetPassConfig : public ImmutablePass {
protected:
TargetMachine *TM;
PassManagerBase ±
bool Initialized; // Flagged after all passes are configured.
// Target Pass Options
//
@ -62,6 +63,8 @@ public:
return TM->getTargetLowering();
}
void setInitialized() { Initialized = true; }
CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); }
void setDisableVerify(bool disable) { DisableVerify = disable; }
@ -84,6 +87,9 @@ public:
/// Fully developed targets will not generally override this.
virtual void addMachinePasses();
protected:
// Helper to verify the analysis is really immutable.
void setOpt(bool &Opt, bool Val);
/// Methods with trivial inline returns are convenient points in the common
/// codegen pass pipeline where targets may insert passes. Methods with
/// out-of-line standard implementations are major CodeGen stages called by

View File

@ -147,6 +147,8 @@ static MCContext *addPassesToGenerateCode(LLVMTargetMachine *TM,
PassConfig->addMachinePasses();
PassConfig->setInitialized();
return Context;
}

View File

@ -84,7 +84,10 @@ char TargetPassConfig::ID = 0;
TargetPassConfig::~TargetPassConfig() {}
TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm)
: ImmutablePass(ID), TM(tm), PM(pm), DisableVerify(false) {
: ImmutablePass(ID), TM(tm), PM(pm), Initialized(false),
DisableVerify(false),
EnableTailMerge(true) {
// Register all target independent codegen passes to activate their PassIDs,
// including this pass itself.
initializeCodeGen(*PassRegistry::getPassRegistry());
@ -103,6 +106,12 @@ TargetPassConfig::TargetPassConfig()
llvm_unreachable("TargetPassConfig should not be constructed on-the-fly");
}
// Helper to verify the analysis is really immutable.
void TargetPassConfig::setOpt(bool &Opt, bool Val) {
assert(!Initialized && "PassConfig is immutable");
Opt = Val;
}
void TargetPassConfig::addPass(char &ID) {
// FIXME: check user overrides
Pass *P = Pass::createPass(ID);

View File

@ -385,5 +385,7 @@ bool PTXPassConfig::addCodeGenPasses(MCContext *&OutContext) {
PM.add(createPTXMFInfoExtract(getPTXTargetMachine(), getOptLevel()));
PM.add(createPTXFPRoundingModePass(getPTXTargetMachine(), getOptLevel()));
setInitialized();
return false;
}