blob: 91e115cba6cc44915a9edbaa904ce77af50cdaf0 [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 {
Chris Lattnerb515d752009-08-23 07:49:08 +000020 raw_ostream &OS; // raw_ostream to print on
Chris Lattnere8e1e4b2007-05-06 02:30:12 +000021 public:
Daniel Dunbard1ce3b42008-10-22 17:39:14 +000022 static char ID; // Pass identification, replacement for typeid
Daniel Dunbard1ce3b42008-10-22 17:39:14 +000023 explicit WriteBitcodePass(raw_ostream &o)
Owen Anderson9ccaf532010-08-05 23:42:04 +000024 : ModulePass(ID), OS(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) {
Chris Lattnerb515d752009-08-23 07:49:08 +000029 WriteBitcodeToFile(&M, OS);
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
Daniel Dunbard1ce3b42008-10-22 17:39:14 +000037/// createBitcodeWriterPass - Create and return a pass that writes the module
38/// to the specified ostream.
39ModulePass *llvm::createBitcodeWriterPass(raw_ostream &Str) {
40 return new WriteBitcodePass(Str);
41}