aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorKarl Schimpf <kschimpf@google.com>2013-11-21 10:34:00 -0800
committerKarl Schimpf <kschimpf@google.com>2013-11-21 10:34:00 -0800
commit7026af7138fccfb256456b04b375d39b025bdb7c (patch)
tree0afbf310102dd6975b6f2fc3fda8120313b91825 /lib/Bitcode
parent44e5b95659ac983b60877a5606f893105d0c6057 (diff)
Clean up handling of PNaCl bitcode headers.
Write out all of PNaCl bitcode headers using a single interface function. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/61753017
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
index eb22910c8d..968be249ed 100644
--- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
+++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
@@ -1183,9 +1183,14 @@ static void WriteModule(const Module *M, NaClBitstreamWriter &Stream) {
static const size_t kMaxVariableFieldSize = 256;
// Write out the given Header to the bitstream.
-static void WriteHeader(
- const NaClBitcodeHeader &Header,
- NaClBitstreamWriter& Stream) {
+void llvm::NaClWriteHeader(const NaClBitcodeHeader &Header,
+ NaClBitstreamWriter &Stream) {
+ // Emit the file magic number;
+ Stream.Emit((unsigned)'P', 8);
+ Stream.Emit((unsigned)'E', 8);
+ Stream.Emit((unsigned)'X', 8);
+ Stream.Emit((unsigned)'E', 8);
+
// Emit placeholder for number of bytes used to hold header fields.
// This value is necessary so that the streamable reader can preallocate
// a buffer to read the fields.
@@ -1228,12 +1233,6 @@ void llvm::NaClWriteBitcodeToFile(const Module *M, raw_ostream &Out,
{
NaClBitstreamWriter Stream(Buffer);
- // Emit the file header.
- Stream.Emit((unsigned)'P', 8);
- Stream.Emit((unsigned)'E', 8);
- Stream.Emit((unsigned)'X', 8);
- Stream.Emit((unsigned)'E', 8);
-
// Define header and install into stream.
{
NaClBitcodeHeader Header;
@@ -1245,7 +1244,7 @@ void llvm::NaClWriteBitcodeToFile(const Module *M, raw_ostream &Out,
(!AcceptSupportedOnly && Header.IsReadable()))) {
report_fatal_error(Header.Unsupported());
}
- WriteHeader(Header, Stream);
+ NaClWriteHeader(Header, Stream);
}
// Emit the module.