From 8498efd0821d30f473d873bd4378484f914d9be5 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Wed, 28 Jul 1993 10:12:33 -0700 Subject: (expand_call): For unaligned arguments on BYTES_BIG_ENDIAN machines, correct bitfield offset calculations. From-SVN: r5013 --- gcc/calls.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'gcc') 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, -- cgit v1.1