[patch][commit] Extend cgen-fpu Implementation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[patch][commit] Extend cgen-fpu Implementation

Dave Brolley-2
I've committed this patch which implementes some of the unimplemented
fpu and fp methods.

Dave


2006-05-10  Dave Brolley  <[hidden email]>

        * fp.cxx (fp::integer (long long&, round_mode_t)): New method.
        (fp::integer (unsigned long long&, round_mode_t)): New method.
        * fp.h: Likewise.
        * cgen-fpu.cxx (unorderedsf): New method.
        (adddf, subdf, muldf, divdf, negdf, absdf, sqrtdf): Implemented.
        (eqdf, ltdf, ledf, gtdf, gedf, gedf): Implemented.
        (unordereddf): New method.
        (unordereddf, fextsfdf): Implemented.
        (floatdisf, fixsfsi, fixsfdi, floatsidf, floatdidf, fixdfsi)
        (fixdfdi): Implemented.
        * cgen-fpu.h: Likewise.

Index: sid/component/cgen-cpu/cgen-fpu.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/cgen-fpu.cxx,v
retrieving revision 1.1
diff -c -p -r1.1 cgen-fpu.cxx
*** sid/component/cgen-cpu/cgen-fpu.cxx 19 Aug 2005 19:01:51 -0000 1.1
--- sid/component/cgen-cpu/cgen-fpu.cxx 10 May 2006 21:06:12 -0000
*************** int cgen_fp_ops::gesf (cgen_fpu*, SF x,
*** 114,146 ****
    return fp (x) >= fp (y);
  }
 
! #if 0
  /* basic DF ops */
! DF cgen_fp_ops::adddf (cgen_fpu*, DF, DF);
! DF cgen_fp_ops::subdf (cgen_fpu*, DF, DF);
! DF cgen_fp_ops::muldf (cgen_fpu*, DF, DF);
! DF cgen_fp_ops::divdf (cgen_fpu*, DF, DF);
! DF cgen_fp_ops::negdf (cgen_fpu*, DF);
! DF cgen_fp_ops::absdf (cgen_fpu*, DF);
! DF cgen_fp_ops::sqrtdf (cgen_fpu*, DF);
  DF cgen_fp_ops::invdf (cgen_fpu*, DF);
  DF cgen_fp_ops::cosdf (cgen_fpu*, DF);
  DF cgen_fp_ops::sindf (cgen_fpu*, DF);
  DF cgen_fp_ops::mindf (cgen_fpu*, DF, DF);
  DF cgen_fp_ops::maxdf (cgen_fpu*, DF, DF);
 
! int cgen_fp_ops::eqdf (cgen_fpu*, DF, DF);
! int cgen_fp_ops::nedf (cgen_fpu*, DF, DF);
! int cgen_fp_ops::ltdf (cgen_fpu*, DF, DF);
! int cgen_fp_ops::ledf (cgen_fpu*, DF, DF);
! int cgen_fp_ops::gtdf (cgen_fpu*, DF, DF);
! int cgen_fp_ops::gedf (cgen_fpu*, DF, DF);
!
!   /* SF/DF conversion ops */
! DF cgen_fp_ops::fextsfdf (cgen_fpu*, SF);
! SF cgen_fp_ops::ftruncdfsf (cgen_fpu*, DF);
 
- #endif // not implemented yet
  SF cgen_fp_ops::floatsisf (cgen_fpu* fpu, SI x)
  {
    fp r = fp::from_int (x);
--- 114,251 ----
    return fp (x) >= fp (y);
  }
 
! int cgen_fp_ops::unorderedsf (cgen_fpu*, SF x, SF y)
! {
!   fp f1(x);
!   fp f2(y);
!   return f1.is_nan () || f2.is_nan ();
! }
!
  /* basic DF ops */
