xref: /linux/arch/powerpc/math-emu/fmsub.c (revision 5cd272085bbc905532869f3e1fd18a7100496b56)
1*5cd27208SKumar Gala #include <linux/types.h>
2*5cd27208SKumar Gala #include <linux/errno.h>
3*5cd27208SKumar Gala #include <asm/uaccess.h>
4*5cd27208SKumar Gala 
5*5cd27208SKumar Gala #include "soft-fp.h"
6*5cd27208SKumar Gala #include "double.h"
7*5cd27208SKumar Gala 
8*5cd27208SKumar Gala int
9*5cd27208SKumar Gala fmsub(void *frD, void *frA, void *frB, void *frC)
10*5cd27208SKumar Gala {
11*5cd27208SKumar Gala 	FP_DECL_D(R);
12*5cd27208SKumar Gala 	FP_DECL_D(A);
13*5cd27208SKumar Gala 	FP_DECL_D(B);
14*5cd27208SKumar Gala 	FP_DECL_D(C);
15*5cd27208SKumar Gala 	FP_DECL_D(T);
16*5cd27208SKumar Gala 	int ret = 0;
17*5cd27208SKumar Gala 
18*5cd27208SKumar Gala #ifdef DEBUG
19*5cd27208SKumar Gala 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
20*5cd27208SKumar Gala #endif
21*5cd27208SKumar Gala 
22*5cd27208SKumar Gala 	__FP_UNPACK_D(A, frA);
23*5cd27208SKumar Gala 	__FP_UNPACK_D(B, frB);
24*5cd27208SKumar Gala 	__FP_UNPACK_D(C, frC);
25*5cd27208SKumar Gala 
26*5cd27208SKumar Gala #ifdef DEBUG
27*5cd27208SKumar Gala 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
28*5cd27208SKumar Gala 	printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
29*5cd27208SKumar Gala 	printk("C: %ld %lu %lu %ld (%ld)\n", C_s, C_f1, C_f0, C_e, C_c);
30*5cd27208SKumar Gala #endif
31*5cd27208SKumar Gala 
32*5cd27208SKumar Gala 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
33*5cd27208SKumar Gala 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
34*5cd27208SKumar Gala 		ret |= EFLAG_VXIMZ;
35*5cd27208SKumar Gala 
36*5cd27208SKumar Gala 	FP_MUL_D(T, A, C);
37*5cd27208SKumar Gala 
38*5cd27208SKumar Gala 	if (B_c != FP_CLS_NAN)
39*5cd27208SKumar Gala 		B_s ^= 1;
40*5cd27208SKumar Gala 
41*5cd27208SKumar Gala 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
42*5cd27208SKumar Gala 		ret |= EFLAG_VXISI;
43*5cd27208SKumar Gala 
44*5cd27208SKumar Gala 	FP_ADD_D(R, T, B);
45*5cd27208SKumar Gala 
46*5cd27208SKumar Gala #ifdef DEBUG
47*5cd27208SKumar Gala 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
48*5cd27208SKumar Gala #endif
49*5cd27208SKumar Gala 
50*5cd27208SKumar Gala 	return (ret | __FP_PACK_D(frD, R));
51*5cd27208SKumar Gala }
52