- PassInfo *PIObj; // The PassInfo object for this pass
- void registerPass(PassInfo *);
- void unregisterPass(PassInfo *);
-
- // setPreservesCFG - Notice that this pass only depends on the CFG, so
- // transformations that do not modify the CFG do not invalidate this pass.
- //
- void setPreservesCFG();
-};
-
-template<typename PassName>
-Pass *callDefaultCtor() { return new PassName(); }
-
-template<typename PassName>
-struct RegisterPass : public RegisterPassBase {
-
- // 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));
- }
-
- // 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));
- }
-
- // Register Pass using TargetData constructor...
- RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
- Pass *(*datactor)(const TargetData &)) {
- registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
- 0, datactor));
- }
-
- // 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));
- }
-};