Eric Botcazou <ebotca...@adacore.com> writes: >> If so, it seems odd that we're using a property of STR_RTX to determine >> the interpretation/justification of VALUE. That is, we're using >> FIELDMODE before, rather than after: >> >> /* This is the mode we must force value to, so that there will be >> enough subwords to extract. Note that fieldmode will often (always?) be >> VOIDmode, because that is what store_field uses to indicate that this is a >> bit field, but passing VOIDmode to operand_subword_force >> is not allowed. */ >> fieldmode = GET_MODE (value); >> if (fieldmode == VOIDmode) >> fieldmode = smallest_mode_for_size (nwords * BITS_PER_WORD, MODE_INT); > > First of all, reusing FIELDMODE here is clearly very confusing, this > should be VALUEMODE instead. > > OK, I understand the concern. But what if VALUE has VOIDmode and the field > BLKmode? In this case, VALUEMODE may be integral and using it to determine > the justification will be wrong.
Ah, so in the BLKmode case, VALUE can still be a nonzero const_int? What are the justification rules in that case? Naively, I'd have expected a store of (const_int 1) into a BLKmode field to set one of the bits to 1, but it sounds from the above like it depends on endianness: for little-endian targets it always sets a bit, but for big-endian targets it only sets a bit if the field width is a multiple of UNITS_PER_WORD. >> In this sort of assignment, what does VALUE look like? Does it need to be >> BLKmode? Or can it have an integer mode? (I assume the former, since the >> latter seems contrary to what you said about integer modes above.) > > I think it must be BLKmode or VOIDmode. > >> Must VALUE be a memory? > > Or a constant probably. > >> Could we assert: >> >> gcc_assert ((fieldmode == BLKmode) == (GET_MODE (value) == BLKmode)); >> gcc_assert (fieldmode != BLKmode || MEM_P (value)); >> >> at the beginning of store_bit_field_1? > > We could indeed try, modulo constants I think. OK, thanks, that sounds better. If we can iron out what the nonzero constant case means then I'd be happy with that. Richard