1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
25cd27208SKumar Gala #include <linux/types.h>
35cd27208SKumar Gala #include <linux/errno.h>
47c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
55cd27208SKumar Gala
6d2b194edSKumar Gala #include <asm/sfp-machine.h>
7d2b194edSKumar Gala #include <math-emu/soft-fp.h>
8d2b194edSKumar Gala #include <math-emu/double.h>
95cd27208SKumar Gala
105cd27208SKumar Gala int
fmsub(void * frD,void * frA,void * frB,void * frC)115cd27208SKumar Gala fmsub(void *frD, void *frA, void *frB, void *frC)
125cd27208SKumar Gala {
135cd27208SKumar Gala FP_DECL_D(R);
145cd27208SKumar Gala FP_DECL_D(A);
155cd27208SKumar Gala FP_DECL_D(B);
165cd27208SKumar Gala FP_DECL_D(C);
175cd27208SKumar Gala FP_DECL_D(T);
18d2b194edSKumar Gala FP_DECL_EX;
195cd27208SKumar Gala
205cd27208SKumar Gala #ifdef DEBUG
21e48b1b45SHarvey Harrison printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
225cd27208SKumar Gala #endif
235cd27208SKumar Gala
24d2b194edSKumar Gala FP_UNPACK_DP(A, frA);
25d2b194edSKumar Gala FP_UNPACK_DP(B, frB);
26d2b194edSKumar Gala FP_UNPACK_DP(C, frC);
275cd27208SKumar Gala
285cd27208SKumar Gala #ifdef DEBUG
295cd27208SKumar Gala printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
305cd27208SKumar Gala printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
315cd27208SKumar Gala printk("C: %ld %lu %lu %ld (%ld)\n", C_s, C_f1, C_f0, C_e, C_c);
325cd27208SKumar Gala #endif
335cd27208SKumar Gala
345cd27208SKumar Gala if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
355cd27208SKumar Gala (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
36033b8a33SLiu Yu FP_SET_EXCEPTION(EFLAG_VXIMZ);
375cd27208SKumar Gala
385cd27208SKumar Gala FP_MUL_D(T, A, C);
395cd27208SKumar Gala
405cd27208SKumar Gala if (B_c != FP_CLS_NAN)
415cd27208SKumar Gala B_s ^= 1;
425cd27208SKumar Gala
435cd27208SKumar Gala if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
44033b8a33SLiu Yu FP_SET_EXCEPTION(EFLAG_VXISI);
455cd27208SKumar Gala
465cd27208SKumar Gala FP_ADD_D(R, T, B);
475cd27208SKumar Gala
485cd27208SKumar Gala #ifdef DEBUG
495cd27208SKumar Gala printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
505cd27208SKumar Gala #endif
515cd27208SKumar Gala
52d2b194edSKumar Gala __FP_PACK_D(frD, R);
53d2b194edSKumar Gala
54d2b194edSKumar Gala return FP_CUR_EXCEPTIONS;
555cd27208SKumar Gala }
56