1 //===- LegacyPassManager.h - Legacy 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 legacy 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_IR_LEGACYPASSMANAGER_H
18 #define LLVM_IR_LEGACYPASSMANAGER_H
20 #include "llvm/Pass.h"
21 #include "llvm/Support/CBindingWrapping.h"
30 class PassManagerImpl;
31 class FunctionPassManagerImpl;
33 /// PassManagerBase - An abstract interface to allow code to add passes to
34 /// a pass manager without having to hard-code what kind of pass manager
36 class PassManagerBase {
38 virtual ~PassManagerBase();
40 /// add - Add a pass to the queue of passes to run. This passes ownership of
41 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
42 /// will be destroyed as well, so there is no need to delete the pass. This
43 /// implies that all passes MUST be allocated with 'new'.
44 virtual void add(Pass *P) = 0;
47 /// PassManager manages ModulePassManagers
48 class PassManager : public PassManagerBase {
54 /// add - Add a pass to the queue of passes to run. This passes ownership of
55 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
56 /// will be destroyed as well, so there is no need to delete the pass. This
57 /// implies that all passes MUST be allocated with 'new'.
60 /// run - Execute all of the passes scheduled for execution. Keep track of
61 /// whether any of the passes modifies the module, and if so, return true.
65 /// PassManagerImpl_New is the actual class. PassManager is just the
66 /// wraper to publish simple pass manager interface
70 /// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
71 class FunctionPassManager : public PassManagerBase {
73 /// FunctionPassManager ctor - This initializes the pass manager. It needs,
74 /// but does not take ownership of, the specified Module.
75 explicit FunctionPassManager(Module *M);
76 ~FunctionPassManager();
78 /// add - Add a pass to the queue of passes to run. This passes
79 /// ownership of the Pass to the PassManager. When the
80 /// PassManager_X is destroyed, the pass will be destroyed as well, so
81 /// there is no need to delete the pass.
82 /// This implies that all passes MUST be allocated with 'new'.
85 /// run - Execute all of the passes scheduled for execution. Keep
86 /// track of whether any of the passes modifies the function, and if
89 bool run(Function &F);
91 /// doInitialization - Run all of the initializers for the function passes.
93 bool doInitialization();
95 /// doFinalization - Run all of the finalizers for the function passes.
97 bool doFinalization();
100 FunctionPassManagerImpl *FPM;
104 } // End legacy namespace
106 // Create wrappers for C Binding types (see CBindingWrapping.h).
107 DEFINE_STDCXX_CONVERSION_FUNCTIONS(legacy::PassManagerBase, LLVMPassManagerRef)
109 } // End llvm namespace