~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/CodeGen/MachineFunctionPrinterPass.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
11
 
//
12
 
//===----------------------------------------------------------------------===//
13
 
 
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"
18
 
 
19
 
using namespace llvm;
20
 
 
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;
27
 
 
28
 
  raw_ostream &OS;
29
 
  const std::string Banner;
30
 
 
31
 
  MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner) 
32
 
      : MachineFunctionPass(ID), OS(os), Banner(banner) {}
33
 
 
34
 
  const char *getPassName() const { return "MachineFunction Printer"; }
35
 
 
36
 
  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
37
 
    AU.setPreservesAll();
38
 
    MachineFunctionPass::getAnalysisUsage(AU);
39
 
  }
40
 
 
41
 
  bool runOnMachineFunction(MachineFunction &MF) {
42
 
    OS << "# " << Banner << ":\n";
43
 
    MF.print(OS);
44
 
    return false;
45
 
  }
46
 
};
47
 
 
48
 
char MachineFunctionPrinterPass::ID = 0;
49
 
}
50
 
 
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);
58
 
}
59
 
 
60
 
}