This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Simulation of MIPS recip and rsqrt instructions


cgd@broadcom.com writes:
> In adding those calls to sim_fpu_inv() I did not notice the changes to
> sim_fpu_inv() in our source which replace its entire body with:
> 
> #if 0
> 	... old body ...
> #else
>   const sim_fpu sim_fpu_one = {
>     sim_fpu_class_number, 0, IMPLICIT_1, 0
>   };  
>   return sim_fpu_div (f, &sim_fpu_one, r, sim_fpu_round_default);
> #endif
> 
> 8-)

Ah. ;)  Out of interest, how come you're using these local constants?
I noticed the same thing in cp1.c.  Is it just supposed to lead to
better optimisation than the global sim_fpu_one?

> > Unfortunately, sim_fpu_inv isn't commented and cp1.c seems to be
> > its only active user.  Which should change?
> 
> For small values of only.  8-)
> 
> common/cgen-accfp.c seems to use it as well for "invsf" and "invdf".

Yeah, but nothing seems to use invsf and invdf.  AFAICT, the mips
port really is the only active user.

> Anybody got a clue as to what the cgen-accfp.c 'invsf' and 'invdf' fns
> are supposed to do?

Not me.  I looked at the cgen docs, but it didn't mention it
explicitly.  But like you & Andrew say, it's probably better
to patch sim_fpu_inv().  Please install my second patch if it's
OK.  I realise I missed the change log first time, so here it
is again.

Richard

	* sim-fpu.c (sim_fpu_inv): Use sim_fpu_div.

Index: sim/common/sim-fpu.c
===================================================================
RCS file: /cvs/src/src/sim/common/sim-fpu.c,v
retrieving revision 1.4
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.4 sim-fpu.c
*** sim/common/sim-fpu.c	12 Jun 2002 00:46:11 -0000	1.4
--- sim/common/sim-fpu.c	26 Nov 2002 20:33:46 -0000
*************** INLINE_SIM_FPU (int)
*** 1754,1786 ****
  sim_fpu_inv (sim_fpu *f,
  	     const sim_fpu *r)
  {
!   if (sim_fpu_is_snan (r))
!     {
!       *f = *r;
!       f->class = sim_fpu_class_qnan;
!       return sim_fpu_status_invalid_snan;
!     }
!   if (sim_fpu_is_qnan (r))
!     {
!       *f = *r;
!       f->class = sim_fpu_class_qnan;
!       return 0;
!     }
!   if (sim_fpu_is_infinity (r))
!     {
!       *f = sim_fpu_zero;
!       f->sign = r->sign;
!       return 0;
!     }
!   if (sim_fpu_is_zero (r))
!     {
!       f->class = sim_fpu_class_infinity;
!       f->sign = r->sign;
!       return sim_fpu_status_invalid_div0;
!     }
!   *f = *r;
!   f->normal_exp = - r->normal_exp;
!   return 0;
  }
  
  
--- 1754,1760 ----
  sim_fpu_inv (sim_fpu *f,
  	     const sim_fpu *r)
  {
!   return sim_fpu_div (f, &sim_fpu_one, r);
  }
  
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]