Commit 71c00b5c by Richard Guenther Committed by Richard Biener

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
parent 58f986ca
2009-09-01 Richard Guenther <rguenther@suse.de> 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 ... * tree-flow.h (mark_addressable): Move declaration ...
* tree.h (mark_addressable): ... here. * tree.h (mark_addressable): ... here.
* stmt.c (expand_asm_operands): Use mark_addressable, not * stmt.c (expand_asm_operands): Use mark_addressable, not
......
...@@ -9092,7 +9092,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, ...@@ -9092,7 +9092,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src,
srcvar = build_fold_indirect_ref_loc (loc, src); srcvar = build_fold_indirect_ref_loc (loc, src);
if (TREE_THIS_VOLATILE (srcvar)) if (TREE_THIS_VOLATILE (srcvar))
return NULL_TREE; 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; srcvar = NULL_TREE;
/* With memcpy, it is possible to bypass aliasing rules, so without /* With memcpy, it is possible to bypass aliasing rules, so without
this check i.e. execute/20060930-2.c would be misoptimized, 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, ...@@ -9110,7 +9110,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src,
destvar = build_fold_indirect_ref_loc (loc, dest); destvar = build_fold_indirect_ref_loc (loc, dest);
if (TREE_THIS_VOLATILE (destvar)) if (TREE_THIS_VOLATILE (destvar))
return NULL_TREE; 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; destvar = NULL_TREE;
else if (!var_decl_component_p (destvar)) else if (!var_decl_component_p (destvar))
destvar = NULL_TREE; destvar = NULL_TREE;
......
2009-09-01 Richard Guenther <rguenther@suse.de> 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. * cp-objcp-common.h (LANG_HOOKS_MARK_ADDRESSABLE): Remove.
2009-08-31 Dodji Seketeli <dodji@redhat.com> 2009-08-31 Dodji Seketeli <dodji@redhat.com>
......
...@@ -109,7 +109,7 @@ cp_expr_size (const_tree exp) ...@@ -109,7 +109,7 @@ cp_expr_size (const_tree exp)
} }
else else
/* Use the default code. */ /* 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. */ /* Langhook for tree_size: determine size of our 'x' and 'c' nodes. */
......
...@@ -99,8 +99,6 @@ extern bool cp_function_decl_explicit_p (tree decl); ...@@ -99,8 +99,6 @@ extern bool cp_function_decl_explicit_p (tree decl);
#define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN cp_dump_tree #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN cp_dump_tree
#undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN #undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
#define LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN cp_type_quals #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 #undef LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR
#define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr #define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr
......
...@@ -246,7 +246,7 @@ expr_size (tree exp) ...@@ -246,7 +246,7 @@ expr_size (tree exp)
size = TREE_OPERAND (exp, 1); size = TREE_OPERAND (exp, 1);
else else
{ {
size = lang_hooks.expr_size (exp); size = tree_expr_size (exp);
gcc_assert (size); gcc_assert (size);
gcc_assert (size == SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, exp)); gcc_assert (size == SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, exp));
} }
...@@ -266,7 +266,7 @@ int_expr_size (tree exp) ...@@ -266,7 +266,7 @@ int_expr_size (tree exp)
size = TREE_OPERAND (exp, 1); size = TREE_OPERAND (exp, 1);
else else
{ {
size = lang_hooks.expr_size (exp); size = tree_expr_size (exp);
gcc_assert (size); gcc_assert (size);
} }
......
...@@ -58,7 +58,6 @@ extern void lhd_incomplete_type_error (const_tree, const_tree); ...@@ -58,7 +58,6 @@ extern void lhd_incomplete_type_error (const_tree, const_tree);
extern tree lhd_type_promotes_to (tree); extern tree lhd_type_promotes_to (tree);
extern void lhd_register_builtin_type (tree, const char *); extern void lhd_register_builtin_type (tree, const char *);
extern bool lhd_decl_ok_for_sibcall (const_tree); 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 size_t lhd_tree_size (enum tree_code);
extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT); extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT);
extern tree lhd_expr_to_decl (tree, bool *, bool *); extern tree lhd_expr_to_decl (tree, bool *, bool *);
...@@ -100,7 +99,6 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, ...@@ -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_PRINT_ERROR_FUNCTION lhd_print_error_function
#define LANG_HOOKS_DECL_PRINTABLE_NAME lhd_decl_printable_name #define LANG_HOOKS_DECL_PRINTABLE_NAME lhd_decl_printable_name
#define LANG_HOOKS_DWARF_NAME lhd_dwarf_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_TREE_SIZE lhd_tree_size
#define LANG_HOOKS_TYPES_COMPATIBLE_P lhd_types_compatible_p #define LANG_HOOKS_TYPES_COMPATIBLE_P lhd_types_compatible_p
#define LANG_HOOKS_BUILTIN_FUNCTION lhd_builtin_function #define LANG_HOOKS_BUILTIN_FUNCTION lhd_builtin_function
...@@ -254,7 +252,6 @@ extern tree lhd_make_node (enum tree_code); ...@@ -254,7 +252,6 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_DWARF_NAME, \ LANG_HOOKS_DWARF_NAME, \
LANG_HOOKS_TYPES_COMPATIBLE_P, \ LANG_HOOKS_TYPES_COMPATIBLE_P, \
LANG_HOOKS_PRINT_ERROR_FUNCTION, \ LANG_HOOKS_PRINT_ERROR_FUNCTION, \
LANG_HOOKS_EXPR_SIZE, \
LANG_HOOKS_TO_TARGET_CHARSET, \ LANG_HOOKS_TO_TARGET_CHARSET, \
LANG_HOOKS_ATTRIBUTE_TABLE, \ LANG_HOOKS_ATTRIBUTE_TABLE, \
LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, \ LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, \
......
...@@ -260,19 +260,6 @@ lhd_tree_dump_type_quals (const_tree t) ...@@ -260,19 +260,6 @@ lhd_tree_dump_type_quals (const_tree t)
return TYPE_QUALS (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. */ /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form. */
int int
......
...@@ -348,12 +348,6 @@ struct lang_hooks ...@@ -348,12 +348,6 @@ struct lang_hooks
void (*print_error_function) (struct diagnostic_context *, const char *, void (*print_error_function) (struct diagnostic_context *, const char *,
struct diagnostic_info *); 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 /* Convert a character from the host's to the target's character
set. The character should be in what C calls the "basic source set. The character should be in what C calls the "basic source
character set" (roughly, the set of characters defined by plain character set" (roughly, the set of characters defined by plain
......
...@@ -293,7 +293,7 @@ rtx_addr_can_trap_p_1 (const_rtx x, HOST_WIDE_INT offset, HOST_WIDE_INT size, ...@@ -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); decl = SYMBOL_REF_DECL (x);
/* Else check that the access is in bounds. TODO: restructure /* 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) if (!decl)
decl_size = -1; decl_size = -1;
else if (DECL_P (decl) && DECL_SIZE_UNIT (decl)) else if (DECL_P (decl) && DECL_SIZE_UNIT (decl))
......
...@@ -2194,6 +2194,18 @@ max_int_size_in_bytes (const_tree type) ...@@ -2194,6 +2194,18 @@ max_int_size_in_bytes (const_tree type)
return size; 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. /* Return the bit position of FIELD, in bits from the start of the record.
This is a tree of type bitsizetype. */ This is a tree of type bitsizetype. */
......
...@@ -4180,6 +4180,7 @@ extern tree expr_last (tree); ...@@ -4180,6 +4180,7 @@ extern tree expr_last (tree);
extern tree size_in_bytes (const_tree); extern tree size_in_bytes (const_tree);
extern HOST_WIDE_INT int_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 HOST_WIDE_INT max_int_size_in_bytes (const_tree);
extern tree tree_expr_size (const_tree);
extern tree bit_position (const_tree); extern tree bit_position (const_tree);
extern HOST_WIDE_INT int_bit_position (const_tree); extern HOST_WIDE_INT int_bit_position (const_tree);
extern tree byte_position (const_tree); extern tree byte_position (const_tree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment