1 //===- llvm/PassManager.h - Container for Passes ----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the PassManager class. This class is used to hold,
11 // maintain, and optimize execution of Passes. The PassManager class ensures
12 // that analysis results are available before a pass runs, and that Pass's are
13 // destroyed when the PassManager is destroyed.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_PASSMANAGER_H
18 #define LLVM_PASSMANAGER_H
20 #include "llvm/Pass.h"
28 class PassManagerImpl;
29 class FunctionPassManagerImpl;
31 /// PassManagerBase - An abstract interface to allow code to add passes to
32 /// a pass manager without having to hard-code what kind of pass manager
34 class PassManagerBase {
36 virtual ~PassManagerBase();
38 /// add - Add a pass to the queue of passes to run. This passes ownership of
39 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
40 /// will be destroyed as well, so there is no need to delete the pass. This
41 /// implies that all passes MUST be allocated with 'new'.
42 virtual void add(Pass *P) = 0;
45 /// PassManager manages ModulePassManagers
46 class PassManager : public PassManagerBase {
52 /// add - Add a pass to the queue of passes to run. This passes ownership of
53 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
54 /// will be destroyed as well, so there is no need to delete the pass. This
55 /// implies that all passes MUST be allocated with 'new'.
58 /// run - Execute all of the passes scheduled for execution. Keep track of
59 /// whether any of the passes modifies the module, and if so, return true.
64 /// PassManagerImpl_New is the actual class. PassManager is just the
65 /// wraper to publish simple pass manager interface
69 /// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
70 class FunctionPassManager : public PassManagerBase {
72 /// FunctionPassManager ctor - This initializes the pass manager. It needs,
73 /// but does not take ownership of, the specified Module.
74 explicit FunctionPassManager(Module *M);
75 ~FunctionPassManager();
77 /// add - Add a pass to the queue of passes to run. This passes
78 /// ownership of the Pass to the PassManager. When the
79 /// PassManager_X is destroyed, the pass will be destroyed as well, so
80 /// there is no need to delete the pass. (TODO delete passes.)
81 /// This implies that all passes MUST be allocated with 'new'.
84 /// run - Execute all of the passes scheduled for execution. Keep
85 /// track of whether any of the passes modifies the function, and if
88 bool run(Function &F);
90 /// doInitialization - Run all of the initializers for the function passes.
92 bool doInitialization();
94 /// doFinalization - Run all of the finalizers for the function passes.
96 bool doFinalization();
99 FunctionPassManagerImpl *FPM;
103 } // End llvm namespace