This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] sh_store_return_value



More sh stuff. For inferior function calls, make sure the return value
is stored where it should.

Elena

2000-07-03  Elena Zannoni  <ezannoni@kwikemart.cygnus.com>

	* config/sh/tm-sh.h (STORE_RETURN_VALUE): Redefine as
 	sh_store_return_value().
	* sh-tdep.c (sh_store_return_value): New function. Store the
 	value returned by a function into the appropriate register.

Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.7
diff -c -u -p -r1.7 sh-tdep.c
--- sh-tdep.c	2000/07/03 18:59:36	1.7
+++ sh-tdep.c	2000/07/03 19:20:43
@@ -784,6 +897,29 @@ sh_extract_return_value (type, regbuf, v
     memcpy (valbuf, ((char *) regbuf) + 8 - len, len);
   else
     error ("bad size for return value");
+}
+
+/* If the architecture is sh4 or sh3e, store a function's return value
+   in the R0 general register or in the FP0 floating point register,
+   depending on the type of the return value. In all the other cases
+   the result is stored in r0. */
+void
+sh_store_return_value (struct type *type, void *valbuf)
+{
+  int cpu;
+  if (TARGET_ARCHITECTURE->arch == bfd_arch_sh)
+    cpu = TARGET_ARCHITECTURE->mach;
+  else
+    cpu = 0;
+  if (cpu == bfd_mach_sh3e || cpu == bfd_mach_sh4)
+    {
+      if (TYPE_CODE (type) == TYPE_CODE_FLT) 
+	write_register_bytes (REGISTER_BYTE (FP0_REGNUM), valbuf, TYPE_LENGTH (type));
+      else
+	write_register_bytes (REGISTER_BYTE (0), valbuf, TYPE_LENGTH (type));
+    }
+  else
+    write_register_bytes (REGISTER_BYTE (0), valbuf, TYPE_LENGTH (type));
 }
 
 void
Index: config/sh/tm-sh.h
===================================================================
RCS file: /cvs/src/src/gdb/config/sh/tm-sh.h,v
retrieving revision 1.5
diff -c -u -p -r1.5 tm-sh.h
--- tm-sh.h	2000/05/28 01:12:40	1.5
+++ tm-sh.h	2000/07/03 19:20:45
@@ -181,12 +181,11 @@ extern void sh_extract_return_value (str
 	sh_extract_return_value (TYPE, REGBUF, VALBUF)
 
 /* Write into appropriate registers a function return value
-   of type TYPE, given in virtual format.
+   of type TYPE, given in virtual format. */
 
-   Things always get returned in R0/R1 */
-
+extern void sh_store_return_value (struct type *, void *);
 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
-  write_register_bytes (REGISTER_BYTE(0), VALBUF, TYPE_LENGTH (TYPE))
+  sh_store_return_value (TYPE, VALBUF)
 
 /* Extract from an array REGBUF containing the (raw) register state
    the address in which a function should return its structure value,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]