> Not quite:
> 
>       offset_int woffset
>         = (wi::to_offset (xoffset)
>            + wi::lrshift (wi::to_offset (DECL_FIELD_BIT_OFFSET (field)),
>                           LOG2_BITS_PER_UNIT));
> 
> offset_int is the type that can hold all bit positions, byte positions, byte 
> sizes and bit sizes.

Yep, I worked that out in meantime. Now I get:
../../gcc/tree.h: In function �long int int_bit_position(const_tree)�:
../../gcc/tree.h:3890:24: error: �to_offset� is not a member of �wi�
   return (wi::lrshift (wi::to_offset (DECL_FIELD_OFFSET (field)), 
BITS_PER_UNIT_LOG)
                        ^

> 
> One can use wi::to_offset to convert things into it.  You can see woffset 
> uses to see that various uses to convert back out.  The idea is that 
> eventually all the code that plays with that concept, could use that type.  
> Convert into it sooner, and convert out of it later.

There is quite some code in ipa-devirt, so I will look into updating it as 
HOST_WIDE_INT is
not that safe in that case.

Perhaps int_bit_position should be updated to return offset_int and make the 
conversion to
HOST_WIDE_INT optionally happen at the caller side?

Honza

Reply via email to