|
|
|||
File indexing completed on 2026-05-10 08:44:07
0001 //===- LegacyPassManager.h - Legacy Container for Passes --------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This file defines the legacy PassManager class. This class is used to hold, 0010 // maintain, and optimize execution of Passes. The PassManager class ensures 0011 // that analysis results are available before a pass runs, and that Pass's are 0012 // destroyed when the PassManager is destroyed. 0013 // 0014 //===----------------------------------------------------------------------===// 0015 0016 #ifndef LLVM_IR_LEGACYPASSMANAGER_H 0017 #define LLVM_IR_LEGACYPASSMANAGER_H 0018 0019 #include "llvm/Support/CBindingWrapping.h" 0020 0021 namespace llvm { 0022 0023 class Function; 0024 class Pass; 0025 class Module; 0026 0027 namespace legacy { 0028 0029 // Whether or not -debug-pass has been specified. For use to check if it's 0030 // specified alongside the new PM. 0031 bool debugPassSpecified(); 0032 0033 class PassManagerImpl; 0034 class FunctionPassManagerImpl; 0035 0036 /// PassManagerBase - An abstract interface to allow code to add passes to 0037 /// a pass manager without having to hard-code what kind of pass manager 0038 /// it is. 0039 class PassManagerBase { 0040 public: 0041 virtual ~PassManagerBase(); 0042 0043 /// Add a pass to the queue of passes to run. This passes ownership of 0044 /// the Pass to the PassManager. When the PassManager is destroyed, the pass 0045 /// will be destroyed as well, so there is no need to delete the pass. This 0046 /// may even destroy the pass right away if it is found to be redundant. This 0047 /// implies that all passes MUST be allocated with 'new'. 0048 virtual void add(Pass *P) = 0; 0049 }; 0050 0051 /// PassManager manages ModulePassManagers 0052 class PassManager : public PassManagerBase { 0053 public: 0054 0055 PassManager(); 0056 ~PassManager() override; 0057 0058 void add(Pass *P) override; 0059 0060 /// run - Execute all of the passes scheduled for execution. Keep track of 0061 /// whether any of the passes modifies the module, and if so, return true. 0062 bool run(Module &M); 0063 0064 private: 0065 /// PassManagerImpl_New is the actual class. PassManager is just the 0066 /// wraper to publish simple pass manager interface 0067 PassManagerImpl *PM; 0068 }; 0069 0070 /// FunctionPassManager manages FunctionPasses. 0071 class FunctionPassManager : public PassManagerBase { 0072 public: 0073 /// FunctionPassManager ctor - This initializes the pass manager. It needs, 0074 /// but does not take ownership of, the specified Module. 0075 explicit FunctionPassManager(Module *M); 0076 ~FunctionPassManager() override; 0077 0078 void add(Pass *P) override; 0079 0080 /// run - Execute all of the passes scheduled for execution. Keep 0081 /// track of whether any of the passes modifies the function, and if 0082 /// so, return true. 0083 /// 0084 bool run(Function &F); 0085 0086 /// doInitialization - Run all of the initializers for the function passes. 0087 /// 0088 bool doInitialization(); 0089 0090 /// doFinalization - Run all of the finalizers for the function passes. 0091 /// 0092 bool doFinalization(); 0093 0094 private: 0095 FunctionPassManagerImpl *FPM; 0096 Module *M; 0097 }; 0098 0099 } // End legacy namespace 0100 0101 // Create wrappers for C Binding types (see CBindingWrapping.h). 0102 DEFINE_STDCXX_CONVERSION_FUNCTIONS(legacy::PassManagerBase, LLVMPassManagerRef) 0103 0104 } // End llvm namespace 0105 0106 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|