BlockInfoRecords.pop_back();
}
}
+
+ std::vector<unsigned char> &getBuffer() { return Out; }
+
//===--------------------------------------------------------------------===//
// Basic Primitives for emitting bits to the stream.
//===--------------------------------------------------------------------===//
class ModuleProvider;
class MemoryBuffer;
class ModulePass;
+ class BitstreamWriter;
class raw_ostream;
/// getBitcodeModuleProvider - Read the header of the specified bitcode buffer
/// raw output stream.
void WriteBitcodeToFile(const Module *M, raw_ostream &Out);
+ /// WriteBitcodeToStream - Write the specified module to the specified
+ /// raw output stream.
+ void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream);
+
/// CreateBitcodeWriterPass - Create and return a pass that writes the module
/// to the specified ostream.
ModulePass *CreateBitcodeWriterPass(std::ostream &Str);
BitstreamWriter Stream(Buffer);
Buffer.reserve(256*1024);
+
+ WriteBitcodeToStream( M, Stream );
+
+ // If writing to stdout, set binary mode.
+ if (&llvm::outs() == &Out)
+ sys::Program::ChangeStdoutToBinary();
+
+ // Write the generated bitstream to "Out".
+ Out.write((char*)&Buffer.front(), Buffer.size());
+ // Make sure it hits disk now.
+ Out.flush();
+}
+
+/// WriteBitcodeToStream - Write the specified module to the specified output
+/// stream.
+void llvm::WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream) {
// If this is darwin, emit a file header and trailer if needed.
bool isDarwin = M->getTargetTriple().find("-darwin") != std::string::npos;
if (isDarwin)
WriteModule(M, Stream);
if (isDarwin)
- EmitDarwinBCTrailer(Stream, Buffer.size());
-
-
- // If writing to stdout, set binary mode.
- if (&llvm::outs() == &Out)
- sys::Program::ChangeStdoutToBinary();
-
- // Write the generated bitstream to "Out".
- Out.write((char*)&Buffer.front(), Buffer.size());
-
- // Make sure it hits disk now.
- Out.flush();
+ EmitDarwinBCTrailer(Stream, Stream.getBuffer().size());
}