Added ability to register FunctionPasses as optimizations, with

TargetMachine-accepting constructors (thanks to Chris).

llvm-svn: 9781
This commit is contained in:
Misha Brukman 2003-11-07 18:56:32 +00:00
parent 9347dcdeb9
commit 9116e0e93e

View File

@ -219,6 +219,15 @@ struct RegisterOpt : public RegisterPassBase {
if (CFGOnly) setOnlyUsesCFG();
}
/// Register FunctionPass using default constructor explicitly...
///
RegisterOpt(const char *PassArg, const char *Name, FunctionPass *(*ctor)(),
bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Optimization, (Pass*(*)())ctor));
if (CFGOnly) setOnlyUsesCFG();
}
/// Register Pass using TargetMachine constructor...
///
RegisterOpt(const char *PassArg, const char *Name,
@ -227,6 +236,17 @@ struct RegisterOpt : public RegisterPassBase {
PassInfo::Optimization, 0, targetctor));
if (CFGOnly) setOnlyUsesCFG();
}
/// Register FunctionPass using TargetMachine constructor...
///
RegisterOpt(const char *PassArg, const char *Name,
FunctionPass *(*targetctor)(TargetMachine &),
bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Optimization, 0,
(Pass*(*)(TargetMachine&))targetctor));
if (CFGOnly) setOnlyUsesCFG();
}
};
/// RegisterAnalysis - Register something that is to show up in Analysis, this