LegacyPassManager.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //===- LegacyPassManager.h - Legacy 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 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.
  14. //
  15. //===----------------------------------------------------------------------===//
  16. #ifndef LLVM_IR_LEGACYPASSMANAGER_H
  17. #define LLVM_IR_LEGACYPASSMANAGER_H
  18. #include "llvm/Pass.h"
  19. #include "llvm/Support/CBindingWrapping.h"
  20. namespace llvm {
  21. class Pass;
  22. class Module;
  23. namespace legacy {
  24. class PassManagerImpl;
  25. class FunctionPassManagerImpl;
  26. /// PassManagerBase - An abstract interface to allow code to add passes to
  27. /// a pass manager without having to hard-code what kind of pass manager
  28. /// it is.
  29. class PassManagerBase {
  30. public:
  31. virtual ~PassManagerBase();
  32. /// Add a pass to the queue of passes to run. This passes ownership of
  33. /// the Pass to the PassManager. When the PassManager is destroyed, the pass
  34. /// will be destroyed as well, so there is no need to delete the pass. This
  35. /// may even destroy the pass right away if it is found to be redundant. This
  36. /// implies that all passes MUST be allocated with 'new'.
  37. virtual void add(Pass *P) = 0;
  38. raw_ostream *TrackPassOS = nullptr; // HLSL Change - add this field
  39. };
  40. /// PassManager manages ModulePassManagers
  41. class PassManager : public PassManagerBase {
  42. public:
  43. PassManager();
  44. ~PassManager() override;
  45. void add(Pass *P) override;
  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() override;
  61. void add(Pass *P) override;
  62. /// run - Execute all of the passes scheduled for execution. Keep
  63. /// track of whether any of the passes modifies the function, and if
  64. /// so, return true.
  65. ///
  66. bool run(Function &F);
  67. /// doInitialization - Run all of the initializers for the function passes.
  68. ///
  69. bool doInitialization();
  70. /// doFinalization - Run all of the finalizers for the function passes.
  71. ///
  72. bool doFinalization();
  73. private:
  74. FunctionPassManagerImpl *FPM;
  75. Module *M;
  76. };
  77. } // End legacy namespace
  78. // Create wrappers for C Binding types (see CBindingWrapping.h).
  79. DEFINE_STDCXX_CONVERSION_FUNCTIONS(legacy::PassManagerBase, LLVMPassManagerRef)
  80. } // End llvm namespace
  81. #endif