summaryrefslogtreecommitdiff
path: root/gcc/expmed.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-04 10:48:40 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-04 10:48:40 +0000
commit3d09ba95c150d9676f9a2585fb61315e86fa644a (patch)
tree6c37f118811f8cff123ef56870a20145fd74b472 /gcc/expmed.c
parentd8c40eff56f69877b33c697ded756d50fde90c27 (diff)
downloadgcc-3d09ba95c150d9676f9a2585fb61315e86fa644a.tar.gz
Add subreg_memory_offset helper functions
This patch adds routines for converting a SUBREG_BYTE offset into a memory address offset. The two only differ for paradoxical subregs, where SUBREG_BYTE is always 0 but the memory address offset can be negative. 2017-09-04 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * rtl.h (subreg_memory_offset): Declare. * emit-rtl.c (subreg_memory_offset): New function. * expmed.c (store_bit_field_1): Use it. * expr.c (undefined_operand_subword_p): Likewise. * simplify-rtx.c (simplify_subreg): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251644
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r--gcc/expmed.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index ff9eb5b2c71..f82bfc75627 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -727,29 +727,7 @@ store_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize,
while (GET_CODE (op0) == SUBREG)
{
- /* The following line once was done only if WORDS_BIG_ENDIAN,
- but I think that is a mistake. WORDS_BIG_ENDIAN is
- meaningful at a much higher level; when structures are copied
- between memory and regs, the higher-numbered regs
- always get higher addresses. */
- int inner_mode_size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0)));
- int outer_mode_size = GET_MODE_SIZE (GET_MODE (op0));
- int byte_offset = 0;
-
- /* Paradoxical subregs need special handling on big-endian machines. */
- if (paradoxical_subreg_p (op0))
- {
- int difference = inner_mode_size - outer_mode_size;
-
- if (WORDS_BIG_ENDIAN)
- byte_offset += (difference / UNITS_PER_WORD) * UNITS_PER_WORD;
- if (BYTES_BIG_ENDIAN)
- byte_offset += difference % UNITS_PER_WORD;
- }
- else
- byte_offset = SUBREG_BYTE (op0);
-
- bitnum += byte_offset * BITS_PER_UNIT;
+ bitnum += subreg_memory_offset (op0) * BITS_PER_UNIT;
op0 = SUBREG_REG (op0);
}