Pass.h (221345) | Pass.h (234353) |
---|---|
1//===- llvm/Pass.h - Base class for Passes ----------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 39 unchanged lines hidden (view full) --- 48// AnalysisID - Use the PassInfo to identify a pass... 49typedef const void* AnalysisID; 50 51/// Different types of internal pass managers. External pass managers 52/// (PassManager and FunctionPassManager) are not represented here. 53/// Ordering of pass manager types is important here. 54enum PassManagerType { 55 PMT_Unknown = 0, | 1//===- llvm/Pass.h - Base class for Passes ----------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 39 unchanged lines hidden (view full) --- 48// AnalysisID - Use the PassInfo to identify a pass... 49typedef const void* AnalysisID; 50 51/// Different types of internal pass managers. External pass managers 52/// (PassManager and FunctionPassManager) are not represented here. 53/// Ordering of pass manager types is important here. 54enum PassManagerType { 55 PMT_Unknown = 0, |
56 PMT_ModulePassManager = 1, ///< MPPassManager | 56 PMT_ModulePassManager = 1, ///< MPPassManager |
57 PMT_CallGraphPassManager, ///< CGPassManager 58 PMT_FunctionPassManager, ///< FPPassManager 59 PMT_LoopPassManager, ///< LPPassManager 60 PMT_RegionPassManager, ///< RGPassManager 61 PMT_BasicBlockPassManager, ///< BBPassManager 62 PMT_Last 63}; 64 --- 14 unchanged lines hidden (view full) --- 79/// constrained passes described below. 80/// 81class Pass { 82 AnalysisResolver *Resolver; // Used to resolve analysis 83 const void *PassID; 84 PassKind Kind; 85 void operator=(const Pass&); // DO NOT IMPLEMENT 86 Pass(const Pass &); // DO NOT IMPLEMENT | 57 PMT_CallGraphPassManager, ///< CGPassManager 58 PMT_FunctionPassManager, ///< FPPassManager 59 PMT_LoopPassManager, ///< LPPassManager 60 PMT_RegionPassManager, ///< RGPassManager 61 PMT_BasicBlockPassManager, ///< BBPassManager 62 PMT_Last 63}; 64 --- 14 unchanged lines hidden (view full) --- 79/// constrained passes described below. 80/// 81class Pass { 82 AnalysisResolver *Resolver; // Used to resolve analysis 83 const void *PassID; 84 PassKind Kind; 85 void operator=(const Pass&); // DO NOT IMPLEMENT 86 Pass(const Pass &); // DO NOT IMPLEMENT |
87 | 87 |
88public: | 88public: |
89 explicit Pass(PassKind K, char &pid); | 89 explicit Pass(PassKind K, char &pid) : Resolver(0), PassID(&pid), Kind(K) { } |
90 virtual ~Pass(); 91 | 90 virtual ~Pass(); 91 |
92 | 92 |
93 PassKind getPassKind() const { return Kind; } | 93 PassKind getPassKind() const { return Kind; } |
94 | 94 |
95 /// getPassName - Return a nice clean name for a pass. This usually 96 /// implemented in terms of the name that is registered by one of the 97 /// Registration templates, but can be overloaded directly. 98 /// 99 virtual const char *getPassName() const; 100 101 /// getPassID - Return the PassID number that corresponds to this pass. | 95 /// getPassName - Return a nice clean name for a pass. This usually 96 /// implemented in terms of the name that is registered by one of the 97 /// Registration templates, but can be overloaded directly. 98 /// 99 virtual const char *getPassName() const; 100 101 /// getPassID - Return the PassID number that corresponds to this pass. |
102 virtual AnalysisID getPassID() const { | 102 AnalysisID getPassID() const { |
103 return PassID; 104 } 105 106 /// print - Print out the internal state of the pass. This is called by 107 /// Analyze to print out the contents of an analysis. Otherwise it is not 108 /// necessary to implement this method. Beware that the module pointer MAY be 109 /// null. This automatically forwards to a virtual function that does not 110 /// provide the Module* in case the analysis doesn't need it it can just be 111 /// ignored. 112 /// 113 virtual void print(raw_ostream &O, const Module *M) const; 114 void dump() const; // dump - Print to stderr. 115 116 /// createPrinterPass - Get a Pass appropriate to print the IR this 117 /// pass operates on (Module, Function or MachineFunction). 118 virtual Pass *createPrinterPass(raw_ostream &O, 119 const std::string &Banner) const = 0; 120 121 /// Each pass is responsible for assigning a pass manager to itself. | 103 return PassID; 104 } 105 106 /// print - Print out the internal state of the pass. This is called by 107 /// Analyze to print out the contents of an analysis. Otherwise it is not 108 /// necessary to implement this method. Beware that the module pointer MAY be 109 /// null. This automatically forwards to a virtual function that does not 110 /// provide the Module* in case the analysis doesn't need it it can just be 111 /// ignored. 112 /// 113 virtual void print(raw_ostream &O, const Module *M) const; 114 void dump() const; // dump - Print to stderr. 115 116 /// createPrinterPass - Get a Pass appropriate to print the IR this 117 /// pass operates on (Module, Function or MachineFunction). 118 virtual Pass *createPrinterPass(raw_ostream &O, 119 const std::string &Banner) const = 0; 120 121 /// Each pass is responsible for assigning a pass manager to itself. |
122 /// PMS is the stack of available pass manager. 123 virtual void assignPassManager(PMStack &, | 122 /// PMS is the stack of available pass manager. 123 virtual void assignPassManager(PMStack &, |
124 PassManagerType) {} 125 /// Check if available pass managers are suitable for this pass or not. 126 virtual void preparePassManager(PMStack &); | 124 PassManagerType) {} 125 /// Check if available pass managers are suitable for this pass or not. 126 virtual void preparePassManager(PMStack &); |
127 | 127 |
128 /// Return what kind of Pass Manager can manage this pass. 129 virtual PassManagerType getPotentialPassManagerType() const; 130 131 // Access AnalysisResolver 132 void setResolver(AnalysisResolver *AR); 133 AnalysisResolver *getResolver() const { return Resolver; } 134 135 /// getAnalysisUsage - This function should be overriden by passes that need --- 18 unchanged lines hidden (view full) --- 154 155 /// getAdjustedAnalysisPointer - This method is used when a pass implements 156 /// an analysis interface through multiple inheritance. If needed, it should 157 /// override this to adjust the this pointer as needed for the specified pass 158 /// info. 159 virtual void *getAdjustedAnalysisPointer(AnalysisID ID); 160 virtual ImmutablePass *getAsImmutablePass(); 161 virtual PMDataManager *getAsPMDataManager(); | 128 /// Return what kind of Pass Manager can manage this pass. 129 virtual PassManagerType getPotentialPassManagerType() const; 130 131 // Access AnalysisResolver 132 void setResolver(AnalysisResolver *AR); 133 AnalysisResolver *getResolver() const { return Resolver; } 134 135 /// getAnalysisUsage - This function should be overriden by passes that need --- 18 unchanged lines hidden (view full) --- 154 155 /// getAdjustedAnalysisPointer - This method is used when a pass implements 156 /// an analysis interface through multiple inheritance. If needed, it should 157 /// override this to adjust the this pointer as needed for the specified pass 158 /// info. 159 virtual void *getAdjustedAnalysisPointer(AnalysisID ID); 160 virtual ImmutablePass *getAsImmutablePass(); 161 virtual PMDataManager *getAsPMDataManager(); |
162 | 162 |
163 /// verifyAnalysis() - This member can be implemented by a analysis pass to | 163 /// verifyAnalysis() - This member can be implemented by a analysis pass to |
164 /// check state of analysis information. | 164 /// check state of analysis information. |
165 virtual void verifyAnalysis() const; 166 167 // dumpPassStructure - Implement the -debug-passes=PassStructure option 168 virtual void dumpPassStructure(unsigned Offset = 0); 169 170 // lookupPassInfo - Return the pass info object for the specified pass class, 171 // or null if it is not known. 172 static const PassInfo *lookupPassInfo(const void *TI); 173 174 // lookupPassInfo - Return the pass info object for the pass with the given 175 // argument string, or null if it is not known. 176 static const PassInfo *lookupPassInfo(StringRef Arg); 177 | 165 virtual void verifyAnalysis() const; 166 167 // dumpPassStructure - Implement the -debug-passes=PassStructure option 168 virtual void dumpPassStructure(unsigned Offset = 0); 169 170 // lookupPassInfo - Return the pass info object for the specified pass class, 171 // or null if it is not known. 172 static const PassInfo *lookupPassInfo(const void *TI); 173 174 // lookupPassInfo - Return the pass info object for the pass with the given 175 // argument string, or null if it is not known. 176 static const PassInfo *lookupPassInfo(StringRef Arg); 177 |
178 // createPass - Create a object for the specified pass class, 179 // or null if it is not known. 180 static Pass *createPass(AnalysisID ID); 181 |
|
178 /// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to 179 /// get analysis information that might be around, for example to update it. 180 /// This is different than getAnalysis in that it can fail (if the analysis 181 /// results haven't been computed), so should only be used if you can handle 182 /// the case when the analysis is not available. This method is often used by 183 /// transformation APIs to update analysis results for a pass automatically as 184 /// the transform is performed. 185 /// --- 35 unchanged lines hidden (view full) --- 221public: 222 /// createPrinterPass - Get a module printer pass. 223 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; 224 225 /// runOnModule - Virtual method overriden by subclasses to process the module 226 /// being operated on. 227 virtual bool runOnModule(Module &M) = 0; 228 | 182 /// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to 183 /// get analysis information that might be around, for example to update it. 184 /// This is different than getAnalysis in that it can fail (if the analysis 185 /// results haven't been computed), so should only be used if you can handle 186 /// the case when the analysis is not available. This method is often used by 187 /// transformation APIs to update analysis results for a pass automatically as 188 /// the transform is performed. 189 /// --- 35 unchanged lines hidden (view full) --- 225public: 226 /// createPrinterPass - Get a module printer pass. 227 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; 228 229 /// runOnModule - Virtual method overriden by subclasses to process the module 230 /// being operated on. 231 virtual bool runOnModule(Module &M) = 0; 232 |
229 virtual void assignPassManager(PMStack &PMS, | 233 virtual void assignPassManager(PMStack &PMS, |
230 PassManagerType T); 231 232 /// Return what kind of Pass Manager can manage this pass. 233 virtual PassManagerType getPotentialPassManagerType() const; 234 235 explicit ModulePass(char &pid) : Pass(PT_Module, pid) {} 236 // Force out-of-line virtual method. 237 virtual ~ModulePass(); --- 16 unchanged lines hidden (view full) --- 254 virtual void initializePass(); 255 256 virtual ImmutablePass *getAsImmutablePass() { return this; } 257 258 /// ImmutablePasses are never run. 259 /// 260 bool runOnModule(Module &) { return false; } 261 | 234 PassManagerType T); 235 236 /// Return what kind of Pass Manager can manage this pass. 237 virtual PassManagerType getPotentialPassManagerType() const; 238 239 explicit ModulePass(char &pid) : Pass(PT_Module, pid) {} 240 // Force out-of-line virtual method. 241 virtual ~ModulePass(); --- 16 unchanged lines hidden (view full) --- 258 virtual void initializePass(); 259 260 virtual ImmutablePass *getAsImmutablePass() { return this; } 261 262 /// ImmutablePasses are never run. 263 /// 264 bool runOnModule(Module &) { return false; } 265 |
262 explicit ImmutablePass(char &pid) | 266 explicit ImmutablePass(char &pid) |
263 : ModulePass(pid) {} | 267 : ModulePass(pid) {} |
264 | 268 |
265 // Force out-of-line virtual method. 266 virtual ~ImmutablePass(); 267}; 268 269//===----------------------------------------------------------------------===// 270/// FunctionPass class - This class is used to implement most global 271/// optimizations. Optimizations should subclass this class if they meet the 272/// following constraints: --- 8 unchanged lines hidden (view full) --- 281 282 /// createPrinterPass - Get a function printer pass. 283 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; 284 285 /// doInitialization - Virtual method overridden by subclasses to do 286 /// any necessary per-module initialization. 287 /// 288 virtual bool doInitialization(Module &); | 269 // Force out-of-line virtual method. 270 virtual ~ImmutablePass(); 271}; 272 273//===----------------------------------------------------------------------===// 274/// FunctionPass class - This class is used to implement most global 275/// optimizations. Optimizations should subclass this class if they meet the 276/// following constraints: --- 8 unchanged lines hidden (view full) --- 285 286 /// createPrinterPass - Get a function printer pass. 287 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; 288 289 /// doInitialization - Virtual method overridden by subclasses to do 290 /// any necessary per-module initialization. 291 /// 292 virtual bool doInitialization(Module &); |
289 | 293 |
290 /// runOnFunction - Virtual method overriden by subclasses to do the 291 /// per-function processing of the pass. 292 /// 293 virtual bool runOnFunction(Function &F) = 0; 294 295 /// doFinalization - Virtual method overriden by subclasses to do any post 296 /// processing needed after all passes have run. 297 /// 298 virtual bool doFinalization(Module &); 299 | 294 /// runOnFunction - Virtual method overriden by subclasses to do the 295 /// per-function processing of the pass. 296 /// 297 virtual bool runOnFunction(Function &F) = 0; 298 299 /// doFinalization - Virtual method overriden by subclasses to do any post 300 /// processing needed after all passes have run. 301 /// 302 virtual bool doFinalization(Module &); 303 |
300 virtual void assignPassManager(PMStack &PMS, | 304 virtual void assignPassManager(PMStack &PMS, |
301 PassManagerType T); 302 303 /// Return what kind of Pass Manager can manage this pass. 304 virtual PassManagerType getPotentialPassManagerType() const; 305}; 306 307 308 --- 34 unchanged lines hidden (view full) --- 343 /// 344 virtual bool doFinalization(Function &); 345 346 /// doFinalization - Virtual method overriden by subclasses to do any post 347 /// processing needed after all passes have run. 348 /// 349 virtual bool doFinalization(Module &); 350 | 305 PassManagerType T); 306 307 /// Return what kind of Pass Manager can manage this pass. 308 virtual PassManagerType getPotentialPassManagerType() const; 309}; 310 311 312 --- 34 unchanged lines hidden (view full) --- 347 /// 348 virtual bool doFinalization(Function &); 349 350 /// doFinalization - Virtual method overriden by subclasses to do any post 351 /// processing needed after all passes have run. 352 /// 353 virtual bool doFinalization(Module &); 354 |
351 virtual void assignPassManager(PMStack &PMS, | 355 virtual void assignPassManager(PMStack &PMS, |
352 PassManagerType T); 353 354 /// Return what kind of Pass Manager can manage this pass. 355 virtual PassManagerType getPotentialPassManagerType() const; 356}; 357 358/// If the user specifies the -time-passes argument on an LLVM tool command line 359/// then the value of this boolean will be true, otherwise false. --- 12 unchanged lines hidden --- | 356 PassManagerType T); 357 358 /// Return what kind of Pass Manager can manage this pass. 359 virtual PassManagerType getPotentialPassManagerType() const; 360}; 361 362/// If the user specifies the -time-passes argument on an LLVM tool command line 363/// then the value of this boolean will be true, otherwise false. --- 12 unchanged lines hidden --- |