aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-12-21 07:01:38 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-12-21 07:01:38 +0000
commite7301f5fcbfa649beb05da1e3508db7fc7c4d26b (patch)
tree78865bf62d706915d434176a2fbc7d8632a24802 /gcc/tree-cfg.c
parentf8f667be749428f92a33d6c4ff8b56538f958c10 (diff)
downloadgcc-e7301f5fcbfa649beb05da1e3508db7fc7c4d26b.zip
gcc-e7301f5fcbfa649beb05da1e3508db7fc7c4d26b.tar.gz
gcc-e7301f5fcbfa649beb05da1e3508db7fc7c4d26b.tar.bz2
poly_int: bit_field_size/offset
verify_expr ensured that the size and offset in gimple BIT_FIELD_REFs satisfied tree_fits_uhwi_p. This patch extends that so that they can be poly_uint64s, and adds helper routines for accessing them when the verify_expr requirements apply. 2017-12-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (bit_field_size, bit_field_offset): New functions. * hsa-gen.c (gen_hsa_addr): Use them. * tree-ssa-forwprop.c (simplify_bitfield_ref): Likewise. (simplify_vector_constructor): Likewise. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise. * tree-cfg.c (verify_expr): Require the sizes and offsets of a BIT_FIELD_REF to be poly_uint64s rather than uhwis. * fold-const.c (fold_ternary_loc): Protect tree_to_uhwi with tree_fits_uhwi_p. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255926
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index ae5335b..bed4947 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -3170,8 +3170,9 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
tree t0 = TREE_OPERAND (t, 0);
tree t1 = TREE_OPERAND (t, 1);
tree t2 = TREE_OPERAND (t, 2);
- if (!tree_fits_uhwi_p (t1)
- || !tree_fits_uhwi_p (t2)
+ poly_uint64 size, bitpos;
+ if (!poly_int_tree_p (t1, &size)
+ || !poly_int_tree_p (t2, &bitpos)
|| !types_compatible_p (bitsizetype, TREE_TYPE (t1))
|| !types_compatible_p (bitsizetype, TREE_TYPE (t2)))
{
@@ -3179,8 +3180,7 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
return t;
}
if (INTEGRAL_TYPE_P (TREE_TYPE (t))
- && (TYPE_PRECISION (TREE_TYPE (t))
- != tree_to_uhwi (t1)))
+ && maybe_ne (TYPE_PRECISION (TREE_TYPE (t)), size))
{
error ("integral result type precision does not match "
"field size of BIT_FIELD_REF");
@@ -3188,16 +3188,16 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
}
else if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
&& TYPE_MODE (TREE_TYPE (t)) != BLKmode
- && (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (t)))
- != tree_to_uhwi (t1)))
+ && maybe_ne (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (t))),
+ size))
{
error ("mode size of non-integral result does not "
"match field size of BIT_FIELD_REF");
return t;
}
if (!AGGREGATE_TYPE_P (TREE_TYPE (t0))
- && (tree_to_uhwi (t1) + tree_to_uhwi (t2)
- > tree_to_uhwi (TYPE_SIZE (TREE_TYPE (t0)))))
+ && maybe_gt (size + bitpos,
+ tree_to_poly_uint64 (TYPE_SIZE (TREE_TYPE (t0)))))
{
error ("position plus size exceeds size of referenced object in "
"BIT_FIELD_REF");