From 71c00b5c9996d96beed71c4998df027363b19091 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 1 Sep 2009 08:41:53 +0000 Subject: [PATCH] tree.c (tree_expr_size): New function. 2009-09-01 Richard Guenther * 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 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/builtins.c | 4 ++-- gcc/cp/ChangeLog | 5 +++++ gcc/cp/cp-objcp-common.c | 2 +- gcc/cp/cp-objcp-common.h | 2 -- gcc/explow.c | 4 ++-- gcc/langhooks-def.h | 3 --- gcc/langhooks.c | 13 ------------- gcc/langhooks.h | 6 ------ gcc/rtlanal.c | 2 +- gcc/tree.c | 12 ++++++++++++ gcc/tree.h | 1 + 12 files changed, 38 insertions(+), 30 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b1577c55c7..dc65f0effbf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2009-09-01 Richard Guenther + + * 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 * tree-flow.h (mark_addressable): Move declaration ... diff --git a/gcc/builtins.c b/gcc/builtins.c index ed97d485167..7ea899d19ba 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 19c17be7da5..b391672b904 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2009-09-01 Richard Guenther + + * 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 * cp-objcp-common.h (LANG_HOOKS_MARK_ADDRESSABLE): Remove. diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 2363cd7abdb..32e5530f243 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -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. */ diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index fe8a04721f3..19fce29d0b9 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -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 diff --git a/gcc/explow.c b/gcc/explow.c index 933eac81bb1..3073ff0eb91 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -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); } diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index afbab6fd4ed..aebab55ad12 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -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, \ diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 194993f7ab3..7d2c0b08a01 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -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 diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 4a590dea504..cf3bda05606 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -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 diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index aebcfa66904..27a46d9e73d 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -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)) diff --git a/gcc/tree.c b/gcc/tree.c index 60416d342c7..66ac70288b3 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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)); +} /* Return the bit position of FIELD, in bits from the start of the record. This is a tree of type bitsizetype. */ diff --git a/gcc/tree.h b/gcc/tree.h index 441612afc71..110beb10099 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -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);