2010-04-03 07:51:10 +00:00
|
|
|
//===-- MachineFunctionPrinterPass.cpp ------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// MachineFunctionPrinterPass implementation.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/Passes.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2012-08-15 19:34:23 +00:00
|
|
|
#include "llvm/CodeGen/SlotIndexes.h"
|
2010-04-03 07:51:10 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2012-08-15 19:34:23 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2010-04-03 07:51:10 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
/// MachineFunctionPrinterPass - This is a pass to dump the IR of a
|
|
|
|
/// MachineFunction.
|
|
|
|
///
|
|
|
|
struct MachineFunctionPrinterPass : public MachineFunctionPass {
|
|
|
|
static char ID;
|
|
|
|
|
|
|
|
raw_ostream &OS;
|
|
|
|
const std::string Banner;
|
|
|
|
|
2012-08-15 19:34:23 +00:00
|
|
|
MachineFunctionPrinterPass() : MachineFunctionPass(ID), OS(dbgs()) { }
|
2010-04-03 07:51:10 +00:00
|
|
|
MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner)
|
2010-09-17 15:48:55 +00:00
|
|
|
: MachineFunctionPass(ID), OS(os), Banner(banner) {}
|
2010-04-03 07:51:10 +00:00
|
|
|
|
|
|
|
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";
|
2012-08-15 19:34:23 +00:00
|
|
|
MF.print(OS, getAnalysisIfAvailable<SlotIndexes>());
|
2010-04-03 07:51:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
char MachineFunctionPrinterPass::ID = 0;
|
|
|
|
}
|
|
|
|
|
2012-12-02 13:10:19 +00:00
|
|
|
char &llvm::MachineFunctionPrinterPassID = MachineFunctionPrinterPass::ID;
|
2012-08-15 19:34:23 +00:00
|
|
|
INITIALIZE_PASS(MachineFunctionPrinterPass, "print-machineinstrs",
|
|
|
|
"Machine Function Printer", false, false)
|
|
|
|
|
2010-04-03 07:51:10 +00:00
|
|
|
namespace llvm {
|
|
|
|
/// Returns a newly-created MachineFunction Printer pass. The
|
|
|
|
/// default banner is empty.
|
|
|
|
///
|
|
|
|
MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
|
|
|
|
const std::string &Banner){
|
|
|
|
return new MachineFunctionPrinterPass(OS, Banner);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|