the various ConstantExpr::get*Ty methods existed to work with issues around
[llvm/stm8.git] / lib / CodeGen / MachineFunctionPrinterPass.cpp
blob2aaa798a02c19d9f4968f9e85b549143551efc6b
1 //===-- MachineFunctionPrinterPass.cpp ------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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"
19 using namespace llvm;
21 namespace {
22 /// MachineFunctionPrinterPass - This is a pass to dump the IR of a
23 /// MachineFunction.
24 ///
25 struct MachineFunctionPrinterPass : public MachineFunctionPass {
26 static char ID;
28 raw_ostream &OS;
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 {
37 AU.setPreservesAll();
38 MachineFunctionPass::getAnalysisUsage(AU);
41 bool runOnMachineFunction(MachineFunction &MF) {
42 OS << "# " << Banner << ":\n";
43 MF.print(OS);
44 return false;
48 char MachineFunctionPrinterPass::ID = 0;
51 namespace llvm {
52 /// Returns a newly-created MachineFunction Printer pass. The
53 /// default banner is empty.
54 ///
55 MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
56 const std::string &Banner){
57 return new MachineFunctionPrinterPass(OS, Banner);