diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-08-30 11:14:49 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-08-30 11:14:49 +0000 |
commit | ae9270466ed530df375bcaf6b3d834dbef6e3965 (patch) | |
tree | ab6119ee9f8a12e6d5463797916b7995fad7bf4a /gcc/expmed.c | |
parent | 0ef40942d026e60b28d384b0fb2ff203bf1beca1 (diff) | |
download | gcc-ae9270466ed530df375bcaf6b3d834dbef6e3965.zip gcc-ae9270466ed530df375bcaf6b3d834dbef6e3965.tar.gz gcc-ae9270466ed530df375bcaf6b3d834dbef6e3965.tar.bz2 |
[39/77] Two changes to the get_best_mode interface
get_best_mode always returns a scalar_int_mode on success,
so this patch makes that explicit in the type system. Also,
the "largest_mode" argument is used simply to provide a maximum
size, and in practice that size is always a compile-time constant,
even when the concept of variable-sized modes is added later.
The patch therefore passes the size directly.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* machmode.h (bit_field_mode_iterator::next_mode): Take a pointer
to a scalar_int_mode instead of a machine_mode.
(bit_field_mode_iterator::m_mode): Change type to opt_scalar_int_mode.
(get_best_mode): Return a boolean and use a pointer argument to store
the selected mode. Replace the limit mode parameter with a bit limit.
* expmed.c (adjust_bit_field_mem_for_reg): Use scalar_int_mode
for the values returned by bit_field_mode_iterator::next_mode.
(store_bit_field): Update call to get_best_mode.
(store_fixed_bit_field): Likewise.
(extract_fixed_bit_field): Likewise.
* expr.c (optimize_bitfield_assignment_op): Likewise.
* fold-const.c (optimize_bit_field_compare): Likewise.
(fold_truth_andor_1): Likewise.
* stor-layout.c (bit_field_mode_iterator::next_mode): As above.
Update for new type of m_mode.
(get_best_mode): As above.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251491
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r-- | gcc/expmed.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c index 051e048..641bc24 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -461,7 +461,7 @@ adjust_bit_field_mem_for_reg (enum extraction_pattern pattern, bit_field_mode_iterator iter (bitsize, bitnum, bitregion_start, bitregion_end, MEM_ALIGN (op0), MEM_VOLATILE_P (op0)); - machine_mode best_mode; + scalar_int_mode best_mode; if (iter.next_mode (&best_mode)) { /* We can use a memory in BEST_MODE. See whether this is true for @@ -479,7 +479,7 @@ adjust_bit_field_mem_for_reg (enum extraction_pattern pattern, fieldmode)) limit_mode = insn.field_mode; - machine_mode wider_mode; + scalar_int_mode wider_mode; while (iter.next_mode (&wider_mode) && GET_MODE_SIZE (wider_mode) <= GET_MODE_SIZE (limit_mode)) best_mode = wider_mode; @@ -1095,7 +1095,8 @@ store_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, bit region. */ if (MEM_P (str_rtx) && bitregion_start > 0) { - machine_mode bestmode; + scalar_int_mode best_mode; + machine_mode addr_mode = VOIDmode; HOST_WIDE_INT offset, size; gcc_assert ((bitregion_start % BITS_PER_UNIT) == 0); @@ -1105,11 +1106,13 @@ store_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, size = (bitnum + bitsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT; bitregion_end -= bitregion_start; bitregion_start = 0; - bestmode = get_best_mode (bitsize, bitnum, - bitregion_start, bitregion_end, - MEM_ALIGN (str_rtx), VOIDmode, - MEM_VOLATILE_P (str_rtx)); - str_rtx = adjust_bitfield_address_size (str_rtx, bestmode, offset, size); + if (get_best_mode (bitsize, bitnum, + bitregion_start, bitregion_end, + MEM_ALIGN (str_rtx), INT_MAX, + MEM_VOLATILE_P (str_rtx), &best_mode)) + addr_mode = best_mode; + str_rtx = adjust_bitfield_address_size (str_rtx, addr_mode, + offset, size); } if (!store_bit_field_1 (str_rtx, bitsize, bitnum, @@ -1143,10 +1146,10 @@ store_fixed_bit_field (rtx op0, unsigned HOST_WIDE_INT bitsize, if (GET_MODE_BITSIZE (mode) == 0 || GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (word_mode)) mode = word_mode; - mode = get_best_mode (bitsize, bitnum, bitregion_start, bitregion_end, - MEM_ALIGN (op0), mode, MEM_VOLATILE_P (op0)); - - if (mode == VOIDmode) + scalar_int_mode best_mode; + if (!get_best_mode (bitsize, bitnum, bitregion_start, bitregion_end, + MEM_ALIGN (op0), GET_MODE_BITSIZE (mode), + MEM_VOLATILE_P (op0), &best_mode)) { /* The only way this should occur is if the field spans word boundaries. */ @@ -1155,7 +1158,7 @@ store_fixed_bit_field (rtx op0, unsigned HOST_WIDE_INT bitsize, return; } - op0 = narrow_bit_field_mem (op0, mode, bitsize, bitnum, &bitnum); + op0 = narrow_bit_field_mem (op0, best_mode, bitsize, bitnum, &bitnum); } store_fixed_bit_field_1 (op0, bitsize, bitnum, value, reverse); @@ -1998,11 +2001,9 @@ extract_fixed_bit_field (machine_mode tmode, rtx op0, { if (MEM_P (op0)) { - machine_mode mode - = get_best_mode (bitsize, bitnum, 0, 0, MEM_ALIGN (op0), word_mode, - MEM_VOLATILE_P (op0)); - - if (mode == VOIDmode) + scalar_int_mode mode; + if (!get_best_mode (bitsize, bitnum, 0, 0, MEM_ALIGN (op0), + BITS_PER_WORD, MEM_VOLATILE_P (op0), &mode)) /* The only way this should occur is if the field spans word boundaries. */ return extract_split_bit_field (op0, bitsize, bitnum, unsignedp, |