10b57cec5SDimitry Andric //===- NewPMDriver.h - Function to drive opt with the new PM ----*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric /// \file 90b57cec5SDimitry Andric /// 100b57cec5SDimitry Andric /// A single function which is called to drive the opt behavior for the new 110b57cec5SDimitry Andric /// PassManager. 120b57cec5SDimitry Andric /// 130b57cec5SDimitry Andric /// This is only in a separate TU with a header to avoid including all of the 140b57cec5SDimitry Andric /// old pass manager headers and the new pass manager headers into the same 150b57cec5SDimitry Andric /// file. Eventually all of the routines here will get folded back into 160b57cec5SDimitry Andric /// opt.cpp. 170b57cec5SDimitry Andric /// 180b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 190b57cec5SDimitry Andric 200b57cec5SDimitry Andric #ifndef LLVM_TOOLS_OPT_NEWPMDRIVER_H 210b57cec5SDimitry Andric #define LLVM_TOOLS_OPT_NEWPMDRIVER_H 220b57cec5SDimitry Andric 23e8d8bef9SDimitry Andric #include "llvm/Support/CommandLine.h" 245ffd83dbSDimitry Andric 250b57cec5SDimitry Andric namespace llvm { 26*0fca6ea1SDimitry Andric class PassBuilder; 270b57cec5SDimitry Andric class StringRef; 280b57cec5SDimitry Andric class Module; 2981ad6265SDimitry Andric class PassPlugin; 300b57cec5SDimitry Andric class TargetMachine; 310b57cec5SDimitry Andric class ToolOutputFile; 32e8d8bef9SDimitry Andric class TargetLibraryInfoImpl; 33e8d8bef9SDimitry Andric 34e8d8bef9SDimitry Andric extern cl::opt<bool> DebugifyEach; 35e8d8bef9SDimitry Andric extern cl::opt<std::string> DebugifyExport; 360b57cec5SDimitry Andric 37753f127fSDimitry Andric extern cl::opt<bool> VerifyEachDebugInfoPreserve; 38753f127fSDimitry Andric extern cl::opt<std::string> VerifyDIPreserveExport; 39753f127fSDimitry Andric 400b57cec5SDimitry Andric namespace opt_tool { 410b57cec5SDimitry Andric enum OutputKind { 420b57cec5SDimitry Andric OK_NoOutput, 430b57cec5SDimitry Andric OK_OutputAssembly, 440b57cec5SDimitry Andric OK_OutputBitcode, 450b57cec5SDimitry Andric OK_OutputThinLTOBitcode, 460b57cec5SDimitry Andric }; 47bdd1243dSDimitry Andric enum VerifierKind { VK_NoVerifier, VK_VerifyOut, VK_VerifyEachPass }; 480b57cec5SDimitry Andric enum PGOKind { 490b57cec5SDimitry Andric NoPGO, 500b57cec5SDimitry Andric InstrGen, 510b57cec5SDimitry Andric InstrUse, 520b57cec5SDimitry Andric SampleUse 530b57cec5SDimitry Andric }; 540b57cec5SDimitry Andric enum CSPGOKind { NoCSPGO, CSInstrGen, CSInstrUse }; 550b57cec5SDimitry Andric } 560b57cec5SDimitry Andric 57fe6060f1SDimitry Andric void printPasses(raw_ostream &OS); 58fe6060f1SDimitry Andric 590b57cec5SDimitry Andric /// Driver function to run the new pass manager over a module. 600b57cec5SDimitry Andric /// 610b57cec5SDimitry Andric /// This function only exists factored away from opt.cpp in order to prevent 620b57cec5SDimitry Andric /// inclusion of the new pass manager headers and the old headers into the same 630b57cec5SDimitry Andric /// file. It's interface is consequentially somewhat ad-hoc, but will go away 640b57cec5SDimitry Andric /// when the transition finishes. 650b57cec5SDimitry Andric /// 660b57cec5SDimitry Andric /// ThinLTOLinkOut is only used when OK is OK_OutputThinLTOBitcode, and can be 670b57cec5SDimitry Andric /// nullptr. 68*0fca6ea1SDimitry Andric bool runPassPipeline( 69*0fca6ea1SDimitry Andric StringRef Arg0, Module &M, TargetMachine *TM, TargetLibraryInfoImpl *TLII, 70*0fca6ea1SDimitry Andric ToolOutputFile *Out, ToolOutputFile *ThinLinkOut, 71*0fca6ea1SDimitry Andric ToolOutputFile *OptRemarkFile, StringRef PassPipeline, 72*0fca6ea1SDimitry Andric ArrayRef<PassPlugin> PassPlugins, 73*0fca6ea1SDimitry Andric ArrayRef<std::function<void(llvm::PassBuilder &)>> PassBuilderCallbacks, 7406c3fb27SDimitry Andric opt_tool::OutputKind OK, opt_tool::VerifierKind VK, 750b57cec5SDimitry Andric bool ShouldPreserveAssemblyUseListOrder, 76*0fca6ea1SDimitry Andric bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex, 77*0fca6ea1SDimitry Andric bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve, 7806c3fb27SDimitry Andric bool UnifiedLTO = false); 790b57cec5SDimitry Andric } // namespace llvm 800b57cec5SDimitry Andric 810b57cec5SDimitry Andric #endif 82