aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Bitcode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-07-09 05:14:23 +0000
committerChris Lattner <sabre@nondot.org>2008-07-09 05:14:23 +0000
commit65b13ff987257e9087c06ebb73cd478777765d01 (patch)
tree914c16b89dfc2af72fe4eb3a213c4db392be03c2 /include/llvm/Bitcode
parent7e03fd6e31ed6f7bd640764b3cd50ecb8cace83b (diff)
downloadexternal_llvm-65b13ff987257e9087c06ebb73cd478777765d01.zip
external_llvm-65b13ff987257e9087c06ebb73cd478777765d01.tar.gz
external_llvm-65b13ff987257e9087c06ebb73cd478777765d01.tar.bz2
Add a little wrapper header that is put around bc files when emitting
bc files for modules with a target triple that indicates they are for darwin. The reader unconditionally handles this, and the writer could turn this on for more targets if we care. This change has two benefits for darwin: 1) it allows us to encode the cpu type of the file in an easy to read place that doesn't require decoding the bc file. 2) it works around a bug (IMO) in darwin's AR where it is incapable of handling files that are not a multiple of 8 bytes long. BC files are only guaranteed to be multiples of 4 bytes long. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53275 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bitcode')
-rw-r--r--include/llvm/Bitcode/BitstreamWriter.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/llvm/Bitcode/BitstreamWriter.h b/include/llvm/Bitcode/BitstreamWriter.h
index 3b7e405..f76bb88 100644
--- a/include/llvm/Bitcode/BitstreamWriter.h
+++ b/include/llvm/Bitcode/BitstreamWriter.h
@@ -157,6 +157,15 @@ public:
Emit(Val, CurCodeSize);
}
+ // BackpatchWord - Backpatch a 32-bit word in the output with the specified
+ // value.
+ void BackpatchWord(unsigned ByteNo, unsigned NewWord) {
+ Out[ByteNo++] = (unsigned char)(NewWord >> 0);
+ Out[ByteNo++] = (unsigned char)(NewWord >> 8);
+ Out[ByteNo++] = (unsigned char)(NewWord >> 16);
+ Out[ByteNo ] = (unsigned char)(NewWord >> 24);
+ }
+
//===--------------------------------------------------------------------===//
// Block Manipulation
//===--------------------------------------------------------------------===//
@@ -227,10 +236,7 @@ public:
unsigned ByteNo = B.StartSizeWord*4;
// Update the block size field in the header of this sub-block.
- Out[ByteNo++] = (unsigned char)(SizeInWords >> 0);
- Out[ByteNo++] = (unsigned char)(SizeInWords >> 8);
- Out[ByteNo++] = (unsigned char)(SizeInWords >> 16);
- Out[ByteNo++] = (unsigned char)(SizeInWords >> 24);
+ BackpatchWord(ByteNo, SizeInWords);
// Restore the inner block's code size and abbrev table.
CurCodeSize = B.PrevCodeSize;