Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.3 KiB

  1. //===- llvm/PassManager.h - Container 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. //===----------------------------------------------------------------------===//
  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. #ifndef LLVM_PASSMANAGER_H
  17. #define LLVM_PASSMANAGER_H
  18. #include "llvm/Pass.h"
  19. namespace llvm {
  20. class Pass;
  21. class Module;
  22. class PassManagerImpl;
  23. class FunctionPassManagerImpl;
  24. /// PassManagerBase - An abstract interface to allow code to add passes to
  25. /// a pass manager without having to hard-code what kind of pass manager
  26. /// it is.
  27. class PassManagerBase {
  28. public:
  29. virtual ~PassManagerBase();
  30. /// add - Add a pass to the queue of passes to run. This passes ownership of
  31. /// the Pass to the PassManager. When the PassManager is destroyed, the pass
  32. /// will be destroyed as well, so there is no need to delete the pass. This
  33. /// implies that all passes MUST be allocated with 'new'.
  34. virtual void add(Pass *P) = 0;
  35. };
  36. /// PassManager manages ModulePassManagers
  37. class PassManager : public PassManagerBase {
  38. public:
  39. PassManager();
  40. ~PassManager();
  41. /// add - Add a pass to the queue of passes to run. This passes ownership of
  42. /// the Pass to the PassManager. When the PassManager is destroyed, the pass
  43. /// will be destroyed as well, so there is no need to delete the pass. This
  44. /// implies that all passes MUST be allocated with 'new'.
  45. void add(Pass *P);
  46. /// run - Execute all of the passes scheduled for execution. Keep track of
  47. /// whether any of the passes modifies the module, and if so, return true.
  48. bool run(Module &M);
  49. private:
  50. /// PassManagerImpl_New is the actual class. PassManager is just the
  51. /// wraper to publish simple pass manager interface
  52. PassManagerImpl *PM;
  53. };
  54. /// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
  55. class FunctionPassManager : public PassManagerBase {
  56. public:
  57. /// FunctionPassManager ctor - This initializes the pass manager. It needs,
  58. /// but does not take ownership of, the specified Module.
  59. explicit FunctionPassManager(Module *M);
  60. ~FunctionPassManager();
  61. /// add - Add a pass to the queue of passes to run. This passes
  62. /// ownership of the Pass to the PassManager. When the
  63. /// PassManager_X is destroyed, the pass will be destroyed as well, so
  64. /// there is no need to delete the pass.
  65. /// This implies that all passes MUST be allocated with 'new'.
  66. void add(Pass *P);
  67. /// run - Execute all of the passes scheduled for execution. Keep
  68. /// track of whether any of the passes modifies the function, and if
  69. /// so, return true.
  70. ///
  71. bool run(Function &F);
  72. /// doInitialization - Run all of the initializers for the function passes.
  73. ///
  74. bool doInitialization();
  75. /// doFinalization - Run all of the finalizers for the function passes.
  76. ///
  77. bool doFinalization();
  78. private:
  79. FunctionPassManagerImpl *FPM;
  80. Module *M;
  81. };
  82. } // End llvm namespace
  83. #endif