! DF cgen_fp_ops::adddf (cgen_fpu *fpu, DF x, DF y)
! {
!   fp r = fp (x) + fp (y);
!   check_result (fpu, r);
!   DF tmp;
!   r.pack (tmp);
!   return tmp;
! }
!
! DF cgen_fp_ops::subdf (cgen_fpu *fpu, DF x, DF y)
! {
!   fp r = fp (x) - fp (y);
!   check_result (fpu, r);
!   DF tmp;
!   r.pack (tmp);
!   return tmp;
! }
!
! DF cgen_fp_ops::muldf (cgen_fpu *fpu, DF x, DF y)
! {
!   fp r = fp (x) * fp (y);
!   check_result (fpu, r);
!   DF tmp;
!   r.pack (tmp);
!   return tmp;
! }
!
! DF cgen_fp_ops::divdf (cgen_fpu *fpu, DF x, DF y)
! {
!   fp r = fp (x) / fp (y);
!   check_result (fpu, r);
!   DF tmp;
!   r.pack (tmp);
!   return tmp;
! }
!
! DF cgen_fp_ops::negdf (cgen_fpu *fpu, DF x)
! {
!   fp r (x);
!   r = fp::neg (r);
!   check_result (fpu, r);
!   DF tmp;
!   r.pack (tmp);
!   return tmp;
! }
!
! DF cgen_fp_ops::absdf (cgen_fpu *fpu, DF x)
! {
!   fp r (x);
!   r = fp::abs (r);
!   check_result (fpu, r);
!   DF tmp;
!   r.pack (tmp);
!   return tmp;
! }
!
! DF cgen_fp_ops::sqrtdf (cgen_fpu *fpu, DF x)
! {
!   fp r (x);
!   r = fp::sqrt (r);
!   check_result (fpu, r);
!   DF tmp;
!   r.pack (tmp);
!   return tmp;
! }
!
! #if 0
  DF cgen_fp_ops::invdf (cgen_fpu*, DF);
  DF cgen_fp_ops::cosdf (cgen_fpu*, DF);
  DF cgen_fp_ops::sindf (cgen_fpu*, DF);
  DF cgen_fp_ops::mindf (cgen_fpu*, DF, DF);
  DF cgen_fp_ops::maxdf (cgen_fpu*, DF, DF);
+ #endif
 
! int cgen_fp_ops::eqdf (cgen_fpu *fpu, DF x, DF y)
! {
!   return fp (x) == fp (y);
! }
!
! int cgen_fp_ops::nedf (cgen_fpu *fpu, DF x, DF y)
! {
!   return fp (x) == fp (y);
! }
! int cgen_fp_ops::ltdf (cgen_fpu *fpu, DF x, DF y)
! {
!   return fp (x) < fp (y);
! }
! int cgen_fp_ops::ledf (cgen_fpu *fpu, DF x, DF y)
! {
!   return fp (x) <= fp (y);
! }
! int cgen_fp_ops::gtdf (cgen_fpu *fpu, DF x, DF y)
! {
!   return fp (x) > fp (y);
! }
! int cgen_fp_ops::gedf (cgen_fpu *fpu, DF x, DF y)
! {
!   return fp (x) >= fp (y);
! }
!
! int cgen_fp_ops::unordereddf (cgen_fpu *fpu, DF x, DF y)
! {
!   fp f1(x);
!   fp f2(y);
!   return f1.is_nan () || f2.is_nan ();
! }
!
! /* SF/DF conversion ops */
! DF cgen_fp_ops::fextsfdf (cgen_fpu *fpu, SF x)
! {
!   fp r (x);
!   DF tmp;
!   r.pack (tmp);
!   return tmp;
! }
!
! SF cgen_fp_ops::ftruncdfsf (cgen_fpu *fpu, DF x)
! {
!   fp r (x);
!   SF tmp;
!   r.pack (tmp);
!   return tmp;
! }
 
  SF cgen_fp_ops::floatsisf (cgen_fpu* fpu, SI x)
  {
    fp r = fp::from_int (x);
*************** SF cgen_fp_ops::floatsisf (cgen_fpu* fpu
*** 149,179 ****
    r.pack (tmp);
    return tmp;
  }
  #if 0 // not implemented yet
- SF cgen_fp_ops::floatdisf (cgen_fpu*, DI);
  SF cgen_fp_ops::ufloatsisf (cgen_fpu*, USI);
  SF cgen_fp_ops::ufloatdisf (cgen_fpu*, UDI);
  #endif // not implemented yet
 
! SI cgen_fp_ops::fixsfsi (cgen_fpu*, SF x)
  {
    fp r (x);
!   unsigned int tmp;
    r.integer (tmp, fp::round_default);
    return tmp;
  }
  #if 0 // not implemented yet
- DI cgen_fp_ops::fixsfdi (cgen_fpu*, SF);
  USI cgen_fp_ops::ufixsfsi (cgen_fpu*, SF)
  UDI cgen_fp_ops::ufixsfdi (cgen_fpu*, SF);
 
! DF cgen_fp_ops::floatsidf (cgen_fpu*, SI);
! DF cgen_fp_ops::floatdidf (cgen_fpu*, DI);
  DF cgen_fp_ops::ufloatsidf (cgen_fpu*, USI);
  DF cgen_fp_ops::ufloatdidf (cgen_fpu*, UDI);
 
! SI cgen_fp_ops::fixdfsi (cgen_fpu*, DF);
! DI cgen_fp_ops::fixdfdi (cgen_fpu*, DF);
  USI cgen_fp_ops::ufixdfsi (cgen_fpu*, DF);
  UDI cgen_fp_ops::ufixdfdi (cgen_fpu*, DF);
 
--- 254,333 ----
    r.pack (tmp);
    return tmp;
  }
