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