IRPrintingPasses.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //===- IRPrintingPasses.h - Passes to print out IR constructs ---*- 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. /// \file
  10. ///
  11. /// This file defines passes to print out IR in various granularities. The
  12. /// PrintModulePass pass simply prints out the entire module when it is
  13. /// executed. The PrintFunctionPass class is designed to be pipelined with
  14. /// other FunctionPass's, and prints out the functions of the module as they
  15. /// are processed.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_IR_IRPRINTINGPASSES_H
  19. #define LLVM_IR_IRPRINTINGPASSES_H
  20. #include "llvm/ADT/StringRef.h"
  21. #include <string>
  22. namespace llvm {
  23. class BasicBlockPass;
  24. class Function;
  25. class FunctionPass;
  26. class Module;
  27. class ModulePass;
  28. class PreservedAnalyses;
  29. class raw_ostream;
  30. /// \brief Create and return a pass that writes the module to the specified
  31. /// \c raw_ostream.
  32. ModulePass *createPrintModulePass(raw_ostream &OS,
  33. const std::string &Banner = "",
  34. bool ShouldPreserveUseListOrder = false);
  35. /// \brief Create and return a pass that prints functions to the specified
  36. /// \c raw_ostream as they are processed.
  37. FunctionPass *createPrintFunctionPass(raw_ostream &OS,
  38. const std::string &Banner = "");
  39. /// \brief Create and return a pass that writes the BB to the specified
  40. /// \c raw_ostream.
  41. BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
  42. const std::string &Banner = "");
  43. /// \brief Pass for printing a Module as LLVM's text IR assembly.
  44. ///
  45. /// Note: This pass is for use with the new pass manager. Use the create...Pass
  46. /// functions above to create passes for use with the legacy pass manager.
  47. class PrintModulePass {
  48. raw_ostream &OS;
  49. std::string Banner;
  50. bool ShouldPreserveUseListOrder;
  51. public:
  52. PrintModulePass();
  53. PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
  54. bool ShouldPreserveUseListOrder = false);
  55. PreservedAnalyses run(Module &M);
  56. static StringRef name() { return "PrintModulePass"; }
  57. };
  58. /// \brief Pass for printing a Function as LLVM's text IR assembly.
  59. ///
  60. /// Note: This pass is for use with the new pass manager. Use the create...Pass
  61. /// functions above to create passes for use with the legacy pass manager.
  62. class PrintFunctionPass {
  63. raw_ostream &OS;
  64. std::string Banner;
  65. public:
  66. PrintFunctionPass();
  67. PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
  68. PreservedAnalyses run(Function &F);
  69. static StringRef name() { return "PrintFunctionPass"; }
  70. };
  71. } // End llvm namespace
  72. #endif