diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-08-30 11:14:59 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-08-30 11:14:59 +0000 |
commit | 5602f58c633e51b03b5f18bbd65924b4b842d075 (patch) | |
tree | d8955268a1ac99ffbf94233ae93e5a60a4f5595a /gcc/expmed.c | |
parent | ae9270466ed530df375bcaf6b3d834dbef6e3965 (diff) | |
download | gcc-5602f58c633e51b03b5f18bbd65924b4b842d075.zip gcc-5602f58c633e51b03b5f18bbd65924b4b842d075.tar.gz gcc-5602f58c633e51b03b5f18bbd65924b4b842d075.tar.bz2 |
[40/77] Use scalar_int_mode for extraction_insn fields
insv, extv and eztzv modify or read a field in a register or
memory. The field always has a scalar integer mode, while the
register or memory either has a scalar integer mode or BLKmode.
The mode of the bit position is also a scalar integer.
This patch uses the type system to make that explicit.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* optabs-query.h (extraction_insn::struct_mode): Change type to
opt_scalar_int_mode and update comment.
(extraction_insn::field_mode): Change type to scalar_int_mode.
(extraction_insn::pos_mode): Likewise.
* combine.c (make_extraction): Update accordingly.
* optabs-query.c (get_traditional_extraction_insn): Likewise.
(get_optab_extraction_insn): Likewise.
* recog.c (simplify_while_replacing): Likewise.
* expmed.c (narrow_bit_field_mem): Change the type of the mode
parameter to opt_scalar_int_mode.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251492
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r-- | gcc/expmed.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c index 641bc24..dabde4e 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -411,31 +411,33 @@ flip_storage_order (machine_mode mode, rtx x) return result; } -/* Adjust bitfield memory MEM so that it points to the first unit of mode - MODE that contains a bitfield of size BITSIZE at bit position BITNUM. - If MODE is BLKmode, return a reference to every byte in the bitfield. - Set *NEW_BITNUM to the bit position of the field within the new memory. */ +/* If MODE is set, adjust bitfield memory MEM so that it points to the + first unit of mode MODE that contains a bitfield of size BITSIZE at + bit position BITNUM. If MODE is not set, return a BLKmode reference + to every byte in the bitfield. Set *NEW_BITNUM to the bit position + of the field within the new memory. */ static rtx -narrow_bit_field_mem (rtx mem, machine_mode mode, +narrow_bit_field_mem (rtx mem, opt_scalar_int_mode mode, unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, unsigned HOST_WIDE_INT *new_bitnum) { - if (mode == BLKmode) + scalar_int_mode imode; + if (mode.exists (&imode)) + { + unsigned int unit = GET_MODE_BITSIZE (imode); + *new_bitnum = bitnum % unit; + HOST_WIDE_INT offset = (bitnum - *new_bitnum) / BITS_PER_UNIT; + return adjust_bitfield_address (mem, imode, offset); + } + else { *new_bitnum = bitnum % BITS_PER_UNIT; HOST_WIDE_INT offset = bitnum / BITS_PER_UNIT; HOST_WIDE_INT size = ((*new_bitnum + bitsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT); - return adjust_bitfield_address_size (mem, mode, offset, size); - } - else - { - unsigned int unit = GET_MODE_BITSIZE (mode); - *new_bitnum = bitnum % unit; - HOST_WIDE_INT offset = (bitnum - *new_bitnum) / BITS_PER_UNIT; - return adjust_bitfield_address (mem, mode, offset); + return adjust_bitfield_address_size (mem, BLKmode, offset, size); } } |