* i386-tdep.c (i386_extract_return_value): Use

convert_typed_floating to extract floating-point value from
register buffer.
(i386_store_return_value): Use convert_typed_floating to store
floating-point return balue in register buffer
(i386_register_virtual_type): Change type of floating-point
registers to builtin_type_i387_ext.
(i386_register_convert_to_virtual): Use convert_typed_floating to
do the conversion.
(i386_register_convert_to_raw): Likewise.
This commit is contained in:
Mark Kettenis
2001-10-29 23:49:31 +00:00
parent 43686d6411
commit c6ba6f0d51
2 changed files with 45 additions and 56 deletions

View File

@ -1,3 +1,16 @@
2001-10-30 Mark Kettenis <kettenis@gnu.org>
* i386-tdep.c (i386_extract_return_value): Use
convert_typed_floating to extract floating-point value from
register buffer.
(i386_store_return_value): Use convert_typed_floating to store
floating-point return balue in register buffer
(i386_register_virtual_type): Change type of floating-point
registers to builtin_type_i387_ext.
(i386_register_convert_to_virtual): Use convert_typed_floating to
do the conversion.
(i386_register_convert_to_raw): Likewise.
2001-10-29 Mark Kettenis <kettenis@gnu.org> 2001-10-29 Mark Kettenis <kettenis@gnu.org>
* doublest.h (convert_typed_floating): New prototype. * doublest.h (convert_typed_floating): New prototype.

View File

@ -869,26 +869,12 @@ i386_extract_return_value (struct type *type, char *regbuf, char *valbuf)
return; return;
} }
/* Floating-point return values can be found in %st(0). */ /* Floating-point return values can be found in %st(0). Convert
if (len == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT its contents to the desired type. This is probably not
&& TARGET_LONG_DOUBLE_FORMAT == &floatformat_i387_ext) exactly how it would happen on the target itself, but it is
{ the best we can do. */
/* Copy straight over, but take care of the padding. */ convert_typed_floating (&regbuf[REGISTER_BYTE (FP0_REGNUM)],
memcpy (valbuf, &regbuf[REGISTER_BYTE (FP0_REGNUM)], builtin_type_i387_ext, valbuf, type);
FPU_REG_RAW_SIZE);
memset (valbuf + FPU_REG_RAW_SIZE, 0, len - FPU_REG_RAW_SIZE);
}
else
{
/* Convert the extended floating-point number found in
%st(0) to the desired type. This is probably not exactly
how it would happen on the target itself, but it is the
best we can do. */
DOUBLEST val;
floatformat_to_doublest (&floatformat_i387_ext,
&regbuf[REGISTER_BYTE (FP0_REGNUM)], &val);
store_floating (valbuf, TYPE_LENGTH (type), val);
}
} }
else else
{ {
@ -928,6 +914,7 @@ i386_store_return_value (struct type *type, char *valbuf)
if (TYPE_CODE (type) == TYPE_CODE_FLT) if (TYPE_CODE (type) == TYPE_CODE_FLT)
{ {
unsigned int fstat; unsigned int fstat;
char buf[FPU_REG_RAW_SIZE];
if (NUM_FREGS == 0) if (NUM_FREGS == 0)
{ {
@ -939,27 +926,13 @@ i386_store_return_value (struct type *type, char *valbuf)
storing the return value in %st(0), we have to simulate the storing the return value in %st(0), we have to simulate the
state of the FPU at function return point. */ state of the FPU at function return point. */
if (len == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT /* Convert the value found in VALBUF to the extended
&& TARGET_LONG_DOUBLE_FORMAT == &floatformat_i387_ext) floating-point format used by the FPU. This is probably
{ not exactly how it would happen on the target itself, but
/* Copy straight over. */ it is the best we can do. */
write_register_bytes (REGISTER_BYTE (FP0_REGNUM), valbuf, convert_typed_floating (valbuf, type, buf, builtin_type_i387_ext);
FPU_REG_RAW_SIZE); write_register_bytes (REGISTER_BYTE (FP0_REGNUM), buf,
} FPU_REG_RAW_SIZE);
else
{
char buf[FPU_REG_RAW_SIZE];
DOUBLEST val;
/* Convert the value found in VALBUF to the extended
floating-point format used by the FPU. This is probably
not exactly how it would happen on the target itself, but
it is the best we can do. */
val = extract_floating (valbuf, TYPE_LENGTH (type));
floatformat_from_doublest (&floatformat_i387_ext, &val, buf);
write_register_bytes (REGISTER_BYTE (FP0_REGNUM), buf,
FPU_REG_RAW_SIZE);
}
/* Set the top of the floating-point register stack to 7. The /* Set the top of the floating-point register stack to 7. The
actual value doesn't really matter, but 7 is what a normal actual value doesn't really matter, but 7 is what a normal
@ -1017,7 +990,7 @@ i386_register_virtual_type (int regnum)
return lookup_pointer_type (builtin_type_void); return lookup_pointer_type (builtin_type_void);
if (IS_FP_REGNUM (regnum)) if (IS_FP_REGNUM (regnum))
return builtin_type_long_double; return builtin_type_i387_ext;
if (IS_SSE_REGNUM (regnum)) if (IS_SSE_REGNUM (regnum))
return builtin_type_v4sf; return builtin_type_v4sf;
@ -1044,8 +1017,7 @@ void
i386_register_convert_to_virtual (int regnum, struct type *type, i386_register_convert_to_virtual (int regnum, struct type *type,
char *from, char *to) char *from, char *to)
{ {
char buf[12]; gdb_assert (IS_FP_REGNUM (regnum));
DOUBLEST d;
/* We only support floating-point values. */ /* We only support floating-point values. */
if (TYPE_CODE (type) != TYPE_CODE_FLT) if (TYPE_CODE (type) != TYPE_CODE_FLT)
@ -1056,14 +1028,9 @@ i386_register_convert_to_virtual (int regnum, struct type *type,
return; return;
} }
/* First add the necessary padding. */ /* Convert to TYPE. This should be a no-op if TYPE is equivalent to
memcpy (buf, from, FPU_REG_RAW_SIZE); the extended floating-point format used by the FPU. */
memset (buf + FPU_REG_RAW_SIZE, 0, sizeof buf - FPU_REG_RAW_SIZE); convert_typed_floating (from, builtin_type_i387_ext, to, type);
/* Convert to TYPE. This should be a no-op, if TYPE is equivalent
to the extended floating-point format used by the FPU. */
d = extract_floating (buf, sizeof buf);
store_floating (to, TYPE_LENGTH (type), d);
} }
/* Convert data from virtual format with type TYPE in buffer FROM to /* Convert data from virtual format with type TYPE in buffer FROM to
@ -1073,11 +1040,20 @@ void
i386_register_convert_to_raw (struct type *type, int regnum, i386_register_convert_to_raw (struct type *type, int regnum,
char *from, char *to) char *from, char *to)
{ {
gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT gdb_assert (IS_FP_REGNUM (regnum));
&& TYPE_LENGTH (type) == 12);
/* Simply omit the two unused bytes. */ /* We only support floating-point values. */
memcpy (to, from, FPU_REG_RAW_SIZE); if (TYPE_CODE (type) != TYPE_CODE_FLT)
{
warning ("Cannot convert non-floating-point type "
"to floating-point register value.");
memset (to, 0, TYPE_LENGTH (type));
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);
} }