NewPMDriver.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //===- NewPMDriver.h - Function to drive opt with the new PM ----*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. /// \file
  9. ///
  10. /// A single function which is called to drive the opt behavior for the new
  11. /// PassManager.
  12. ///
  13. /// This is only in a separate TU with a header to avoid including all of the
  14. /// old pass manager headers and the new pass manager headers into the same
  15. /// file. Eventually all of the routines here will get folded back into
  16. /// opt.cpp.
  17. ///
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_TOOLS_OPT_NEWPMDRIVER_H
  20. #define LLVM_TOOLS_OPT_NEWPMDRIVER_H
  21. #include "llvm/Support/CommandLine.h"
  22. namespace llvm {
  23. class StringRef;
  24. class Module;
  25. class PassPlugin;
  26. class TargetMachine;
  27. class ToolOutputFile;
  28. class TargetLibraryInfoImpl;
  29. extern cl::opt<bool> DebugifyEach;
  30. extern cl::opt<std::string> DebugifyExport;
  31. extern cl::opt<bool> VerifyEachDebugInfoPreserve;
  32. extern cl::opt<std::string> VerifyDIPreserveExport;
  33. namespace opt_tool {
  34. enum OutputKind {
  35. OK_NoOutput,
  36. OK_OutputAssembly,
  37. OK_OutputBitcode,
  38. OK_OutputThinLTOBitcode,
  39. };
  40. enum VerifierKind { VK_NoVerifier, VK_VerifyOut, VK_VerifyEachPass };
  41. enum PGOKind {
  42. NoPGO,
  43. InstrGen,
  44. InstrUse,
  45. SampleUse
  46. };
  47. enum CSPGOKind { NoCSPGO, CSInstrGen, CSInstrUse };
  48. }
  49. void printPasses(raw_ostream &OS);
  50. /// Driver function to run the new pass manager over a module.
  51. ///
  52. /// This function only exists factored away from opt.cpp in order to prevent
  53. /// inclusion of the new pass manager headers and the old headers into the same
  54. /// file. It's interface is consequentially somewhat ad-hoc, but will go away
  55. /// when the transition finishes.
  56. ///
  57. /// ThinLTOLinkOut is only used when OK is OK_OutputThinLTOBitcode, and can be
  58. /// nullptr.
  59. bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
  60. TargetLibraryInfoImpl *TLII, ToolOutputFile *Out,
  61. ToolOutputFile *ThinLinkOut, ToolOutputFile *OptRemarkFile,
  62. StringRef PassPipeline,
  63. ArrayRef<PassPlugin> PassPlugins, opt_tool::OutputKind OK,
  64. opt_tool::VerifierKind VK,
  65. bool ShouldPreserveAssemblyUseListOrder,
  66. bool ShouldPreserveBitcodeUseListOrder,
  67. bool EmitSummaryIndex, bool EmitModuleHash,
  68. bool EnableDebugify, bool VerifyDIPreserve);
  69. } // namespace llvm
  70. #endif