[cfe-commits] r43857 - /cfe/trunk/CodeGen/CodeGenTypes.cpp
Devang Patel
dpatel at apple.com
Wed Nov 7 16:18:00 PST 2007
Author: dpatel
Date: Wed Nov 7 18:17:59 2007
New Revision: 43857
URL: http://llvm.org/viewvc/llvm-project?rev=43857&view=rev
Log:
Keep track of beginning offset for the bit field that does not start at byte boundry.
Modified:
cfe/trunk/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.cpp?rev=43857&r1=43856&r2=43857&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.cpp Wed Nov 7 18:17:59 2007
@@ -33,7 +33,8 @@
class RecordOrganizer {
public:
explicit RecordOrganizer(CodeGenTypes &Types) :
- CGT(Types), STy(NULL), FieldNo(0), Cursor(0), ExtraBits(0) {}
+ CGT(Types), STy(NULL), FieldNo(0), Cursor(0), ExtraBits(0),
+ CurrentFieldStart(0) {}
/// addField - Add new field.
void addField(const FieldDecl *FD);
@@ -72,6 +73,11 @@
/* If last field is a bitfield then it may not have occupied all allocated
bits. Use remaining bits for next field if it also a bitfield. */
uint64_t ExtraBits;
+ /* CurrentFieldStart - Indicates starting offset for current llvm field.
+ When current llvm field is shared by multiple bitfields, this is
+ used find starting bit offset for the bitfield from the beginning of
+ llvm field. */
+ uint64_t CurrentFieldStart;
llvm::SmallVector<const FieldDecl *, 8> FieldDecls;
std::vector<const llvm::Type*> LLVMFields;
};
@@ -397,12 +403,12 @@
// Calculate extra bits available in this bitfield.
ExtraBits = CGT.getTargetData().getTypeSizeInBits(Ty) - BitFieldSize;
addLLVMField(Ty, BitFieldSize, FD, 0, ExtraBits);
- } else if (ExtraBits > BitFieldSize) {
+ } else if (ExtraBits >= BitFieldSize) {
// Reuse existing llvm field
ExtraBits = ExtraBits - BitFieldSize;
- Cursor = Cursor + BitFieldSize;
- CGT.addFieldInfo(FD, FieldNo, Cursor /* FIXME : This is incorrect */,
+ CGT.addFieldInfo(FD, FieldNo, Cursor - CurrentFieldStart,
ExtraBits);
+ Cursor = Cursor + BitFieldSize;
++FieldNo;
} else
assert (!FD->isBitField() && "Bit fields are not yet supported");
@@ -440,6 +446,7 @@
// combining consequetive padding fields.
addPaddingFields(Cursor % AlignmentInBits);
+ CurrentFieldStart = Cursor;
Cursor += Size;
LLVMFields.push_back(Ty);
if (FD)
More information about the cfe-commits
mailing list