blob: 522060e78e714125af7437c9a4e8aba7bb452857 [file] [log] [blame]
Chris Lattnere8e1e4b2007-05-06 02:30:12 +00001//===--- Bitcode/Writer/BitcodeWriterPass.cpp - Bitcode Writer ------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnere8e1e4b2007-05-06 02:30:12 +00007//
8//===----------------------------------------------------------------------===//
9//
10// BitcodeWriterPass implementation.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Bitcode/ReaderWriter.h"
15#include "llvm/Pass.h"
16using namespace llvm;
17
18namespace {
19 class WriteBitcodePass : public ModulePass {
Gordon Henriksenbd76d662007-11-04 20:28:31 +000020 std::ostream &Out; // ostream to print on
Chris Lattnere8e1e4b2007-05-06 02:30:12 +000021 public:
22 static char ID; // Pass identifcation, replacement for typeid
Dan Gohmanadf3eab2007-11-19 15:30:20 +000023 explicit WriteBitcodePass(std::ostream &o)
24 : ModulePass((intptr_t) &ID), Out(o) {}
Gordon Henriksenbd76d662007-11-04 20:28:31 +000025
26 const char *getPassName() const { return "Bitcode Writer"; }
Chris Lattnere8e1e4b2007-05-06 02:30:12 +000027
28 bool runOnModule(Module &M) {
Gordon Henriksenbd76d662007-11-04 20:28:31 +000029 WriteBitcodeToFile(&M, Out);
Chris Lattnere8e1e4b2007-05-06 02:30:12 +000030 return false;
31 }
32 };
33}
34
35char WriteBitcodePass::ID = 0;
Chris Lattnere8e1e4b2007-05-06 02:30:12 +000036
37/// CreateBitcodeWriterPass - Create and return a pass that writes the module
38/// to the specified ostream.
39ModulePass *llvm::CreateBitcodeWriterPass(std::ostream &Str) {
40 return new WriteBitcodePass(Str);
41}
42
43