aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1993-07-28 10:12:33 -0700
committerJim Wilson <wilson@gcc.gnu.org>1993-07-28 10:12:33 -0700
commit8498efd0821d30f473d873bd4378484f914d9be5 (patch)
tree4ecd48a57a442512fc6daa2e334c103cf346da60
parent0eb61c19ed94cea01e7e8e0540a932f15acf7ac7 (diff)
downloadgcc-8498efd0821d30f473d873bd4378484f914d9be5.zip
gcc-8498efd0821d30f473d873bd4378484f914d9be5.tar.gz
gcc-8498efd0821d30f473d873bd4378484f914d9be5.tar.bz2
(expand_call): For unaligned arguments on
BYTES_BIG_ENDIAN machines, correct bitfield offset calculations. From-SVN: r5013
-rw-r--r--gcc/calls.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/calls.c b/gcc/calls.c
index f426263..d9ec9da 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -1623,6 +1623,7 @@ expand_call (exp, target, ignore)
< MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
{
int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
+ int big_endian_correction = 0;
args[i].n_aligned_regs
= args[i].partial ? args[i].partial
@@ -1631,6 +1632,13 @@ expand_call (exp, target, ignore)
args[i].aligned_regs = (rtx *) alloca (sizeof (rtx)
* args[i].n_aligned_regs);
+ /* Structures smaller than a word are aligned to the least signifcant
+ byte (to the right). On a BYTES_BIG_ENDIAN machine, this means we
+ must skip the empty high order bytes when calculating the bit
+ offset. */
+ if (BYTES_BIG_ENDIAN && bytes < UNITS_PER_WORD)
+ big_endian_correction = (BITS_PER_WORD - (bytes * BITS_PER_UNIT));
+
for (j = 0; j < args[i].n_aligned_regs; j++)
{
rtx reg = gen_reg_rtx (word_mode);
@@ -1651,12 +1659,10 @@ expand_call (exp, target, ignore)
bitpos < BITS_PER_WORD && bytes > 0;
bitpos += bitsize, bytes -= bitsize / BITS_PER_UNIT)
{
- int xbitpos = (BYTES_BIG_ENDIAN
- ? BITS_PER_WORD - bitpos - bitsize
- : bitpos);
+ int xbitpos = bitpos + big_endian_correction;
store_bit_field (reg, bitsize, xbitpos, word_mode,
- extract_bit_field (word, bitsize, xbitpos, 1,
+ extract_bit_field (word, bitsize, bitpos, 1,
NULL_RTX, word_mode,
word_mode,
bitsize / BITS_PER_UNIT,