* emit-rtl.c (set_mem_attributes_minus_bitpos): Rename from
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Jul 2002 19:53:34 +0000 (19:53 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Jul 2002 19:53:34 +0000 (19:53 +0000)
        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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@55846 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/emit-rtl.c
gcc/expr.c
gcc/expr.h

index b7a5e9b..c38471f 100644 (file)
@@ -1,3 +1,13 @@
+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
index 67c4cfb..0bba4a2 100644 (file)
@@ -1679,19 +1679,22 @@ component_ref_for_mem_expr (ref)
 
 /* 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
@@ -1760,6 +1763,7 @@ set_mem_attributes (ref, t, objectp)
        {
          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);
@@ -1784,6 +1788,7 @@ set_mem_attributes (ref, t, objectp)
        {
          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?  */
        }
@@ -1817,13 +1822,17 @@ set_mem_attributes (ref, t, objectp)
                  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?  */
            }
@@ -1847,6 +1856,11 @@ set_mem_attributes (ref, t, objectp)
        }
     }
 
+  /* 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));
@@ -1863,6 +1877,15 @@ set_mem_attributes (ref, t, objectp)
     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
index 1b880c1..810400c 100644 (file)
@@ -3846,17 +3846,7 @@ expand_assignment (to, from, want_value, suggest_reg)
             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
index ea51ba8..64340a2 100644 (file)
@@ -666,6 +666,12 @@ extern void maybe_set_unchanging PARAMS ((rtx, tree));
    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.  */