Commit d2b194ed authored by Kumar Gala's avatar Kumar Gala

powerpc/math-emu: Use kernel generic math-emu code

The math emulation code is centered around a set of generic macros that
provide the core of the emulation that are shared by the various
architectures and other projects (like glibc).  Each arch implements its
own sfp-machine.h to specific various arch specific details.

For historic reasons that are now lost the powerpc math-emu code had
its own version of the common headers.  This moves us to using the
kernel generic version and thus getting fixes when those are updated.

Also cleaned up exception/error reporting from the FP emulation functions.
Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
parent a969e76a
...@@ -79,27 +79,44 @@ ...@@ -79,27 +79,44 @@
* #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv_64(D,R,X,Y) * #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv_64(D,R,X,Y)
*/ */
#define _FP_MUL_MEAT_S(R,X,Y) _FP_MUL_MEAT_1_wide(S,R,X,Y,umul_ppmm) #define _FP_MUL_MEAT_S(R,X,Y) _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
#define _FP_MUL_MEAT_D(R,X,Y) _FP_MUL_MEAT_2_wide(D,R,X,Y,umul_ppmm) #define _FP_MUL_MEAT_D(R,X,Y) _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y) #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y)
#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv_64(D,R,X,Y) #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
/* These macros define what NaN looks like. They're supposed to expand to /* These macros define what NaN looks like. They're supposed to expand to
* a comma-separated set of 32bit unsigned ints that encode NaN. * a comma-separated set of 32bit unsigned ints that encode NaN.
*/ */
#define _FP_NANFRAC_S _FP_QNANBIT_S #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
#define _FP_NANFRAC_D _FP_QNANBIT_D, 0 #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0 #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
#define _FP_NANSIGN_S 0
#define _FP_NANSIGN_D 0
#define _FP_NANSIGN_Q 0
#define _FP_KEEPNANFRACP 1 #define _FP_KEEPNANFRACP 1
/* Exception flags. We use the bit positions of the appropriate bits
in the FPSCR, which also correspond to the FE_* bits. This makes
everything easier ;-). */
#define FP_EX_INVALID (1 << (31 - 2))
#define FP_EX_INVALID_SNAN EFLAG_VXSNAN
#define FP_EX_INVALID_ISI EFLAG_VXISI
#define FP_EX_INVALID_IDI EFLAG_VXIDI
#define FP_EX_INVALID_ZDZ EFLAG_VXZDZ
#define FP_EX_INVALID_IMZ EFLAG_VXIMZ
#define FP_EX_OVERFLOW (1 << (31 - 3))
#define FP_EX_UNDERFLOW (1 << (31 - 4))
#define FP_EX_DIVZERO (1 << (31 - 5))
#define FP_EX_INEXACT (1 << (31 - 6))
/* This macro appears to be called when both X and Y are NaNs, and /* This macro appears to be called when both X and Y are NaNs, and
* has to choose one and copy it to R. i386 goes for the larger of the * has to choose one and copy it to R. i386 goes for the larger of the
* two, sparc64 just picks Y. I don't understand this at all so I'll * two, sparc64 just picks Y. I don't understand this at all so I'll
* go with sparc64 because it's shorter :-> -- PMM * go with sparc64 because it's shorter :-> -- PMM
*/ */
#define _FP_CHOOSENAN(fs, wc, R, X, Y) \ #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
do { \ do { \
R##_s = Y##_s; \ R##_s = Y##_s; \
_FP_FRAC_COPY_##wc(R,Y); \ _FP_FRAC_COPY_##wc(R,Y); \
...@@ -107,62 +124,6 @@ ...@@ -107,62 +124,6 @@
} while (0) } while (0)
extern void fp_unpack_d(long *, unsigned long *, unsigned long *,
long *, long *, void *);
extern int fp_pack_d(void *, long, unsigned long, unsigned long, long, long);
extern int fp_pack_ds(void *, long, unsigned long, unsigned long, long, long);
#define __FP_UNPACK_RAW_1(fs, X, val) \
do { \
union _FP_UNION_##fs *_flo = \
(union _FP_UNION_##fs *)val; \
\
X##_f = _flo->bits.frac; \
X##_e = _flo->bits.exp; \
X##_s = _flo->bits.sign; \
} while (0)
#define __FP_UNPACK_RAW_2(fs, X, val) \
do { \
union _FP_UNION_##fs *_flo = \
(union _FP_UNION_##fs *)val; \
\
X##_f0 = _flo->bits.frac0; \
X##_f1 = _flo->bits.frac1; \
X##_e = _flo->bits.exp; \
X##_s = _flo->bits.sign; \
} while (0)
#define __FP_UNPACK_S(X,val) \
do { \
__FP_UNPACK_RAW_1(S,X,val); \
_FP_UNPACK_CANONICAL(S,1,X); \
} while (0)
#define __FP_UNPACK_D(X,val) \
fp_unpack_d(&X##_s, &X##_f1, &X##_f0, &X##_e, &X##_c, val)
#define __FP_PACK_RAW_1(fs, val, X) \
do { \
union _FP_UNION_##fs *_flo = \
(union _FP_UNION_##fs *)val; \
\
_flo->bits.frac = X##_f; \
_flo->bits.exp = X##_e; \
_flo->bits.sign = X##_s; \
} while (0)
#define __FP_PACK_RAW_2(fs, val, X) \
do { \
union _FP_UNION_##fs *_flo = \
(union _FP_UNION_##fs *)val; \
\
_flo->bits.frac0 = X##_f0; \
_flo->bits.frac1 = X##_f1; \
_flo->bits.exp = X##_e; \
_flo->bits.sign = X##_s; \
} while (0)
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -182,15 +143,30 @@ extern int fp_pack_ds(void *, long, unsigned long, unsigned long, long, long); ...@@ -182,15 +143,30 @@ extern int fp_pack_ds(void *, long, unsigned long, unsigned long, long, long);
#define __FP_PACK_S(val,X) \ #define __FP_PACK_S(val,X) \
({ int __exc = _FP_PACK_CANONICAL(S,1,X); \ ({ int __exc = _FP_PACK_CANONICAL(S,1,X); \
if(!__exc || !__FPU_TRAP_P(__exc)) \ if(!__exc || !__FPU_TRAP_P(__exc)) \
__FP_PACK_RAW_1(S,val,X); \ _FP_PACK_RAW_1_P(S,val,X); \
__exc; \ __exc; \
}) })
#define __FP_PACK_D(val,X) \ #define __FP_PACK_D(val,X) \
fp_pack_d(val, X##_s, X##_f1, X##_f0, X##_e, X##_c) do { \
_FP_PACK_CANONICAL(D, 2, X); \
#define __FP_PACK_DS(val,X) \ if (!FP_CUR_EXCEPTIONS || !__FPU_TRAP_P(FP_CUR_EXCEPTIONS)) \
fp_pack_ds(val, X##_s, X##_f1, X##_f0, X##_e, X##_c) _FP_PACK_RAW_2_P(D, val, X); \
} while (0)
#define __FP_PACK_DS(val,X) \
do { \
FP_DECL_S(__X); \
FP_CONV(S, D, 1, 2, __X, X); \
_FP_PACK_CANONICAL(S, 1, __X); \
if (!FP_CUR_EXCEPTIONS || !__FPU_TRAP_P(FP_CUR_EXCEPTIONS)) { \
_FP_UNPACK_CANONICAL(S, 1, __X); \
FP_CONV(D, S, 2, 1, X, __X); \
_FP_PACK_CANONICAL(D, 2, X); \
if (!FP_CUR_EXCEPTIONS || !__FPU_TRAP_P(FP_CUR_EXCEPTIONS)) \
_FP_PACK_RAW_2_P(D, val, X); \
} \
} while (0)
/* Obtain the current rounding mode. */ /* Obtain the current rounding mode. */
#define FP_ROUNDMODE \ #define FP_ROUNDMODE \
......
...@@ -4,13 +4,14 @@ obj-y := math.o fmr.o lfd.o stfd.o ...@@ -4,13 +4,14 @@ obj-y := math.o fmr.o lfd.o stfd.o
obj-$(CONFIG_MATH_EMULATION) += fabs.o fadd.o fadds.o fcmpo.o fcmpu.o \ obj-$(CONFIG_MATH_EMULATION) += fabs.o fadd.o fadds.o fcmpo.o fcmpu.o \
fctiw.o fctiwz.o fdiv.o fdivs.o \ fctiw.o fctiwz.o fdiv.o fdivs.o \
fmadd.o fmadds.o fmsub.o fmsubs.o \ fmadd.o fmadds.o fmsub.o fmsubs.o \
fmul.o fmuls.o fnabs.o fneg.o types.o \ fmul.o fmuls.o fnabs.o fneg.o \
fnmadd.o fnmadds.o fnmsub.o fnmsubs.o \ fnmadd.o fnmadds.o fnmsub.o fnmsubs.o \
fres.o frsp.o frsqrte.o fsel.o lfs.o \ fres.o frsp.o frsqrte.o fsel.o lfs.o \
fsqrt.o fsqrts.o fsub.o fsubs.o \ fsqrt.o fsqrts.o fsub.o fsubs.o \
mcrfs.o mffs.o mtfsb0.o mtfsb1.o \ mcrfs.o mffs.o mtfsb0.o mtfsb1.o \
mtfsf.o mtfsfi.o stfiwx.o stfs.o \ mtfsf.o mtfsfi.o stfiwx.o stfs.o
udivmodti4.o
CFLAGS_fabs.o = -fno-builtin-fabs CFLAGS_fabs.o = -fno-builtin-fabs
CFLAGS_math.o = -fno-builtin-fabs CFLAGS_math.o = -fno-builtin-fabs
EXTRA_CFLAGS = -I. -Iinclude/math-emu -w
/*
* Definitions for IEEE Double Precision
*/
#if _FP_W_TYPE_SIZE < 32
#error "Here's a nickel kid. Go buy yourself a real computer."
#endif
#if _FP_W_TYPE_SIZE < 64
#define _FP_FRACTBITS_D (2 * _FP_W_TYPE_SIZE)
#else
#define _FP_FRACTBITS_D _FP_W_TYPE_SIZE
#endif
#define _FP_FRACBITS_D 53
#define _FP_FRACXBITS_D (_FP_FRACTBITS_D - _FP_FRACBITS_D)
#define _FP_WFRACBITS_D (_FP_WORKBITS + _FP_FRACBITS_D)
#define _FP_WFRACXBITS_D (_FP_FRACTBITS_D - _FP_WFRACBITS_D)
#define _FP_EXPBITS_D 11
#define _FP_EXPBIAS_D 1023
#define _FP_EXPMAX_D 2047
#define _FP_QNANBIT_D \
((_FP_W_TYPE)1 << ((_FP_FRACBITS_D-2) % _FP_W_TYPE_SIZE))
#define _FP_IMPLBIT_D \
((_FP_W_TYPE)1 << ((_FP_FRACBITS_D-1) % _FP_W_TYPE_SIZE))
#define _FP_OVERFLOW_D \
((_FP_W_TYPE)1 << (_FP_WFRACBITS_D % _FP_W_TYPE_SIZE))
#if _FP_W_TYPE_SIZE < 64
union _FP_UNION_D
{
double flt;
struct {
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned sign : 1;
unsigned exp : _FP_EXPBITS_D;
unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
unsigned frac0 : _FP_W_TYPE_SIZE;
#else
unsigned frac0 : _FP_W_TYPE_SIZE;
unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
unsigned exp : _FP_EXPBITS_D;
unsigned sign : 1;
#endif
} bits __attribute__((packed));
};
#define FP_DECL_D(X) _FP_DECL(2,X)
#define FP_UNPACK_RAW_D(X,val) _FP_UNPACK_RAW_2(D,X,val)
#define FP_PACK_RAW_D(val,X) _FP_PACK_RAW_2(D,val,X)
#define FP_UNPACK_D(X,val) \
do { \
_FP_UNPACK_RAW_2(D,X,val); \
_FP_UNPACK_CANONICAL(D,2,X); \
} while (0)
#define FP_PACK_D(val,X) \
do { \
_FP_PACK_CANONICAL(D,2,X); \
_FP_PACK_RAW_2(D,val,X); \
} while (0)
#define FP_NEG_D(R,X) _FP_NEG(D,2,R,X)
#define FP_ADD_D(R,X,Y) _FP_ADD(D,2,R,X,Y)
#define FP_SUB_D(R,X,Y) _FP_SUB(D,2,R,X,Y)
#define FP_MUL_D(R,X,Y) _FP_MUL(D,2,R,X,Y)
#define FP_DIV_D(R,X,Y) _FP_DIV(D,2,R,X,Y)
#define FP_SQRT_D(R,X) _FP_SQRT(D,2,R,X)
#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,2,r,X,Y,un)
#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,2,r,X,Y)
#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,2,r,X,rsz,rsg)
#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,2,X,r,rs,rt)
#else
union _FP_UNION_D
{
double flt;
struct {
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned sign : 1;
unsigned exp : _FP_EXPBITS_D;
unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
#else
unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
unsigned exp : _FP_EXPBITS_D;
unsigned sign : 1;
#endif
} bits __attribute__((packed));
};
#define FP_DECL_D(X) _FP_DECL(1,X)
#define FP_UNPACK_RAW_D(X,val) _FP_UNPACK_RAW_1(D,X,val)
#define FP_PACK_RAW_D(val,X) _FP_PACK_RAW_1(D,val,X)
#define FP_UNPACK_D(X,val) \
do { \
_FP_UNPACK_RAW_1(D,X,val); \
_FP_UNPACK_CANONICAL(D,1,X); \
} while (0)
#define FP_PACK_D(val,X) \
do { \
_FP_PACK_CANONICAL(D,1,X); \
_FP_PACK_RAW_1(D,val,X); \
} while (0)
#define FP_NEG_D(R,X) _FP_NEG(D,1,R,X)
#define FP_ADD_D(R,X,Y) _FP_ADD(D,1,R,X,Y)
#define FP_SUB_D(R,X,Y) _FP_SUB(D,1,R,X,Y)
#define FP_MUL_D(R,X,Y) _FP_MUL(D,1,R,X,Y)
#define FP_DIV_D(R,X,Y) _FP_DIV(D,1,R,X,Y)
#define FP_SQRT_D(R,X) _FP_SQRT(D,1,R,X)
/* The implementation of _FP_MUL_D and _FP_DIV_D should be chosen by
the target machine. */
#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,1,r,X,Y,un)
#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,1,r,X,Y)
#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,1,r,X,rsz,rsg)
#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,1,X,r,rs,rt)
#endif /* W_TYPE_SIZE < 64 */
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fadd(void *frD, void *frA, void *frB) fadd(void *frD, void *frA, void *frB)
...@@ -11,28 +12,28 @@ fadd(void *frD, void *frA, void *frB) ...@@ -11,28 +12,28 @@ fadd(void *frD, void *frA, void *frB)
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p\n", __func__, frD, frA, frB); printk("%s: %p %p %p\n", __func__, frD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c); printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
#endif #endif
if (A_s != B_s && A_c == FP_CLS_INF && B_c == FP_CLS_INF)
ret |= EFLAG_VXISI;
FP_ADD_D(R, A, B); FP_ADD_D(R, A, B);
#ifdef DEBUG #ifdef DEBUG
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fadds(void *frD, void *frA, void *frB) fadds(void *frD, void *frA, void *frB)
...@@ -12,28 +13,27 @@ fadds(void *frD, void *frA, void *frB) ...@@ -12,28 +13,27 @@ fadds(void *frD, void *frA, void *frB)
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
int ret = 0; FP_DECL_EX;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p\n", __func__, frD, frA, frB); printk("%s: %p %p %p\n", __func__, frD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c); printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
#endif #endif
if (A_s != B_s && A_c == FP_CLS_INF && B_c == FP_CLS_INF)
ret |= EFLAG_VXISI;
FP_ADD_D(R, A, B); FP_ADD_D(R, A, B);
#ifdef DEBUG #ifdef DEBUG
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fcmpo(u32 *ccr, int crfD, void *frA, void *frB) fcmpo(u32 *ccr, int crfD, void *frA, void *frB)
{ {
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_EX;
int code[4] = { (1 << 3), (1 << 1), (1 << 2), (1 << 0) }; int code[4] = { (1 << 3), (1 << 1), (1 << 2), (1 << 0) };
long cmp; long cmp;
int ret = 0; int ret = 0;
...@@ -18,8 +20,8 @@ fcmpo(u32 *ccr, int crfD, void *frA, void *frB) ...@@ -18,8 +20,8 @@ fcmpo(u32 *ccr, int crfD, void *frA, void *frB)
printk("%s: %p (%08x) %d %p %p\n", __func__, ccr, *ccr, crfD, frA, frB); printk("%s: %p (%08x) %d %p %p\n", __func__, ccr, *ccr, crfD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
......
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fcmpu(u32 *ccr, int crfD, void *frA, void *frB) fcmpu(u32 *ccr, int crfD, void *frA, void *frB)
{ {
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_EX;
int code[4] = { (1 << 3), (1 << 1), (1 << 2), (1 << 0) }; int code[4] = { (1 << 3), (1 << 1), (1 << 2), (1 << 0) };
long cmp; long cmp;
...@@ -17,8 +19,8 @@ fcmpu(u32 *ccr, int crfD, void *frA, void *frB) ...@@ -17,8 +19,8 @@ fcmpu(u32 *ccr, int crfD, void *frA, void *frB)
printk("%s: %p (%08x) %d %p %p\n", __func__, ccr, *ccr, crfD, frA, frB); printk("%s: %p (%08x) %d %p %p\n", __func__, ccr, *ccr, crfD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
......
...@@ -2,16 +2,18 @@ ...@@ -2,16 +2,18 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fctiw(u32 *frD, void *frB) fctiw(u32 *frD, void *frB)
{ {
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_EX;
unsigned int r; unsigned int r;
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
FP_TO_INT_D(r, B, 32, 1); FP_TO_INT_D(r, B, 32, 1);
frD[1] = r; frD[1] = r;
......
...@@ -2,13 +2,15 @@ ...@@ -2,13 +2,15 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fctiwz(u32 *frD, void *frB) fctiwz(u32 *frD, void *frB)
{ {
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_EX;
u32 fpscr; u32 fpscr;
unsigned int r; unsigned int r;
...@@ -16,7 +18,7 @@ fctiwz(u32 *frD, void *frB) ...@@ -16,7 +18,7 @@ fctiwz(u32 *frD, void *frB)
__FPU_FPSCR &= ~(3); __FPU_FPSCR &= ~(3);
__FPU_FPSCR |= FP_RND_ZERO; __FPU_FPSCR |= FP_RND_ZERO;
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
FP_TO_INT_D(r, B, 32, 1); FP_TO_INT_D(r, B, 32, 1);
frD[1] = r; frD[1] = r;
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fdiv(void *frD, void *frA, void *frB) fdiv(void *frD, void *frA, void *frB)
...@@ -11,14 +12,15 @@ fdiv(void *frD, void *frA, void *frB) ...@@ -11,14 +12,15 @@ fdiv(void *frD, void *frA, void *frB)
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p\n", __func__, frD, frA, frB); printk("%s: %p %p %p\n", __func__, frD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -49,5 +51,7 @@ fdiv(void *frD, void *frA, void *frB) ...@@ -49,5 +51,7 @@ fdiv(void *frD, void *frA, void *frB)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fdivs(void *frD, void *frA, void *frB) fdivs(void *frD, void *frA, void *frB)
...@@ -12,14 +13,15 @@ fdivs(void *frD, void *frA, void *frB) ...@@ -12,14 +13,15 @@ fdivs(void *frD, void *frA, void *frB)
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p\n", __func__, frD, frA, frB); printk("%s: %p %p %p\n", __func__, frD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -51,5 +53,7 @@ fdivs(void *frD, void *frA, void *frB) ...@@ -51,5 +53,7 @@ fdivs(void *frD, void *frA, void *frB)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fmadd(void *frD, void *frA, void *frB, void *frC) fmadd(void *frD, void *frA, void *frB, void *frC)
...@@ -13,15 +14,16 @@ fmadd(void *frD, void *frA, void *frB, void *frC) ...@@ -13,15 +14,16 @@ fmadd(void *frD, void *frA, void *frB, void *frC)
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(C); FP_DECL_D(C);
FP_DECL_D(T); FP_DECL_D(T);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
__FP_UNPACK_D(C, frC); FP_UNPACK_DP(C, frC);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -44,5 +46,7 @@ fmadd(void *frD, void *frA, void *frB, void *frC) ...@@ -44,5 +46,7 @@ fmadd(void *frD, void *frA, void *frB, void *frC)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fmadds(void *frD, void *frA, void *frB, void *frC) fmadds(void *frD, void *frA, void *frB, void *frC)
...@@ -14,15 +15,16 @@ fmadds(void *frD, void *frA, void *frB, void *frC) ...@@ -14,15 +15,16 @@ fmadds(void *frD, void *frA, void *frB, void *frC)
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(C); FP_DECL_D(C);
FP_DECL_D(T); FP_DECL_D(T);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
__FP_UNPACK_D(C, frC); FP_UNPACK_DP(C, frC);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -45,5 +47,7 @@ fmadds(void *frD, void *frA, void *frB, void *frC) ...@@ -45,5 +47,7 @@ fmadds(void *frD, void *frA, void *frB, void *frC)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fmsub(void *frD, void *frA, void *frB, void *frC) fmsub(void *frD, void *frA, void *frB, void *frC)
...@@ -13,15 +14,16 @@ fmsub(void *frD, void *frA, void *frB, void *frC) ...@@ -13,15 +14,16 @@ fmsub(void *frD, void *frA, void *frB, void *frC)
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(C); FP_DECL_D(C);
FP_DECL_D(T); FP_DECL_D(T);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
__FP_UNPACK_D(C, frC); FP_UNPACK_DP(C, frC);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -47,5 +49,7 @@ fmsub(void *frD, void *frA, void *frB, void *frC) ...@@ -47,5 +49,7 @@ fmsub(void *frD, void *frA, void *frB, void *frC)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fmsubs(void *frD, void *frA, void *frB, void *frC) fmsubs(void *frD, void *frA, void *frB, void *frC)
...@@ -14,15 +15,16 @@ fmsubs(void *frD, void *frA, void *frB, void *frC) ...@@ -14,15 +15,16 @@ fmsubs(void *frD, void *frA, void *frB, void *frC)
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(C); FP_DECL_D(C);
FP_DECL_D(T); FP_DECL_D(T);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
__FP_UNPACK_D(C, frC); FP_UNPACK_DP(C, frC);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -48,5 +50,7 @@ fmsubs(void *frD, void *frA, void *frB, void *frC) ...@@ -48,5 +50,7 @@ fmsubs(void *frD, void *frA, void *frB, void *frC)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fmul(void *frD, void *frA, void *frB) fmul(void *frD, void *frA, void *frB)
...@@ -11,14 +12,15 @@ fmul(void *frD, void *frA, void *frB) ...@@ -11,14 +12,15 @@ fmul(void *frD, void *frA, void *frB)
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p\n", __func__, frD, frA, frB); printk("%s: %p %p %p\n", __func__, frD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n", printk("A: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n",
...@@ -38,5 +40,7 @@ fmul(void *frD, void *frA, void *frB) ...@@ -38,5 +40,7 @@ fmul(void *frD, void *frA, void *frB)
R_s, R_f1, R_f0, R_e, R_c, R_f1, R_f0, R_e + 1023); R_s, R_f1, R_f0, R_e, R_c, R_f1, R_f0, R_e + 1023);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fmuls(void *frD, void *frA, void *frB) fmuls(void *frD, void *frA, void *frB)
...@@ -12,14 +13,15 @@ fmuls(void *frD, void *frA, void *frB) ...@@ -12,14 +13,15 @@ fmuls(void *frD, void *frA, void *frB)
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p\n", __func__, frD, frA, frB); printk("%s: %p %p %p\n", __func__, frD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n", printk("A: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n",
...@@ -39,5 +41,7 @@ fmuls(void *frD, void *frA, void *frB) ...@@ -39,5 +41,7 @@ fmuls(void *frD, void *frA, void *frB)
R_s, R_f1, R_f0, R_e, R_c, R_f1, R_f0, R_e + 1023); R_s, R_f1, R_f0, R_e, R_c, R_f1, R_f0, R_e + 1023);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fnmadd(void *frD, void *frA, void *frB, void *frC) fnmadd(void *frD, void *frA, void *frB, void *frC)
...@@ -13,15 +14,16 @@ fnmadd(void *frD, void *frA, void *frB, void *frC) ...@@ -13,15 +14,16 @@ fnmadd(void *frD, void *frA, void *frB, void *frC)
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(C); FP_DECL_D(C);
FP_DECL_D(T); FP_DECL_D(T);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
__FP_UNPACK_D(C, frC); FP_UNPACK_DP(C, frC);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -47,5 +49,7 @@ fnmadd(void *frD, void *frA, void *frB, void *frC) ...@@ -47,5 +49,7 @@ fnmadd(void *frD, void *frA, void *frB, void *frC)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fnmadds(void *frD, void *frA, void *frB, void *frC) fnmadds(void *frD, void *frA, void *frB, void *frC)
...@@ -14,15 +15,16 @@ fnmadds(void *frD, void *frA, void *frB, void *frC) ...@@ -14,15 +15,16 @@ fnmadds(void *frD, void *frA, void *frB, void *frC)
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(C); FP_DECL_D(C);
FP_DECL_D(T); FP_DECL_D(T);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
__FP_UNPACK_D(C, frC); FP_UNPACK_DP(C, frC);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -48,5 +50,7 @@ fnmadds(void *frD, void *frA, void *frB, void *frC) ...@@ -48,5 +50,7 @@ fnmadds(void *frD, void *frA, void *frB, void *frC)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fnmsub(void *frD, void *frA, void *frB, void *frC) fnmsub(void *frD, void *frA, void *frB, void *frC)
...@@ -13,15 +14,16 @@ fnmsub(void *frD, void *frA, void *frB, void *frC) ...@@ -13,15 +14,16 @@ fnmsub(void *frD, void *frA, void *frB, void *frC)
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(C); FP_DECL_D(C);
FP_DECL_D(T); FP_DECL_D(T);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
__FP_UNPACK_D(C, frC); FP_UNPACK_DP(C, frC);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -50,5 +52,7 @@ fnmsub(void *frD, void *frA, void *frB, void *frC) ...@@ -50,5 +52,7 @@ fnmsub(void *frD, void *frA, void *frB, void *frC)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fnmsubs(void *frD, void *frA, void *frB, void *frC) fnmsubs(void *frD, void *frA, void *frB, void *frC)
...@@ -14,15 +15,16 @@ fnmsubs(void *frD, void *frA, void *frB, void *frC) ...@@ -14,15 +15,16 @@ fnmsubs(void *frD, void *frA, void *frB, void *frC)
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(C); FP_DECL_D(C);
FP_DECL_D(T); FP_DECL_D(T);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
__FP_UNPACK_D(C, frC); FP_UNPACK_DP(C, frC);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -51,5 +53,7 @@ fnmsubs(void *frD, void *frA, void *frB, void *frC) ...@@ -51,5 +53,7 @@ fnmsubs(void *frD, void *frA, void *frB, void *frC)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,24 +2,28 @@ ...@@ -2,24 +2,28 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
frsp(void *frD, void *frB) frsp(void *frD, void *frB)
{ {
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_EX;
#ifdef DEBUG #ifdef DEBUG
printk("%s: D %p, B %p\n", __func__, frD, frB); printk("%s: D %p, B %p\n", __func__, frD, frB);
#endif #endif
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c); printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
#endif #endif
return __FP_PACK_DS(frD, B); __FP_PACK_DS(frD, B);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,19 +2,21 @@ ...@@ -2,19 +2,21 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fsel(u32 *frD, void *frA, u32 *frB, u32 *frC) fsel(u32 *frD, void *frA, u32 *frB, u32 *frC)
{ {
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_EX;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
......
...@@ -2,21 +2,23 @@ ...@@ -2,21 +2,23 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fsqrt(void *frD, void *frB) fsqrt(void *frD, void *frB)
{ {
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frB); printk("%s: %p %p %p %p\n", __func__, frD, frB);
#endif #endif
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c); printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
...@@ -33,5 +35,7 @@ fsqrt(void *frD, void *frB) ...@@ -33,5 +35,7 @@ fsqrt(void *frD, void *frB)
printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,22 +2,24 @@ ...@@ -2,22 +2,24 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fsqrts(void *frD, void *frB) fsqrts(void *frD, void *frB)
{ {
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frB); printk("%s: %p %p %p %p\n", __func__, frD, frB);
#endif #endif
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c); printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
...@@ -34,5 +36,7 @@ fsqrts(void *frD, void *frB) ...@@ -34,5 +36,7 @@ fsqrts(void *frD, void *frB)
printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include <math-emu/double.h>
int int
fsub(void *frD, void *frA, void *frB) fsub(void *frD, void *frA, void *frB)
...@@ -11,14 +12,15 @@ fsub(void *frD, void *frA, void *frB) ...@@ -11,14 +12,15 @@ fsub(void *frD, void *frA, void *frB)
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p\n", __func__, frD, frA, frB); printk("%s: %p %p %p\n", __func__, frD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -37,5 +39,7 @@ fsub(void *frD, void *frA, void *frB) ...@@ -37,5 +39,7 @@ fsub(void *frD, void *frA, void *frB)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_D(frD, R)); __FP_PACK_D(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
fsubs(void *frD, void *frA, void *frB) fsubs(void *frD, void *frA, void *frB)
...@@ -12,14 +13,15 @@ fsubs(void *frD, void *frA, void *frB) ...@@ -12,14 +13,15 @@ fsubs(void *frD, void *frA, void *frB)
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_D(B); FP_DECL_D(B);
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_EX;
int ret = 0; int ret = 0;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %p %p %p\n", __func__, frD, frA, frB); printk("%s: %p %p %p\n", __func__, frD, frA, frB);
#endif #endif
__FP_UNPACK_D(A, frA); FP_UNPACK_DP(A, frA);
__FP_UNPACK_D(B, frB); FP_UNPACK_DP(B, frB);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -38,5 +40,7 @@ fsubs(void *frD, void *frA, void *frB) ...@@ -38,5 +40,7 @@ fsubs(void *frD, void *frA, void *frB)
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return (ret | __FP_PACK_DS(frD, R)); __FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
} }
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "sfp-machine.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/double.h>
int int
lfd(void *frD, void *ea) lfd(void *frD, void *ea)
......
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
lfs(void *frD, void *ea) lfs(void *frD, void *ea)
{ {
FP_DECL_D(R); FP_DECL_D(R);
FP_DECL_S(A); FP_DECL_S(A);
FP_DECL_EX;
float f; float f;
#ifdef DEBUG #ifdef DEBUG
...@@ -20,7 +22,7 @@ lfs(void *frD, void *ea) ...@@ -20,7 +22,7 @@ lfs(void *frD, void *ea)
if (copy_from_user(&f, ea, sizeof(float))) if (copy_from_user(&f, ea, sizeof(float)))
return -EFAULT; return -EFAULT;
__FP_UNPACK_S(A, &f); FP_UNPACK_S(A, f);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %ld (%ld) [%08lx]\n", A_s, A_f, A_e, A_c, printk("A: %ld %lu %ld (%ld) [%08lx]\n", A_s, A_f, A_e, A_c,
...@@ -33,5 +35,12 @@ lfs(void *frD, void *ea) ...@@ -33,5 +35,12 @@ lfs(void *frD, void *ea)
printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif #endif
return __FP_PACK_D(frD, R); if (R_c == FP_CLS_NAN) {
R_e = _FP_EXPMAX_D;
_FP_PACK_RAW_2_P(D, frD, R);
} else {
__FP_PACK_D(frD, R);
}
return 0;
} }
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/reg.h> #include <asm/reg.h>
#include "sfp-machine.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/double.h>
#define FLOATFUNC(x) extern int x(void *, void *, void *, void *) #define FLOATFUNC(x) extern int x(void *, void *, void *, void *)
...@@ -168,6 +168,8 @@ record_exception(struct pt_regs *regs, int eflag) ...@@ -168,6 +168,8 @@ record_exception(struct pt_regs *regs, int eflag)
fpscr |= FPSCR_ZX; fpscr |= FPSCR_ZX;
if (eflag & EFLAG_INEXACT) if (eflag & EFLAG_INEXACT)
fpscr |= FPSCR_XX; fpscr |= FPSCR_XX;
if (eflag & EFLAG_INVALID)
fpscr |= FPSCR_VX;
if (eflag & EFLAG_VXSNAN) if (eflag & EFLAG_VXSNAN)
fpscr |= FPSCR_VXSNAN; fpscr |= FPSCR_VXSNAN;
if (eflag & EFLAG_VXISI) if (eflag & EFLAG_VXISI)
...@@ -188,7 +190,7 @@ record_exception(struct pt_regs *regs, int eflag) ...@@ -188,7 +190,7 @@ record_exception(struct pt_regs *regs, int eflag)
fpscr |= FPSCR_VXCVI; fpscr |= FPSCR_VXCVI;
} }
fpscr &= ~(FPSCR_VX); // fpscr &= ~(FPSCR_VX);
if (fpscr & (FPSCR_VXSNAN | FPSCR_VXISI | FPSCR_VXIDI | if (fpscr & (FPSCR_VXSNAN | FPSCR_VXISI | FPSCR_VXIDI |
FPSCR_VXZDZ | FPSCR_VXIMZ | FPSCR_VXVC | FPSCR_VXZDZ | FPSCR_VXIMZ | FPSCR_VXVC |
FPSCR_VXSOFT | FPSCR_VXSQRT | FPSCR_VXCVI)) FPSCR_VXSOFT | FPSCR_VXSQRT | FPSCR_VXCVI))
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include <math-emu/soft-fp.h>
int int
mcrfs(u32 *ccr, u32 crfD, u32 crfS) mcrfs(u32 *ccr, u32 crfD, u32 crfS)
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include <math-emu/soft-fp.h>
int int
mffs(u32 *frD) mffs(u32 *frD)
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include <math-emu/soft-fp.h>
int int
mtfsb0(int crbD) mtfsb0(int crbD)
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include <math-emu/soft-fp.h>
int int
mtfsb1(int crbD) mtfsb1(int crbD)
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include <math-emu/soft-fp.h>
int int
mtfsf(unsigned int FM, u32 *frB) mtfsf(unsigned int FM, u32 *frB)
{ {
u32 mask; u32 mask;
u32 fpscr;
if (FM == 0) if (FM == 0)
return 0; return 0;
...@@ -37,6 +39,22 @@ mtfsf(unsigned int FM, u32 *frB) ...@@ -37,6 +39,22 @@ mtfsf(unsigned int FM, u32 *frB)
__FPU_FPSCR &= ~(mask); __FPU_FPSCR &= ~(mask);
__FPU_FPSCR |= (frB[1] & mask); __FPU_FPSCR |= (frB[1] & mask);
__FPU_FPSCR &= ~(FPSCR_VX);
if (__FPU_FPSCR & (FPSCR_VXSNAN | FPSCR_VXISI | FPSCR_VXIDI |
FPSCR_VXZDZ | FPSCR_VXIMZ | FPSCR_VXVC |
FPSCR_VXSOFT | FPSCR_VXSQRT | FPSCR_VXCVI))
__FPU_FPSCR |= FPSCR_VX;
fpscr = __FPU_FPSCR;
fpscr &= ~(FPSCR_FEX);
if (((fpscr & FPSCR_VX) && (fpscr & FPSCR_VE)) ||
((fpscr & FPSCR_OX) && (fpscr & FPSCR_OE)) ||
((fpscr & FPSCR_UX) && (fpscr & FPSCR_UE)) ||
((fpscr & FPSCR_ZX) && (fpscr & FPSCR_ZE)) ||
((fpscr & FPSCR_XX) && (fpscr & FPSCR_XE)))
fpscr |= FPSCR_FEX;
__FPU_FPSCR = fpscr;
#ifdef DEBUG #ifdef DEBUG
printk("%s: %02x %p: %08lx\n", __func__, FM, frB, __FPU_FPSCR); printk("%s: %02x %p: %08lx\n", __func__, FM, frB, __FPU_FPSCR);
#endif #endif
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include <math-emu/soft-fp.h>
int int
mtfsfi(unsigned int crfD, unsigned int IMM) mtfsfi(unsigned int crfD, unsigned int IMM)
......
/*
* Basic one-word fraction declaration and manipulation.
*/
#define _FP_FRAC_DECL_1(X) _FP_W_TYPE X##_f
#define _FP_FRAC_COPY_1(D,S) (D##_f = S##_f)
#define _FP_FRAC_SET_1(X,I) (X##_f = I)
#define _FP_FRAC_HIGH_1(X) (X##_f)
#define _FP_FRAC_LOW_1(X) (X##_f)
#define _FP_FRAC_WORD_1(X,w) (X##_f)
#define _FP_FRAC_ADDI_1(X,I) (X##_f += I)
#define _FP_FRAC_SLL_1(X,N) \
do { \
if (__builtin_constant_p(N) && (N) == 1) \
X##_f += X##_f; \
else \
X##_f <<= (N); \
} while (0)
#define _FP_FRAC_SRL_1(X,N) (X##_f >>= N)
/* Right shift with sticky-lsb. */
#define _FP_FRAC_SRS_1(X,N,sz) __FP_FRAC_SRS_1(X##_f, N, sz)
#define __FP_FRAC_SRS_1(X,N,sz) \
(X = (X >> (N) | (__builtin_constant_p(N) && (N) == 1 \
? X & 1 : (X << (_FP_W_TYPE_SIZE - (N))) != 0)))
#define _FP_FRAC_ADD_1(R,X,Y) (R##_f = X##_f + Y##_f)
#define _FP_FRAC_SUB_1(R,X,Y) (R##_f = X##_f - Y##_f)
#define _FP_FRAC_CLZ_1(z, X) __FP_CLZ(z, X##_f)
/* Predicates */
#define _FP_FRAC_NEGP_1(X) ((_FP_WS_TYPE)X##_f < 0)
#define _FP_FRAC_ZEROP_1(X) (X##_f == 0)
#define _FP_FRAC_OVERP_1(fs,X) (X##_f & _FP_OVERFLOW_##fs)
#define _FP_FRAC_EQ_1(X, Y) (X##_f == Y##_f)
#define _FP_FRAC_GE_1(X, Y) (X##_f >= Y##_f)
#define _FP_FRAC_GT_1(X, Y) (X##_f > Y##_f)
#define _FP_ZEROFRAC_1 0
#define _FP_MINFRAC_1 1
/*
* Unpack the raw bits of a native fp value. Do not classify or
* normalize the data.
*/
#define _FP_UNPACK_RAW_1(fs, X, val) \
do { \
union _FP_UNION_##fs _flo; _flo.flt = (val); \
\
X##_f = _flo.bits.frac; \
X##_e = _flo.bits.exp; \
X##_s = _flo.bits.sign; \
} while (0)
/*
* Repack the raw bits of a native fp value.
*/
#define _FP_PACK_RAW_1(fs, val, X) \
do { \
union _FP_UNION_##fs _flo; \
\
_flo.bits.frac = X##_f; \
_flo.bits.exp = X##_e; \
_flo.bits.sign = X##_s; \
\
(val) = _flo.flt; \
} while (0)
/*
* Multiplication algorithms:
*/
/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
multiplication immediately. */
#define _FP_MUL_MEAT_1_imm(fs, R, X, Y) \
do { \
R##_f = X##_f * Y##_f; \
/* Normalize since we know where the msb of the multiplicands \
were (bit B), we know that the msb of the of the product is \
at either 2B or 2B-1. */ \
_FP_FRAC_SRS_1(R, _FP_WFRACBITS_##fs-1, 2*_FP_WFRACBITS_##fs); \
} while (0)
/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
#define _FP_MUL_MEAT_1_wide(fs, R, X, Y, doit) \
do { \
_FP_W_TYPE _Z_f0, _Z_f1; \
doit(_Z_f1, _Z_f0, X##_f, Y##_f); \
/* Normalize since we know where the msb of the multiplicands \
were (bit B), we know that the msb of the of the product is \
at either 2B or 2B-1. */ \
_FP_FRAC_SRS_2(_Z, _FP_WFRACBITS_##fs-1, 2*_FP_WFRACBITS_##fs); \
R##_f = _Z_f0; \
} while (0)
/* Finally, a simple widening multiply algorithm. What fun! */
#define _FP_MUL_MEAT_1_hard(fs, R, X, Y) \
do { \
_FP_W_TYPE _xh, _xl, _yh, _yl, _z_f0, _z_f1, _a_f0, _a_f1; \
\
/* split the words in half */ \
_xh = X##_f >> (_FP_W_TYPE_SIZE/2); \
_xl = X##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1); \
_yh = Y##_f >> (_FP_W_TYPE_SIZE/2); \
_yl = Y##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1); \
\
/* multiply the pieces */ \
_z_f0 = _xl * _yl; \
_a_f0 = _xh * _yl; \
_a_f1 = _xl * _yh; \
_z_f1 = _xh * _yh; \
\
/* reassemble into two full words */ \
if ((_a_f0 += _a_f1) < _a_f1) \
_z_f1 += (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2); \
_a_f1 = _a_f0 >> (_FP_W_TYPE_SIZE/2); \
_a_f0 = _a_f0 << (_FP_W_TYPE_SIZE/2); \
_FP_FRAC_ADD_2(_z, _z, _a); \
\
/* normalize */ \
_FP_FRAC_SRS_2(_z, _FP_WFRACBITS_##fs - 1, 2*_FP_WFRACBITS_##fs); \
R##_f = _z_f0; \
} while (0)
/*
* Division algorithms:
*/
/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
division immediately. Give this macro either _FP_DIV_HELP_imm for
C primitives or _FP_DIV_HELP_ldiv for the ISO function. Which you
choose will depend on what the compiler does with divrem4. */
#define _FP_DIV_MEAT_1_imm(fs, R, X, Y, doit) \
do { \
_FP_W_TYPE _q, _r; \
X##_f <<= (X##_f < Y##_f \
? R##_e--, _FP_WFRACBITS_##fs \
: _FP_WFRACBITS_##fs - 1); \
doit(_q, _r, X##_f, Y##_f); \
R##_f = _q | (_r != 0); \
} while (0)
/* GCC's longlong.h defines a 2W / 1W => (1W,1W) primitive udiv_qrnnd
that may be useful in this situation. This first is for a primitive
that requires normalization, the second for one that does not. Look
for UDIV_NEEDS_NORMALIZATION to tell which your machine needs. */
#define _FP_DIV_MEAT_1_udiv_norm(fs, R, X, Y) \
do { \
_FP_W_TYPE _nh, _nl, _q, _r; \
\
/* Normalize Y -- i.e. make the most significant bit set. */ \
Y##_f <<= _FP_WFRACXBITS_##fs - 1; \
\
/* Shift X op correspondingly high, that is, up one full word. */ \
if (X##_f <= Y##_f) \
{ \
_nl = 0; \
_nh = X##_f; \
} \
else \
{ \
R##_e++; \
_nl = X##_f << (_FP_W_TYPE_SIZE-1); \
_nh = X##_f >> 1; \
} \
\
udiv_qrnnd(_q, _r, _nh, _nl, Y##_f); \
R##_f = _q | (_r != 0); \
} while (0)
#define _FP_DIV_MEAT_1_udiv(fs, R, X, Y) \
do { \
_FP_W_TYPE _nh, _nl, _q, _r; \
if (X##_f < Y##_f) \
{ \
R##_e--; \
_nl = X##_f << _FP_WFRACBITS_##fs; \
_nh = X##_f >> _FP_WFRACXBITS_##fs; \
} \
else \
{ \
_nl = X##_f << (_FP_WFRACBITS_##fs - 1); \
_nh = X##_f >> (_FP_WFRACXBITS_##fs + 1); \
} \
udiv_qrnnd(_q, _r, _nh, _nl, Y##_f); \
R##_f = _q | (_r != 0); \
} while (0)
/*
* Square root algorithms:
* We have just one right now, maybe Newton approximation
* should be added for those machines where division is fast.
*/
#define _FP_SQRT_MEAT_1(R, S, T, X, q) \
do { \
while (q) \
{ \
T##_f = S##_f + q; \
if (T##_f <= X##_f) \
{ \
S##_f = T##_f + q; \
X##_f -= T##_f; \
R##_f += q; \
} \
_FP_FRAC_SLL_1(X, 1); \
q >>= 1; \
} \
} while (0)
/*
* Assembly/disassembly for converting to/from integral types.
* No shifting or overflow handled here.
*/
#define _FP_FRAC_ASSEMBLE_1(r, X, rsize) (r = X##_f)
#define _FP_FRAC_DISASSEMBLE_1(X, r, rsize) (X##_f = r)
/*
* Convert FP values between word sizes
*/
#define _FP_FRAC_CONV_1_1(dfs, sfs, D, S) \
do { \
D##_f = S##_f; \
if (_FP_WFRACBITS_##sfs > _FP_WFRACBITS_##dfs) \
_FP_FRAC_SRS_1(D, (_FP_WFRACBITS_##sfs-_FP_WFRACBITS_##dfs), \
_FP_WFRACBITS_##sfs); \
else \
D##_f <<= _FP_WFRACBITS_##dfs - _FP_WFRACBITS_##sfs; \
} while (0)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Definitions for IEEE Single Precision
*/
#if _FP_W_TYPE_SIZE < 32
#error "Here's a nickel kid. Go buy yourself a real computer."
#endif
#define _FP_FRACBITS_S 24
#define _FP_FRACXBITS_S (_FP_W_TYPE_SIZE - _FP_FRACBITS_S)
#define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S)
#define _FP_WFRACXBITS_S (_FP_W_TYPE_SIZE - _FP_WFRACBITS_S)
#define _FP_EXPBITS_S 8
#define _FP_EXPBIAS_S 127
#define _FP_EXPMAX_S 255
#define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
#define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
#define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
/* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
chosen by the target machine. */
union _FP_UNION_S
{
float flt;
struct {
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned sign : 1;
unsigned exp : _FP_EXPBITS_S;
unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
#else
unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
unsigned exp : _FP_EXPBITS_S;
unsigned sign : 1;
#endif
} bits __attribute__((packed));
};
#define FP_DECL_S(X) _FP_DECL(1,X)
#define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val)
#define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X)
#define FP_UNPACK_S(X,val) \
do { \
_FP_UNPACK_RAW_1(S,X,val); \
_FP_UNPACK_CANONICAL(S,1,X); \
} while (0)
#define FP_PACK_S(val,X) \
do { \
_FP_PACK_CANONICAL(S,1,X); \
_FP_PACK_RAW_1(S,val,X); \
} while (0)
#define FP_NEG_S(R,X) _FP_NEG(S,1,R,X)
#define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y)
#define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y)
#define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y)
#define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y)
#define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X)
#define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
#define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
#define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
#define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
#ifndef SOFT_FP_H
#define SOFT_FP_H
#include "sfp-machine.h"
#define _FP_WORKBITS 3
#define _FP_WORK_LSB ((_FP_W_TYPE)1 << 3)
#define _FP_WORK_ROUND ((_FP_W_TYPE)1 << 2)
#define _FP_WORK_GUARD ((_FP_W_TYPE)1 << 1)
#define _FP_WORK_STICKY ((_FP_W_TYPE)1 << 0)
#ifndef FP_RND_NEAREST
# define FP_RND_NEAREST 0
# define FP_RND_ZERO 1
# define FP_RND_PINF 2
# define FP_RND_MINF 3
#ifndef FP_ROUNDMODE
# define FP_ROUNDMODE FP_RND_NEAREST
#endif
#endif
#define _FP_ROUND_NEAREST(wc, X) \
({ int __ret = 0; \
int __frac = _FP_FRAC_LOW_##wc(X) & 15; \
if (__frac & 7) { \
__ret = EFLAG_INEXACT; \
if ((__frac & 7) != _FP_WORK_ROUND) \
_FP_FRAC_ADDI_##wc(X, _FP_WORK_ROUND); \
else if (__frac & _FP_WORK_LSB) \
_FP_FRAC_ADDI_##wc(X, _FP_WORK_ROUND); \
} \
__ret; \
})
#define _FP_ROUND_ZERO(wc, X) \
({ int __ret = 0; \
if (_FP_FRAC_LOW_##wc(X) & 7) \
__ret = EFLAG_INEXACT; \
__ret; \
})
#define _FP_ROUND_PINF(wc, X) \
({ int __ret = EFLAG_INEXACT; \
if (!X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \
_FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \
else __ret = 0; \
__ret; \
})
#define _FP_ROUND_MINF(wc, X) \
({ int __ret = EFLAG_INEXACT; \
if (X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \
_FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \
else __ret = 0; \
__ret; \
})
#define _FP_ROUND(wc, X) \
({ int __ret = 0; \
switch (FP_ROUNDMODE) \
{ \
case FP_RND_NEAREST: \
__ret |= _FP_ROUND_NEAREST(wc,X); \
break; \
case FP_RND_ZERO: \
__ret |= _FP_ROUND_ZERO(wc,X); \
break; \
case FP_RND_PINF: \
__ret |= _FP_ROUND_PINF(wc,X); \
break; \
case FP_RND_MINF: \
__ret |= _FP_ROUND_MINF(wc,X); \
break; \
}; \
__ret; \
})
#define FP_CLS_NORMAL 0
#define FP_CLS_ZERO 1
#define FP_CLS_INF 2
#define FP_CLS_NAN 3
#define _FP_CLS_COMBINE(x,y) (((x) << 2) | (y))
#include "op-1.h"
#include "op-2.h"
#include "op-4.h"
#include "op-common.h"
/* Sigh. Silly things longlong.h needs. */
#define UWtype _FP_W_TYPE
#define W_TYPE_SIZE _FP_W_TYPE_SIZE
typedef int SItype __attribute__((mode(SI)));
typedef int DItype __attribute__((mode(DI)));
typedef unsigned int USItype __attribute__((mode(SI)));
typedef unsigned int UDItype __attribute__((mode(DI)));
#if _FP_W_TYPE_SIZE == 32
typedef unsigned int UHWtype __attribute__((mode(HI)));
#elif _FP_W_TYPE_SIZE == 64
typedef USItype UHWtype;
#endif
#endif
...@@ -2,23 +2,24 @@ ...@@ -2,23 +2,24 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "soft-fp.h" #include <asm/sfp-machine.h>
#include "double.h" #include <math-emu/soft-fp.h>
#include "single.h" #include <math-emu/double.h>
#include <math-emu/single.h>
int int
stfs(void *frS, void *ea) stfs(void *frS, void *ea)
{ {
FP_DECL_D(A); FP_DECL_D(A);
FP_DECL_S(R); FP_DECL_S(R);
FP_DECL_EX;
float f; float f;
int err;
#ifdef DEBUG #ifdef DEBUG
printk("%s: S %p, ea %p\n", __func__, frS, ea); printk("%s: S %p, ea %p\n", __func__, frS, ea);
#endif #endif
__FP_UNPACK_D(A, frS); FP_UNPACK_DP(A, frS);
#ifdef DEBUG #ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
...@@ -30,12 +31,12 @@ stfs(void *frS, void *ea) ...@@ -30,12 +31,12 @@ stfs(void *frS, void *ea)
printk("R: %ld %lu %ld (%ld)\n", R_s, R_f, R_e, R_c); printk("R: %ld %lu %ld (%ld)\n", R_s, R_f, R_e, R_c);
#endif #endif
err = _FP_PACK_CANONICAL(S, 1, R); _FP_PACK_CANONICAL(S, 1, R);
if (!err || !__FPU_TRAP_P(err)) { if (!FP_CUR_EXCEPTIONS || !__FPU_TRAP_P(FP_CUR_EXCEPTIONS)) {
__FP_PACK_RAW_1(S, &f, R); _FP_PACK_RAW_1_P(S, &f, R);
if (copy_to_user(ea, &f, sizeof(float))) if (copy_to_user(ea, &f, sizeof(float)))
return -EFAULT; return -EFAULT;
} }
return err; return FP_CUR_EXCEPTIONS;
} }
#include "soft-fp.h"
#include "double.h"
#include "single.h"
void
fp_unpack_d(long *_s, unsigned long *_f1, unsigned long *_f0,
long *_e, long *_c, void *val)
{
FP_DECL_D(X);
__FP_UNPACK_RAW_2(D, X, val);
_FP_UNPACK_CANONICAL(D, 2, X);
*_s = X_s;
*_f1 = X_f1;
*_f0 = X_f0;
*_e = X_e;
*_c = X_c;
}
int
fp_pack_d(void *val, long X_s, unsigned long X_f1,
unsigned long X_f0, long X_e, long X_c)
{
int exc;
exc = _FP_PACK_CANONICAL(D, 2, X);
if (!exc || !__FPU_TRAP_P(exc))
__FP_PACK_RAW_2(D, val, X);
return exc;
}
int
fp_pack_ds(void *val, long X_s, unsigned long X_f1,
unsigned long X_f0, long X_e, long X_c)
{
FP_DECL_S(__X);
int exc;
FP_CONV(S, D, 1, 2, __X, X);
exc = _FP_PACK_CANONICAL(S, 1, __X);
if (!exc || !__FPU_TRAP_P(exc)) {
_FP_UNPACK_CANONICAL(S, 1, __X);
FP_CONV(D, S, 2, 1, X, __X);
exc |= _FP_PACK_CANONICAL(D, 2, X);
if (!exc || !__FPU_TRAP_P(exc))
__FP_PACK_RAW_2(D, val, X);
}
return exc;
}
/* This has so very few changes over libgcc2's __udivmoddi4 it isn't funny. */ /* This has so very few changes over libgcc2's __udivmoddi4 it isn't funny. */
#include "soft-fp.h" #include <math-emu/soft-fp.h>
#undef count_leading_zeros #undef count_leading_zeros
#define count_leading_zeros __FP_CLZ #define count_leading_zeros __FP_CLZ
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment