// layout object. However, this is blocked on other cleanups to the
// Objective-C code, so for now we just live with allocating a bunch of these
// objects.
- unsigned FieldNo = 0; // This value is unused.
CGBitFieldInfo *Info =
- new (CGF.CGM.getContext()) CGBitFieldInfo(
- LTy, FieldNo, BitOffset, BitFieldSize, IvarTy->isSignedIntegerType());
+ new (CGF.CGM.getContext()) CGBitFieldInfo(BitFieldSize,
+ IvarTy->isSignedIntegerType());
// We always construct a single, possibly unaligned, access for this case.
Info->setNumComponents(1);
};
private:
- /// The number of access components to use.
- unsigned NumComponents;
-
/// The components to use to access the bit-field. We may need up to three
/// separate components to support up to i64 bit-field access (4 + 2 + 1 byte
/// accesses).
// FIXME: De-hardcode this, just allocate following the struct.
AccessInfo Components[3];
-public:
- CGBitFieldInfo(const llvm::Type *FieldTy, unsigned FieldNo,
- unsigned Start, unsigned Size, bool IsSigned)
- : FieldTy(FieldTy), FieldNo(FieldNo),
- Start(Start), Size(Size), IsSigned(IsSigned) {}
+ /// The total size of the bit-field, in bits.
+ unsigned Size;
- const llvm::Type *FieldTy;
- unsigned FieldNo;
+ /// The number of access components to use.
+ unsigned NumComponents;
- unsigned Start;
- unsigned Size;
+ /// Whether the bit-field is signed.
bool IsSigned : 1;
+public:
+ CGBitFieldInfo(unsigned Size, bool IsSigned)
+ : Size(Size), IsSigned(IsSigned) {}
+
public:
/// \brief Check whether this bit-field access is (i.e., should be sign
/// extended on loads).
uint64_t TypeSizeInBytes = Types.getTargetData().getTypeAllocSize(Ty);
uint64_t TypeSizeInBits = TypeSizeInBytes * 8;
+ unsigned StartBit = FieldOffset % TypeSizeInBits;
bool IsSigned = FD->getType()->isSignedIntegerType();
- CGBitFieldInfo BFI(Ty, FieldOffset / TypeSizeInBits,
- FieldOffset % TypeSizeInBits, FieldSize, IsSigned);
+ 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.
- unsigned LowBits = std::min(FieldSize, TypeSizeInBits - BFI.Start);
+ unsigned LowBits = std::min(FieldSize, TypeSizeInBits - StartBit);
bool NeedsHighAccess = LowBits != FieldSize;
BFI.setNumComponents(1 + NeedsHighAccess);
LowAccess.FieldIndex = 0;
LowAccess.FieldByteOffset =
TypeSizeInBytes * ((FieldOffset / 8) / TypeSizeInBytes);
- LowAccess.FieldBitStart = BFI.Start;
+ LowAccess.FieldBitStart = StartBit;
LowAccess.AccessWidth = TypeSizeInBits;
// FIXME: This might be wrong!
LowAccess.AccessAlignment = 0;
void CGBitFieldInfo::print(llvm::raw_ostream &OS) const {
OS << "<CGBitFieldInfo";
- OS << " FieldTy:" << *FieldTy;
- OS << " FieldNo:" << FieldNo;
- OS << " Start:" << Start;
OS << " Size:" << Size;
OS << " IsSigned:" << IsSigned << "\n";