• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- Bitcode/Writer/BitcodeWriterPass.cpp - Bitcode Writer ------------===//
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 // BitcodeWriterPass implementation.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "ReaderWriter_2_9_func.h"
15 #include "llvm/IR/Function.h"
16 #include "llvm/IR/Instructions.h"
17 #include "llvm/IR/Module.h"
18 #include "llvm/Pass.h"
19 using namespace llvm;
20 
21 namespace {
22   class WriteBitcodePass : public ModulePass {
23     raw_ostream &OS; // raw_ostream to print on
24 
25   public:
26     static char ID; // Pass identification, replacement for typeid
WriteBitcodePass(raw_ostream & o)27     explicit WriteBitcodePass(raw_ostream &o)
28       : ModulePass(ID), OS(o) {}
29 
getPassName() const30     const char *getPassName() const { return "Bitcode Writer"; }
31 
runOnModule(Module & M)32     bool runOnModule(Module &M) {
33       bool Changed = false;
34       llvm_2_9_func::WriteBitcodeToFile(&M, OS);
35       return Changed;
36     }
37   };
38 }
39 
40 char WriteBitcodePass::ID = 0;
41 
42 /// createBitcodeWriterPass - Create and return a pass that writes the module
43 /// to the specified ostream.
createBitcodeWriterPass(llvm::raw_ostream & Str)44 llvm::ModulePass *llvm_2_9_func::createBitcodeWriterPass(llvm::raw_ostream &Str) {
45   return new WriteBitcodePass(Str);
46 }
47