Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa(arm)/rfc] Eliminate HOST_{FLOAT,DOUBLE,...}_FORMAT
@ 2001-06-28 23:04 Andrew Cagney
  2001-06-29  5:16 ` Richard Earnshaw
       [not found] ` <5137-Fri29Jun2001120040+0300-eliz@is.elta.co.il>
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Cagney @ 2001-06-28 23:04 UTC (permalink / raw)
  To: gdb-patches

Hello,

The attatched should catch a few eyebrows :-)

The existing GDB tries to be smart about converting host/target floating 
point values - if it thinks that host-float == target-float then it just 
does a move instead of a conversion.

This patch eliminates the short cut.  Instead the conversion is always 
routed through floatformat_{to,from}_doublest().  The most telling 
comment and the reason this will probably catch a few eyebrows can be 
found in i387-tdep.c:

!   /* Avoid call to floatformat_to_doublest if possible to preserve as
!      much information as possible.  */

To me, the comment doesn't make sense.  If sizeof (host long double) == 
size of (target long double) and information is still being lost then I 
think floatformat_* has a bug.

As a side effect it also cleans up the ARM target-float -> 
target->double conversion so that it is more portable (well I think it is).

Comments?  Approval for the ARM part?  I can/should separate the arm 
part out.

	Andrew




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa(arm)/rfc] Eliminate HOST_{FLOAT,DOUBLE,...}_FORMAT
  2001-06-28 23:04 [rfa(arm)/rfc] Eliminate HOST_{FLOAT,DOUBLE,...}_FORMAT Andrew Cagney
@ 2001-06-29  5:16 ` Richard Earnshaw
  2001-06-29  8:43   ` Andrew Cagney
       [not found] ` <5137-Fri29Jun2001120040+0300-eliz@is.elta.co.il>
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Earnshaw @ 2001-06-29  5:16 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches, Richard.Earnshaw

> Hello,
> 
> The attatched should catch a few eyebrows :-)
> 
> The existing GDB tries to be smart about converting host/target floating 
> point values - if it thinks that host-float == target-float then it just 
> does a move instead of a conversion.
> 
> This patch eliminates the short cut.  Instead the conversion is always 
> routed through floatformat_{to,from}_doublest().  The most telling 
> comment and the reason this will probably catch a few eyebrows can be 
> found in i387-tdep.c:
> 
> !   /* Avoid call to floatformat_to_doublest if possible to preserve as
> !      much information as possible.  */
> 
> To me, the comment doesn't make sense.  If sizeof (host long double) == 
> size of (target long double) and information is still being lost then I 
> think floatformat_* has a bug.
> 
> As a side effect it also cleans up the ARM target-float -> 
> target->double conversion so that it is more portable (well I think it is).
> 
> Comments?  Approval for the ARM part?  I can/should separate the arm 
> part out.

The ARM part looks like a good move to me (not that that need count for 
anything).  Overall, it all looks pretty sensible...

R.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa(arm)/rfc] Eliminate HOST_{FLOAT,DOUBLE,...}_FORMAT
       [not found] ` <5137-Fri29Jun2001120040+0300-eliz@is.elta.co.il>
@ 2001-06-29  8:31   ` Andrew Cagney
  2001-06-29  9:01     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Cagney @ 2001-06-29  8:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

> To me, the comment doesn't make sense.  If sizeof (host long double) == 
>> size of (target long double) and information is still being lost then I 
>> think floatformat_* has a bug.
> 
> 
> You could lose information if the original value's bit pattern is not
> a valid FP number.  Does floatformat_to_doublest handle these
> situations 110% correctly?  I see at least one FIXME comment in the
> code there.


At present this loss happens randomly depending on the host / target 
combination.  I would prefer GDB to at least have slightly more 
consistent behavour.

The next step would be to ramp up sim/common/sim-fpu.[hc] and use that 
for all FP caculations.

--

Anyway, looking at the code, yes there are several nasty errors:

   unsigned long mant;

should be ULONGEST so that it fits a 64 bit mantisa and:

       dto += ldexp ((double) mant, exponent - mant_bits);

unfortunatly doesn't take a ``long double''.

   /* Note that if exponent indicates a NaN, we can't really do anything 
useful
      (not knowing if the host has NaN's, or how to build one).  So it will
      end up as an infinity or something close; that is OK.  */


sigh.

	Andrew





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa(arm)/rfc] Eliminate HOST_{FLOAT,DOUBLE,...}_FORMAT
  2001-06-29  5:16 ` Richard Earnshaw
@ 2001-06-29  8:43   ` Andrew Cagney
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2001-06-29  8:43 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: gdb-patches

> The ARM part looks like a good move to me (not that that need count for 
> anything).  Overall, it all looks pretty sensible...


Ok.  I'll check the arm part in and then re-think the more general changes.

	Andrew




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa(arm)/rfc] Eliminate HOST_{FLOAT,DOUBLE,...}_FORMAT
  2001-06-29  8:31   ` Andrew Cagney
@ 2001-06-29  9:01     ` Eli Zaretskii
  2001-06-29  9:12       ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2001-06-29  9:01 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

> Date: Fri, 29 Jun 2001 11:17:23 -0400
> From: Andrew Cagney <ac131313@cygnus.com>
> > 
> > You could lose information if the original value's bit pattern is not
> > a valid FP number.  Does floatformat_to_doublest handle these
> > situations 110% correctly?  I see at least one FIXME comment in the
> > code there.
> 
> 
> At present this loss happens randomly depending on the host / target 
> combination.  I would prefer GDB to at least have slightly more 
> consistent behavour.

I agree with the goal, but I don't think we could explain to users of
native debuggers that they have NaN's being converted to Inf's in the
name of consistency ;-)

>  /* Note that if exponent indicates a NaN, we can't really do anything useful
>     (not knowing if the host has NaN's, or how to build one).  So it will
>     end up as an infinity or something close; that is OK.  */

Perhaps we should allow each native platform to provide a function
that produces a NaN for every FP type it supports?  Then utils.c won't
need to bother about doing things it doesn't know about.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa(arm)/rfc] Eliminate HOST_{FLOAT,DOUBLE,...}_FORMAT
  2001-06-29  9:01     ` Eli Zaretskii
@ 2001-06-29  9:12       ` Andrew Cagney
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2001-06-29  9:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

>  /* Note that if exponent indicates a NaN, we can't really do anything useful
>> (not knowing if the host has NaN's, or how to build one).  So it will
>> end up as an infinity or something close; that is OK.  */
> 
> 
> Perhaps we should allow each native platform to provide a function
> that produces a NaN for every FP type it supports?  Then utils.c won't
> need to bother about doing things it doesn't know about.


We've already (almost) got this.  sim/common/sim_fpu.[ch] portably 
implements exact IEEE floating point (it ``just'' lacks support for 80 
floats).

	Andrew



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-06-29  9:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-28 23:04 [rfa(arm)/rfc] Eliminate HOST_{FLOAT,DOUBLE,...}_FORMAT Andrew Cagney
2001-06-29  5:16 ` Richard Earnshaw
2001-06-29  8:43   ` Andrew Cagney
     [not found] ` <5137-Fri29Jun2001120040+0300-eliz@is.elta.co.il>
2001-06-29  8:31   ` Andrew Cagney
2001-06-29  9:01     ` Eli Zaretskii
2001-06-29  9:12       ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox