xref: /freebsd/contrib/llvm-project/llvm/tools/opt/NewPMDriver.h (revision f9fd7337f63698f33239c58c07bf430198235a22)
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 #include "llvm/ADT/ArrayRef.h"
24 
25 namespace llvm {
26 class StringRef;
27 class Module;
28 class TargetMachine;
29 class ToolOutputFile;
30 
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 
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                      ToolOutputFile *Out, ToolOutputFile *ThinLinkOut,
63                      ToolOutputFile *OptRemarkFile, StringRef PassPipeline,
64                      ArrayRef<StringRef> PassInfos, opt_tool::OutputKind OK,
65                      opt_tool::VerifierKind VK,
66                      bool ShouldPreserveAssemblyUseListOrder,
67                      bool ShouldPreserveBitcodeUseListOrder,
68                      bool EmitSummaryIndex, bool EmitModuleHash,
69                      bool EnableDebugify, bool Coroutines);
70 } // namespace llvm
71 
72 #endif
73