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 | 1c7658fd32f26a3ea5fa1421494b2449c9eba3c9 (patch) | |
tree | f10a9a6ff8cf0b678b9069c0e17b0568f8ec1287 | |
parent | 4b16e97ff7761cfc61a42b15dfce5d868335196f (diff) |
Make CGRecordLayoutBuilder deal with wide bit-fields. Will land tests shortly (Daniel, please review).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101472 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGRecordLayoutBuilder.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index 28564eb129..141ddd7f2b 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/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 |