This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PRs 52080, 52097 and 48124, rewrite bitfield expansion, enable the C++ memory model wrt bitfields everywhere


On Tue, 3 Apr 2012, Eric Botcazou wrote:

> > For the case in question offset is (D.2640_7 + -1) * 20 + 16.  I wonder
> > why DECL_FIELD_OFFSET of the outermost COMPONENT_REF is not added
> > to bitpos by get_inner_reference (that is what get_bit_range assumes ...).
> 
> DECL_FIELD_OFFSET is added to offset and DECL_FIELD_BIT_OFFSET to bitpos.
> 
> > So, how would you make sure this works?  Match the fact that
> > get_inner_reference does _not_ add DECL_FIELD_OFFSET to bitpos,
> > and, if DECL_FIELD_OFFSET is an INTEGER_CST simply subtract that
> > from offset and add it to bitpos?  I suppose that would work.
> 
> Yes, but the amount is simply the negative bitstart (which is a multiple of 
> BITS_PER_UNIT).  This is the same kind of adjustment now done at the end of 
> get_inner_reference to avoid negative bit positions there too.
> 
> > Though doing that in get_inner_reference for DECL_BIT_FIELD_TYPE
> > fields may make sense as well.
> 
> That would be more complicated, as we would need to split the offset into
> variable and fixed part.
> 
> 
> Tentative patch attached, regtested for Ada on x86 and x86-64.  I'll do a full 
> testing cycle if it is approved.

Yes, the patch is ok.

Thanks,
Richard.

> 
> 	* expr.c (get_bit_range): Add OFFSET parameter and adjust BITPOS.
> 	Change type of BITOFFSET to signed.  Make sure the lower bound of
> 	the computed range is non-negative by adjusting OFFSET and BITPOS.
> 	(expand_assignment): Adjust call to get_bit_range.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]