diff options
author | Anders Carlsson <andersca@mac.com> | 2010-04-16 16:23:02 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-04-16 16:23:02 +0000 |
commit | be6f3181dd6fdc23388d00476379c0fbc1b6a5c7 (patch) | |
tree | 693565a8112bd10d41cfc49e52a6e5dfe0d2ed93 /clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | |
parent | f13f69f296c2a0433e694e7fa93fd79247186da9 (diff) | |
download | bcm5719-llvm-be6f3181dd6fdc23388d00476379c0fbc1b6a5c7.tar.gz bcm5719-llvm-be6f3181dd6fdc23388d00476379c0fbc1b6a5c7.zip |
Make CGRecordLayoutBuilder deal with wide bit-fields. Will land tests shortly (Daniel, please review).
llvm-svn: 101472
Diffstat (limited to 'clang/lib/CodeGen/CGRecordLayoutBuilder.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp index 28564eb1293..141ddd7f2bd 100644 --- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -153,9 +153,28 @@ static CGBitFieldInfo ComputeBitFieldInfo(CodeGenTypes &Types, uint64_t TypeSizeInBytes = Types.getTargetData().getTypeAllocSize(Ty); uint64_t TypeSizeInBits = TypeSizeInBytes * 8; - unsigned StartBit = FieldOffset % TypeSizeInBits; bool IsSigned = FD->getType()->isSignedIntegerType(); + if (FieldSize > TypeSizeInBits) { + // We have a wide bit-field. + + CGBitFieldInfo::AccessInfo Component; + + Component.FieldIndex = 0; + Component.FieldByteOffset = + TypeSizeInBytes * ((FieldOffset / 8) / TypeSizeInBytes); + Component.FieldBitStart = 0; + Component.AccessWidth = TypeSizeInBits; + // FIXME: This might be wrong! + Component.AccessAlignment = 0; + Component.TargetBitOffset = 0; + Component.TargetBitWidth = TypeSizeInBits; + + return CGBitFieldInfo(TypeSizeInBits, 1, &Component, IsSigned); + } + + unsigned StartBit = FieldOffset % TypeSizeInBits; + // The current policy is to always access the bit-field using the source type // of the bit-field. With the C bit-field rules, this implies that we always // use either one or two accesses, and two accesses can only occur with a |