From e47577ab7b5afee567e9f300c054a25cd7fe1d1b Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sun, 9 May 2004 18:51:38 +0000 Subject: [PATCH] * m68k-tdep.c (m68k_convert_register_p, m68k_register_to_value) (m68k_value_to_register): New functions. (m68k_gdbarch_init): Set convert_register_p, register_to_value and value_to_register. --- gdb/ChangeLog | 5 +++++ gdb/m68k-tdep.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 13e3a6ac0d0..75fa25a3967 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2004-05-09 Mark Kettenis + * m68k-tdep.c (m68k_convert_register_p, m68k_register_to_value) + (m68k_value_to_register): New functions. + (m68k_gdbarch_init): Set convert_register_p, register_to_value and + value_to_register. + * defs.h (enum return_value_convention): Add RETURN_VALUE_ABI_RETURNS_ADDRESS and RETURN_VALUE_ABI_PRESERVES_ADDRESS. diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index d860cfb8ebc..b254005956a 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -129,6 +129,62 @@ m68k_register_name (int regnum) else return register_names[regnum]; } + +/* Return nonzero if a value of type TYPE stored in register REGNUM + needs any special handling. */ + +static int +m68k_convert_register_p (int regnum, struct type *type) +{ + return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7); +} + +/* Read a value of type TYPE from register REGNUM in frame FRAME, and + return its contents in TO. */ + +static void +m68k_register_to_value (struct frame_info *frame, int regnum, + struct type *type, void *to) +{ + char from[M68K_MAX_REGISTER_SIZE]; + + /* We only support floating-point values. */ + if (TYPE_CODE (type) != TYPE_CODE_FLT) + { + warning ("Cannot convert floating-point register value " + "to non-floating-point type."); + return; + } + + /* Convert to TYPE. This should be a no-op if TYPE is equivalent to + the extended floating-point format used by the FPU. */ + get_frame_register (frame, regnum, from); + convert_typed_floating (from, builtin_type_m68881_ext, to, type); +} + +/* Write the contents FROM of a value of type TYPE into register + REGNUM in frame FRAME. */ + +static void +m68k_value_to_register (struct frame_info *frame, int regnum, + struct type *type, const void *from) +{ + char to[M68K_MAX_REGISTER_SIZE]; + + /* We only support floating-point values. */ + if (TYPE_CODE (type) != TYPE_CODE_FLT) + { + warning ("Cannot convert non-floating-point type " + "to floating-point register value."); + return; + } + + /* Convert from TYPE. This should be a no-op if TYPE is equivalent + to the extended floating-point format used by the FPU. */ + convert_typed_floating (from, type, to, builtin_type_m68881_ext); + put_frame_register (frame, regnum, to); +} + /* There is a fair number of calling conventions that are in somewhat wide use. The 68000/08/10 don't support an FPU, not even as a @@ -1051,6 +1107,9 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_pc_regnum (gdbarch, M68K_PC_REGNUM); set_gdbarch_ps_regnum (gdbarch, M68K_PS_REGNUM); set_gdbarch_fp0_regnum (gdbarch, M68K_FP0_REGNUM); + set_gdbarch_convert_register_p (gdbarch, m68k_convert_register_p); + set_gdbarch_register_to_value (gdbarch, m68k_register_to_value); + set_gdbarch_value_to_register (gdbarch, m68k_value_to_register); set_gdbarch_push_dummy_call (gdbarch, m68k_push_dummy_call); set_gdbarch_return_value (gdbarch, m68k_return_value); -- 2.30.2