LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PassManager.h

Go to the documentation of this file.
00001 //===- llvm/PassManager.h - Container for Passes ----------------*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the PassManager class.  This class is used to hold,
00011 // maintain, and optimize execution of Passes.  The PassManager class ensures
00012 // that analysis results are available before a pass runs, and that Pass's are
00013 // destroyed when the PassManager is destroyed.
00014 //
00015 //===----------------------------------------------------------------------===//
00016 
00017 #ifndef LLVM_PASSMANAGER_H
00018 #define LLVM_PASSMANAGER_H
00019 
00020 namespace llvm {
00021 
00022 class Pass;
00023 class ModulePass;
00024 class Module;
00025 class ModuleProvider;
00026 template<class UnitType> class PassManagerT;
00027 
00028 class PassManager {
00029   PassManagerT<Module> *PM;    // This is a straightforward Pimpl class
00030 public:
00031   PassManager();
00032   ~PassManager();
00033 
00034   /// add - Add a pass to the queue of passes to run.  This passes ownership of
00035   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
00036   /// will be destroyed as well, so there is no need to delete the pass.  This
00037   /// implies that all passes MUST be allocated with 'new'.
00038   ///
00039   void add(Pass *P);
00040 
00041   /// run - Execute all of the passes scheduled for execution.  Keep track of
00042   /// whether any of the passes modifies the module, and if so, return true.
00043   ///
00044   bool run(Module &M);
00045 };
00046 
00047 class FunctionPass;
00048 class ImmutablePass;
00049 class Function;
00050 
00051 class FunctionPassManager {
00052   PassManagerT<Function> *PM;    // This is a straightforward Pimpl class
00053   ModuleProvider *MP;
00054 public:
00055   FunctionPassManager(ModuleProvider *P);
00056   ~FunctionPassManager();
00057 
00058   /// add - Add a pass to the queue of passes to run.  This passes
00059   /// ownership of the FunctionPass to the PassManager.  When the
00060   /// PassManager is destroyed, the pass will be destroyed as well, so
00061   /// there is no need to delete the pass.  This implies that all
00062   /// passes MUST be allocated with 'new'.
00063   ///
00064   void add(FunctionPass *P);
00065 
00066   /// add - ImmutablePasses are not FunctionPasses, so we have a 
00067   /// special hack to get them into a FunctionPassManager.
00068   ///
00069   void add(ImmutablePass *IP);
00070 
00071   /// run - Execute all of the passes scheduled for execution.  Keep
00072   /// track of whether any of the passes modifies the function, and if
00073   /// so, return true.
00074   ///
00075   bool run(Function &F);
00076 };
00077 
00078 } // End llvm namespace
00079 
00080 #endif