tree.c (tree_expr_size): New function.
authorRichard Guenther <rguenther@suse.de>
Tue, 1 Sep 2009 08:41:53 +0000 (08:41 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 1 Sep 2009 08:41:53 +0000 (08:41 +0000)
2009-09-01  Richard Guenther  <rguenther@suse.de>

* tree.c (tree_expr_size): New function.
* tree.h (tree_expr_size): Declare.
* rtlanal.c (rtx_addr_can_trap_p_1): Adjust comment.
* builtins.c (fold_builtin_memory_op): Use tree_expr_size.
* langhooks.c (lhd_expr_size): Remove.
* langhooks.h (struct lang_hooks): Remove expr_size.
* explow.c (expr_size): Use tree_expr_size.
(int_expr_size): Likewise.
* langhooks-def.h (lhd_expr_size): Remove.
(LANG_HOOKS_EXPR_SIZE): Likewise.
(LANG_HOOKS_INITIALIZER): Adjust.

cp/
* cp-objcp-common.c (cp_expr_size): Use tree_expr_size.
* cp-objcp-common.h (LANG_HOOKS_EXPR_SIZE): Do not define.

From-SVN: r151261

12 files changed:
gcc/ChangeLog
gcc/builtins.c
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/cp/cp-objcp-common.h
gcc/explow.c
gcc/langhooks-def.h
gcc/langhooks.c
gcc/langhooks.h
gcc/rtlanal.c
gcc/tree.c
gcc/tree.h

index 9b1577c55c75aaa5695de93a958d68755be233b8..dc65f0effbf7516c2b8c4b77d543e3d931baf749 100644 (file)
@@ -1,3 +1,17 @@
+2009-09-01  Richard Guenther  <rguenther@suse.de>
+
+       * tree.c (tree_expr_size): New function.
+       * tree.h (tree_expr_size): Declare.
+       * rtlanal.c (rtx_addr_can_trap_p_1): Adjust comment.
+       * builtins.c (fold_builtin_memory_op): Use tree_expr_size.
+       * langhooks.c (lhd_expr_size): Remove.
+       * langhooks.h (struct lang_hooks): Remove expr_size.
+       * explow.c (expr_size): Use tree_expr_size.
+       (int_expr_size): Likewise.
+       * langhooks-def.h (lhd_expr_size): Remove.
+       (LANG_HOOKS_EXPR_SIZE): Likewise.
+       (LANG_HOOKS_INITIALIZER): Adjust.
+
 2009-09-01  Richard Guenther  <rguenther@suse.de>
 
        * tree-flow.h (mark_addressable): Move declaration ...
index ed97d485167c60a43e9c4ddc95475bd3733f4d06..7ea899d19bacaa5727ea9456e1d406f2300446d0 100644 (file)
@@ -9092,7 +9092,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src,
          srcvar = build_fold_indirect_ref_loc (loc, src);
          if (TREE_THIS_VOLATILE (srcvar))
            return NULL_TREE;
-         else if (!tree_int_cst_equal (lang_hooks.expr_size (srcvar), len))
+         else if (!tree_int_cst_equal (tree_expr_size (srcvar), len))
            srcvar = NULL_TREE;
          /* With memcpy, it is possible to bypass aliasing rules, so without
             this check i.e. execute/20060930-2.c would be misoptimized,
@@ -9110,7 +9110,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src,
          destvar = build_fold_indirect_ref_loc (loc, dest);
          if (TREE_THIS_VOLATILE (destvar))
            return NULL_TREE;
-         else if (!tree_int_cst_equal (lang_hooks.expr_size (destvar), len))
+         else if (!tree_int_cst_equal (tree_expr_size (destvar), len))
            destvar = NULL_TREE;
          else if (!var_decl_component_p (destvar))
            destvar = NULL_TREE;
index 19c17be7da5377195987e0c28dd388dd792b8cb6..b391672b904888dd09f2a5cf97d1161e46f06b73 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-01  Richard Guenther  <rguenther@suse.de>
+
+       * cp-objcp-common.c (cp_expr_size): Use tree_expr_size.
+       * cp-objcp-common.h (LANG_HOOKS_EXPR_SIZE): Do not define.
+
 2009-09-01  Richard Guenther  <rguenther@suse.de>
 
        * cp-objcp-common.h (LANG_HOOKS_MARK_ADDRESSABLE): Remove.
index 2363cd7abdbe747a85abd0b69d7b4b894d7b68a2..32e5530f24352c68a45a462439b2078a13e3bd8a 100644 (file)
@@ -109,7 +109,7 @@ cp_expr_size (const_tree exp)
     }
   else
     /* Use the default code.  */
-    return lhd_expr_size (exp);
+    return tree_expr_size (exp);
 }
 
 /* Langhook for tree_size: determine size of our 'x' and 'c' nodes.  */
index fe8a04721f3ee9497a50b1ea07b5e0865301be98..19fce29d0b94425ecf12f9a37affdeeb0803db52 100644 (file)
@@ -99,8 +99,6 @@ extern bool cp_function_decl_explicit_p (tree decl);
 #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN cp_dump_tree
 #undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
 #define LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN cp_type_quals
-#undef LANG_HOOKS_EXPR_SIZE
-#define LANG_HOOKS_EXPR_SIZE cp_expr_size
 
 #undef LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR
 #define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr
index 933eac81bb143b7c356b702573de81038a671aa0..3073ff0eb918043ee112368795a93e224f1ae708 100644 (file)
@@ -246,7 +246,7 @@ expr_size (tree exp)
     size = TREE_OPERAND (exp, 1);
   else
     {
-      size = lang_hooks.expr_size (exp);
+      size = tree_expr_size (exp);
       gcc_assert (size);
       gcc_assert (size == SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, exp));
     }
