blob: cc105c9167353b6c8154ef18925ca37cc7877405 [file] [log] [blame]
Stephen Hinesd711dec2013-01-08 16:23:30 -08001//===--- 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_3_2.h"
Stephen Hines99d42902013-12-16 17:45:42 -080015#include "llvm/IR/Function.h"
16#include "llvm/IR/Instructions.h"
17#include "llvm/IR/Module.h"
Stephen Hinesd711dec2013-01-08 16:23:30 -080018#include "llvm/Pass.h"
19using namespace llvm;
20
21namespace {
22 class WriteBitcodePass : public ModulePass {
23 raw_ostream &OS; // raw_ostream to print on
Stephen Hines99d42902013-12-16 17:45:42 -080024
Stephen Hinesd711dec2013-01-08 16:23:30 -080025 public:
26 static char ID; // Pass identification, replacement for typeid
27 explicit WriteBitcodePass(raw_ostream &o)
28 : ModulePass(ID), OS(o) {}
29
30 const char *getPassName() const { return "Bitcode Writer"; }
31
32 bool runOnModule(Module &M) {
Stephen Hines99d42902013-12-16 17:45:42 -080033 bool Changed = false;
Stephen Hinesd711dec2013-01-08 16:23:30 -080034 llvm_3_2::WriteBitcodeToFile(&M, OS);
Stephen Hines99d42902013-12-16 17:45:42 -080035 return Changed;
Stephen Hinesd711dec2013-01-08 16:23:30 -080036 }
37 };
38}
39
40char WriteBitcodePass::ID = 0;
41
Stephen Hinesd711dec2013-01-08 16:23:30 -080042/// createBitcodeWriterPass - Create and return a pass that writes the module
43/// to the specified ostream.
44ModulePass *llvm_3_2::createBitcodeWriterPass(raw_ostream &Str) {
45 return new WriteBitcodePass(Str);
46}