Commit defc6f26 by Richard Sandiford Committed by Richard Sandiford

Handle variable-length vectors in compute_record_mode

This patch makes compute_record_mode handle SVE vectors in the
same way as it would handle fixed-length vectors.  There should
be no change in behaviour for other targets.

This is needed for the SVE equivalent of arm_neon.h types like
int8x8x2_t (i.e. a pair of int8x8_ts).

2019-09-18  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* stor-layout.c (compute_record_mode): Operate on poly_uint64
	sizes instead of uhwi sizes.

From-SVN: r275869
parent ef20d221
2019-09-18 Richard Sandiford <richard.sandiford@arm.com> 2019-09-18 Richard Sandiford <richard.sandiford@arm.com>
* stor-layout.c (compute_record_mode): Operate on poly_uint64
sizes instead of uhwi sizes.
2019-09-18 Richard Sandiford <richard.sandiford@arm.com>
* dwarf2out.c (loc_list_from_tree_1): Handle POLY_INT_CST. * dwarf2out.c (loc_list_from_tree_1): Handle POLY_INT_CST.
(add_const_value_attribute): Handle CONST_POLY_INT. (add_const_value_attribute): Handle CONST_POLY_INT.
......
...@@ -1811,7 +1811,8 @@ compute_record_mode (tree type) ...@@ -1811,7 +1811,8 @@ compute_record_mode (tree type)
line. */ line. */
SET_TYPE_MODE (type, BLKmode); SET_TYPE_MODE (type, BLKmode);
if (! tree_fits_uhwi_p (TYPE_SIZE (type))) poly_uint64 type_size;
if (!poly_int_tree_p (TYPE_SIZE (type), &type_size))
return; return;
/* A record which has any BLKmode members must itself be /* A record which has any BLKmode members must itself be
...@@ -1822,20 +1823,21 @@ compute_record_mode (tree type) ...@@ -1822,20 +1823,21 @@ compute_record_mode (tree type)
if (TREE_CODE (field) != FIELD_DECL) if (TREE_CODE (field) != FIELD_DECL)
continue; continue;
poly_uint64 field_size;
if (TREE_CODE (TREE_TYPE (field)) == ERROR_MARK if (TREE_CODE (TREE_TYPE (field)) == ERROR_MARK
|| (TYPE_MODE (TREE_TYPE (field)) == BLKmode || (TYPE_MODE (TREE_TYPE (field)) == BLKmode
&& ! TYPE_NO_FORCE_BLK (TREE_TYPE (field)) && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field))
&& !(TYPE_SIZE (TREE_TYPE (field)) != 0 && !(TYPE_SIZE (TREE_TYPE (field)) != 0
&& integer_zerop (TYPE_SIZE (TREE_TYPE (field))))) && integer_zerop (TYPE_SIZE (TREE_TYPE (field)))))
|| ! tree_fits_uhwi_p (bit_position (field)) || !tree_fits_poly_uint64_p (bit_position (field))
|| DECL_SIZE (field) == 0 || DECL_SIZE (field) == 0
|| ! tree_fits_uhwi_p (DECL_SIZE (field))) || !poly_int_tree_p (DECL_SIZE (field), &field_size))
return; return;
/* If this field is the whole struct, remember its mode so /* If this field is the whole struct, remember its mode so
that, say, we can put a double in a class into a DF that, say, we can put a double in a class into a DF
register instead of forcing it to live in the stack. */ register instead of forcing it to live in the stack. */
if (simple_cst_equal (TYPE_SIZE (type), DECL_SIZE (field)) if (known_eq (field_size, type_size)
/* Partial int types (e.g. __int20) may have TYPE_SIZE equal to /* Partial int types (e.g. __int20) may have TYPE_SIZE equal to
wider types (e.g. int32), despite precision being less. Ensure wider types (e.g. int32), despite precision being less. Ensure
that the TYPE_MODE of the struct does not get set to the partial that the TYPE_MODE of the struct does not get set to the partial
...@@ -1855,7 +1857,6 @@ compute_record_mode (tree type) ...@@ -1855,7 +1857,6 @@ compute_record_mode (tree type)
For UNION_TYPE, if the widest field is MODE_INT then use that mode. For UNION_TYPE, if the widest field is MODE_INT then use that mode.
If the widest field is MODE_PARTIAL_INT, and the union will be passed If the widest field is MODE_PARTIAL_INT, and the union will be passed
by reference, then use that mode. */ by reference, then use that mode. */
poly_uint64 type_size;
if ((TREE_CODE (type) == RECORD_TYPE if ((TREE_CODE (type) == RECORD_TYPE
|| (TREE_CODE (type) == UNION_TYPE || (TREE_CODE (type) == UNION_TYPE
&& (GET_MODE_CLASS (mode) == MODE_INT && (GET_MODE_CLASS (mode) == MODE_INT
...@@ -1864,7 +1865,6 @@ compute_record_mode (tree type) ...@@ -1864,7 +1865,6 @@ compute_record_mode (tree type)
(pack_cumulative_args (0), (pack_cumulative_args (0),
function_arg_info (type, mode, /*named=*/false))))))) function_arg_info (type, mode, /*named=*/false)))))))
&& mode != VOIDmode && mode != VOIDmode
&& poly_int_tree_p (TYPE_SIZE (type), &type_size)
&& known_eq (GET_MODE_BITSIZE (mode), type_size)) && known_eq (GET_MODE_BITSIZE (mode), type_size))
; ;
else else
......
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