Commit 1079d2c1 by Richard Sandiford Committed by Richard Sandiford

poly_int: decode_addr_const

This patch makes the varasm-local addr_const track polynomial offsets.
I'm not sure how useful this is, but it was easier to convert than not.

2017-12-21  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* varasm.c (addr_const::offset): Change from HOST_WIDE_INT
	to poly_int64.
	(decode_addr_const): Update accordingly.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r255927
parent e7301f5f
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* varasm.c (addr_const::offset): Change from HOST_WIDE_INT
to poly_int64.
(decode_addr_const): Update accordingly.
2017-12-21 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* tree.h (bit_field_size, bit_field_offset): New functions. * tree.h (bit_field_size, bit_field_offset): New functions.
* hsa-gen.c (gen_hsa_addr): Use them. * hsa-gen.c (gen_hsa_addr): Use them.
* tree-ssa-forwprop.c (simplify_bitfield_ref): Likewise. * tree-ssa-forwprop.c (simplify_bitfield_ref): Likewise.
...@@ -2872,30 +2872,33 @@ assemble_real (REAL_VALUE_TYPE d, scalar_float_mode mode, unsigned int align, ...@@ -2872,30 +2872,33 @@ assemble_real (REAL_VALUE_TYPE d, scalar_float_mode mode, unsigned int align,
struct addr_const { struct addr_const {
rtx base; rtx base;
HOST_WIDE_INT offset; poly_int64 offset;
}; };
static void static void
decode_addr_const (tree exp, struct addr_const *value) decode_addr_const (tree exp, struct addr_const *value)
{ {
tree target = TREE_OPERAND (exp, 0); tree target = TREE_OPERAND (exp, 0);
HOST_WIDE_INT offset = 0; poly_int64 offset = 0;
rtx x; rtx x;
while (1) while (1)
{ {
poly_int64 bytepos;
if (TREE_CODE (target) == COMPONENT_REF if (TREE_CODE (target) == COMPONENT_REF
&& tree_fits_shwi_p (byte_position (TREE_OPERAND (target, 1)))) && poly_int_tree_p (byte_position (TREE_OPERAND (target, 1)),
&bytepos))
{ {
offset += int_byte_position (TREE_OPERAND (target, 1)); offset += bytepos;
target = TREE_OPERAND (target, 0); target = TREE_OPERAND (target, 0);
} }
else if (TREE_CODE (target) == ARRAY_REF else if (TREE_CODE (target) == ARRAY_REF
|| TREE_CODE (target) == ARRAY_RANGE_REF) || TREE_CODE (target) == ARRAY_RANGE_REF)
{ {
/* Truncate big offset. */ /* Truncate big offset. */
offset += (TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (target))) offset
* TREE_INT_CST_LOW (TREE_OPERAND (target, 1))); += (TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (target)))
* wi::to_poly_widest (TREE_OPERAND (target, 1)).force_shwi ());
target = TREE_OPERAND (target, 0); target = TREE_OPERAND (target, 0);
} }
else if (TREE_CODE (target) == MEM_REF else if (TREE_CODE (target) == MEM_REF
...@@ -3040,14 +3043,14 @@ const_hash_1 (const tree exp) ...@@ -3040,14 +3043,14 @@ const_hash_1 (const tree exp)
case SYMBOL_REF: case SYMBOL_REF:
/* Don't hash the address of the SYMBOL_REF; /* Don't hash the address of the SYMBOL_REF;
only use the offset and the symbol name. */ only use the offset and the symbol name. */
hi = value.offset; hi = value.offset.coeffs[0];
p = XSTR (value.base, 0); p = XSTR (value.base, 0);
for (i = 0; p[i] != 0; i++) for (i = 0; p[i] != 0; i++)
hi = ((hi * 613) + (unsigned) (p[i])); hi = ((hi * 613) + (unsigned) (p[i]));
break; break;
case LABEL_REF: case LABEL_REF:
hi = (value.offset hi = (value.offset.coeffs[0]
+ CODE_LABEL_NUMBER (label_ref_label (value.base)) * 13); + CODE_LABEL_NUMBER (label_ref_label (value.base)) * 13);
break; break;
...@@ -3233,7 +3236,7 @@ compare_constant (const tree t1, const tree t2) ...@@ -3233,7 +3236,7 @@ compare_constant (const tree t1, const tree t2)
decode_addr_const (t1, &value1); decode_addr_const (t1, &value1);
decode_addr_const (t2, &value2); decode_addr_const (t2, &value2);
if (value1.offset != value2.offset) if (maybe_ne (value1.offset, value2.offset))
return 0; return 0;
code = GET_CODE (value1.base); code = GET_CODE (value1.base);
......
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