* defs.h, findvar.c (extract_floating, store_floating): New functions.

* Move SWAP_TARGET_AND_HOST from defs.h to findvar.c because it is
	now used only by extract_floating and store_floating.
	* valprint.c (print_floating): Use unsigned arithmetic.  Use
	extract_unsigned_integer instead of SWAP_TARGET_AND_HOST.
	Change sizeof (float) to 4 and sizeof (double) to 8 (those are always
	the relevant sizes for this code, which is in #ifdef IEEE_FLOAT).
	* values.c (unpack_long, unpack_double, value_from_double),
	valarith.c (value_binop), stabsread.c (define_symbol):
	Use extract_floating and store_floating instead of
	SWAP_TARGET_AND_HOST.
	* config/m68k/tm-m68k.h, config/i960/tm-i960.h (REGISTER_CONVERT_*):
	Use extract_floating and store_floating.
	* config/m88k/tm-m88k.h: Add comments (it should be doing the same).
	* i386-tdep.c (i386_extract_return_value),
	* remote-nindy.c (nindy_store_registers): Use store_floating.
This commit is contained in:
Jim Kingdon 1993-10-29 18:16:33 +00:00
parent e1ec9f078f
commit bf5c0d6448
7 changed files with 96 additions and 108 deletions

View File

@ -1,3 +1,22 @@
Fri Oct 29 08:11:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
* defs.h, findvar.c (extract_floating, store_floating): New functions.
* Move SWAP_TARGET_AND_HOST from defs.h to findvar.c because it is
now used only by extract_floating and store_floating.
* valprint.c (print_floating): Use unsigned arithmetic. Use
extract_unsigned_integer instead of SWAP_TARGET_AND_HOST.
Change sizeof (float) to 4 and sizeof (double) to 8 (those are always
the relevant sizes for this code, which is in #ifdef IEEE_FLOAT).
* values.c (unpack_long, unpack_double, value_from_double),
valarith.c (value_binop), stabsread.c (define_symbol):
Use extract_floating and store_floating instead of
SWAP_TARGET_AND_HOST.
* config/m68k/tm-m68k.h, config/i960/tm-i960.h (REGISTER_CONVERT_*):
Use extract_floating and store_floating.
* config/m88k/tm-m88k.h: Add comments (it should be doing the same).
* i386-tdep.c (i386_extract_return_value),
* remote-nindy.c (nindy_store_registers): Use store_floating.
Fri Oct 29 09:31:38 1993 Steve Chamberlain (sac@rtl.cygnus.com)
* remote-sim.c (gdbsim_store_register): Change var name so

View File

@ -169,26 +169,32 @@ extern CORE_ADDR saved_pc_after_call ();
extern struct ext_format ext_format_i960;
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
{ \
if ((REGNUM) >= FP0_REGNUM) \
ieee_extended_to_double (&ext_format_i960, (FROM), (double *)(TO)); \
else \
double val; \
if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
{ \
ieee_extended_to_double (&ext_format_i960, (FROM), &val); \
store_floating ((TO), REGISTER_VIRTUAL_SIZE (REGNUM), val); \
} \
else \
memcpy ((TO), (FROM), 4); \
}
/* Convert data from virtual format for register REGNUM
to raw format for register REGNUM. */
#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
{ \
if ((REGNUM) >= FP0_REGNUM) \
double_to_ieee_extended (&ext_format_i960, (double *)(FROM), (TO)); \
else \
memcpy ((TO), (FROM), 4); \
if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
{ \
double val = extract_floating ((FROM), REGISTER_VIRTUAL_SIZE (REGNUM)); \
double_to_ieee_extended (&ext_format_i960, &val, (TO)); \
} \
else \
memcpy ((TO), (FROM), 4); \
}
/* Return the GDB type object for the "standard" data type
of data in register N. */

View File

@ -156,8 +156,12 @@ extern const struct ext_format ext_format_68881;
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
{ \
if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
ieee_extended_to_double (&ext_format_68881, (FROM), (double *)(TO)); \
double val; \
if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
{ \
ieee_extended_to_double (&ext_format_68881, (FROM), &val); \
store_floating ((TO), REGISTER_VIRTUAL_SIZE (REGNUM), val); \
} \
else \
memcpy ((TO), (FROM), 4); \
}
@ -168,7 +172,10 @@ extern const struct ext_format ext_format_68881;
#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
{ \
if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
double_to_ieee_extended (&ext_format_68881, (double *)(FROM), (TO)); \
{ \
double val = extract_floating ((FROM), REGISTER_VIRTUAL_SIZE (REGNUM)); \
double_to_ieee_extended (&ext_format_68881, &val, (TO)); \
} \
else \
memcpy ((TO), (FROM), 4); \
}

View File

@ -386,10 +386,13 @@ if (!target_is_m88110) \
#define REGISTER_CONVERTIBLE(N) ((N) >= XFP_REGNUM)
/* Convert data from raw format for register REGNUM
to virtual format for register REGNUM. */
extern const struct ext_format ext_format_m88110;
/* Convert data from raw format for register REGNUM
to virtual format for register REGNUM. */
/* FIXME: Use store_floating like tm-m68k.h. */
extern const struct ext_format ext_format_m88110;
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
{ \
if ((REGNUM) < XFP_REGNUM) \
@ -401,6 +404,8 @@ if (!target_is_m88110) \
/* Convert data from virtual format for register REGNUM
to raw format for register REGNUM. */
/* FIXME: Use extract_floating like tm-m68k.h. */
#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
{ \
if ((REGNUM) < XFP_REGNUM) \

View File

@ -472,7 +472,7 @@ nindy_store_registers(regno)
int regno;
{
struct nindy_regs nindy_regs;
int regnum, inv;
int regnum;
double dub;
memcpy (nindy_regs.local_regs, &registers[REGISTER_BYTE (R0_REGNUM)], 16*4);
@ -480,18 +480,14 @@ nindy_store_registers(regno)
memcpy (nindy_regs.pcw_acw, &registers[REGISTER_BYTE (PCW_REGNUM)], 2*4);
memcpy (nindy_regs.ip, &registers[REGISTER_BYTE (IP_REGNUM)], 1*4);
memcpy (nindy_regs.tcw, &registers[REGISTER_BYTE (TCW_REGNUM)], 1*4);
/* Float regs. Only works on IEEE_FLOAT hosts. FIXME! */
for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++) {
ieee_extended_to_double (&ext_format_i960,
&registers[REGISTER_BYTE (regnum)], &dub);
/* dub now in host byte order */
/* FIXME-someday, the arguments to unpack_double are backward.
It expects a target double and returns a host; we pass the opposite.
This mostly works but not quite. */
dub = unpack_double (builtin_type_double, (char *)&dub, &inv);
/* dub now in target byte order */
memcpy (&nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)], &dub, 8);
}
for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++)
{
ieee_extended_to_double (&ext_format_i960,
&registers[REGISTER_BYTE (regnum)], &dub);
store_floating (&nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)],
REGISTER_VIRTUAL_SIZE (regnum),
dub);
}
immediate_quit++;
ninRegsPut( (char *) &nindy_regs );

