aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGRecordLayoutBuilder.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-04-15 05:09:32 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-04-15 05:09:32 +0000
commit2df2569679237b4979654a8663cd61aea67ab207 (patch)
treec2a48d8f611462b90df65df8f1d1ef93c40723db /lib/CodeGen/CGRecordLayoutBuilder.cpp
parent7fb619500404129322af972aab66c369949a2a74 (diff)
IRgen: Change CGBitFieldInfo to take the AccessInfo as constructor arguments, it is now an immutable object.
Also, add some checking of various invariants that should hold on the CGBitFieldInfo access. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRecordLayoutBuilder.cpp')
-rw-r--r--lib/CodeGen/CGRecordLayoutBuilder.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp
index cfdae2445e..28564eb129 100644
--- a/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -155,18 +155,19 @@ static CGBitFieldInfo ComputeBitFieldInfo(CodeGenTypes &Types,
unsigned StartBit = FieldOffset % TypeSizeInBits;
bool IsSigned = FD->getType()->isSignedIntegerType();
- CGBitFieldInfo BFI(FieldSize, IsSigned);
// 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
// packed structure when the bit-field straddles an alignment boundary.
+ CGBitFieldInfo::AccessInfo Components[2];
+
unsigned LowBits = std::min(FieldSize, TypeSizeInBits - StartBit);
bool NeedsHighAccess = LowBits != FieldSize;
- BFI.setNumComponents(1 + NeedsHighAccess);
+ unsigned NumComponents = 1 + NeedsHighAccess;
// FIXME: This access policy is probably wrong on big-endian systems.
- CGBitFieldInfo::AccessInfo &LowAccess = BFI.getComponent(0);
+ CGBitFieldInfo::AccessInfo &LowAccess = Components[0];
LowAccess.FieldIndex = 0;
LowAccess.FieldByteOffset =
TypeSizeInBytes * ((FieldOffset / 8) / TypeSizeInBytes);
@@ -178,7 +179,7 @@ static CGBitFieldInfo ComputeBitFieldInfo(CodeGenTypes &Types,
LowAccess.TargetBitWidth = LowBits;
if (NeedsHighAccess) {
- CGBitFieldInfo::AccessInfo &HighAccess = BFI.getComponent(1);
+ CGBitFieldInfo::AccessInfo &HighAccess = Components[1];
HighAccess.FieldIndex = 0;
HighAccess.FieldByteOffset = LowAccess.FieldByteOffset + TypeSizeInBytes;
HighAccess.FieldBitStart = 0;
@@ -189,7 +190,7 @@ static CGBitFieldInfo ComputeBitFieldInfo(CodeGenTypes &Types,
HighAccess.TargetBitWidth = FieldSize - LowBits;
}
- return BFI;
+ return CGBitFieldInfo(FieldSize, NumComponents, Components, IsSigned);
}
void CGRecordLayoutBuilder::LayoutBitField(const FieldDecl *D,