IRPrintingPasses.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- IRPrintingPasses.h - Passes to print out IR constructs ---*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. /// \file
  14. ///
  15. /// This file defines passes to print out IR in various granularities. The
  16. /// PrintModulePass pass simply prints out the entire module when it is
  17. /// executed. The PrintFunctionPass class is designed to be pipelined with
  18. /// other FunctionPass's, and prints out the functions of the module as they
  19. /// are processed.
  20. ///
  21. //===----------------------------------------------------------------------===//
  22. #ifndef LLVM_IRPRINTER_IRPRINTINGPASSES_H
  23. #define LLVM_IRPRINTER_IRPRINTINGPASSES_H
  24. #include "llvm/IR/PassManager.h"
  25. #include <string>
  26. namespace llvm {
  27. class raw_ostream;
  28. class Function;
  29. class Module;
  30. class Pass;
  31. /// Pass (for the new pass manager) for printing a Module as
  32. /// LLVM's text IR assembly.
  33. class PrintModulePass : public PassInfoMixin<PrintModulePass> {
  34. raw_ostream &OS;
  35. std::string Banner;
  36. bool ShouldPreserveUseListOrder;
  37. bool EmitSummaryIndex;
  38. public:
  39. PrintModulePass();
  40. PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
  41. bool ShouldPreserveUseListOrder = false,
  42. bool EmitSummaryIndex = false);
  43. PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
  44. static bool isRequired() { return true; }
  45. };
  46. /// Pass (for the new pass manager) for printing a Function as
  47. /// LLVM's text IR assembly.
  48. class PrintFunctionPass : public PassInfoMixin<PrintFunctionPass> {
  49. raw_ostream &OS;
  50. std::string Banner;
  51. public:
  52. PrintFunctionPass();
  53. PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
  54. PreservedAnalyses run(Function &F, AnalysisManager<Function> &);
  55. static bool isRequired() { return true; }
  56. };
  57. } // namespace llvm
  58. #endif
  59. #ifdef __GNUC__
  60. #pragma GCC diagnostic pop
  61. #endif