1
//===-- MachineFunctionPrinterPass.cpp ------------------------------------===//
3
// The LLVM Compiler Infrastructure
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
8
//===----------------------------------------------------------------------===//
10
// MachineFunctionPrinterPass implementation.
12
//===----------------------------------------------------------------------===//
14
#include "llvm/CodeGen/Passes.h"
15
#include "llvm/CodeGen/MachineFunctionPass.h"
16
#include "llvm/CodeGen/MachineFunction.h"
17
#include "llvm/Support/raw_ostream.h"
22
/// MachineFunctionPrinterPass - This is a pass to dump the IR of a
25
struct MachineFunctionPrinterPass : public MachineFunctionPass {
29
const std::string Banner;
31
MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner)
32
: MachineFunctionPass(ID), OS(os), Banner(banner) {}
34
const char *getPassName() const { return "MachineFunction Printer"; }
36
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
38
MachineFunctionPass::getAnalysisUsage(AU);
41
bool runOnMachineFunction(MachineFunction &MF) {
42
OS << "# " << Banner << ":\n";
48
char MachineFunctionPrinterPass::ID = 0;
52
/// Returns a newly-created MachineFunction Printer pass. The
53
/// default banner is empty.
55
MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
56
const std::string &Banner){
57
return new MachineFunctionPrinterPass(OS, Banner);