* 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.
This commit is contained in:
parent
f63f176ed6
commit
d532c08fb0
@ -1,3 +1,15 @@
|
||||
2003-06-15 Mark Kettenis <kettenis@gnu.org>
|
||||
|
||||
* 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.
|
||||
|
||||
2003-06-14 Andrew Cagney <cagney@redhat.com>
|
||||
|
||||
* mips-tdep.c (mips_register_to_value): Make static.
|
||||
|
@ -1392,36 +1392,21 @@ i386_register_to_value (struct frame_info *frame, int regnum,
|
||||
|
||||
if (i386_fp_regnum_p (regnum))
|
||||
{
|
||||
char from[I386_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. */
|
||||
frame_read_register (frame, regnum, from);
|
||||
convert_typed_floating (from, builtin_type_i387_ext, to, type);
|
||||
i387_register_to_value (frame, regnum, type, to);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdb_assert (TYPE_LENGTH (type) == 8);
|
||||
|
||||
/* Read the first part. */
|
||||
gdb_assert (register_size (current_gdbarch, regnum) == 4);
|
||||
frame_read_register (frame, regnum, (char *) to + 0);
|
||||
gdb_assert (TYPE_LENGTH (type) == 8);
|
||||
|
||||
/* Read the second part. */
|
||||
regnum = i386_next_regnum (regnum);
|
||||
gdb_assert (regnum != -1);
|
||||
gdb_assert (register_size (current_gdbarch, regnum));
|
||||
frame_read_register (frame, regnum, (char *) to + 4);
|
||||
}
|
||||
/* Read the first part. */
|
||||
gdb_assert (register_size (current_gdbarch, regnum) == 4);
|
||||
frame_read_register (frame, regnum, (char *) to + 0);
|
||||
|
||||
/* Read the second part. */
|
||||
regnum = i386_next_regnum (regnum);
|
||||
gdb_assert (regnum != -1);
|
||||
gdb_assert (register_size (current_gdbarch, regnum));
|
||||
frame_read_register (frame, regnum, (char *) to + 4);
|
||||
}
|
||||
|
||||
/* Write the contents FROM of a value of type TYPE into register
|
||||
@ -1433,36 +1418,21 @@ i386_value_to_register (struct frame_info *frame, int regnum,
|
||||
{
|
||||
if (i386_fp_regnum_p (regnum))
|
||||
{
|
||||
char to[I386_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_i387_ext);
|
||||
put_frame_register (frame, regnum, to);
|
||||
i387_value_to_register (frame, regnum, type, from);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdb_assert (TYPE_LENGTH (type) == 8);
|
||||
|
||||
/* Write the first part. */
|
||||
gdb_assert (register_size (current_gdbarch, regnum) == 4);
|
||||
put_frame_register (frame, regnum, (const char *) from + 0);
|
||||
gdb_assert (TYPE_LENGTH (type) == 8);
|
||||
|
||||
/* Write the second part. */
|
||||
regnum = i386_next_regnum (regnum);
|
||||
gdb_assert (regnum != -1);
|
||||
gdb_assert (register_size (current_gdbarch, regnum) == 4);
|
||||
put_frame_register (frame, regnum, (const char *) from + 4);
|
||||
}
|
||||
/* Write the first part. */
|
||||
gdb_assert (register_size (current_gdbarch, regnum) == 4);
|
||||
put_frame_register (frame, regnum, (const char *) from + 0);
|
||||
|
||||
/* Write the second part. */
|
||||
regnum = i386_next_regnum (regnum);
|
||||
gdb_assert (regnum != -1);
|
||||
gdb_assert (register_size (current_gdbarch, regnum) == 4);
|
||||
put_frame_register (frame, regnum, (const char *) from + 4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -24,6 +24,7 @@
|
||||
struct gdbarch;
|
||||
struct ui_file;
|
||||
struct frame_info;
|
||||
struct type;
|
||||
|
||||
/* Print out the i387 floating point state. */
|
||||
|
||||
@ -32,6 +33,18 @@ extern void i387_print_float_info (struct gdbarch *gdbarch,
|
||||
struct frame_info *frame,
|
||||
const char *args);
|
||||
|
||||
/* Read a value of type TYPE from register REGNUM in frame FRAME, and
|
||||
return its contents in TO. */
|
||||
|
||||
extern void i387_register_to_value (struct frame_info *frame, int regnum,
|
||||
struct type *type, void *to);
|
||||
|
||||
/* Write the contents FROM of a value of type TYPE into register
|
||||
REGNUM in frame FRAME. */
|
||||
|
||||
extern void i387_value_to_register (struct frame_info *frame, int regnum,
|
||||
struct type *type, const void *from);
|
||||
|
||||
/* Fill register REGNUM in GDB's register array with the appropriate
|
||||
value from *FSAVE. This function masks off any of the reserved
|
||||
bits in *FSAVE. */
|
||||
|
@ -208,6 +208,15 @@ x86_64_dwarf_reg_to_regnum (int reg)
|
||||
|
||||
return regnum;
|
||||
}
|
||||
|
||||
/* Return nonzero if a value of type TYPE stored in register REGNUM
|
||||
needs any special handling. */
|
||||
|
||||
static int
|
||||
x86_64_convert_register_p (int regnum, struct type *type)
|
||||
{
|
||||
return i386_fp_regnum_p (regnum);
|
||||
}
|
||||
|
||||
|
||||
/* The returning of values is done according to the special algorithm.
|
||||
@ -1178,6 +1187,10 @@ x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
||||
/* Call dummy code. */
|
||||
set_gdbarch_push_dummy_call (gdbarch, x86_64_push_dummy_call);
|
||||
|
||||
set_gdbarch_convert_register_p (gdbarch, x86_64_convert_register_p);
|
||||
set_gdbarch_register_to_value (gdbarch, i387_register_to_value);
|
||||
set_gdbarch_value_to_register (gdbarch, i387_value_to_register);
|
||||
|
||||
set_gdbarch_extract_return_value (gdbarch, x86_64_extract_return_value);
|
||||
set_gdbarch_store_return_value (gdbarch, x86_64_store_return_value);
|
||||
/* Override, since this is handled by x86_64_extract_return_value. */
|
||||
|
Loading…
Reference in New Issue
Block a user