1 //===- llvm/Assembly/PrintModulePass.h - Printing Pass -----------*- C++ -*--=//
3 // This file defines two passes to print out a module. The PrintModulePass pass
4 // simply prints out the entire module when it is executed. The
5 // PrintFunctionPass class is designed to be pipelined with other
6 // FunctionPass's, and prints out the functions of the class as they are
9 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H
12 #define LLVM_ASSEMBLY_PRINTMODULEPASS_H
14 #include "llvm/Pass.h"
15 #include "llvm/Value.h"
18 class PrintModulePass : public Pass {
19 std::ostream *Out; // ostream to print on
20 bool DeleteStream; // Delete the ostream in our dtor?
22 inline PrintModulePass(std::ostream *o = &std::cout, bool DS = false)
23 : Out(o), DeleteStream(DS) {
26 inline ~PrintModulePass() {
27 if (DeleteStream) delete Out;
35 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
40 class PrintFunctionPass : public FunctionPass {
41 std::string Banner; // String to print before each function
42 std::ostream *Out; // ostream to print on
43 bool DeleteStream; // Delete the ostream in our dtor?
45 inline PrintFunctionPass(const std::string &B, std::ostream *o = &std::cout,
47 : Banner(B), Out(o), DeleteStream(DS) {
50 inline ~PrintFunctionPass() {
51 if (DeleteStream) delete Out;
54 // runOnFunction - This pass just prints a banner followed by the function as
57 bool runOnFunction(Function *F) {
58 (*Out) << Banner << (Value*)F;
62 virtual void getAnalysisUsage(AnalysisUsage &AU) const {