Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add IEEE FP mode control functions and definitions for SH5.



details:   https://anonhg.NetBSD.org/src/rev/62c43d09d00c
branches:  trunk
changeset: 533997:62c43d09d00c
user:      scw <scw%NetBSD.org@localhost>
date:      Fri Jul 12 12:20:24 2002 +0000

description:
Add IEEE FP mode control functions and definitions for SH5.

diffstat:

 lib/libc/arch/sh5/gen/Makefile.inc  |   5 ++++-
 lib/libc/arch/sh5/gen/fpgetmask.S   |  21 +++++++++++++++++++++
 lib/libc/arch/sh5/gen/fpgetround.S  |  21 +++++++++++++++++++++
 lib/libc/arch/sh5/gen/fpgetsticky.S |  21 +++++++++++++++++++++
 lib/libc/arch/sh5/gen/fpsetmask.S   |  28 ++++++++++++++++++++++++++++
 lib/libc/arch/sh5/gen/fpsetround.S  |  28 ++++++++++++++++++++++++++++
 lib/libc/arch/sh5/gen/fpsetsticky.S |  28 ++++++++++++++++++++++++++++
 sys/arch/sh5/include/ieeefp.h       |  22 +++++++++++-----------
 8 files changed, 162 insertions(+), 12 deletions(-)

diffs (230 lines):

diff -r ee0e1376eefe -r 62c43d09d00c lib/libc/arch/sh5/gen/Makefile.inc
--- a/lib/libc/arch/sh5/gen/Makefile.inc        Fri Jul 12 11:20:12 2002 +0000
+++ b/lib/libc/arch/sh5/gen/Makefile.inc        Fri Jul 12 12:20:24 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.3 2002/07/11 14:23:05 scw Exp $
+#      $NetBSD: Makefile.inc,v 1.4 2002/07/12 12:20:25 scw Exp $
 
 SRCS+= __setjmp14.S __sigsetjmp14.S _setjmp.S \
        alloca.S \
@@ -8,5 +8,8 @@
 SRCS+= ieee754_frexp.c ieee754_infinity.c ieee754_isinf.c ieee754_isnan.c \
        ieee754_ldexp.c ieee754_modf.c ieee754_nanf.c
 
+SRCS+= fpgetmask.S fpgetround.S fpgetsticky.S \
+       fpsetmask.S fpsetround.S fpsetsticky.S
+
 LSRCS+= Lint_bswap16.c Lint_bswap32.c Lint_bswap64.c
 DPSRCS+= Lint_bswap16.c Lint_bswap32.c Lint_bswap64.c
