X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FAssembly%2FPrintModulePass.h;h=239fbcc0c8caae629e7a7ac18adb85e58d03b21d;hb=d6a49773ffbe35847baa7a68773ebbb326120dd0;hp=770682d256db61cf52de33bccdc0d66bdb1b5114;hpb=d96662360f49f9b94d0faa7ea8dba8582bc1b364;p=oota-llvm.git diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h index 770682d256d..239fbcc0c8c 100644 --- a/include/llvm/Assembly/PrintModulePass.h +++ b/include/llvm/Assembly/PrintModulePass.h @@ -2,15 +2,15 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines two passes to print out a module. The PrintModulePass pass // simply prints out the entire module when it is executed. The // PrintFunctionPass class is designed to be pipelined with other -// FunctionPass's, and prints out the functions of the class as they are +// FunctionPass's, and prints out the functions of the module as they are // processed. // //===----------------------------------------------------------------------===// @@ -18,62 +18,24 @@ #ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H #define LLVM_ASSEMBLY_PRINTMODULEPASS_H -#include "llvm/Pass.h" -#include "llvm/Module.h" -#include "llvm/Support/Streams.h" +#include namespace llvm { - -class PrintModulePass : public ModulePass { - llvm_ostream *Out; // ostream to print on - bool DeleteStream; // Delete the ostream in our dtor? -public: - PrintModulePass() : Out(&llvm_cerr), DeleteStream(false) {} - PrintModulePass(llvm_ostream *o, bool DS = false) - : Out(o), DeleteStream(DS) { - } - - ~PrintModulePass() { - if (DeleteStream) delete Out; - } - - bool runOnModule(Module &M) { - (*Out) << M << std::flush; - return false; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } -}; - -class PrintFunctionPass : public FunctionPass { - std::string Banner; // String to print before each function - llvm_ostream *Out; // ostream to print on - bool DeleteStream; // Delete the ostream in our dtor? -public: - PrintFunctionPass() : Banner(""), Out(&llvm_cerr), DeleteStream(false) {} - PrintFunctionPass(const std::string &B, llvm_ostream *o = &llvm_cout, - bool DS = false) - : Banner(B), Out(o), DeleteStream(DS) { - } - - inline ~PrintFunctionPass() { - if (DeleteStream) delete Out; - } - - // runOnFunction - This pass just prints a banner followed by the function as - // it's processed. - // - bool runOnFunction(Function &F) { - (*Out) << Banner << static_cast(F); - return false; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } -}; + class FunctionPass; + class ModulePass; + class raw_ostream; + + /// createPrintModulePass - Create and return a pass that writes the + /// module to the specified raw_ostream. + ModulePass *createPrintModulePass(raw_ostream *OS, + bool DeleteStream=false, + const std::string &Banner = ""); + + /// createPrintFunctionPass - Create and return a pass that prints + /// functions to the specified raw_ostream as they are processed. + FunctionPass *createPrintFunctionPass(const std::string &Banner, + raw_ostream *OS, + bool DeleteStream=false); } // End llvm namespace