NewPMDriver.h 2.5 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/ADT/ArrayRef.h"
  22. #include "llvm/Support/CommandLine.h"
  23. namespace llvm {
  24. class StringRef;
  25. class Module;
  26. class TargetMachine;
  27. class ToolOutputFile;
  28. class TargetLibraryInfoImpl;
  29. extern cl::opt<bool> DebugifyEach;
  30. extern cl::opt<std::string> DebugifyExport;
  31. namespace opt_tool {
  32. enum OutputKind {
  33. OK_NoOutput,
  34. OK_OutputAssembly,
  35. OK_OutputBitcode,
  36. OK_OutputThinLTOBitcode,
  37. };
  38. enum VerifierKind {
  39. VK_NoVerifier,
  40. VK_VerifyInAndOut,
  41. VK_VerifyEachPass
  42. };
  43. enum PGOKind {
  44. NoPGO,
  45. InstrGen,
  46. InstrUse,
  47. SampleUse
  48. };
  49. enum CSPGOKind { NoCSPGO, CSInstrGen, CSInstrUse };
  50. }
  51. void printPasses(raw_ostream &OS);
  52. /// Driver function to run the new pass manager over a module.
  53. ///
  54. /// This function only exists factored away from opt.cpp in order to prevent
  55. /// inclusion of the new pass manager headers and the old headers into the same
  56. /// file. It's interface is consequentially somewhat ad-hoc, but will go away
  57. /// when the transition finishes.
  58. ///
  59. /// ThinLTOLinkOut is only used when OK is OK_OutputThinLTOBitcode, and can be
  60. /// nullptr.
  61. bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
  62. TargetLibraryInfoImpl *TLII, ToolOutputFile *Out,
  63. ToolOutputFile *ThinLinkOut, ToolOutputFile *OptRemarkFile,
  64. StringRef PassPipeline, ArrayRef<StringRef> PassInfos,
  65. opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
  66. bool ShouldPreserveAssemblyUseListOrder,
  67. bool ShouldPreserveBitcodeUseListOrder,
  68. bool EmitSummaryIndex, bool EmitModuleHash,
  69. bool EnableDebugify);
  70. } // namespace llvm
  71. #endif