1 //===- llvm/PassManager.h - Container for Passes ----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source 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"
29 class ModulePassManager;
30 class FunctionPassManagerT;
31 class BasicBlockPassManager;
34 ModulePassManager *PM; // This is a straightforward Pimpl class
39 /// add - Add a pass to the queue of passes to run. This passes ownership of
40 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
41 /// will be destroyed as well, so there is no need to delete the pass. This
42 /// implies that all passes MUST be allocated with 'new'.
46 /// run - Execute all of the passes scheduled for execution. Keep track of
47 /// whether any of the passes modifies the module, and if so, return true.
56 class FunctionPassManager {
57 FunctionPassManagerT *PM; // This is a straightforward Pimpl class
60 FunctionPassManager(ModuleProvider *P);
61 ~FunctionPassManager();
63 /// add - Add a pass to the queue of passes to run. This passes
64 /// ownership of the FunctionPass to the PassManager. When the
65 /// PassManager is destroyed, the pass will be destroyed as well, so
66 /// there is no need to delete the pass. This implies that all
67 /// passes MUST be allocated with 'new'.
69 void add(FunctionPass *P);
71 /// add - ImmutablePasses are not FunctionPasses, so we have a
72 /// special hack to get them into a FunctionPassManager.
74 void add(ImmutablePass *IP);
76 /// doInitialization - Run all of the initializers for the function passes.
78 bool doInitialization();
80 /// run - Execute all of the passes scheduled for execution. Keep
81 /// track of whether any of the passes modifies the function, and if
84 bool run(Function &F);
86 /// doFinalization - Run all of the initializers for the function passes.
88 bool doFinalization();
91 class ModulePassManager_New;
92 class PassManagerImpl_New;
94 /// PassManagerAnalysisHelper helps pass manager analysis required by
95 /// the managed passes. It provides methods to add/remove analysis
96 /// available and query if certain analysis is available or not.
97 class PassManagerAnalysisHelper {
101 /// Return true IFF pass P's required analysis set does not required new
103 bool manageablePass(Pass *P);
105 /// Return true IFF AnalysisID AID is currently available.
106 bool analysisCurrentlyAvailable(AnalysisID AID);
108 /// Augment RequiredSet by adding analysis required by pass P.
109 void noteDownRequiredAnalysis(Pass *P);
111 /// Remove AnalysisID from the RequiredSet
112 void removeAnalysis(AnalysisID AID);
114 /// Remove Analysis that is not preserved by the pass
115 void removeNotPreservedAnalysis(Pass *P);
117 /// Remove dead passes
118 void removeDeadPasses() { /* TODO : Implement */ }
121 // Required set of analysis for the passes managed by this manager
122 std::vector<AnalysisID> RequiredSet;
125 /// PassManager_New manages ModulePassManagers
126 class PassManager_New : public Pass,
127 public PassManagerAnalysisHelper {
133 /// add - Add a pass to the queue of passes to run. This passes ownership of
134 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
135 /// will be destroyed as well, so there is no need to delete the pass. This
136 /// implies that all passes MUST be allocated with 'new'.
139 /// run - Execute all of the passes scheduled for execution. Keep track of
140 /// whether any of the passes modifies the module, and if so, return true.
145 /// PassManagerImpl_New is the actual class. PassManager_New is just the
146 /// wraper to publish simple pass manager interface
147 PassManagerImpl_New *PM;
151 } // End llvm namespace