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