Fri Jun 27 19:19:12 1997 Michael Snyder (msnyder@cleaver.cygnus.com)
authorMichael Snyder <msnyder@vmware.com>
Sat, 28 Jun 1997 02:23:30 +0000 (02:23 +0000)
committerMichael Snyder <msnyder@vmware.com>
Sat, 28 Jun 1997 02:23:30 +0000 (02:23 +0000)
        * config/mips/tm-mips.h (USE_STRUCT_CONVENTION): MIPS_EABI returns
        structs in a register wherever possible.

gdb/ChangeLog
gdb/config/mips/tm-mips.h
gdb/mips-tdep.c

index 407f95696c428e237fb5f501a448d8e8ae092c23..05300769f3b5975314c3fd475d24703fe4e243ec 100644 (file)
@@ -1,3 +1,11 @@
+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.
+       * mips-tdep.c (mips_extract_return_value): handle structs.
+       (mips_store_return_value): handle values smaller than MIPS_REGSIZE
+       (including structs, if gdb ever allows it).
+
 start-sanitize-sh4
 Fri Jun 20 17:58:34 1997  Fred Fish  <fnf@cygnus.com>
 
index 70bf2e4350a727e924d003993f7391d39e191f22..ca92c35ca0637b08578fb18a260f1685519953b1 100644 (file)
@@ -331,9 +331,14 @@ extern void mips_store_return_value PARAMS ((struct type *, char *));
   (extract_address (REGBUF + REGISTER_BYTE (V0_REGNUM), \
                    REGISTER_RAW_SIZE (V0_REGNUM)))
 
+#if MIPS_EABI
+#undef  USE_STRUCT_CONVENTION
+#define USE_STRUCT_CONVENTION(gcc_p, type) \
+  (TYPE_LENGTH (type) > 2 * MIPS_REGSIZE)
+#else
 /* Structures are returned by ref in extra arg0 */
 #define USE_STRUCT_CONVENTION(gcc_p, type)     1
-
+#endif
 \f
 /* Describe the pointer in each stack frame to the previous stack frame
    (its caller).  */
index 7771cdb5a94bfb362d30ec7d940692903eab7b5c..285d37949b6e6581022ff26f587bc95f1a392317 100644 (file)
@@ -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 */