]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
langhooks.h (LANG_HOOKS_HONOR_READONLY): New macro.
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Fri, 19 Oct 2001 19:54:06 +0000 (19:54 +0000)
committerRichard Kenner <kenner@gcc.gnu.org>
Fri, 19 Oct 2001 19:54:06 +0000 (15:54 -0400)
* langhooks.h (LANG_HOOKS_HONOR_READONLY): New macro.
* toplev.h (struct lang_hooks): New field HONOR_READONLY.
* emit-rtl.c (set_mem_attributes): Set RTX_UNCHANGING_P from
TREE_READONLY and TYPE_READONLY if lang_hooks.honor_readonly.
Set alignment from type if INDIRECT_REF.
(adjust_address_1, offset_address): Simplify alignment compuitation.
* expr.c (expand_expr, case INDIRECT_REF): Don't set RTX_UNCHANGING_P
here; done by set_mem_attributes.

From-SVN: r46361

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

index 69bc79dcd827b13aacb31f584edd69589fe2a305..0c724c34456c124d9aba05994d4ff2590345de69 100644 (file)
@@ -1,3 +1,14 @@
+Fri Oct 19 15:24:39 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+       * langhooks.h (LANG_HOOKS_HONOR_READONLY): New macro.
+       * toplev.h (struct lang_hooks): New field HONOR_READONLY.
+       * emit-rtl.c (set_mem_attributes): Set RTX_UNCHANGING_P from
+       TREE_READONLY and TYPE_READONLY if lang_hooks.honor_readonly.
+       Set alignment from type if INDIRECT_REF.
+       (adjust_address_1, offset_address): Simplify alignment compuitation.
+       * expr.c (expand_expr, case INDIRECT_REF): Don't set RTX_UNCHANGING_P
+       here; done by set_mem_attributes.
+
 2001-10-19  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * Makefile.in (rtlanal.o): Depend on $(TM_P_H).
index c7c61401b5e2f620f6efe65c4a6c0faba54b0bf5..45fd406f4c981a3db66ea54e16605c0d10d2a879 100644 (file)
@@ -1672,13 +1672,11 @@ set_mem_attributes (ref, t, objectp)
      front-end routine).  */
   set_mem_alias_set (ref, get_alias_set (t));
 
-  /* It is incorrect to set RTX_UNCHANGING_P from TREE_READONLY (type)
-     here, because, in C and C++, the fact that a location is accessed
-     through a const expression does not mean that the value there can
-     never change.  */
-
   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)));
 
   /* If we are making an object of this type, we know that it is a scalar if
      the type is not an aggregate.  */
@@ -1717,6 +1715,10 @@ set_mem_attributes (ref, t, objectp)
         ? GEN_INT (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (t)), 1))
         : 0, DECL_ALIGN (t) / BITS_PER_UNIT);
 
+  /* If this is an INDIRECT_REF, we know its alignment.  */
+  if (TREE_CODE (t) == INDIRECT_REF)
+    set_mem_align (ref, TYPE_ALIGN (type) / BITS_PER_UNIT);
+
   /* Now see if we can say more about whether it's an aggregate or
      scalar.  If we already know it's an aggregate, don't bother.  */
   if (MEM_IN_STRUCT_P (ref))
@@ -1860,14 +1862,11 @@ adjust_address_1 (memref, mode, offset, validate)
   if (memoffset)
     memoffset = GEN_INT (offset + INTVAL (memoffset));
 
-  /* If the offset is negative, don't try to update the alignment.  If it's
-     zero, the alignment hasn't changed.  Otherwise, the known alignment may
-     be less strict.  */
-  if (offset < 0)
-    memalign = 1;
-
-  while (offset > 0 && (offset % memalign) != 0)
-    memalign >>= 1;
+  /* Compute the new alignment by taking the MIN of the alignment and the
+     lowest-order set bit in OFFSET, but don't change the alignment if OFFSET
+     if zero.  */
+  if (offset != 0)
+    memalign = MIN (memalign, offset & -offset);
 
   MEM_ATTRS (new)
     = get_mem_attrs (MEM_ALIAS_SET (memref), MEM_DECL (memref), memoffset,
@@ -1893,15 +1892,11 @@ offset_address (memref, offset, pow2)
   rtx new = change_address_1 (memref, VOIDmode,
                              gen_rtx_PLUS (Pmode, XEXP (memref, 0),
                                            force_reg (Pmode, offset)), 1);
-  unsigned int memalign = MEM_ALIGN (memref);
 
   /* Update the alignment to reflect the offset.  Reset the offset, which
      we don't know.  */
-  while (pow2 % memalign != 0)
-    memalign >>= 1;
-
   MEM_ATTRS (new) = get_mem_attrs (MEM_ALIAS_SET (memref), MEM_DECL (memref),
-                                  0, 0, memalign);
+                                  0, 0, MIN (MEM_ALIGN (memref), pow2));
   return new;
 }
   
index f486b32e4fdc4b86b2aaa299b7b3add0ed7ad610..3290b39496d1abce1b1c7a5271c459e5410115f3 100644 (file)
@@ -6812,13 +6812,6 @@ expand_expr (exp, target, tmode, modifier)
        temp = gen_rtx_MEM (mode, op0);
        set_mem_attributes (temp, exp, 0);
 
-       /* It is incorrect to set RTX_UNCHANGING_P from TREE_READONLY
-          here, because, in C and C++, the fact that a location is accessed
-          through a pointer to const does not mean that the value there can
-          never change.  Languages where it can never change should
-          also set TREE_STATIC.  */
-       RTX_UNCHANGING_P (temp) = TREE_READONLY (exp) & TREE_STATIC (exp);
-
        /* If we are writing to this object and its type is a record with
           readonly fields, we must mark it as readonly so it will
           conflict with readonly references to those fields.  */
index 43335fa2ba6a422096e8ea5ad1e58eea22e4067f..e3067fb261104db0c9e775ecabcc59cb5e228924 100644 (file)
@@ -39,6 +39,9 @@ Boston, MA 02111-1307, USA.  */
 #ifndef LANG_HOOKS_POST_OPTIONS
 #define LANG_HOOKS_POST_OPTIONS NULL
 #endif
+#ifndef LANG_HOOKS_HONOR_READONLY
+#define LANG_HOOKS_HONOR_READONLY 0
+#endif
 
 /* Declarations of default tree inlining hooks.  */
 tree tree_inlining_default_hook_walk_subtrees PARAMS ((tree*, int *,
@@ -108,6 +111,7 @@ int tree_inlining_default_hook_anon_aggr_type_p PARAMS ((tree));
   LANG_HOOKS_INIT_OPTIONS, \
   LANG_HOOKS_DECODE_OPTION, \
   LANG_HOOKS_POST_OPTIONS, \
+  LANG_HOOKS_HONOR_READONLY, \
   LANG_HOOKS_TREE_INLINING_INITIALIZER \
 }
 
index 72fa2fd640aba41e4190cbc5cdc64fa1e4a1ca14..c9b60ee2c3ed97d9df30f54fb2212b930c944cc1 100644 (file)
@@ -166,6 +166,9 @@ struct lang_hooks
   /* Called when all command line options have been processed.  */
   void (*post_options) PARAMS ((void));
 
+  /* Nonzero if TYPE_READONLY and TREE_READONLY should always be honored.  */
+  int honor_readonly;
+
   struct lang_hooks_for_tree_inlining tree_inlining;
 
   /* Whenever you add entries here, make sure you adjust langhooks.h