================ @@ -394,33 +412,155 @@ void CGRecordLowering::accumulateFields() { : getStorageType(*Field), *Field)); ++Field; - } else { - ++Field; } } } -void -CGRecordLowering::accumulateBitFields(RecordDecl::field_iterator Field, - RecordDecl::field_iterator FieldEnd) { - // Run stores the first element of the current run of bitfields. FieldEnd is - // used as a special value to note that we don't have a current run. A - // bitfield run is a contiguous collection of bitfields that can be stored in - // the same storage block. Zero-sized bitfields and bitfields that would - // cross an alignment boundary break a run and start a new one. - RecordDecl::field_iterator Run = FieldEnd; - // Tail is the offset of the first bit off the end of the current run. It's - // used to determine if the ASTRecordLayout is treating these two bitfields as - // contiguous. StartBitOffset is offset of the beginning of the Run. - uint64_t StartBitOffset, Tail = 0; +namespace { + +// A run of bitfields assigned to the same access unit -- the size of memory +// loads & stores. +class BitFieldAccessUnit { + RecordDecl::field_iterator Begin; // Field at start of this access unit. + RecordDecl::field_iterator End; // Field just after this access unit. + + CharUnits StartOffset; // Starting offset in the containing record. + CharUnits EndOffset; // Finish offset (exclusive) in the containing record. + + bool ContainsVolatile; // This access unit contains a volatile bitfield. + +public: + // End barrier constructor. + BitFieldAccessUnit(RecordDecl::field_iterator F, CharUnits Offset, + bool Volatile = false) + : Begin(F), End(F), StartOffset(Offset), EndOffset(Offset), + ContainsVolatile(Volatile) {} + + // Collect contiguous bitfields into an access unit. + BitFieldAccessUnit(RecordDecl::field_iterator FieldBegin, + RecordDecl::field_iterator FieldEnd, + const CGRecordLowering &CGRL); ---------------- urnathan wrote:
Updated to add gatherBitFieldAccessUnit and installBitFieldAccessUnit members of CGRecordLowering. You're right that it makes the structure clearer. https://github.com/llvm/llvm-project/pull/65742 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits