-private:
- friend class PassManagerT<Module>;
- friend class PassManagerT<Function>;
- friend class PassManagerT<BasicBlock>;
- virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisSet &Req,
- AnalysisSet &Dest, AnalysisSet &Prov);
- virtual void addToPassManager(PassManagerT<Function> *PM,AnalysisSet &Req,
- AnalysisSet &Dest, AnalysisSet &Prov);
+
+//===----------------------------------------------------------------------===//
+/// ImmutablePass class - This class is used to provide information that does
+/// not need to be run. This is useful for things like target information and
+/// "basic" versions of AnalysisGroups.
+///
+class ImmutablePass : public ModulePass {
+public:
+ /// initializePass - This method may be overriden by immutable passes to allow
+ /// them to perform various initialization actions they require. This is
+ /// primarily because an ImmutablePass can "require" another ImmutablePass,
+ /// and if it does, the overloaded version of initializePass may get access to
+ /// these passes with getAnalysis<>.
+ ///
+ virtual void initializePass() {}
+
+ /// ImmutablePasses are never run.
+ ///
+ virtual bool runOnModule(Module &M) { return false; }
+
+ ImmutablePass(intptr_t pid) : ModulePass(pid) {}
+ // Force out-of-line virtual method.
+ virtual ~ImmutablePass();
+};
+
+//===----------------------------------------------------------------------===//
+/// FunctionPass class - This class is used to implement most global
+/// optimizations. Optimizations should subclass this class if they meet the
+/// following constraints:
+///
+/// 1. Optimizations are organized globally, i.e., a function at a time
+/// 2. Optimizing a function does not cause the addition or removal of any
+/// functions in the module
+///
+class FunctionPass : public Pass {
+public:
+ FunctionPass(intptr_t pid) : Pass(pid) {}
+
+ /// doInitialization - Virtual method overridden by subclasses to do
+ /// any necessary per-module initialization.
+ ///
+ virtual bool doInitialization(Module &M) { return false; }
+
+ /// runOnFunction - Virtual method overriden by subclasses to do the
+ /// per-function processing of the pass.
+ ///
+ virtual bool runOnFunction(Function &F) = 0;
+
+ /// doFinalization - Virtual method overriden by subclasses to do any post
+ /// processing needed after all passes have run.
+ ///
+ virtual bool doFinalization(Module &M) { return false; }
+
+ /// runOnModule - On a module, we run this pass by initializing,
+ /// ronOnFunction'ing once for every function in the module, then by
+ /// finalizing.
+ ///
+ virtual bool runOnModule(Module &M);
+
+ /// run - On a function, we simply initialize, run the function, then
+ /// finalize.
+ ///
+ bool run(Function &F);
+
+ virtual void assignPassManager(PMStack &PMS,
+ PassManagerType T = PMT_FunctionPassManager);
+
+ /// Return what kind of Pass Manager can manage this pass.
+ virtual PassManagerType getPotentialPassManagerType() const {
+ return PMT_FunctionPassManager;
+ }