Commit 370f4759 by Richard Guenther Committed by Richard Biener

tree.h (ptrofftype_p): New helper function.

2011-08-16  Richard Guenther  <rguenther@suse.de>

	* tree.h (ptrofftype_p): New helper function.
	* tree-cfg.c (verify_expr): Use ptrofftype_p for POINTER_PLUS_EXPR
	offset verification.
	(verify_gimple_assign_binary): Likewise.
	* tree.c (build2_stat): Likewise.
	* tree-chrec.c (chrec_fold_plus_poly_poly): Likewise.
	(reset_evolution_in_loop): Likewise.
	* tree-chrec.h (build_polynomial_chrec): Likewise.

From-SVN: r177784
parent c5058418
2011-08-16 Richard Guenther <rguenther@suse.de>
* tree.h (ptrofftype_p): New helper function.
* tree-cfg.c (verify_expr): Use ptrofftype_p for POINTER_PLUS_EXPR
offset verification.
(verify_gimple_assign_binary): Likewise.
* tree.c (build2_stat): Likewise.
* tree-chrec.c (chrec_fold_plus_poly_poly): Likewise.
(reset_evolution_in_loop): Likewise.
* tree-chrec.h (build_polynomial_chrec): Likewise.
2011-08-16 Liang Wang <lwang1@marvell.com> 2011-08-16 Liang Wang <lwang1@marvell.com>
* ggc.h (ggc_alloc_rtvec_sized): Change arguments of * ggc.h (ggc_alloc_rtvec_sized): Change arguments of
......
...@@ -2772,13 +2772,11 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) ...@@ -2772,13 +2772,11 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
error ("invalid operand to pointer plus, first operand is not a pointer"); error ("invalid operand to pointer plus, first operand is not a pointer");
return t; return t;
} }
/* Check to make sure the second operand is an integer with type of /* Check to make sure the second operand is a ptrofftype. */
sizetype. */ if (!ptrofftype_p (TREE_TYPE (TREE_OPERAND (t, 1))))
if (!useless_type_conversion_p (sizetype,
TREE_TYPE (TREE_OPERAND (t, 1))))
{ {
error ("invalid operand to pointer plus, second operand is not an " error ("invalid operand to pointer plus, second operand is not an "
"integer with type of sizetype"); "integer type of appropriate width");
return t; return t;
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
...@@ -3525,7 +3523,7 @@ verify_gimple_assign_binary (gimple stmt) ...@@ -3525,7 +3523,7 @@ verify_gimple_assign_binary (gimple stmt)
do_pointer_plus_expr_check: do_pointer_plus_expr_check:
if (!POINTER_TYPE_P (rhs1_type) if (!POINTER_TYPE_P (rhs1_type)
|| !useless_type_conversion_p (lhs_type, rhs1_type) || !useless_type_conversion_p (lhs_type, rhs1_type)
|| !useless_type_conversion_p (sizetype, rhs2_type)) || !ptrofftype_p (rhs2_type))
{ {
error ("type mismatch in pointer plus expression"); error ("type mismatch in pointer plus expression");
debug_generic_stmt (lhs_type); debug_generic_stmt (lhs_type);
......
...@@ -95,14 +95,14 @@ chrec_fold_plus_poly_poly (enum tree_code code, ...@@ -95,14 +95,14 @@ chrec_fold_plus_poly_poly (enum tree_code code,
tree left, right; tree left, right;
struct loop *loop0 = get_chrec_loop (poly0); struct loop *loop0 = get_chrec_loop (poly0);
struct loop *loop1 = get_chrec_loop (poly1); struct loop *loop1 = get_chrec_loop (poly1);
tree rtype = code == POINTER_PLUS_EXPR ? sizetype : type; tree rtype = code == POINTER_PLUS_EXPR ? chrec_type (poly1) : type;
gcc_assert (poly0); gcc_assert (poly0);
gcc_assert (poly1); gcc_assert (poly1);
gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC); gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC); gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC);
if (POINTER_TYPE_P (chrec_type (poly0))) if (POINTER_TYPE_P (chrec_type (poly0)))
gcc_assert (chrec_type (poly1) == sizetype); gcc_assert (ptrofftype_p (chrec_type (poly1)));
else else
gcc_assert (chrec_type (poly0) == chrec_type (poly1)); gcc_assert (chrec_type (poly0) == chrec_type (poly1));
gcc_assert (type == chrec_type (poly0)); gcc_assert (type == chrec_type (poly0));
...@@ -831,7 +831,7 @@ reset_evolution_in_loop (unsigned loop_num, ...@@ -831,7 +831,7 @@ reset_evolution_in_loop (unsigned loop_num,
struct loop *loop = get_loop (loop_num); struct loop *loop = get_loop (loop_num);
if (POINTER_TYPE_P (chrec_type (chrec))) if (POINTER_TYPE_P (chrec_type (chrec)))
gcc_assert (sizetype == chrec_type (new_evol)); gcc_assert (ptrofftype_p (chrec_type (new_evol)));
else else
gcc_assert (chrec_type (chrec) == chrec_type (new_evol)); gcc_assert (chrec_type (chrec) == chrec_type (new_evol));
......
...@@ -145,7 +145,7 @@ build_polynomial_chrec (unsigned loop_num, ...@@ -145,7 +145,7 @@ build_polynomial_chrec (unsigned loop_num,
/* Types of left and right sides of a chrec should be compatible. */ /* Types of left and right sides of a chrec should be compatible. */
if (POINTER_TYPE_P (TREE_TYPE (left))) if (POINTER_TYPE_P (TREE_TYPE (left)))
gcc_assert (sizetype == TREE_TYPE (right)); gcc_assert (ptrofftype_p (TREE_TYPE (right)));
else else
gcc_assert (TREE_TYPE (left) == TREE_TYPE (right)); gcc_assert (TREE_TYPE (left) == TREE_TYPE (right));
......
...@@ -3784,8 +3784,7 @@ build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL) ...@@ -3784,8 +3784,7 @@ build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL)
if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt) if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt)
gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0)) gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0))
&& INTEGRAL_TYPE_P (TREE_TYPE (arg1)) && ptrofftype_p (TREE_TYPE (arg1)));
&& useless_type_conversion_p (sizetype, TREE_TYPE (arg1)));
t = make_node_stat (code PASS_MEM_STAT); t = make_node_stat (code PASS_MEM_STAT);
TREE_TYPE (t) = tt; TREE_TYPE (t) = tt;
......
...@@ -5313,6 +5313,16 @@ truth_value_p (enum tree_code code) ...@@ -5313,6 +5313,16 @@ truth_value_p (enum tree_code code)
|| code == TRUTH_XOR_EXPR || code == TRUTH_NOT_EXPR); || code == TRUTH_XOR_EXPR || code == TRUTH_NOT_EXPR);
} }
/* Return whether TYPE is a type suitable for an offset for
a POINTER_PLUS_EXPR. */
static inline bool
ptrofftype_p (tree type)
{
return (INTEGRAL_TYPE_P (type)
&& TYPE_PRECISION (type) == TYPE_PRECISION (sizetype)
&& TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype));
}
/* Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF. */ /* Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF. */
static inline tree static inline tree
fold_build_pointer_plus_loc (location_t loc, tree ptr, tree off) fold_build_pointer_plus_loc (location_t loc, tree ptr, tree off)
......
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