representation of struct field offsets

Chris Lattner clattner@apple.com
Thu Sep 28 20:54:00 GMT 2006


On Sep 28, 2006, at 1:43 PM, Mark Mitchell wrote:
> Sandra Loosemore wrote:
>
>> I've been having a heck of a time figuring out how to translate  
>> the offsets for struct fields from the DWARF encoding back to  
>> GCC's internal encoding for the LTO project.
>
> Yes, that's a nasty bit.
>
> I think the DECL_FIELD_OFFSET/DECL_FIELD_BIT_OFFSET stuff is, quite  
> simply, mis-designed.  The way I think it should work is for  
> DECL_FIELD_OFFSET to be the byte offset, and DECL_FIELD_BIT_OFFSET  
> to be the bit offset, always less than BITS_PER_UNIT.

An alternative design, which would save a field, is just to keep the  
offset of a field, in bits, from the start of the structure.

The only trouble you'll probably run into is with fields whose offset  
from the start of a structure is variable.

-Chris






More information about the Gcc mailing list