> This patch splits out a fairly common operation: that of narrowing a MEM > to a particular mode and adjusting the bit number accordingly. > > I've kept with "bit_field" rather than "bitfield" for consistency with > the callers, although we do have "bitfield" in "adjust_bitfield_address".
My bad. Feel free to rename it. > gcc/ > * expmed.c (narrow_bit_field_mem): New function. > (store_bit_field_using_insv, store_bit_field_1, store_fixed_bit_field) > (extract_bit_field_1): Use it. This is a good cleanup but... > Index: gcc/expmed.c > =================================================================== > --- gcc/expmed.c 2012-10-30 19:25:44.797368678 +0000 > +++ gcc/expmed.c 2012-10-30 19:25:47.730368671 +0000 > @@ -387,6 +387,23 @@ mode_for_extraction (enum extraction_pat > return data->operand[opno].mode; > } > > +/* Adjust bitfield memory MEM so that it points to the first unit of > + mode MODE that contains the bitfield at bit position BITNUM. > + Set NEW_BITNUM to the bit position of the field within the > + new memory. */ > + > +static rtx > +narrow_bit_field_mem (rtx mem, enum machine_mode mode, > + unsigned HOST_WIDE_INT bitnum, > + unsigned HOST_WIDE_INT &new_bitnum) > +{ > + unsigned int unit = GET_MODE_BITSIZE (mode); > + unsigned HOST_WIDE_INT offset = bitnum / unit * GET_MODE_SIZE (mode); > + mem = adjust_bitfield_address (mem, mode, offset); > + new_bitnum = bitnum % unit; > + return mem; > +} Ugh. :-) I cannot see any advantages in using references here except for... > + /* Get a reference to the first byte of the field. */ > + xop0 = narrow_bit_field_mem (xop0, byte_mode, bitnum, bitnum); > + op0 = narrow_bit_field_mem (op0, byte_mode, bitnum, bitnum); ... mightily confusing the reader here. -- Eric Botcazou