@@ -266,7 +266,7 @@ int_expr_size (tree exp)
     size = TREE_OPERAND (exp, 1);
   else
     {
-      size = lang_hooks.expr_size (exp);
+      size = tree_expr_size (exp);
       gcc_assert (size);
     }
 
index afbab6fd4ed3141b6b8158d273f7770ccb26ba50..aebab55ad1246f7e7db68d6ae56709c6c8654f3f 100644 (file)
@@ -58,7 +58,6 @@ extern void lhd_incomplete_type_error (const_tree, const_tree);
 extern tree lhd_type_promotes_to (tree);
 extern void lhd_register_builtin_type (tree, const char *);
 extern bool lhd_decl_ok_for_sibcall (const_tree);
-extern tree lhd_expr_size (const_tree);
 extern size_t lhd_tree_size (enum tree_code);
 extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT);
 extern tree lhd_expr_to_decl (tree, bool *, bool *);
@@ -100,7 +99,6 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
 #define LANG_HOOKS_PRINT_ERROR_FUNCTION lhd_print_error_function
 #define LANG_HOOKS_DECL_PRINTABLE_NAME lhd_decl_printable_name
 #define LANG_HOOKS_DWARF_NAME          lhd_dwarf_name
-#define LANG_HOOKS_EXPR_SIZE           lhd_expr_size
 #define LANG_HOOKS_TREE_SIZE           lhd_tree_size
 #define LANG_HOOKS_TYPES_COMPATIBLE_P  lhd_types_compatible_p
 #define LANG_HOOKS_BUILTIN_FUNCTION    lhd_builtin_function
@@ -254,7 +252,6 @@ extern tree lhd_make_node (enum tree_code);
   LANG_HOOKS_DWARF_NAME, \
   LANG_HOOKS_TYPES_COMPATIBLE_P, \
   LANG_HOOKS_PRINT_ERROR_FUNCTION, \
-  LANG_HOOKS_EXPR_SIZE, \
   LANG_HOOKS_TO_TARGET_CHARSET, \
   LANG_HOOKS_ATTRIBUTE_TABLE, \
   LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, \
index 194993f7ab342aa440acecaff14386df32513cb2..7d2c0b08a010928717d3a472d29a4ce06588ce2d 100644 (file)
@@ -260,19 +260,6 @@ lhd_tree_dump_type_quals (const_tree t)
   return TYPE_QUALS (t);
 }
 
-/* lang_hooks.expr_size: Determine the size of the value of an expression T
-   in a language-specific way.  Returns a tree for the size in bytes.  */
-
-tree
-lhd_expr_size (const_tree exp)
-{
-  if (DECL_P (exp)
-      && DECL_SIZE_UNIT (exp) != 0)
-    return DECL_SIZE_UNIT (exp);
-  else
-    return size_in_bytes (TREE_TYPE (exp));
-}
-
 /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form.  */
 
 int
index 4a590dea5047a0a8ce5bd2679ee29e293ce10dc3..cf3bda05606623607c418d7380cf1be194f5bfe9 100644 (file)
@@ -348,12 +348,6 @@ struct lang_hooks
   void (*print_error_function) (struct diagnostic_context *, const char *,
                                struct diagnostic_info *);
 
-  /* Called from expr_size to calculate the size of the value of an
-     expression in a language-dependent way.  Returns a tree for the size
-     in bytes.  A frontend can call lhd_expr_size to get the default
-     semantics in cases that it doesn't want to handle specially.  */
-  tree (*expr_size) (const_tree);
-
   /* Convert a character from the host's to the target's character
      set.  The character should be in what C calls the "basic source
      character set" (roughly, the set of characters defined by plain
index aebcfa66904266e9ebab7f2ed882ca1cbd38bd98..27a46d9e73d58b0388cd6a3bce8ab90d838f8336 100644 (file)
@@ -293,7 +293,7 @@ rtx_addr_can_trap_p_1 (const_rtx x, HOST_WIDE_INT offset, HOST_WIDE_INT size,
          decl = SYMBOL_REF_DECL (x);
 
          /* Else check that the access is in bounds.  TODO: restructure
-            expr_size/lhd_expr_size/int_expr_size and just use the latter.  */
+            expr_size/tree_expr_size/int_expr_size and just use the latter.  */
          if (!decl)
            decl_size = -1;
          else if (DECL_P (decl) && DECL_SIZE_UNIT (decl))
index 60416d342c7b33632db1f9ad0ba846112917e21f..66ac70288b3334ceec5d5063eaf6b8bcd843d299 100644 (file)
@@ -2194,6 +2194,18 @@ max_int_size_in_bytes (const_tree type)
 
   return size;
 }
+
+/* Returns a tree for the size of EXP in bytes.  */
+
+tree
+tree_expr_size (const_tree exp)
+{
+  if (DECL_P (exp)
+      && DECL_SIZE_UNIT (exp) != 0)
+    return DECL_SIZE_UNIT (exp);
+  else
+    return size_in_bytes (TREE_TYPE (exp));
+}
 \f
 /* Return the bit position of FIELD, in bits from the start of the record.
    This is a tree of type bitsizetype.  */
index 441612afc71424295328ff65e241d89157debd1b..110beb100993713b4037753036a6d6d67b452047 100644 (file)
@@ -4180,6 +4180,7 @@ extern tree expr_last (tree);
 extern tree size_in_bytes (const_tree);
 extern HOST_WIDE_INT int_size_in_bytes (const_tree);
 extern HOST_WIDE_INT max_int_size_in_bytes (const_tree);
+extern tree tree_expr_size (const_tree);
 extern tree bit_position (const_tree);
 extern HOST_WIDE_INT int_bit_position (const_tree);
 extern tree byte_position (const_tree);