diff -r ee0e1376eefe -r 62c43d09d00c lib/libc/arch/sh5/gen/fpgetmask.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/sh5/gen/fpgetmask.S Fri Jul 12 12:20:24 2002 +0000
@@ -0,0 +1,21 @@
+/*     $NetBSD: fpgetmask.S,v 1.1 2002/07/12 12:20:25 scw Exp $        */
+
+/*
+ * Written by Steve C. Woodford at Wasabi Systems for NetBSD.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpgetmask,_fpgetmask)
+ENTRY(_fpgetmask)
+#else
+ENTRY(fpgetmask)
+#endif
+       fgetscr fr0
+       ptabs/l r18, tr0
+       fmov.sl fr0, r2
+       shlri   r2, 7, r2       /* Get Enable mask to low bits */
+       andi    r2, 0x1f, r2    /* Zap unwanted bits */
+       blink   tr0, r63
diff -r ee0e1376eefe -r 62c43d09d00c lib/libc/arch/sh5/gen/fpgetround.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/sh5/gen/fpgetround.S        Fri Jul 12 12:20:24 2002 +0000
@@ -0,0 +1,21 @@
+/*     $NetBSD: fpgetround.S,v 1.1 2002/07/12 12:20:25 scw Exp $       */
+
+/*
+ * Written by Steve C. Woodford at Wasabi Systems for NetBSD.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpgetround,_fpgetround)
+ENTRY(_fpgetround)
+#else
+ENTRY(fpgetround)
+#endif
+       fgetscr fr0
+       ptabs/l r18, tr0
+       fmov.sl fr0, r2
+       andi    r2, 1, r2       /* Rounding mode is in bit#0 */
+       xori    r2, 1, r2       /* We use inverse of h/w bit */
+       blink   tr0, r63
diff -r ee0e1376eefe -r 62c43d09d00c lib/libc/arch/sh5/gen/fpgetsticky.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/sh5/gen/fpgetsticky.S       Fri Jul 12 12:20:24 2002 +0000
@@ -0,0 +1,21 @@
+/*     $NetBSD: fpgetsticky.S,v 1.1 2002/07/12 12:20:25 scw Exp $      */
+
+/*
+ * Written by Steve C. Woodford at Wasabi Systems for NetBSD.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpgetsticky,_fpgetsticky)
+ENTRY(_fpgetsticky)
+#else
+ENTRY(fpgetsticky)
+#endif
+       fgetscr fr0
+       ptabs/l r18, tr0
+       fmov.sl fr0, r2
+       shlri   r2, 2, r2       /* Get sticky mask to low bits */
+       andi    r2, 0x1f, r2    /* Zap unwanted bits */
+       blink   tr0, r63
diff -r ee0e1376eefe -r 62c43d09d00c lib/libc/arch/sh5/gen/fpsetmask.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/sh5/gen/fpsetmask.S Fri Jul 12 12:20:24 2002 +0000
@@ -0,0 +1,28 @@
+/*     $NetBSD: fpsetmask.S,v 1.1 2002/07/12 12:20:25 scw Exp $        */
+
+/*
+ * Written by Steve C. Woodford at Wasabi Systems for NetBSD.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpsetmask,_fpsetmask)
+ENTRY(_fpsetmask)
+#else
+ENTRY(fpsetmask)
+#endif
+       fgetscr fr0
+       ptabs/l r18, tr0
+       fmov.sl fr0, r0
+       movi    0x0f80, r1      /* Mask for Enable bits */
+       shlli   r2, 7, r2       /* Shift supplied mask to correct position */
+       and     r2, r1, r2      /* Zap any unwanted bits in supplied mask */
+       andc    r0, r1, r1      /* Clear the existing mask bits */
+       or      r1, r2, r1      /* OR-in the new mask */
+       fmov.ls r1, fr0
+       shlri   r0, 7, r2       /* Old mask to return value */
+       andi    r2, 0x1f, r2    /* Zap unwanted bits */
+       fputscr fr0             /* Update the current mask */
+       blink   tr0, r63
diff -r ee0e1376eefe -r 62c43d09d00c lib/libc/arch/sh5/gen/fpsetround.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/sh5/gen/fpsetround.S        Fri Jul 12 12:20:24 2002 +0000
@@ -0,0 +1,28 @@
+/*     $NetBSD: fpsetround.S,v 1.1 2002/07/12 12:20:25 scw Exp $       */
+
+/*
+ * Written by Steve C. Woodford at Wasabi Systems for NetBSD.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpsetround,_fpsetround)
+ENTRY(_fpsetround)
+#else
+ENTRY(fpsetround)
+#endif
+       fgetscr fr0
+       ptabs/l r18, tr0
+       fmov.sl fr0, r0
+       movi    1, r1           /* Mask for the rounding mode bit */
+       and     r2, r1, r2      /* Ensure the supplied mask is valid */
+       xor     r2, r1, r2      /* Mode needs to be inverted for the h/w */
+       andc    r0, r1, r1      /* Clear existing mode bit */
+       or      r1, r2, r1      /* OR-in the new mode */
+       xori    r0, 1, r2       /* Copy inv of previous mode to return value */
+       fmov.ls r1, fr0
+       andi    r2, 1, r2       /* Keep only relevant bit of result */
+       fputscr fr0             /* Update mode in h/w */
+       blink   tr0, r63
diff -r ee0e1376eefe -r 62c43d09d00c lib/libc/arch/sh5/gen/fpsetsticky.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/sh5/gen/fpsetsticky.S       Fri Jul 12 12:20:24 2002 +0000
@@ -0,0 +1,28 @@
+/*     $NetBSD: fpsetsticky.S,v 1.1 2002/07/12 12:20:25 scw Exp $      */
+
+/*
+ * Written by Steve C. Woodford at Wasabi Systems for NetBSD
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpsetsticky,_fpsetsticky)
+ENTRY(_fpsetsticky)
+#else
+ENTRY(fpsetsticky)
+#endif
+       fgetscr fr0
+       ptabs/l r18, tr0
+       fmov.sl fr0, r0
+       movi    0x7c, r1        /* Mask for the sticky bits */
+       shlli   r2, 2, r2       /* Shift new mask to correct bit position */
+       and     r2, r1, r2      /* Zap unwanted bits */
+       andc    r0, r1, r1      /* Clear sticky bits in existing mask */
+       or      r1, r2, r1      /* OR-in the new mask */
+       fmov.ls r1, fr0
+       shlri   r0, 2, r2       /* Get old mask in return value */
+       andi    r2, 0x1f, r2    /* Zap unwanted bits */
+       fputscr fr0             /* Update the h/w mask */
+       blink   tr0, r63
diff -r ee0e1376eefe -r 62c43d09d00c sys/arch/sh5/include/ieeefp.h
--- a/sys/arch/sh5/include/ieeefp.h     Fri Jul 12 11:20:12 2002 +0000
+++ b/sys/arch/sh5/include/ieeefp.h     Fri Jul 12 12:20:24 2002 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: ieeefp.h,v 1.1 2002/07/10 10:38:23 scw Exp $   */
+/*     $NetBSD: ieeefp.h,v 1.2 2002/07/12 12:20:24 scw Exp $   */
 
 /*
  * Written by J.T. Conklin, Apr 6, 1995
+ * Updated for SH5 by Steve C. Woodford of Wasabi Systems.
  * Public domain.
  */
 
@@ -9,18 +10,17 @@
 #define        _SH5_IEEEFP_H_
 
 typedef int fp_except;
-#define        FP_X_INV        0x01    /* invalid operation exception */
-#define        FP_X_DNML       0x02    /* denormalization exception */
-#define        FP_X_DZ         0x04    /* divide-by-zero exception */
-#define        FP_X_OFL        0x08    /* overflow exception */
-#define        FP_X_UFL        0x10    /* underflow exception */
-#define        FP_X_IMP        0x20    /* imprecise (loss of precision) */
+#define        FP_X_IMP        0x01    /* imprecise (loss of precision) */
+#define        FP_X_UFL        0x02    /* underflow exception */
+#define        FP_X_OFL        0x04    /* overflow exception */
+#define        FP_X_DZ         0x08    /* divide-by-zero exception */
+#define        FP_X_INV        0x10    /* invalid operation exception */
 
 typedef enum {
-       FP_RN=0,                /* round to nearest representable number */
-       FP_RM=1,                /* round toward negative infinity */
-       FP_RP=2,                /* round toward positive infinity */
-       FP_RZ=3                 /* round to zero (truncate) */
+       FP_RZ=0         /* round to zero (truncate) */
+       FP_RN=1,        /* round to nearest representable number */
+       FP_RM=2,        /* round toward negative infinity (no h/w support) */
+       FP_RP=3,        /* round toward positive infinity (no h/w support) */
 } fp_rnd;
 
 #endif /* !_SH5_IEEEFP_H_ */



Home | Main Index | Thread Index | Old Index