int fsqrts(void *frD, void *frB) { FP_DECL_D(B); FP_DECL_D(R); FP_DECL_EX; #ifdef DEBUG printk("%s: %p %p %p %p\n", __func__, frD, frB); #endif FP_UNPACK_DP(B, frB); #ifdef DEBUG printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c); #endif if (B_s && B_c != FP_CLS_ZERO) FP_SET_EXCEPTION(EFLAG_VXSQRT); if (B_c == FP_CLS_NAN) FP_SET_EXCEPTION(EFLAG_VXSNAN); FP_SQRT_D(R, B); #ifdef DEBUG printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); #endif __FP_PACK_DS(frD, R); return FP_CUR_EXCEPTIONS; }
int fadds(void *frD, void *frA, void *frB) { FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R); FP_DECL_EX; #ifdef DEBUG printk("%s: %p %p %p\n", __func__, frD, frA, frB); #endif FP_UNPACK_DP(A, frA); FP_UNPACK_DP(B, frB); #ifdef DEBUG 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); #endif FP_ADD_D(R, A, B); #ifdef DEBUG printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); #endif __FP_PACK_DS(frD, R); return FP_CUR_EXCEPTIONS; }
int fmuls(void *frD, void *frA, void *frB) { FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R); int ret = 0; #ifdef DEBUG printk("%s: %p %p %p\n", __func__, frD, frA, frB); #endif __FP_UNPACK_D(A, frA); __FP_UNPACK_D(B, frB); #ifdef DEBUG printk("A: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n", A_s, A_f1, A_f0, A_e, A_c, A_f1, A_f0, A_e + 1023); printk("B: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n", B_s, B_f1, B_f0, B_e, B_c, B_f1, B_f0, B_e + 1023); #endif if ((A_c == FP_CLS_INF && B_c == FP_CLS_ZERO) || (A_c == FP_CLS_ZERO && B_c == FP_CLS_INF)) ret |= EFLAG_VXIMZ; FP_MUL_D(R, A, B); #ifdef DEBUG printk("D: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n", R_s, R_f1, R_f0, R_e, R_c, R_f1, R_f0, R_e + 1023); #endif return (ret | __FP_PACK_DS(frD, R)); }
int fcmpu(u32 *ccr, int crfD, void *frA, void *frB) { FP_DECL_D(A); FP_DECL_D(B); int code[4] = { (1 << 3), (1 << 1), (1 << 2), (1 << 0) }; long cmp; #ifdef DEBUG printk("%s: %p (%08x) %d %p %p\n", __FUNCTION__, ccr, *ccr, crfD, frA, frB); #endif __FP_UNPACK_D(A, frA); __FP_UNPACK_D(B, frB); #ifdef DEBUG 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); #endif FP_CMP_D(cmp, A, B, 2); cmp = code[(cmp + 1) & 3]; __FPU_FPSCR &= ~(0x1f000); __FPU_FPSCR |= (cmp << 12); *ccr &= ~(15 << ((7 - crfD) << 2)); *ccr |= (cmp << ((7 - crfD) << 2)); #ifdef DEBUG printk("CR: %08x\n", *ccr); #endif return 0; }
int fadds(void *frD, void *frA, void *frB) { FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R); int ret = 0; #ifdef DEBUG printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB); #endif __FP_UNPACK_D(A, frA); __FP_UNPACK_D(B, frB); #ifdef DEBUG 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); #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); #ifdef DEBUG printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); #endif return (ret | __FP_PACK_DS(frD, R)); }
int fsqrts(void *frD, void *frB) { FP_DECL_D(B); FP_DECL_D(R); int ret = 0; #ifdef DEBUG printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frB); #endif __FP_UNPACK_D(B, frB); #ifdef DEBUG printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c); #endif if (B_s && B_c != FP_CLS_ZERO) ret |= EFLAG_VXSQRT; if (B_c == FP_CLS_NAN) ret |= EFLAG_VXSNAN; FP_SQRT_D(R, B); #ifdef DEBUG printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); #endif return (ret | __FP_PACK_DS(frD, R)); }
CMPtype __unorddf2(DFtype a, DFtype b) { FP_DECL_D(A); FP_DECL_D(B); CMPtype r; FP_UNPACK_RAW_D(A, a); FP_UNPACK_RAW_D(B, b); FP_CMP_UNORD_D(r, A, B); return r; }
CMPtype __c6xabi_eqd(DFtype a, DFtype b) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(B); CMPtype r; FP_UNPACK_RAW_D(A, a); FP_UNPACK_RAW_D(B, b); FP_CMP_EQ_D(r, A, B, 1); FP_HANDLE_EXCEPTIONS; return !r; }
CMPtype __c6xabi_ged(DFtype a, DFtype b) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(B); CMPtype r; FP_UNPACK_RAW_D(A, a); FP_UNPACK_RAW_D(B, b); FP_CMP_D(r, A, B, -2, 2); FP_HANDLE_EXCEPTIONS; return r >= 0; }
DFtype __negdf2 (DFtype a) { FP_DECL_D (A); FP_DECL_D (R); DFtype r; FP_UNPACK_RAW_D (A, a); FP_NEG_D (R, A); FP_PACK_RAW_D (r, R); return r; }
DFtype __negdf2(DFtype a) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(R); DFtype r; FP_UNPACK_D(A, a); FP_NEG_D(R, A); FP_PACK_D(r, R); FP_CLEAR_EXCEPTIONS; FP_HANDLE_EXCEPTIONS; return r; }
double __sqrtdf2(double a) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(R); double r; FP_INIT_ROUNDMODE; FP_UNPACK_D(A, a); FP_SQRT_D(R, A); FP_PACK_D(r, R); FP_HANDLE_EXCEPTIONS; return r; }
void fsqrtd(void *ft, void *fa) { FP_DECL_D(A); FP_DECL_D(R); FP_DECL_EX; FP_UNPACK_DP(A, fa); FP_SQRT_D(R, A); FP_PACK_DP(ft, R); __FPU_FPCSR |= FP_CUR_EXCEPTIONS; }
int fdivs(void *frD, void *frA, void *frB) { FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R); FP_DECL_EX; #ifdef DEBUG printk("%s: %p %p %p\n", __func__, frD, frA, frB); #endif FP_UNPACK_DP(A, frA); FP_UNPACK_DP(B, frB); #ifdef DEBUG 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); #endif if (A_c == FP_CLS_ZERO && B_c == FP_CLS_ZERO) { FP_SET_EXCEPTION(EFLAG_VXZDZ); #ifdef DEBUG printk("%s: FPSCR_VXZDZ raised\n", __func__); #endif } if (A_c == FP_CLS_INF && B_c == FP_CLS_INF) { FP_SET_EXCEPTION(EFLAG_VXIDI); #ifdef DEBUG printk("%s: FPSCR_VXIDI raised\n", __func__); #endif } if (B_c == FP_CLS_ZERO && A_c != FP_CLS_ZERO) { FP_SET_EXCEPTION(EFLAG_DIVZERO); if (__FPU_TRAP_P(EFLAG_DIVZERO)) return FP_CUR_EXCEPTIONS; } FP_DIV_D(R, A, B); #ifdef DEBUG printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); #endif __FP_PACK_DS(frD, R); return FP_CUR_EXCEPTIONS; }
int fnmsub(void *frD, void *frA, void *frB, void *frC) { FP_DECL_D(R); FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(C); FP_DECL_D(T); FP_DECL_EX; #ifdef DEBUG printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); #endif FP_UNPACK_DP(A, frA); FP_UNPACK_DP(B, frB); FP_UNPACK_DP(C, frC); #ifdef DEBUG 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("C: %ld %lu %lu %ld (%ld)\n", C_s, C_f1, C_f0, C_e, C_c); #endif if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) || (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF)) FP_SET_EXCEPTION(EFLAG_VXIMZ); FP_MUL_D(T, A, C); if (B_c != FP_CLS_NAN) B_s ^= 1; if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF) FP_SET_EXCEPTION(EFLAG_VXISI); FP_ADD_D(R, T, B); if (R_c != FP_CLS_NAN) R_s ^= 1; #ifdef DEBUG printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); #endif __FP_PACK_D(frD, R); return FP_CUR_EXCEPTIONS; }
CMPtype __c6xabi_ltd(DFtype a, DFtype b) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(B); CMPtype r; FP_UNPACK_RAW_D(A, a); FP_UNPACK_RAW_D(B, b); FP_CMP_D(r, A, B, 2); if (r == 2 && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B))) FP_SET_EXCEPTION(FP_EX_INVALID); FP_HANDLE_EXCEPTIONS; return r < 0; }
int __gedf2(double a, double b) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(B); int r; FP_UNPACK_RAW_D(A, a); FP_UNPACK_RAW_D(B, b); FP_CMP_D(r, A, B, -2); if (r == -2 && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B))) FP_SET_EXCEPTION(FP_EX_INVALID); FP_HANDLE_EXCEPTIONS; return r; }
DFtype __divdf3(DFtype a, DFtype b) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R); DFtype r; FP_INIT_ROUNDMODE; FP_UNPACK_D(A, a); FP_UNPACK_D(B, b); FP_DIV_D(R, A, B); FP_PACK_D(r, R); FP_HANDLE_EXCEPTIONS; return r; }
DFtype __adddf3(DFtype a, DFtype b) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R); DFtype r; FP_INIT_ROUNDMODE; FP_UNPACK_SEMIRAW_D(A, a); FP_UNPACK_SEMIRAW_D(B, b); FP_ADD_D(R, A, B); FP_PACK_SEMIRAW_D(r, R); FP_HANDLE_EXCEPTIONS; return r; }
int __eqdf2(DFtype a, DFtype b) { FP_DECL_EX; FP_DECL_D(A); FP_DECL_D(B); int r; FP_UNPACK_RAW_D(A, a); FP_UNPACK_RAW_D(B, b); FP_CMP_EQ_D(r, A, B); if (r && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B))) FP_SET_EXCEPTION(FP_EX_INVALID); FP_HANDLE_EXCEPTIONS; return r; }
int stfs(void *frS, void *ea) { FP_DECL_D(A); FP_DECL_S(R); float f; int err; #ifdef DEBUG printk("%s: S %p, ea %p\n", __FUNCTION__, frS, ea); #endif __FP_UNPACK_D(A, frS); #ifdef DEBUG printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); #endif FP_CONV(S, D, 1, 2, R, A); #ifdef DEBUG printk("R: %ld %lu %ld (%ld)\n", R_s, R_f, R_e, R_c); #endif err = _FP_PACK_CANONICAL(S, 1, R); if (!err || !__FPU_TRAP_P(err)) { __FP_PACK_RAW_1(S, &f, R); if (copy_to_user(ea, &f, sizeof(float))) return -EFAULT; } return err; }
int fctiwz(u32 *frD, void *frB) { FP_DECL_D(B); FP_DECL_EX; u32 fpscr; unsigned int r; fpscr = __FPU_FPSCR; __FPU_FPSCR &= ~(3); __FPU_FPSCR |= FP_RND_ZERO; FP_UNPACK_DP(B, frB); FP_TO_INT_D(r, B, 32, 1); frD[1] = r; __FPU_FPSCR = fpscr; #ifdef DEBUG printk("%s: D %p, B %p: ", __func__, frD, frB); dump_double(frD); printk("\n"); #endif return 0; }
CMPtype __gedf2 (DFtype a, DFtype b) { FP_DECL_EX; FP_DECL_D (A); FP_DECL_D (B); CMPtype r; FP_INIT_EXCEPTIONS; FP_UNPACK_RAW_D (A, a); FP_UNPACK_RAW_D (B, b); FP_CMP_D (r, A, B, -2, 2); FP_HANDLE_EXCEPTIONS; return r; }
int fsel(u32 *frD, void *frA, u32 *frB, u32 *frC) { FP_DECL_D(A); FP_DECL_EX; #ifdef DEBUG printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC); #endif FP_UNPACK_DP(A, frA); #ifdef DEBUG printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); printk("B: %08x %08x\n", frB[0], frB[1]); printk("C: %08x %08x\n", frC[0], frC[1]); #endif if (A_c == FP_CLS_NAN || (A_c != FP_CLS_ZERO && A_s)) { frD[0] = frB[0]; frD[1] = frB[1]; } else { frD[0] = frC[0]; frD[1] = frC[1]; } #ifdef DEBUG printk("D: %08x.%08x\n", frD[0], frD[1]); #endif return 0; }
int stfs(void *frS, void *ea) { FP_DECL_D(A); FP_DECL_S(R); FP_DECL_EX; float f; #ifdef DEBUG printk("%s: S %p, ea %p\n", __func__, frS, ea); #endif FP_UNPACK_DP(A, frS); #ifdef DEBUG printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c); #endif FP_CONV(S, D, 1, 2, R, A); #ifdef DEBUG printk("R: %ld %lu %ld (%ld)\n", R_s, R_f, R_e, R_c); #endif _FP_PACK_CANONICAL(S, 1, R); if (!FP_CUR_EXCEPTIONS || !__FPU_TRAP_P(FP_CUR_EXCEPTIONS)) { _FP_PACK_RAW_1_P(S, &f, R); if (copy_to_user(ea, &f, sizeof(float))) return -EFAULT; } return FP_CUR_EXCEPTIONS; }
int fnmsub(void *frD, void *frA, void *frB, void *frC) { FP_DECL_D(R); FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(C); FP_DECL_D(T); int ret = 0; #ifdef DEBUG printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC); #endif __FP_UNPACK_D(A, frA); __FP_UNPACK_D(B, frB); __FP_UNPACK_D(C, frC); #ifdef DEBUG 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("C: %ld %lu %lu %ld (%ld)\n", C_s, C_f1, C_f0, C_e, C_c); #endif if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) || (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF)) ret |= EFLAG_VXIMZ; FP_MUL_D(T, A, C); if (B_c != FP_CLS_NAN) B_s ^= 1; if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF) ret |= EFLAG_VXISI; FP_ADD_D(R, T, B); if (R_c != FP_CLS_NAN) R_s ^= 1; #ifdef DEBUG printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); #endif return (ret | __FP_PACK_D(frD, R)); }
int fdiv(void *frD, void *frA, void *frB) { FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R); int ret = 0; #ifdef DEBUG printk("%s: %p %p %p\n", __func__, frD, frA, frB); #endif __FP_UNPACK_D(A, frA); __FP_UNPACK_D(B, frB); #ifdef DEBUG 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); #endif if (A_c == FP_CLS_ZERO && B_c == FP_CLS_ZERO) { ret |= EFLAG_VXZDZ; #ifdef DEBUG printk("%s: FPSCR_VXZDZ raised\n", __func__); #endif } if (A_c == FP_CLS_INF && B_c == FP_CLS_INF) { ret |= EFLAG_VXIDI; #ifdef DEBUG printk("%s: FPSCR_VXIDI raised\n", __func__); #endif } if (B_c == FP_CLS_ZERO && A_c != FP_CLS_ZERO) { ret |= EFLAG_DIVZERO; if (__FPU_TRAP_P(EFLAG_DIVZERO)) return ret; } FP_DIV_D(R, A, B); #ifdef DEBUG printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c); #endif return (ret | __FP_PACK_D(frD, R)); }
CMPtype __gedf2 (DFtype a, DFtype b) { FP_DECL_EX; FP_DECL_D (A); FP_DECL_D (B); CMPtype r; FP_INIT_EXCEPTIONS; FP_UNPACK_RAW_D (A, a); FP_UNPACK_RAW_D (B, b); FP_CMP_D (r, A, B, -2); if (r == -2) FP_SET_EXCEPTION (FP_EX_INVALID); FP_HANDLE_EXCEPTIONS; return r; }
static int fcnvds(struct sh_fpu_soft_struct *fregs, int n) { FP_DECL_EX; FP_DECL_D(Fn); FP_DECL_S(Fr); UNPACK_D(Fn, DRn); FP_CONV(S, D, 1, 2, Fr, Fn); PACK_S(FPUL, Fr); return 0; }
int FDTOI(unsigned *rd, void *rs2) { FP_DECL_D(A); unsigned r; __FP_UNPACK_D(A, rs2); FP_TO_INT_D(r, A, 32, 1); *rd = r; return 1; }