+
+ SF cgen_fp_ops::floatdisf (cgen_fpu *fpu, DI x)
+ {
+   fp r = fp::from_int (x);
+   check_result (fpu, r);
+   DF tmp;
+   r.pack (tmp);
+   return tmp;
+ }
+
  #if 0 // not implemented yet
  SF cgen_fp_ops::ufloatsisf (cgen_fpu*, USI);
  SF cgen_fp_ops::ufloatdisf (cgen_fpu*, UDI);
  #endif // not implemented yet
 
! SI cgen_fp_ops::fixsfsi (cgen_fpu *fpu, SF x)
! {
!   fp r (x);
!   SI tmp;
!   r.integer (tmp, fp::round_default);
!   return tmp;
! }
!
! DI cgen_fp_ops::fixsfdi (cgen_fpu *fpu, SF x)
  {
    fp r (x);
!   DI tmp;
    r.integer (tmp, fp::round_default);
    return tmp;
  }
+
  #if 0 // not implemented yet
  USI cgen_fp_ops::ufixsfsi (cgen_fpu*, SF)
  UDI cgen_fp_ops::ufixsfdi (cgen_fpu*, SF);
+ #endif
+ DF cgen_fp_ops::floatsidf (cgen_fpu *fpu, SI x)
+ {
+   fp r = fp::from_int (x);
+   check_result (fpu, r);
+   DF tmp;
+   r.pack (tmp);
+   return tmp;
+ }
+
+ DF cgen_fp_ops::floatdidf (cgen_fpu *fpu, DI x)
+ {
+   fp r = fp::from_int (x);
+   check_result (fpu, r);
+   DF tmp;
+   r.pack (tmp);
+   return tmp;
+ }
 
! #if 0
  DF cgen_fp_ops::ufloatsidf (cgen_fpu*, USI);
  DF cgen_fp_ops::ufloatdidf (cgen_fpu*, UDI);
+ #endif
+ SI cgen_fp_ops::fixdfsi (cgen_fpu *fpu, DF x)
+ {
+   fp r (x);
+   SI tmp;
+   r.integer (tmp, fp::round_default);
+   return tmp;
+ }
 
! DI cgen_fp_ops::fixdfdi (cgen_fpu *fpu, DF x)
! {
!   fp r (x);
!   DI tmp;
!   r.integer (tmp, fp::round_default);
!   return tmp;
! }
!
! #if 0
  USI cgen_fp_ops::ufixdfsi (cgen_fpu*, DF);
  UDI cgen_fp_ops::ufixdfdi (cgen_fpu*, DF);
 
Index: sid/component/cgen-cpu/cgen-fpu.h
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/cgen-fpu.h,v
retrieving revision 1.1
diff -c -p -r1.1 cgen-fpu.h
*** sid/component/cgen-cpu/cgen-fpu.h 19 Aug 2005 19:01:51 -0000 1.1
--- sid/component/cgen-cpu/cgen-fpu.h 10 May 2006 21:06:12 -0000
*************** public:
*** 46,53 ****
    virtual int lesf (cgen_fpu*, SF, SF);
    virtual int gtsf (cgen_fpu*, SF, SF);
    virtual int gesf (cgen_fpu*, SF, SF);
 
