On Tue, Aug 30, 2011 at 6:15 PM, Aldy Hernandez <al...@redhat.com> wrote: > >> *bit_offset is supposed to be relative to *byte_offset then it should >> be easy to calculate it without another get_inner_reference. > > Since, as you suggested, we will terminate early on variable length offsets, > we can assume both DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET will be > constants by now.
Yes. > So, I assume we can calculate the bit offset like this: > > *bit_offset = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (fld)) > * BITS_PER_UNIT > + TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (fld))) > - (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (bitregion_start)) > * BITS_PER_UNIT > + TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (bitregion_start))); > > (Yes, I know we can factor out the BITS_PER_UNIT and only do one > multiplication, it's just easier to read this way.) > > Is this what you had in mind? Yes. For convenience I'd simply use double_ints for the intermediate calculations. Richard.