1 //===- PrintPasses.h - Determining whether/when to print IR ---------------===//
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 
9 #ifndef LLVM_IR_PRINTPASSES_H
10 #define LLVM_IR_PRINTPASSES_H
11 
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/CommandLine.h"
14 #include <vector>
15 
16 namespace llvm {
17 
18 enum class ChangePrinter {
19   None,
20   Verbose,
21   Quiet,
22   DiffVerbose,
23   DiffQuiet,
24   ColourDiffVerbose,
25   ColourDiffQuiet,
26   DotCfgVerbose,
27   DotCfgQuiet
28 };
29 
30 extern cl::opt<ChangePrinter> PrintChanged;
31 
32 // Returns true if printing before/after some pass is enabled, whether all
33 // passes or a specific pass.
34 bool shouldPrintBeforeSomePass();
35 bool shouldPrintAfterSomePass();
36 
37 // Returns true if we should print before/after a specific pass. The argument
38 // should be the pass ID, e.g. "instcombine".
39 bool shouldPrintBeforePass(StringRef PassID);
40 bool shouldPrintAfterPass(StringRef PassID);
41 
42 // Returns true if we should print before/after all passes.
43 bool shouldPrintBeforeAll();
44 bool shouldPrintAfterAll();
45 
46 // The list of passes to print before/after, if we only want to print
47 // before/after specific passes.
48 std::vector<std::string> printBeforePasses();
49 std::vector<std::string> printAfterPasses();
50 
51 // Returns true if we should always print the entire module.
52 bool forcePrintModuleIR();
53 
54 // Returns true if we should print the function.
55 bool isFunctionInPrintList(StringRef FunctionName);
56 
57 } // namespace llvm
58 
59 #endif // LLVM_IR_PRINTPASSES_H
60