LLVM API Documentation
00001 //===- IRPrintingPasses.h - Passes to print out IR constructs ---*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 /// \file 00010 /// 00011 /// This file defines passes to print out IR in various granularities. The 00012 /// PrintModulePass pass simply prints out the entire module when it is 00013 /// executed. The PrintFunctionPass class is designed to be pipelined with 00014 /// other FunctionPass's, and prints out the functions of the module as they 00015 /// are processed. 00016 /// 00017 //===----------------------------------------------------------------------===// 00018 00019 #ifndef LLVM_IR_IRPRINTINGPASSES_H 00020 #define LLVM_IR_IRPRINTINGPASSES_H 00021 00022 #include "llvm/ADT/StringRef.h" 00023 #include <string> 00024 00025 namespace llvm { 00026 class BasicBlockPass; 00027 class Function; 00028 class FunctionPass; 00029 class Module; 00030 class ModulePass; 00031 class PreservedAnalyses; 00032 class raw_ostream; 00033 00034 /// \brief Create and return a pass that writes the module to the specified 00035 /// \c raw_ostream. 00036 ModulePass *createPrintModulePass(raw_ostream &OS, 00037 const std::string &Banner = ""); 00038 00039 /// \brief Create and return a pass that prints functions to the specified 00040 /// \c raw_ostream as they are processed. 00041 FunctionPass *createPrintFunctionPass(raw_ostream &OS, 00042 const std::string &Banner = ""); 00043 00044 /// \brief Create and return a pass that writes the BB to the specified 00045 /// \c raw_ostream. 00046 BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS, 00047 const std::string &Banner = ""); 00048 00049 /// \brief Pass for printing a Module as LLVM's text IR assembly. 00050 /// 00051 /// Note: This pass is for use with the new pass manager. Use the create...Pass 00052 /// functions above to create passes for use with the legacy pass manager. 00053 class PrintModulePass { 00054 raw_ostream &OS; 00055 std::string Banner; 00056 00057 public: 00058 PrintModulePass(); 00059 PrintModulePass(raw_ostream &OS, const std::string &Banner = ""); 00060 00061 PreservedAnalyses run(Module *M); 00062 00063 static StringRef name() { return "PrintModulePass"; } 00064 }; 00065 00066 /// \brief Pass for printing a Function as LLVM's text IR assembly. 00067 /// 00068 /// Note: This pass is for use with the new pass manager. Use the create...Pass 00069 /// functions above to create passes for use with the legacy pass manager. 00070 class PrintFunctionPass { 00071 raw_ostream &OS; 00072 std::string Banner; 00073 00074 public: 00075 PrintFunctionPass(); 00076 PrintFunctionPass(raw_ostream &OS, const std::string &Banner = ""); 00077 00078 PreservedAnalyses run(Function *F); 00079 00080 static StringRef name() { return "PrintFunctionPass"; } 00081 }; 00082 00083 } // End llvm namespace 00084 00085 #endif