View File

@ -613,11 +613,13 @@ define_symbol (valu, string, desc, type, objfile)
double d = atof (p);
char *dbl_valu;
/* FIXME-if-picky-about-floating-accuracy: Should be using
target arithmetic to get the value. real.c in GCC
probably has the necessary code. */
/* FIXME: lookup_fundamental_type is a hack. We should be
creating a type especially for the type of float constants.
Problem is, what type should it be? We currently have to
read this in host floating point format, but what type
represents a host format "double"?
Problem is, what type should it be?
Also, what should the name of this type be? Should we
be using 'S' constants (see stabs.texinfo) instead? */
@ -625,11 +627,9 @@ define_symbol (valu, string, desc, type, objfile)
SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
FT_DBL_PREC_FLOAT);
dbl_valu = (char *)
obstack_alloc (&objfile -> symbol_obstack, sizeof (double));
memcpy (dbl_valu, &d, sizeof (double));
/* Put it in target byte order, but it's still in host
floating point format. */
SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double));
obstack_alloc (&objfile -> symbol_obstack,
TYPE_LENGTH (SYMBOL_TYPE (sym)));
store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym)));
SYMBOL_VALUE_BYTES (sym) = dbl_valu;
SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
}

View File

@ -594,49 +594,33 @@ unpack_long (type, valaddr)
register int len = TYPE_LENGTH (type);
register int nosign = TYPE_UNSIGNED (type);
if (code == TYPE_CODE_ENUM || code == TYPE_CODE_BOOL)
code = TYPE_CODE_INT;
if (code == TYPE_CODE_FLT)
switch (code)
{
if (len == sizeof (float))
{
float retval;
memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (double))
{
double retval;
memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
case TYPE_CODE_ENUM:
case TYPE_CODE_BOOL:
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
if (nosign)
return extract_unsigned_integer (valaddr, len);
else
{
error ("Unexpected type of floating point number.");
}
}
else if ((code == TYPE_CODE_INT || code == TYPE_CODE_CHAR) && nosign)
{
return extract_unsigned_integer (valaddr, len);
}
else if (code == TYPE_CODE_INT || code == TYPE_CODE_CHAR)
{
return extract_signed_integer (valaddr, len);
}
/* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure
whether we want this to be true eventually. */
else if (code == TYPE_CODE_PTR || code == TYPE_CODE_REF)
{
return extract_address (valaddr, len);
}
else if (code == TYPE_CODE_MEMBER)
error ("not implemented: member types in unpack_long");
return extract_signed_integer (valaddr, len);
error ("Value not integer or pointer.");
return 0; /* For lint -- never reached */
case TYPE_CODE_FLT:
return extract_floating (valaddr, len);
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
/* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure
whether we want this to be true eventually. */
return extract_address (valaddr, len);
case TYPE_CODE_MEMBER:
error ("not implemented: member types in unpack_long");
default:
error ("Value can't be converted to intenot integer or pointer.");
}
return 0; /* Placate lint. */
}
/* Return a double value from the specified type and address.
@ -663,27 +647,7 @@ unpack_double (type, valaddr, invp)
*invp = 1;
return 1.234567891011121314;
}
if (len == sizeof (float))
{
float retval;
memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (double))
{
double retval;
memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
else
{
error ("Unexpected type of floating point number.");
return 0; /* Placate lint. */
}
return extract_floating (valaddr, TYPE_LENGTH (type));
}
else if (nosign) {
/* Unsigned -- be sure we compensate for signed LONGEST. */
@ -1341,20 +1305,11 @@ value_from_double (type, num)
if (code == TYPE_CODE_FLT)
{
if (len == sizeof (float))
* (float *) VALUE_CONTENTS_RAW (val) = num;
else if (len == sizeof (double))
* (double *) VALUE_CONTENTS_RAW (val) = num;
else
error ("Floating type encountered with unexpected data length.");
store_floating (VALUE_CONTENTS_RAW (val), len, num);
}
else
error ("Unexpected type encountered for floating constant.");
/* num was in host byte order. So now put the value's contents
into target byte order. */
SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (val), len);
return val;
}