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;
34 /// \brief Create and return a pass that writes the module to the specified
36 ModulePass *createPrintModulePass(raw_ostream &OS,
37 const std::string &Banner = "",
38 bool ShouldPreserveUseListOrder = false);
40 /// \brief Create and return a pass that prints functions to the specified
41 /// \c raw_ostream as they are processed.
42 FunctionPass *createPrintFunctionPass(raw_ostream &OS,
43 const std::string &Banner = "");
45 /// \brief Create and return a pass that writes the BB to the specified
47 BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
48 const std::string &Banner = "");
50 /// Print out a name of an LLVM value without any prefixes.
52 /// The name is surrounded with ""'s and escaped if it has any special or
53 /// non-printable characters in it.
54 void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name);
56 /// \brief Pass for printing a Module as LLVM's text IR assembly.
58 /// Note: This pass is for use with the new pass manager. Use the create...Pass
59 /// functions above to create passes for use with the legacy pass manager.
60 class PrintModulePass {
63 bool ShouldPreserveUseListOrder;
67 PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
68 bool ShouldPreserveUseListOrder = false);
70 PreservedAnalyses run(Module &M);
72 static StringRef name() { return "PrintModulePass"; }
75 /// \brief Pass for printing a Function as LLVM's text IR assembly.
77 /// Note: This pass is for use with the new pass manager. Use the create...Pass
78 /// functions above to create passes for use with the legacy pass manager.
79 class PrintFunctionPass {
85 PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
87 PreservedAnalyses run(Function &F);
89 static StringRef name() { return "PrintFunctionPass"; }
92 } // End llvm namespace