* 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) Fri Oct 29 09:31:38 1993 Steve Chamberlain (sac@rtl.cygnus.com)
* remote-sim.c (gdbsim_store_register): Change var name so * 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; 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) \ double val; \
ieee_extended_to_double (&ext_format_i960, (FROM), (double *)(TO)); \ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
else \ { \
ieee_extended_to_double (&ext_format_i960, (FROM), &val); \
store_floating ((TO), REGISTER_VIRTUAL_SIZE (REGNUM), val); \
} \
else \
memcpy ((TO), (FROM), 4); \ memcpy ((TO), (FROM), 4); \
} }
/* Convert data from virtual format for register REGNUM /* Convert data from virtual format for register REGNUM
to raw 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) \ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
double_to_ieee_extended (&ext_format_i960, (double *)(FROM), (TO)); \ { \
else \ double val = extract_floating ((FROM), REGISTER_VIRTUAL_SIZE (REGNUM)); \
memcpy ((TO), (FROM), 4); \ double_to_ieee_extended (&ext_format_i960, &val, (TO)); \
} \
else \
memcpy ((TO), (FROM), 4); \
} }
/* Return the GDB type object for the "standard" data type /* Return the GDB type object for the "standard" data type
of data in register N. */ 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) \ #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
{ \ { \
if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ double val; \
ieee_extended_to_double (&ext_format_68881, (FROM), (double *)(TO)); \ 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 \ else \
memcpy ((TO), (FROM), 4); \ memcpy ((TO), (FROM), 4); \
} }
@ -168,7 +172,10 @@ extern const struct ext_format ext_format_68881;
#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
{ \ { \
if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ 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 \ else \
memcpy ((TO), (FROM), 4); \ memcpy ((TO), (FROM), 4); \
} }

View file

@ -386,10 +386,13 @@ if (!target_is_m88110) \
#define REGISTER_CONVERTIBLE(N) ((N) >= XFP_REGNUM) #define REGISTER_CONVERTIBLE(N) ((N) >= XFP_REGNUM)
/* Convert data from raw format for register REGNUM extern const struct ext_format ext_format_m88110;
to virtual format for register REGNUM. */
/* 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) \ #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
{ \ { \
if ((REGNUM) < XFP_REGNUM) \ if ((REGNUM) < XFP_REGNUM) \
@ -401,6 +404,8 @@ if (!target_is_m88110) \
/* Convert data from virtual format for register REGNUM /* Convert data from virtual format for register REGNUM
to raw 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) \ #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
{ \ { \
if ((REGNUM) < XFP_REGNUM) \ if ((REGNUM) < XFP_REGNUM) \

View file

@ -472,7 +472,7 @@ nindy_store_registers(regno)
int regno; int regno;
{ {
struct nindy_regs nindy_regs; struct nindy_regs nindy_regs;
int regnum, inv; int regnum;
double dub; double dub;
memcpy (nindy_regs.local_regs, &registers[REGISTER_BYTE (R0_REGNUM)], 16*4); 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.pcw_acw, &registers[REGISTER_BYTE (PCW_REGNUM)], 2*4);
memcpy (nindy_regs.ip, &registers[REGISTER_BYTE (IP_REGNUM)], 1*4); memcpy (nindy_regs.ip, &registers[REGISTER_BYTE (IP_REGNUM)], 1*4);
memcpy (nindy_regs.tcw, &registers[REGISTER_BYTE (TCW_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++)
for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++) { {
ieee_extended_to_double (&ext_format_i960, ieee_extended_to_double (&ext_format_i960,
&registers[REGISTER_BYTE (regnum)], &dub); &registers[REGISTER_BYTE (regnum)], &dub);
/* dub now in host byte order */ store_floating (&nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)],
/* FIXME-someday, the arguments to unpack_double are backward. REGISTER_VIRTUAL_SIZE (regnum),
It expects a target double and returns a host; we pass the opposite. dub);
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);
}
immediate_quit++; immediate_quit++;
ninRegsPut( (char *) &nindy_regs ); ninRegsPut( (char *) &nindy_regs );

View file

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

View file

@ -594,49 +594,33 @@ unpack_long (type, valaddr)
register int len = TYPE_LENGTH (type); register int len = TYPE_LENGTH (type);
register int nosign = TYPE_UNSIGNED (type); register int nosign = TYPE_UNSIGNED (type);
if (code == TYPE_CODE_ENUM || code == TYPE_CODE_BOOL) switch (code)
code = TYPE_CODE_INT;
if (code == TYPE_CODE_FLT)
{ {
if (len == sizeof (float)) case TYPE_CODE_ENUM:
{ case TYPE_CODE_BOOL:
float retval; case TYPE_CODE_INT:
memcpy (&retval, valaddr, sizeof (retval)); case TYPE_CODE_CHAR:
SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); if (nosign)
return retval; return extract_unsigned_integer (valaddr, len);
}
if (len == sizeof (double))
{
double retval;
memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
else else
{ return extract_signed_integer (valaddr, len);
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");
error ("Value not integer or pointer."); case TYPE_CODE_FLT:
return 0; /* For lint -- never reached */ 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. /* Return a double value from the specified type and address.
@ -663,27 +647,7 @@ unpack_double (type, valaddr, invp)
*invp = 1; *invp = 1;
return 1.234567891011121314; return 1.234567891011121314;
} }
return extract_floating (valaddr, TYPE_LENGTH (type));
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. */
}
} }
else if (nosign) { else if (nosign) {
/* Unsigned -- be sure we compensate for signed LONGEST. */ /* Unsigned -- be sure we compensate for signed LONGEST. */
@ -1341,20 +1305,11 @@ value_from_double (type, num)
if (code == TYPE_CODE_FLT) if (code == TYPE_CODE_FLT)
{ {
if (len == sizeof (float)) store_floating (VALUE_CONTENTS_RAW (val), len, num);
* (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.");
} }
else else
error ("Unexpected type encountered for floating constant."); 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; return val;
} }