2001-10-18 20:31:42 +00:00
|
|
|
//===- llvm/Assembly/PrintModulePass.h - Printing Pass -----------*- C++ -*--=//
|
|
|
|
//
|
2002-01-21 07:31:50 +00:00
|
|
|
// This file defines two passes to print out a module. The PrintModulePass
|
|
|
|
// pass simply prints out the entire module when it is executed. The
|
|
|
|
// PrintMethodPass class is designed to be pipelined with other MethodPass's,
|
|
|
|
// and prints out the methods of the class as they are processed.
|
2001-10-18 20:31:42 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H
|
|
|
|
#define LLVM_ASSEMBLY_PRINTMODULEPASS_H
|
|
|
|
|
|
|
|
#include "llvm/Pass.h"
|
2002-01-20 22:54:45 +00:00
|
|
|
#include <iostream>
|
2001-10-18 20:31:42 +00:00
|
|
|
|
|
|
|
class PrintModulePass : public Pass {
|
2002-01-20 22:54:45 +00:00
|
|
|
std::ostream *Out; // ostream to print on
|
2001-10-18 20:31:42 +00:00
|
|
|
bool DeleteStream; // Delete the ostream in our dtor?
|
|
|
|
public:
|
2002-01-21 07:31:50 +00:00
|
|
|
inline PrintModulePass(std::ostream *o = &std::cout, bool DS = false)
|
|
|
|
: Out(o), DeleteStream(DS) {
|
2001-10-18 20:31:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline ~PrintModulePass() {
|
|
|
|
if (DeleteStream) delete Out;
|
|
|
|
}
|
|
|
|
|
2002-01-21 07:31:50 +00:00
|
|
|
bool run(Module *M) {
|
|
|
|
(*Out) << M;
|
2001-10-18 20:31:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-01-21 07:31:50 +00:00
|
|
|
};
|
2001-10-18 20:31:42 +00:00
|
|
|
|
2002-04-08 21:52:58 +00:00
|
|
|
class PrintFunctionPass : public MethodPass {
|
2002-01-21 07:31:50 +00:00
|
|
|
std::string Banner; // String to print before each method
|
|
|
|
std::ostream *Out; // ostream to print on
|
|
|
|
bool DeleteStream; // Delete the ostream in our dtor?
|
|
|
|
public:
|
2002-04-08 21:52:58 +00:00
|
|
|
inline PrintFunctionPass(const std::string &B, std::ostream *o = &std::cout,
|
|
|
|
bool DS = false)
|
2002-01-21 07:31:50 +00:00
|
|
|
: Banner(B), Out(o), DeleteStream(DS) {
|
|
|
|
}
|
|
|
|
|
2002-04-08 21:52:58 +00:00
|
|
|
inline ~PrintFunctionPass() {
|
2002-01-21 07:31:50 +00:00
|
|
|
if (DeleteStream) delete Out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// runOnMethod - This pass just prints a banner followed by the method as
|
|
|
|
// it's processed.
|
2001-10-18 20:31:42 +00:00
|
|
|
//
|
2002-04-08 21:52:58 +00:00
|
|
|
bool runOnMethod(Function *F) {
|
|
|
|
(*Out) << Banner << F;
|
2001-10-18 20:31:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|