Commit 6ca6193b by John David Anglin Committed by John David Anglin

* expmed.c (extract_bit_field): Fix bit-field extraction from SUBREGs.

From-SVN: r57629
parent d7bb749a
2002-09-29 John David Anglin <dave@hiauly1.hia.nrc.ca>
* expmed.c (extract_bit_field): Fix bit-field extraction from SUBREGs.
2002-09-29 Kazu Hirata <kazu@cs.umass.edu> 2002-09-29 Kazu Hirata <kazu@cs.umass.edu>
* builtins.def: Fix comment formatting. * builtins.def: Fix comment formatting.
......
...@@ -1031,25 +1031,15 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp, ...@@ -1031,25 +1031,15 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp,
if (tmode == VOIDmode) if (tmode == VOIDmode)
tmode = mode; tmode = mode;
while (GET_CODE (op0) == SUBREG) while (GET_CODE (op0) == SUBREG)
{ {
int outer_size = GET_MODE_BITSIZE (GET_MODE (op0)); bitpos += SUBREG_BYTE (op0) * BITS_PER_UNIT;
int inner_size = GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (op0))); if (bitpos > unit)
offset += SUBREG_BYTE (op0) / UNITS_PER_WORD;
inner_size = MIN (inner_size, BITS_PER_WORD);
if (BYTES_BIG_ENDIAN && (outer_size < inner_size))
{ {
bitpos += inner_size - outer_size; offset += (bitpos / unit);
if (bitpos > unit) bitpos %= unit;
{
offset += (bitpos / unit);
bitpos %= unit;
}
} }
op0 = SUBREG_REG (op0); op0 = SUBREG_REG (op0);
} }
...@@ -1086,9 +1076,13 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp, ...@@ -1086,9 +1076,13 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp,
set_mem_expr (op0, 0); set_mem_expr (op0, 0);
} }
/* ??? We currently assume TARGET is at least as big as BITSIZE. /* Extraction of a full-word or multi-word value from a structure
If that's wrong, the solution is to test for it and set TARGET to 0 in a register or aligned memory can be done with just a SUBREG.
if needed. */ A subword value in the least significant part of a register
can also be extracted with a SUBREG. For this, we need the
byte offset of the value in op0. */
byte_offset = bitpos / BITS_PER_UNIT + offset * UNITS_PER_WORD;
/* If OP0 is a register, BITPOS must count within a word. /* If OP0 is a register, BITPOS must count within a word.
But as we have it, it counts within whatever size OP0 now has. But as we have it, it counts within whatever size OP0 now has.
...@@ -1098,14 +1092,9 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp, ...@@ -1098,14 +1092,9 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp,
&& unit > GET_MODE_BITSIZE (GET_MODE (op0))) && unit > GET_MODE_BITSIZE (GET_MODE (op0)))
bitpos += unit - GET_MODE_BITSIZE (GET_MODE (op0)); bitpos += unit - GET_MODE_BITSIZE (GET_MODE (op0));
/* Extracting a full-word or multi-word value /* ??? We currently assume TARGET is at least as big as BITSIZE.
from a structure in a register or aligned memory. If that's wrong, the solution is to test for it and set TARGET to 0
This can be done with just SUBREG. if needed. */
So too extracting a subword value in
the least significant part of the register. */
byte_offset = (bitnum % BITS_PER_WORD) / BITS_PER_UNIT
+ (offset * UNITS_PER_WORD);
mode1 = (VECTOR_MODE_P (tmode) mode1 = (VECTOR_MODE_P (tmode)
? mode ? mode
......
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