aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@redhat.com>2003-11-16 19:10:09 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2003-11-16 19:10:09 +0000
commitc988af2b8cb75ca28789f30a6bb650b38684cc0b (patch)
tree9ef329c0c8bbcf96f5ead9aa89d71751793d4122 /gcc/expr.c
parente0c99e151e45babaac50125628ca9caf0f8c9008 (diff)
downloadgcc-c988af2b8cb75ca28789f30a6bb650b38684cc0b.zip
gcc-c988af2b8cb75ca28789f30a6bb650b38684cc0b.tar.gz
gcc-c988af2b8cb75ca28789f30a6bb650b38684cc0b.tar.bz2
Makefile.in (expr.o): Depend on $(TARGET_H).
* Makefile.in (expr.o): Depend on $(TARGET_H). * target.h (return_in_msb): New target hook. * target-def.h (TARGET_RETURN_IN_MSB): New macro. (TARGET_CALLS): Include it. * calls.c (shift_returned_value): New function. (expand_call): Use it. * expr.c: Include target.h. (copy_blkmode_from_reg): Check targetm.calls.return_in_msb when deciding what padding is needed. Change the name of the local padding variable from big_endian_correction to padding_correction. * stmt.c (shift_return_value): New function. (expand_return): Use it. Adjust memory->register copy in the same way as copy_blkmode_from_reg. Only change the return register's mode if it was originally BLKmode. * doc/tm.texi (TARGET_RETURN_IN_MSB): Document. * config/mips/mips.c (TARGET_RETURN_IN_MSB): Define. (mips_fpr_return_fields): New, split out from mips_function_value. (mips_return_in_msb, mips_return_fpr_pair): New functions. (mips_function_value): Rework to use the functions above. * config/mips/irix6-libc-compat.c: Delete. * config/mips/t-iris6 (LIB2FUNCS_STATIC_EXTRA): Undefine. From-SVN: r73652
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 0dc9c9c..9424bb9 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -47,6 +47,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "langhooks.h"
#include "intl.h"
#include "tm_p.h"
+#include "target.h"
/* Decide whether a function's arguments should be processed
from first to last or from last to first.
@@ -2121,10 +2122,10 @@ emit_group_store (rtx orig_dst, rtx src, tree type ATTRIBUTE_UNUSED, int ssize)
set of registers starting with SRCREG into TGTBLK. If TGTBLK
is null, a stack temporary is created. TGTBLK is returned.
- The primary purpose of this routine is to handle functions
- that return BLKmode structures in registers. Some machines
- (the PA for example) want to return all small structures
- in registers regardless of the structure's alignment. */
+ The purpose of this routine is to handle functions that return
+ BLKmode structures in registers. Some machines (the PA for example)
+ want to return all small structures in registers regardless of the
+ structure's alignment. */
rtx
copy_blkmode_from_reg (rtx tgtblk, rtx srcreg, tree type)
@@ -2132,7 +2133,7 @@ copy_blkmode_from_reg (rtx tgtblk, rtx srcreg, tree type)
unsigned HOST_WIDE_INT bytes = int_size_in_bytes (type);
rtx src = NULL, dst = NULL;
unsigned HOST_WIDE_INT bitsize = MIN (TYPE_ALIGN (type), BITS_PER_WORD);
- unsigned HOST_WIDE_INT bitpos, xbitpos, big_endian_correction = 0;
+ unsigned HOST_WIDE_INT bitpos, xbitpos, padding_correction = 0;
if (tgtblk == 0)
{
@@ -2150,13 +2151,20 @@ copy_blkmode_from_reg (rtx tgtblk, rtx srcreg, tree type)
&& GET_MODE_SIZE (GET_MODE (srcreg)) < UNITS_PER_WORD)
srcreg = convert_to_mode (word_mode, srcreg, TREE_UNSIGNED (type));
- /* Structures whose size is not a multiple of a word are aligned
- to the least significant 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
+ /* If the structure doesn't take up a whole number of words, see whether
+ SRCREG is padded on the left or on the right. If it's on the left,
+ set PADDING_CORRECTION to the number of bits to skip.
+
+ In most ABIs, the structure will be returned at the least end of
+ the register, which translates to right padding on little-endian
+ targets and left padding on big-endian targets. The opposite
+ holds if the structure is returned at the most significant
+ end of the register. */
+ if (bytes % UNITS_PER_WORD != 0
+ && (targetm.calls.return_in_msb (type)
+ ? !BYTES_BIG_ENDIAN
+ : BYTES_BIG_ENDIAN))
+ padding_correction
= (BITS_PER_WORD - ((bytes % UNITS_PER_WORD) * BITS_PER_UNIT));
/* Copy the structure BITSIZE bites at a time.
@@ -2164,15 +2172,15 @@ copy_blkmode_from_reg (rtx tgtblk, rtx srcreg, tree type)
We could probably emit more efficient code for machines which do not use
strict alignment, but it doesn't seem worth the effort at the current
time. */
- for (bitpos = 0, xbitpos = big_endian_correction;
+ for (bitpos = 0, xbitpos = padding_correction;
bitpos < bytes * BITS_PER_UNIT;
bitpos += bitsize, xbitpos += bitsize)
{
/* We need a new source operand each time xbitpos is on a
- word boundary and when xbitpos == big_endian_correction
+ word boundary and when xbitpos == padding_correction
(the first time through). */
if (xbitpos % BITS_PER_WORD == 0
- || xbitpos == big_endian_correction)
+ || xbitpos == padding_correction)
src = operand_subword_force (srcreg, xbitpos / BITS_PER_WORD,
GET_MODE (srcreg));