- #if 0
    /* basic DF ops */
    virtual DF adddf (cgen_fpu*, DF, DF);
    virtual DF subdf (cgen_fpu*, DF, DF);
--- 46,53 ----
    virtual int lesf (cgen_fpu*, SF, SF);
    virtual int gtsf (cgen_fpu*, SF, SF);
    virtual int gesf (cgen_fpu*, SF, SF);
+   virtual int unorderedsf (cgen_fpu*, SF, SF);
 
    /* basic DF ops */
    virtual DF adddf (cgen_fpu*, DF, DF);
    virtual DF subdf (cgen_fpu*, DF, DF);
*************** public:
*** 56,99 ****
    virtual DF negdf (cgen_fpu*, DF);
    virtual DF absdf (cgen_fpu*, DF);
    virtual DF sqrtdf (cgen_fpu*, DF);
    virtual DF invdf (cgen_fpu*, DF);
    virtual DF cosdf (cgen_fpu*, DF);
    virtual DF sindf (cgen_fpu*, DF);
    virtual DF mindf (cgen_fpu*, DF, DF);
    virtual DF maxdf (cgen_fpu*, DF, DF);
!
    virtual int eqdf (cgen_fpu*, DF, DF);
    virtual int nedf (cgen_fpu*, DF, DF);
    virtual int ltdf (cgen_fpu*, DF, DF);
    virtual int ledf (cgen_fpu*, DF, DF);
    virtual int gtdf (cgen_fpu*, DF, DF);
    virtual int gedf (cgen_fpu*, DF, DF);
 
    /* SF/DF conversion ops */
    virtual DF fextsfdf (cgen_fpu*, SF);
    virtual SF ftruncdfsf (cgen_fpu*, DF);
- #endif // not implemented yet
 
    virtual SF floatsisf (cgen_fpu*, SI);
- #if 0 // not implemented yet
    virtual SF floatdisf (cgen_fpu*, DI);
    virtual SF ufloatsisf (cgen_fpu*, USI);
    virtual SF ufloatdisf (cgen_fpu*, UDI);
  #endif // not implemented yet
 
    virtual SI fixsfsi (cgen_fpu*, SF);
- #if 0 // not implemented yet
    virtual DI fixsfdi (cgen_fpu*, SF);
    virtual USI ufixsfsi (cgen_fpu*, SF);
    virtual UDI ufixsfdi (cgen_fpu*, SF);
!
    virtual DF floatsidf (cgen_fpu*, SI);
    virtual DF floatdidf (cgen_fpu*, DI);
    virtual DF ufloatsidf (cgen_fpu*, USI);
    virtual DF ufloatdidf (cgen_fpu*, UDI);
!
    virtual SI fixdfsi (cgen_fpu*, DF);
    virtual DI fixdfdi (cgen_fpu*, DF);
    virtual USI ufixdfsi (cgen_fpu*, DF);
    virtual UDI ufixdfdi (cgen_fpu*, DF);
 
--- 56,102 ----
    virtual DF negdf (cgen_fpu*, DF);
    virtual DF absdf (cgen_fpu*, DF);
    virtual DF sqrtdf (cgen_fpu*, DF);
+ #if 0
    virtual DF invdf (cgen_fpu*, DF);
    virtual DF cosdf (cgen_fpu*, DF);
    virtual DF sindf (cgen_fpu*, DF);
    virtual DF mindf (cgen_fpu*, DF, DF);
    virtual DF maxdf (cgen_fpu*, DF, DF);
! #endif
    virtual int eqdf (cgen_fpu*, DF, DF);
    virtual int nedf (cgen_fpu*, DF, DF);
    virtual int ltdf (cgen_fpu*, DF, DF);
    virtual int ledf (cgen_fpu*, DF, DF);
    virtual int gtdf (cgen_fpu*, DF, DF);
    virtual int gedf (cgen_fpu*, DF, DF);
+   virtual int unordereddf (cgen_fpu*, DF, DF);
 
    /* SF/DF conversion ops */
    virtual DF fextsfdf (cgen_fpu*, SF);
    virtual SF ftruncdfsf (cgen_fpu*, DF);
 
    virtual SF floatsisf (cgen_fpu*, SI);
    virtual SF floatdisf (cgen_fpu*, DI);
