1193323Sed//===--- Bitcode/Writer/BitcodeWriterPass.cpp - Bitcode Writer ------------===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10193323Sed// BitcodeWriterPass implementation.
11193323Sed//
12193323Sed//===----------------------------------------------------------------------===//
13193323Sed
14193323Sed#include "llvm/Bitcode/ReaderWriter.h"
15193323Sed#include "llvm/Pass.h"
16193323Sedusing namespace llvm;
17193323Sed
18193323Sednamespace {
19193323Sed  class WriteBitcodePass : public ModulePass {
20198090Srdivacky    raw_ostream &OS; // raw_ostream to print on
21193323Sed  public:
22193323Sed    static char ID; // Pass identification, replacement for typeid
23193323Sed    explicit WriteBitcodePass(raw_ostream &o)
24212904Sdim      : ModulePass(ID), OS(o) {}
25252723Sdim
26193323Sed    const char *getPassName() const { return "Bitcode Writer"; }
27252723Sdim
28193323Sed    bool runOnModule(Module &M) {
29198090Srdivacky      WriteBitcodeToFile(&M, OS);
30193323Sed      return false;
31193323Sed    }
32193323Sed  };
33193323Sed}
34193323Sed
35193323Sedchar WriteBitcodePass::ID = 0;
36193323Sed
37193323Sed/// createBitcodeWriterPass - Create and return a pass that writes the module
38193323Sed/// to the specified ostream.
39193323SedModulePass *llvm::createBitcodeWriterPass(raw_ostream &Str) {
40193323Sed  return new WriteBitcodePass(Str);
41193323Sed}
42