tree.c (tree_expr_size): New function.

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
This commit is contained in:
Richard Guenther 2009-09-01 08:41:53 +00:00 committed by Richard Biener
parent 58f986ca91
commit 71c00b5c99
12 changed files with 38 additions and 30 deletions

View 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 ...

View 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;

View 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.

View 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. */

View 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

View 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);
}

View 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, \

View 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

View 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

View 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))

View 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));
}
/* Return the bit position of FIELD, in bits from the start of the record.
This is a tree of type bitsizetype. */

View 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);