emit-rtl.c (set_mem_attributes): Set RTX_UNCHANGINGP_P if T is a constant expression.
authorRichard Kenner <kenner@gcc.gnu.org>
Sat, 3 Nov 2001 15:50:04 +0000 (10:50 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Sat, 3 Nov 2001 15:50:04 +0000 (10:50 -0500)
* emit-rtl.c (set_mem_attributes): Set RTX_UNCHANGINGP_P if T is a
constant expression.
(set_mem_decl): New function.
* expr.h (set_mem_decl): New declaration.
* final.c (get_decl_from_op): Don't use ORIGINAL_REGNO if not pseudo.
(output_asm_operand_names): Add tab.
* reload1.c (alter_reg): Set decl of MEM from REG_DECL.

From-SVN: r46733

gcc/emit-rtl.c
gcc/expr.h
gcc/final.c
gcc/reload1.c

index 992d6049781028304fc5d5b92bd8d40fa3b0def6..61866387cf31e6b5c9cedbb075958fe761ce43e1 100644 (file)
@@ -1691,8 +1691,9 @@ set_mem_attributes (ref, t, objectp)
   MEM_VOLATILE_P (ref) = TYPE_VOLATILE (type);
   MEM_IN_STRUCT_P (ref) = AGGREGATE_TYPE_P (type);
   RTX_UNCHANGING_P (ref)
-    |= (lang_hooks.honor_readonly
-       && (TYPE_READONLY (type) || TREE_READONLY (t)));
+    |= ((lang_hooks.honor_readonly
+        && (TYPE_READONLY (type) || TREE_READONLY (t)))
+       || (! TYPE_P (t) && TREE_CONSTANT (t)));
 
   /* If we are making an object of this type, or if this is a DECL, we know
      that it is a scalar if the type is not an aggregate.  */
@@ -1783,6 +1784,18 @@ set_mem_align (mem, align)
                                   MEM_OFFSET (mem), MEM_SIZE (mem), align,
                                   GET_MODE (mem));
 }
+
+/* Set the decl for MEM to DECL.  */
+
+void
+set_mem_decl (mem, decl)
+     rtx mem;
+     tree decl;
+{
+  MEM_ATTRS (mem)
+    = get_mem_attrs (MEM_ALIAS_SET (mem), decl, MEM_OFFSET (mem),
+                    MEM_SIZE (mem), MEM_ALIGN (mem), GET_MODE (mem));
+}
 \f
 /* Return a memory reference like MEMREF, but with its mode changed to MODE
    and its address changed to ADDR.  (VOIDmode means don't change the mode.
index 6680476c8dc6c3d328c14ede8b3e52a95c5b0a97..4b5f124758dcd3f9674c11563f1369a8340965b3 100644 (file)
@@ -615,6 +615,9 @@ extern void set_mem_alias_set PARAMS ((rtx, HOST_WIDE_INT));
 /* Set the alignment of MEM to ALIGN bits.  */
 extern void set_mem_align PARAMS ((rtx, unsigned int));
 
+/* Set the DECL for MEM to DECL.  */
+extern void set_mem_decl PARAMS ((rtx, tree));
+
 /* Return a memory reference like MEMREF, but with its mode changed
    to MODE and its address changed to ADDR.
    (VOIDmode means don't change the mode.
index 8ab79eff46f23fc7829f892c9ca7d9b51fedda9f..6b2ea7eda6014ee716795c2e7bb381037f9de683 100644 (file)
@@ -3304,7 +3304,7 @@ get_decl_from_op (op, paddressp)
 
   *paddressp = 0;
 
-  if (GET_CODE (op) == REG)
+  if (GET_CODE (op) == REG && ORIGINAL_REGNO (op) >= FIRST_PSEUDO_REGISTER)
     return REGNO_DECL (ORIGINAL_REGNO (op));
   else if (GET_CODE (op) != MEM)
     return 0;
@@ -3353,9 +3353,9 @@ output_asm_operand_names (operands, oporder, nops)
 
       if (decl && DECL_NAME (decl))
        {
-         fprintf (asm_out_file, "%s %s%s",
-                  wrote ? "," : ASM_COMMENT_START, addressp ? "*" : "",
-                  IDENTIFIER_POINTER (DECL_NAME (decl)));
+         fprintf (asm_out_file, "%c%s %s%s",
+                  wrote ? ',' : '\t', wrote ? "" : ASM_COMMENT_START,
+                  addressp ? "*" : "", IDENTIFIER_POINTER (DECL_NAME (decl)));
          wrote = 1;
        }
     }
index c5158c7d81bd8f33e2faed26914076cb6475a60a..165573bdf8d867ccaa2a7c1db2207beab52147c9 100644 (file)
@@ -2043,8 +2043,17 @@ alter_reg (i, from_reg)
 
       /* If we have any adjustment to make, or if the stack slot is the
         wrong mode, make a new stack slot.  */
-      if (adjust != 0 || GET_MODE (x) != GET_MODE (regno_reg_rtx[i]))
-       x = adjust_address_nv (x, GET_MODE (regno_reg_rtx[i]), adjust);
+      x = adjust_address_nv (x, GET_MODE (regno_reg_rtx[i]), adjust);
+
+      /* If we have a decl for the original register, set it for the
+        memory.  If this is a shared MEM, make a copy.  */
+      if (REGNO_DECL (i))
+       {
+         if (from_reg != -1 && spill_stack_slot[from_reg] == x)
+           x = copy_rtx (x);
+
+         set_mem_decl (x, REGNO_DECL (i));
+       }
 
       /* Save the stack slot for later.  */
       reg_equiv_memory_loc[i] = x;