std::vector<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
Pass *(*NormalCtor)(); // No argument ctor
- Pass *(*DataCtor)(const TargetData&);// Ctor taking TargetData object...
+ Pass *(*DataCtor)(const TargetData&);// Ctor taking const TargetData object...
+ Pass *(*TargetCtor)(TargetMachine&); // Ctor taking TargetMachine object...
public:
/// PassType - Define symbolic constants that can be used to test to see if
/// PassInfo ctor - Do not call this directly, this should only be invoked
/// through RegisterPass.
PassInfo(const char *name, const char *arg, const std::type_info &ti,
- unsigned pt, Pass *(*normal)(), Pass *(*data)(const TargetData &))
+ unsigned pt, Pass *(*normal)() = 0,
+ Pass *(*datactor)(const TargetData &) = 0,
+ Pass *(*targetctor)(TargetMachine &) = 0)
: PassName(name), PassArgument(arg), TypeInfo(ti), PassType(pt),
- NormalCtor(normal), DataCtor(data) {
+ NormalCtor(normal), DataCtor(datactor), TargetCtor(targetctor) {
}
/// getPassName - Return the friendly name for the pass, never returns null
/// getDataCtor - Return a pointer to a function that creates an instance of
/// the pass and returns it. This returns a constructor for a version of the
- /// pass that takes a TArgetData object as a parameter.
+ /// pass that takes a TargetData object as a parameter.
///
Pass *(*getDataCtor() const)(const TargetData &) {
return DataCtor;
}
+ /// getTargetCtor - Return a pointer to a function that creates an instance of
+ /// the pass and returns it. This returns a constructor for a version of the
+ /// pass that takes a TargetMachine object as a parameter.
+ ///
+ Pass *(*getTargetCtor() const)(TargetMachine &) {
+ return TargetCtor;
+ }
+
/// addInterfaceImplemented - This method is called when this pass is
/// registered as a member of an analysis group with the RegisterAnalysisGroup
/// template.
// Register Pass using default constructor...
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy = 0) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
- callDefaultCtor<PassName>, 0));
+ callDefaultCtor<PassName>));
}
// Register Pass using default constructor explicitly...
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
Pass *(*ctor)()) {
- registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor,0));
+ registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor));
}
// Register Pass using TargetData constructor...
0, datactor));
}
+ // Register Pass using TargetMachine constructor...
+ RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
+ Pass *(*targetctor)(TargetMachine &)) {
+ registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
+ 0, 0, targetctor));
+ }
+
// Generic constructor version that has an unknown ctor type...
template<typename CtorType>
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
CtorType *Fn) {
- registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, 0, 0));
+ registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, 0));
}
};
RegisterOpt(const char *PassArg, const char *Name) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Optimization,
- callDefaultCtor<PassName>, 0));
+ callDefaultCtor<PassName>));
}
/// Register Pass using default constructor explicitly...
///
RegisterOpt(const char *PassArg, const char *Name, Pass *(*ctor)()) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::Optimization, ctor, 0));
+ PassInfo::Optimization, ctor));
}
/// Register Pass using TargetData constructor...
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Optimization, 0, datactor));
}
+
+ /// Register Pass using TargetMachine constructor...
+ ///
+ RegisterOpt(const char *PassArg, const char *Name,
+ Pass *(*targetctor)(TargetMachine &)) {
+ registerPass(new PassInfo(Name, PassArg, typeid(PassName),
+ PassInfo::Optimization, 0, 0, targetctor));
+ }
};
/// RegisterAnalysis - Register something that is to show up in Analysis, this
bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Analysis,
- callDefaultCtor<PassName>, 0));
+ callDefaultCtor<PassName>));
if (CFGOnly)
setPreservesCFG();
}
RegisterLLC(const char *PassArg, const char *Name) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::LLC,
- callDefaultCtor<PassName>, 0));
+ callDefaultCtor<PassName>));
}
/// Register Pass using default constructor explicitly...
///
RegisterLLC(const char *PassArg, const char *Name, Pass *(*ctor)()) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::LLC, ctor, 0));
+ PassInfo::LLC, ctor));
}
/// Register Pass using TargetData constructor...
RegisterLLC(const char *PassArg, const char *Name,
Pass *(*datactor)(TargetMachine &)) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::LLC, 0, 0));
+ PassInfo::LLC));
}
};