+ #if 0 // not implemented yet
    virtual SF ufloatsisf (cgen_fpu*, USI);
    virtual SF ufloatdisf (cgen_fpu*, UDI);
  #endif // not implemented yet
 
    virtual SI fixsfsi (cgen_fpu*, SF);
    virtual DI fixsfdi (cgen_fpu*, SF);
+ #if 0 // not implemented yet
    virtual USI ufixsfsi (cgen_fpu*, SF);
    virtual UDI ufixsfdi (cgen_fpu*, SF);
! #endif
    virtual DF floatsidf (cgen_fpu*, SI);
    virtual DF floatdidf (cgen_fpu*, DI);
+ #if 0
    virtual DF ufloatsidf (cgen_fpu*, USI);
    virtual DF ufloatdidf (cgen_fpu*, UDI);
! #endif
    virtual SI fixdfsi (cgen_fpu*, DF);
    virtual DI fixdfdi (cgen_fpu*, DF);
+ #if 0
    virtual USI ufixdfsi (cgen_fpu*, DF);
    virtual UDI ufixdfdi (cgen_fpu*, DF);
 
Index: sid/component/cgen-cpu/fp.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/fp.cxx,v
retrieving revision 1.3
diff -c -p -r1.3 fp.cxx
*** sid/component/cgen-cpu/fp.cxx 19 Aug 2005 19:01:51 -0000 1.3
--- sid/component/cgen-cpu/fp.cxx 10 May 2006 21:06:12 -0000
***************
*** 1,6 ****
  // fp.cxx - Floating point number class implementation. -*- C++ -*-
 
! // Copyright 1997, 1998, 2002, 2005 Free Software Foundation, Inc.
  // Copyright 2002 Red Hat, Inc.
  // This file is part of SID.
 
--- 1,6 ----
  // fp.cxx - Floating point number class implementation. -*- C++ -*-
 
! // Copyright 1997, 1998, 2002, 2005, 2006 Free Software Foundation, Inc.
  // Copyright 2002 Red Hat, Inc.
  // This file is part of SID.
 
*************** namespace sidutil
*** 754,759 ****
--- 754,765 ----
    }
 
    void
+   fp::integer (long long& i, round_mode_t mode)
+   {
+     fp_to_int (i, mode);
+   }
+
+   void
    fp::integer (unsigned int& i, round_mode_t mode)
    {
      fp_to_int (i, mode);
*************** namespace sidutil
*** 765,770 ****
--- 771,782 ----
      fp_to_int (i, mode);
    }
 
+   void
+   fp::integer (unsigned long long& i, round_mode_t mode)
+   {
+     fp_to_int (i, mode);
+   }
+
    std::ostream& operator<< (std::ostream& out, const fp& f)
    {
      out << ((f.sign) ? "-" : "+");
Index: sid/component/cgen-cpu/fp.h
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/fp.h,v
retrieving revision 1.3
diff -c -p -r1.3 fp.h
*** sid/component/cgen-cpu/fp.h 19 Aug 2005 19:01:51 -0000 1.3
--- sid/component/cgen-cpu/fp.h 10 May 2006 21:06:12 -0000
***************
*** 1,6 ****
  // fp.h - Floating point number class using host integer ops.  -*- C++ -*-
 
! // Copyright 1997, 1998, 2002, 2005 Free Software Foundation, Inc.
  // Copyright 2002 Red Hat, Inc.
  // This file is part of SID.
 
--- 1,6 ----
  // fp.h - Floating point number class using host integer ops.  -*- C++ -*-
 
! // Copyright 1997, 1998, 2002, 2005, 2006 Free Software Foundation, Inc.
  // Copyright 2002 Red Hat, Inc.
  // This file is part of SID.
 
*************** namespace sidutil
*** 259,266 ****
--- 259,268 ----
        // Conversions to integers.
        virtual void integer (int&, round_mode_t = round_default);
        virtual void integer (long&, round_mode_t = round_default);
+       virtual void integer (long long&, round_mode_t = round_default);
        virtual void integer (unsigned int&, round_mode_t = round_default);
        virtual void integer (unsigned long&, round_mode_t = round_default);
+       virtual void integer (unsigned long long&, round_mode_t = round_default);
 
        // Pack an fp into registers of various sizes.
        void pack (cgen::SF&) const;