1 //===- llvm/Assembly/PrintModulePass.h - Printing Pass -----------*- C++ -*--=//
3 // This file defines two passes to print out a module. The PrintModulePass
4 // pass simply prints out the entire module when it is executed. The
5 // PrintMethodPass class is designed to be pipelined with other MethodPass's,
6 // and prints out the methods of the class as they are processed.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H
11 #define LLVM_ASSEMBLY_PRINTMODULEPASS_H
13 #include "llvm/Pass.h"
14 #include "llvm/Assembly/Writer.h"
17 class PrintModulePass : public Pass {
18 std::ostream *Out; // ostream to print on
19 bool DeleteStream; // Delete the ostream in our dtor?
21 inline PrintModulePass(std::ostream *o = &std::cout, bool DS = false)
22 : Out(o), DeleteStream(DS) {
25 inline ~PrintModulePass() {
26 if (DeleteStream) delete Out;
35 class PrintMethodPass : public MethodPass {
36 std::string Banner; // String to print before each method
37 std::ostream *Out; // ostream to print on
38 bool DeleteStream; // Delete the ostream in our dtor?
40 inline PrintMethodPass(const std::string &B, std::ostream *o = &std::cout,
42 : Banner(B), Out(o), DeleteStream(DS) {
45 inline ~PrintMethodPass() {
46 if (DeleteStream) delete Out;
49 // runOnMethod - This pass just prints a banner followed by the method as
52 bool runOnMethod(Method *M) {
53 (*Out) << Banner << M;