'Pass' should now not be derived from by clients. Instead, they should derive
[oota-llvm.git] / include / llvm / PassManager.h
1 //===- llvm/PassManager.h - Container for Passes ----------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
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.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_PASSMANAGER_H
18 #define LLVM_PASSMANAGER_H
19
20 namespace llvm {
21
22 class Pass;
23 class ModulePass;
24 class Module;
25 class ModuleProvider;
26 template<class UnitType> class PassManagerT;
27
28 class PassManager {
29   PassManagerT<Module> *PM;    // This is a straightforward Pimpl class
30 public:
31   PassManager();
32   ~PassManager();
33
34   /// add - Add a pass to the queue of passes to run.  This passes ownership of
35   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
36   /// will be destroyed as well, so there is no need to delete the pass.  This
37   /// implies that all passes MUST be allocated with 'new'.
38   ///
39   void add(Pass *P);
40
41   /// run - Execute all of the passes scheduled for execution.  Keep track of
42   /// whether any of the passes modifies the module, and if so, return true.
43   ///
44   bool run(Module &M);
45 };
46
47 class FunctionPass;
48 class ImmutablePass;
49 class Function;
50
51 class FunctionPassManager {
52   PassManagerT<Function> *PM;    // This is a straightforward Pimpl class
53   ModuleProvider *MP;
54 public:
55   FunctionPassManager(ModuleProvider *P);
56   ~FunctionPassManager();
57
58   /// add - Add a pass to the queue of passes to run.  This passes
59   /// ownership of the FunctionPass to the PassManager.  When the
60   /// PassManager is destroyed, the pass will be destroyed as well, so
61   /// there is no need to delete the pass.  This implies that all
62   /// passes MUST be allocated with 'new'.
63   ///
64   void add(FunctionPass *P);
65
66   /// add - ImmutablePasses are not FunctionPasses, so we have a 
67   /// special hack to get them into a FunctionPassManager.
68   ///
69   void add(ImmutablePass *IP);
70
71   /// run - Execute all of the passes scheduled for execution.  Keep
72   /// track of whether any of the passes modifies the function, and if
73   /// so, return true.
74   ///
75   bool run(Function &F);
76 };
77
78 } // End llvm namespace
79
80 #endif