(store_constructor): Handle TREE_PURPOSE of array constructor.

(expand_expr, ARRAY_REF case): Likewise.

From-SVN: r5315
This commit is contained in:
Richard Stallman 1993-09-13 20:16:51 +00:00
parent 3181cbfdd5
commit 03dc44a614
1 changed files with 31 additions and 8 deletions

View File

@ -2720,19 +2720,41 @@ store_constructor (exp, target)
int bitsize; int bitsize;
int bitpos; int bitpos;
int unsignedp; int unsignedp;
tree index = TREE_PURPOSE (elt);
rtx xtarget = target;
mode = TYPE_MODE (elttype); mode = TYPE_MODE (elttype);
bitsize = GET_MODE_BITSIZE (mode); bitsize = GET_MODE_BITSIZE (mode);
unsignedp = TREE_UNSIGNED (elttype); unsignedp = TREE_UNSIGNED (elttype);
bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype))); if (index != 0 && TREE_CODE (index) != INTEGER_CST)
{
/* We don't currently allow variable indices in a
C initializer, but let's try here to support them. */
rtx pos_rtx, addr, xtarget;
tree position;
store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt), position = size_binop (MULT_EXPR, index, TYPE_SIZE (elttype));
/* The alignment of TARGET is pos_rtx = expand_expr (position, 0, VOIDmode, 0);
at least what its type requires. */ addr = gen_rtx (PLUS, Pmode, XEXP (target, 0), pos_rtx);
VOIDmode, 0, xtarget = change_address (target, mode, addr);
TYPE_ALIGN (type) / BITS_PER_UNIT, store_expr (TREE_VALUE (elt), xtarget, 0);
int_size_in_bytes (type)); }
else
{
if (index != 0)
bitpos = (TREE_INT_CST_LOW (index)
* TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
else
bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
store_field (xtarget, bitsize, bitpos, mode, TREE_VALUE (elt),
/* The alignment of TARGET is
at least what its type requires. */
VOIDmode, 0,
TYPE_ALIGN (type) / BITS_PER_UNIT,
int_size_in_bytes (type));
}
} }
} }
@ -4013,7 +4035,8 @@ expand_expr (exp, target, tmode, modifier)
{ {
tree elem = CONSTRUCTOR_ELTS (init); tree elem = CONSTRUCTOR_ELTS (init);
while (elem && i--) while (elem
&& !tree_int_cst_equal (TREE_PURPOSE (elem), index))
elem = TREE_CHAIN (elem); elem = TREE_CHAIN (elem);
if (elem) if (elem)
return expand_expr (fold (TREE_VALUE (elem)), target, return expand_expr (fold (TREE_VALUE (elem)), target,