diff options
author | Chris Lattner <sabre@nondot.org> | 2004-09-20 04:48:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-09-20 04:48:05 +0000 |
commit | b12914bfc0f76a7a48357162d5f4c39a1343e69b (patch) | |
tree | 00bff0412482165a6d7d60775e4aeb6ebe3b4628 /include/llvm/Pass.h | |
parent | bba61c07ddca19f72b13dd5a410358d296ed1d6a (diff) | |
download | external_llvm-b12914bfc0f76a7a48357162d5f4c39a1343e69b.zip external_llvm-b12914bfc0f76a7a48357162d5f4c39a1343e69b.tar.gz external_llvm-b12914bfc0f76a7a48357162d5f4c39a1343e69b.tar.bz2 |
'Pass' should now not be derived from by clients. Instead, they should derive
from ModulePass. Instead of implementing Pass::run, then should implement
ModulePass::runOnModule.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Pass.h')
-rw-r--r-- | include/llvm/Pass.h | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 08496c5..77f630c 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -84,10 +84,10 @@ public: /// const PassInfo *getPassInfo() const; - /// run - Run this pass, returning true if a modification was made to the + /// runPass - Run this pass, returning true if a modification was made to the /// module argument. This should be implemented by all concrete subclasses. /// - virtual bool run(Module &M) = 0; + virtual bool runPass(Module &M) = 0; /// print - Print out the internal state of the pass. This is called by /// Analyze to print out the contents of an analysis. Otherwise it is not @@ -200,13 +200,27 @@ private: friend class PassManagerT<Module>; friend class PassManagerT<Function>; friend class PassManagerT<BasicBlock>; - virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU); }; inline std::ostream &operator<<(std::ostream &OS, const Pass &P) { P.print(OS, 0); return OS; } +//===----------------------------------------------------------------------===// +/// ModulePass class - This class is used to implement unstructured +/// interprocedural optimizations and analyses. ModulePass's may do anything +/// they want to the program. +/// +struct ModulePass : public Pass { + + /// runOnModule - Virtual method overriden by subclasses to process the module + /// being operated on. + virtual bool runOnModule(Module &M) = 0; + + bool runPass(Module &M) { return runOnModule(M); } + + virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU); +}; //===----------------------------------------------------------------------===// @@ -214,7 +228,7 @@ inline std::ostream &operator<<(std::ostream &OS, const Pass &P) { /// not need to be run. This is useful for things like target information and /// "basic" versions of AnalysisGroups. /// -struct ImmutablePass : public Pass { +struct ImmutablePass : public ModulePass { /// 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, @@ -225,14 +239,13 @@ struct ImmutablePass : public Pass { /// ImmutablePasses are never run. /// - virtual bool run(Module &M) { return false; } + virtual bool runOnModule(Module &M) { return false; } private: friend class PassManagerT<Module>; virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU); }; - //===----------------------------------------------------------------------===// /// FunctionPass class - This class is used to implement most global /// optimizations. Optimizations should subclass this class if they meet the @@ -242,7 +255,7 @@ private: /// 2. Optimizing a function does not cause the addition or removal of any /// functions in the module /// -struct FunctionPass : public Pass { +struct FunctionPass : public ModulePass { /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// @@ -258,10 +271,11 @@ struct FunctionPass : public Pass { /// virtual bool doFinalization(Module &M) { return false; } - /// run - On a module, we run this pass by initializing, ronOnFunction'ing - /// once for every function in the module, then by finalizing. + /// runOnModule - On a module, we run this pass by initializing, + /// ronOnFunction'ing once for every function in the module, then by + /// finalizing. /// - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); /// run - On a function, we simply initialize, run the function, then /// finalize. @@ -323,7 +337,7 @@ struct BasicBlockPass : public FunctionPass { /// To run directly on the basic block, we initialize, runOnBasicBlock, then /// finalize. /// - bool run(BasicBlock &BB); + bool runPass(BasicBlock &BB); private: friend class PassManagerT<Function>; |