summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-06 02:30:12 +0000
committerChris Lattner <sabre@nondot.org>2007-05-06 02:30:12 +0000
commit7ef417107b7ce2b552ba0873a65d1ac7c0b1ee81 (patch)
tree5280a36b10cfa24b8b3a7b4e8cdc6b177d25a9d5 /llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
parentaf8fffc0817c811885387511c96e03a315521509 (diff)
downloadbcm5719-llvm-7ef417107b7ce2b552ba0873a65d1ac7c0b1ee81.tar.gz
bcm5719-llvm-7ef417107b7ce2b552ba0873a65d1ac7c0b1ee81.zip
add a new CreateBitcodeWriterPass method, which creates a bitcode writer as
a pass llvm-svn: 36828
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
new file mode 100644
index 00000000000..74123116da8
--- /dev/null
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
@@ -0,0 +1,43 @@
+//===--- Bitcode/Writer/BitcodeWriterPass.cpp - Bitcode Writer ------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// BitcodeWriterPass implementation.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Pass.h"
+using namespace llvm;
+
+namespace {
+ class WriteBitcodePass : public ModulePass {
+ std::ostream *Out; // ostream to print on
+ public:
+ static char ID; // Pass identifcation, replacement for typeid
+ WriteBitcodePass() : ModulePass((intptr_t) &ID), Out(0) { }
+ WriteBitcodePass(std::ostream &o) : ModulePass((intptr_t) &ID), Out(&o) {}
+
+ bool runOnModule(Module &M) {
+ if (Out)
+ WriteBitcodeToFile(&M, *Out);
+ return false;
+ }
+ };
+}
+
+char WriteBitcodePass::ID = 0;
+static RegisterPass<WriteBitcodePass> X("emitbitcode", "Bitcode Writer");
+
+/// CreateBitcodeWriterPass - Create and return a pass that writes the module
+/// to the specified ostream.
+ModulePass *llvm::CreateBitcodeWriterPass(std::ostream &Str) {
+ return new WriteBitcodePass(Str);
+}
+
+
OpenPOWER on IntegriCloud