diff options
author | Michael Snyder <msnyder@vmware.com> | 1997-06-28 02:23:30 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 1997-06-28 02:23:30 +0000 |
commit | 0af60e0326d6263693fcad779e7f41cdcaf012f7 (patch) | |
tree | 3d422e1e985af380f32d2ec24326bce27f83247c /gdb/mips-tdep.c | |
parent | d006e435275118ac736229dffd19874fee367f9f (diff) | |
download | binutils-gdb-0af60e0326d6263693fcad779e7f41cdcaf012f7.tar.gz |
Fri Jun 27 19:19:12 1997 Michael Snyder (msnyder@cleaver.cygnus.com)
* config/mips/tm-mips.h (USE_STRUCT_CONVENTION): MIPS_EABI returns
structs in a register wherever possible.
Diffstat (limited to 'gdb/mips-tdep.c')
-rw-r--r-- | gdb/mips-tdep.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 7771cdb5a94..285d37949b6 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -1907,15 +1907,21 @@ mips_extract_return_value (valtype, regbuf, valbuf) regnum = 2; if (TYPE_CODE (valtype) == TYPE_CODE_FLT - && (mips_fpu == MIPS_FPU_DOUBLE - || (mips_fpu == MIPS_FPU_SINGLE && len <= MIPS_REGSIZE))) + && (mips_fpu == MIPS_FPU_DOUBLE + || (mips_fpu == MIPS_FPU_SINGLE && len <= MIPS_REGSIZE))) regnum = FP0_REGNUM; - if (TARGET_BYTE_ORDER == BIG_ENDIAN - && TYPE_CODE (valtype) != TYPE_CODE_FLT - && len < REGISTER_RAW_SIZE (regnum)) - offset = REGISTER_RAW_SIZE (regnum) - len; - + if (TARGET_BYTE_ORDER == BIG_ENDIAN) + { /* "un-left-justify" the value from the register */ + if (len < REGISTER_RAW_SIZE (regnum) && + TYPE_CODE (valtype) != TYPE_CODE_FLT) + offset = REGISTER_RAW_SIZE (regnum) - len; + if (len > REGISTER_RAW_SIZE (regnum) && /* odd-size structs */ + len < REGISTER_RAW_SIZE (regnum) * 2 && + (TYPE_CODE (valtype) == TYPE_CODE_STRUCT || + TYPE_CODE (valtype) == TYPE_CODE_UNION)) + offset = 2 * REGISTER_RAW_SIZE (regnum) - len; + } memcpy (valbuf, regbuf + REGISTER_BYTE (regnum) + offset, len); REGISTER_CONVERT_TO_TYPE (regnum, valtype, valbuf); } @@ -1928,18 +1934,31 @@ mips_store_return_value (valtype, valbuf) char *valbuf; { int regnum; + int offset = 0; + int len = TYPE_LENGTH (valtype); char raw_buffer[MAX_REGISTER_RAW_SIZE]; regnum = 2; if (TYPE_CODE (valtype) == TYPE_CODE_FLT - && (mips_fpu == MIPS_FPU_DOUBLE - || (mips_fpu == MIPS_FPU_SINGLE && TYPE_LENGTH (valtype) <= 4))) /* FIXME!! */ + && (mips_fpu == MIPS_FPU_DOUBLE + || (mips_fpu == MIPS_FPU_SINGLE && len <= MIPS_REGSIZE))) regnum = FP0_REGNUM; - memcpy(raw_buffer, valbuf, TYPE_LENGTH (valtype)); + if (TARGET_BYTE_ORDER == BIG_ENDIAN) + { /* "left-justify" the value in the register */ + if (len < REGISTER_RAW_SIZE (regnum)) + offset = REGISTER_RAW_SIZE (regnum) - len; + if (len > REGISTER_RAW_SIZE (regnum) && /* odd-size structs */ + len < REGISTER_RAW_SIZE (regnum) * 2 && + (TYPE_CODE (valtype) == TYPE_CODE_STRUCT || + TYPE_CODE (valtype) == TYPE_CODE_UNION)) + offset = 2 * REGISTER_RAW_SIZE (regnum) - len; + } + memcpy(raw_buffer + offset, valbuf, len); REGISTER_CONVERT_FROM_TYPE(regnum, valtype, raw_buffer); - - write_register_bytes(REGISTER_BYTE (regnum), raw_buffer, TYPE_LENGTH (valtype)); + write_register_bytes(REGISTER_BYTE (regnum), raw_buffer, + len > REGISTER_RAW_SIZE (regnum) ? + len : REGISTER_RAW_SIZE (regnum)); } /* Exported procedure: Is PC in the signal trampoline code */ |