1 //===- IRPrintingPasses.h - Passes to print out IR constructs ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file defines passes to print out IR in various granularities. The
12 /// PrintModulePass pass simply prints out the entire module when it is
13 /// executed. The PrintFunctionPass class is designed to be pipelined with
14 /// other FunctionPass's, and prints out the functions of the module as they
17 //===----------------------------------------------------------------------===//
19 #ifndef LLVM_IR_IRPRINTINGPASSES_H
20 #define LLVM_IR_IRPRINTINGPASSES_H
22 #include "llvm/ADT/StringRef.h"
31 class PreservedAnalyses;
33 template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
35 /// \brief Create and return a pass that writes the module to the specified
37 ModulePass *createPrintModulePass(raw_ostream &OS,
38 const std::string &Banner = "",
39 bool ShouldPreserveUseListOrder = false);
41 /// \brief Create and return a pass that prints functions to the specified
42 /// \c raw_ostream as they are processed.
43 FunctionPass *createPrintFunctionPass(raw_ostream &OS,
44 const std::string &Banner = "");
46 /// \brief Create and return a pass that writes the BB to the specified
48 BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
49 const std::string &Banner = "");
51 /// Print out a name of an LLVM value without any prefixes.
53 /// The name is surrounded with ""'s and escaped if it has any special or
54 /// non-printable characters in it.
55 void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name);
57 /// \brief Pass for printing a Module as LLVM's text IR assembly.
59 /// Note: This pass is for use with the new pass manager. Use the create...Pass
60 /// functions above to create passes for use with the legacy pass manager.
61 class PrintModulePass {
64 bool ShouldPreserveUseListOrder;
68 PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
69 bool ShouldPreserveUseListOrder = false);
71 PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
73 static StringRef name() { return "PrintModulePass"; }
76 /// \brief Pass for printing a Function as LLVM's text IR assembly.
78 /// Note: This pass is for use with the new pass manager. Use the create...Pass
79 /// functions above to create passes for use with the legacy pass manager.
80 class PrintFunctionPass {
86 PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
88 PreservedAnalyses run(Function &F, AnalysisManager<Function> &);
90 static StringRef name() { return "PrintFunctionPass"; }
93 } // End llvm namespace