LLVM  6.0.0svn
IRPrintingPasses.h
Go to the documentation of this file.
1 //===- IRPrintingPasses.h - Passes to print out IR constructs ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
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
15 /// are processed.
16 ///
17 //===----------------------------------------------------------------------===//
18 
19 #ifndef LLVM_IR_IRPRINTINGPASSES_H
20 #define LLVM_IR_IRPRINTINGPASSES_H
21 
22 #include "llvm/ADT/StringRef.h"
23 #include <string>
24 
25 namespace llvm {
26 class BasicBlockPass;
27 class Function;
28 class FunctionPass;
29 class Module;
30 class ModulePass;
31 class PreservedAnalyses;
32 class raw_ostream;
33 template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
34 
35 /// \brief Create and return a pass that writes the module to the specified
36 /// \c raw_ostream.
37 ModulePass *createPrintModulePass(raw_ostream &OS,
38  const std::string &Banner = "",
39  bool ShouldPreserveUseListOrder = false);
40 
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 = "");
45 
46 /// \brief Create and return a pass that writes the BB to the specified
47 /// \c raw_ostream.
48 BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
49  const std::string &Banner = "");
50 
51 /// Print out a name of an LLVM value without any prefixes.
52 ///
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);
56 
57 /// \brief Pass for printing a Module as LLVM's text IR assembly.
58 ///
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.
62  raw_ostream &OS;
63  std::string Banner;
64  bool ShouldPreserveUseListOrder;
65 
66 public:
68  PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
69  bool ShouldPreserveUseListOrder = false);
70 
72 
73  static StringRef name() { return "PrintModulePass"; }
74 };
75 
76 /// \brief Pass for printing a Function as LLVM's text IR assembly.
77 ///
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.
81  raw_ostream &OS;
82  std::string Banner;
83 
84 public:
86  PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
87 
89 
90  static StringRef name() { return "PrintFunctionPass"; }
91 };
92 
93 } // End llvm namespace
94 
95 #endif
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
Pass for printing a Module as LLVM&#39;s text IR assembly.
FunctionPass * createPrintFunctionPass(raw_ostream &OS, const std::string &Banner="")
Create and return a pass that prints functions to the specified raw_ostream as they are processed...
static StringRef name()
F(f)
static StringRef name()
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name)
Print out a name of an LLVM value without any prefixes.
Definition: AsmWriter.cpp:404
BasicBlockPass * createPrintBasicBlockPass(raw_ostream &OS, const std::string &Banner="")
Create and return a pass that writes the BB to the specified raw_ostream.
PreservedAnalyses run(Module &M, AnalysisManager< Module > &)
ModulePass * createPrintModulePass(raw_ostream &OS, const std::string &Banner="", bool ShouldPreserveUseListOrder=false)
Create and return a pass that writes the module to the specified raw_ostream.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
A container for analyses that lazily runs them and caches their results.
Pass for printing a Function as LLVM&#39;s text IR assembly.