#ifndef LLVM_CODEGEN_PASSES_H
#define LLVM_CODEGEN_PASSES_H
+#include <iostream>
+
namespace llvm {
class FunctionPass;
/// MachineFunctionPrinter pass - This pass prints out the machine function to
/// standard error, as a debugging tool.
- FunctionPass *createMachineFunctionPrinterPass();
-
+ FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS = &std::cerr,
+ const std::string &Banner ="");
+
/// PHIElimination pass - This pass eliminates machine instruction PHI nodes
/// by inserting copy instructions. This destroys SSA information, but is the
/// desired input for some register allocators. This pass is "required" by
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 {
}
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 {