* mips-tdep.c (mips_extract_return_value): Fix returning of
authorPeter Schauer <Peter.Schauer@mytum.de>
Tue, 1 Aug 1995 09:20:05 +0000 (09:20 +0000)
committerPeter Schauer <Peter.Schauer@mytum.de>
Tue, 1 Aug 1995 09:20:05 +0000 (09:20 +0000)
values whose length is less than the register size for big endian
targets.
* alpha-tdep.c (alpha_extract_return_value,
alpha_store_return_value):  Use alpha_convert_register_to_*
to handle functions returning "float" correctly.

gdb/ChangeLog
gdb/alpha-tdep.c
gdb/mips-tdep.c

index e6c282c5cf8a7f2324852d248ee971c508f69b8b..09a056cd070b35c0271dd34f122aae048026e553 100644 (file)
@@ -1,3 +1,12 @@
+Tue Aug  1 02:08:30 1995  Peter Schauer  (pes@regent.e-technik.tu-muenchen.de)
+
+       * mips-tdep.c (mips_extract_return_value):  Fix returning of
+       values whose length is less than the register size for big endian
+       targets.
+       * alpha-tdep.c (alpha_extract_return_value,
+       alpha_store_return_value):  Use alpha_convert_register_to_*
+       to handle functions returning "float" correctly.
+
 Mon Jul 31 19:12:48 1995  Stan Shebs  <shebs@andros.cygnus.com>
 
        * h8500-tdep.c: General linting and cleanup.
index fd752f64b202364172d25db5c36c4d268e9861bd..83f1602ac31b57fe5711e5b8763e592dd8c6ca8c 100644 (file)
@@ -1099,11 +1099,12 @@ alpha_extract_return_value (valtype, regbuf, valbuf)
     char regbuf[REGISTER_BYTES];
     char *valbuf;
 {
-  int regnum;
-  
-  regnum = TYPE_CODE (valtype) == TYPE_CODE_FLT ? FP0_REGNUM : V0_REGNUM;
-
-  memcpy (valbuf, regbuf + REGISTER_BYTE (regnum), TYPE_LENGTH (valtype));
+  if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
+    alpha_register_convert_to_virtual (FP0_REGNUM, valtype,
+                                      regbuf + REGISTER_BYTE (FP0_REGNUM),
+                                      valbuf);
+  else
+    memcpy (valbuf, regbuf + REGISTER_BYTE (V0_REGNUM), TYPE_LENGTH (valtype));
 }
 
 /* Given a return value in `regbuf' with a type `valtype', 
@@ -1114,13 +1115,20 @@ alpha_store_return_value (valtype, valbuf)
     struct type *valtype;
     char *valbuf;
 {
-  int regnum;
   char raw_buffer[MAX_REGISTER_RAW_SIZE];
+  int regnum = V0_REGNUM;
+  int length = TYPE_LENGTH (valtype);
   
-  regnum = TYPE_CODE (valtype) == TYPE_CODE_FLT ? FP0_REGNUM : V0_REGNUM;
-  memcpy(raw_buffer, valbuf, TYPE_LENGTH (valtype));
+  if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
+    {
+      regnum = FP0_REGNUM;
+      length = REGISTER_RAW_SIZE (regnum);
+      alpha_register_convert_to_raw (valtype, regnum, valbuf, raw_buffer);
+    }
+  else
+    memcpy (raw_buffer, valbuf, length);
 
-  write_register_bytes(REGISTER_BYTE (regnum), raw_buffer, TYPE_LENGTH (valtype));
+  write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, length);
 }
 
 /* Just like reinit_frame_cache, but with the right arguments to be
index c6ec5f9b46c9e40b51824233892b91ea08abac20..2bd7127b12be33319d9d3a3d0338fa06e7610f6b 100644 (file)
@@ -1227,6 +1227,7 @@ mips_extract_return_value (valtype, regbuf, valbuf)
     char *valbuf;
 {
   int regnum;
+  int offset = 0;
   
   regnum = 2;
   if (TYPE_CODE (valtype) == TYPE_CODE_FLT
@@ -1234,7 +1235,13 @@ mips_extract_return_value (valtype, regbuf, valbuf)
           || (mips_fpu == MIPS_FPU_SINGLE && TYPE_LENGTH (valtype) <= 4)))
     regnum = FP0_REGNUM;
 
-  memcpy (valbuf, regbuf + REGISTER_BYTE (regnum), TYPE_LENGTH (valtype));
+  if (TARGET_BYTE_ORDER == BIG_ENDIAN
+      && TYPE_CODE (valtype) != TYPE_CODE_FLT
+      && TYPE_LENGTH (valtype) < REGISTER_RAW_SIZE (regnum))
+    offset = REGISTER_RAW_SIZE (regnum) - TYPE_LENGTH (valtype);
+
+  memcpy (valbuf, regbuf + REGISTER_BYTE (regnum) + offset,
+         TYPE_LENGTH (valtype));
 #ifdef REGISTER_CONVERT_TO_TYPE
   REGISTER_CONVERT_TO_TYPE(regnum, valtype, valbuf);
 #endif