summaryrefslogtreecommitdiff
path: root/gdb/i387-tdep.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2003-06-15 11:01:46 +0000
committerMark Kettenis <kettenis@gnu.org>2003-06-15 11:01:46 +0000
commit168c4f1285d0794cddd3aa658fdc123cf69fec32 (patch)
tree907788836e1cad13ecb0d842c2afdd49676436a3 /gdb/i387-tdep.c
parentab308810b7d88c3d5660fde267e5b22a26c8d487 (diff)
downloadgdb-168c4f1285d0794cddd3aa658fdc123cf69fec32.tar.gz
* i386-tdep.c (i386_register_to_value, i386_value_to_register):
Move floating-point code to new function in i387-tdep.c. * i387-tdep.c (i387_register_to_value, i387_value_to_register): New functions containing code moved here from i386-tdep.c. * i387-tdep.h: Add opaque declaration for `struct type'. (i387_register_to_value, i387_value_to_register): New prototypes. * x86-64-tdep.c (x86_64_convert_register_p): New function. (x86_64_init_abi): Set convert_register_p, register_to_value and value_to_register here.
Diffstat (limited to 'gdb/i387-tdep.c')
-rw-r--r--gdb/i387-tdep.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index c28420704fc..ee550c6d06e 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -282,6 +282,58 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
fprintf_filtered (file, "Opcode: %s\n",
local_hex_string_custom (fop ? (fop | 0xd800) : 0, "04"));
}
+
+
+/* Read a value of type TYPE from register REGNUM in frame FRAME, and
+ return its contents in TO. */
+
+void
+i387_register_to_value (struct frame_info *frame, int regnum,
+ struct type *type, void *to)
+{
+ char from[I386_MAX_REGISTER_SIZE];
+
+ gdb_assert (i386_fp_regnum_p (regnum));
+
+ /* 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. */
+ frame_read_register (frame, regnum, from);
+ convert_typed_floating (from, builtin_type_i387_ext, to, type);
+}
+
+/* Write the contents FROM of a value of type TYPE into register
+ REGNUM in frame FRAME. */
+
+void
+i387_value_to_register (struct frame_info *frame, int regnum,
+ struct type *type, const void *from)
+{
+ char to[I386_MAX_REGISTER_SIZE];
+
+ gdb_assert (i386_fp_regnum_p (regnum));
+
+ /* 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_i387_ext);
+ put_frame_register (frame, regnum, to);
+}
+
/* FIXME: kettenis/2000-05-21: Right now more than a few i386 targets
define their own routines to manage the floating-point registers in