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