Give clients of MachineFunctionPrinter the ability to specify a banner and
choose an ostream.
llvm-svn: 11016
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index fa779063..e25fe8d 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -34,6 +34,12 @@
namespace {
struct Printer : public MachineFunctionPass {
+ std::ostream *OS;
+ const std::string &Banner;
+
+ Printer (std::ostream *_OS, const std::string &_Banner) :
+ OS (_OS), Banner (_Banner) { }
+
const char *getPassName() const { return "MachineFunction Printer"; }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@@ -41,14 +47,19 @@
}
bool runOnMachineFunction(MachineFunction &MF) {
- MF.dump();
+ (*OS) << Banner;
+ MF.print (*OS);
return false;
}
};
}
-FunctionPass *llvm::createMachineFunctionPrinterPass() {
- return new Printer();
+/// Returns a newly-created MachineFunction Printer pass. The default output
+/// stream is std::cerr; the default banner is empty.
+///
+FunctionPass *llvm::createMachineFunctionPrinterPass(std::ostream *OS,
+ const std::string &Banner) {
+ return new Printer(OS, Banner);
}
namespace {