[cfe-commits] r101472 - /cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Anders Carlsson
andersca at mac.com
Fri Apr 16 09:23:02 PDT 2010
Author: andersca
Date: Fri Apr 16 11:23:02 2010
New Revision: 101472
URL: http://llvm.org/viewvc/llvm-project?rev=101472&view=rev
Log:
Make CGRecordLayoutBuilder deal with wide bit-fields. Will land tests shortly (Daniel, please review).
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=101472&r1=101471&r2=101472&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Fri Apr 16 11:23:02 2010
@@ -153,9 +153,28 @@
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
More information about the cfe-commits
mailing list