diff options
author | Eric Christopher <echristo@apple.com> | 2010-04-01 22:54:42 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-04-01 22:54:42 +0000 |
commit | 1d8f83d0a00e912c55ec0974eba6122666cc6fa1 (patch) | |
tree | 5472afae0575df6c097d8e34f08a07b84ffcf916 /lib/CodeGen/MachineFunction.cpp | |
parent | c8e77640a53823b233f3f7a5c2be12aef9ebc69e (diff) |
Revert r100143.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100146 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | lib/CodeGen/MachineFunction.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 3a7de300c1..f6cc71f3a4 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -39,6 +39,40 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; +namespace { + struct Printer : public MachineFunctionPass { + static char ID; + + raw_ostream &OS; + const std::string Banner; + + Printer(raw_ostream &os, const std::string &banner) + : MachineFunctionPass(&ID), OS(os), Banner(banner) {} + + const char *getPassName() const { return "MachineFunction Printer"; } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + MachineFunctionPass::getAnalysisUsage(AU); + } + + bool runOnMachineFunction(MachineFunction &MF) { + OS << "# " << Banner << ":\n"; + MF.print(OS); + return false; + } + }; + char Printer::ID = 0; +} + +/// Returns a newly-created MachineFunction Printer pass. The default banner is +/// empty. +/// +FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner){ + return new Printer(OS, Banner); +} + //===----------------------------------------------------------------------===// // MachineFunction implementation //===----------------------------------------------------------------------===// |