+2002-07-29 Richard Henderson <rth@redhat.com>
+
+ * emit-rtl.c (set_mem_attributes_minus_bitpos): Rename from
+ set_mem_attributes and add BITPOS argument. Subtract it from
+ OFFSET when same is adjusted.
+ (set_mem_attributes): New wrapper function.
+ * expr.c (expand_assignment): Use set_mem_attributes_minus_bitpos;
+ remove offset adjustment hack.
+ * expr.h (set_mem_attributes_minus_bitpos): Declare.
+
2002-07-29 Gabriel Dos Reis <gdr@nerim.net>
* Makefile.in (C_OBJS): Include c-pretty-print.o
/* Given REF, a MEM, and T, either the type of X or the expression
corresponding to REF, set the memory attributes. OBJECTP is nonzero
- if we are making a new object of this type. */
+ if we are making a new object of this type. BITPOS is nonzero if
+ there is an offset outstanding on T that will be applied later. */
void
-set_mem_attributes (ref, t, objectp)
+set_mem_attributes_minus_bitpos (ref, t, objectp, bitpos)
rtx ref;
tree t;
int objectp;
+ HOST_WIDE_INT bitpos;
{
HOST_WIDE_INT alias = MEM_ALIAS_SET (ref);
tree expr = MEM_EXPR (ref);
rtx offset = MEM_OFFSET (ref);
rtx size = MEM_SIZE (ref);
unsigned int align = MEM_ALIGN (ref);
+ HOST_WIDE_INT apply_bitpos = 0;
tree type;
/* It can happen that type_for_mode was given a mode for which there
{
expr = t;
offset = const0_rtx;
+ apply_bitpos = bitpos;
size = (DECL_SIZE_UNIT (t)
&& host_integerp (DECL_SIZE_UNIT (t), 1)
? GEN_INT (tree_low_cst (DECL_SIZE_UNIT (t), 1)) : 0);
{
expr = component_ref_for_mem_expr (t);
offset = const0_rtx;
+ apply_bitpos = bitpos;
/* ??? Any reason the field size would be different than
the size we got from the type? */
}
if (aoff && aoff < align)
align = aoff;
offset = GEN_INT (ioff);
+ apply_bitpos = bitpos;
}
}
else if (TREE_CODE (t) == COMPONENT_REF)
{
expr = component_ref_for_mem_expr (t);
if (host_integerp (off_tree, 1))
- offset = GEN_INT (tree_low_cst (off_tree, 1));
+ {
+ offset = GEN_INT (tree_low_cst (off_tree, 1));
+ apply_bitpos = bitpos;
+ }
/* ??? Any reason the field size would be different than
the size we got from the type? */
}
}
}
+ /* If we modified OFFSET based on T, then subtract the outstanding
+ bit position offset. */
+ if (apply_bitpos)
+ offset = plus_constant (offset, -(apply_bitpos / BITS_PER_UNIT));
+
/* Now set the attributes we computed above. */
MEM_ATTRS (ref)
= get_mem_attrs (alias, expr, offset, size, align, GET_MODE (ref));
MEM_IN_STRUCT_P (ref) = 1;
}
+void
+set_mem_attributes (ref, t, objectp)
+ rtx ref;
+ tree t;
+ int objectp;
+{
+ set_mem_attributes_minus_bitpos (ref, t, objectp, 0);
+}
+
/* Set the alias set of MEM to SET. */
void
DECL_RTX of the parent struct. Don't munge it. */
to_rtx = shallow_copy_rtx (to_rtx);
- set_mem_attributes (to_rtx, to, 0);
-
- /* If we changed MEM_EXPR, that means we're now referencing
- the COMPONENT_REF, which means that MEM_OFFSET must be
- relative to that field. But we've not yet reflected BITPOS
- in TO_RTX. This will be done in store_field. Adjust for
- that by biasing MEM_OFFSET by -bitpos. */
- if (MEM_EXPR (to_rtx) != old_expr && MEM_OFFSET (to_rtx)
- && (bitpos / BITS_PER_UNIT) != 0)
- set_mem_offset (to_rtx, GEN_INT (INTVAL (MEM_OFFSET (to_rtx))
- - (bitpos / BITS_PER_UNIT)));
+ set_mem_attributes_minus_bitpos (to_rtx, to, 0, bitpos);
}
/* Deal with volatile and readonly fields. The former is only done
corresponding to REF, set the memory attributes. OBJECTP is nonzero
if we are making a new object of this type. */
extern void set_mem_attributes PARAMS ((rtx, tree, int));
+
+/* Similar, except that BITPOS has not yet been applied to REF, so if
+ we alter MEM_OFFSET according to T then we should subtract BITPOS
+ expecting that it'll be added back in later. */
+extern void set_mem_attributes_minus_bitpos PARAMS ((rtx, tree, int,
+ HOST_WIDE_INT));
#endif
/* Assemble the static constant template for function entry trampolines. */