Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/types.h>
0003 #include <linux/errno.h>
0004 #include <linux/uaccess.h>
0005 
0006 #include <asm/sfp-machine.h>
0007 #include <math-emu/soft-fp.h>
0008 #include <math-emu/double.h>
0009 #include <math-emu/single.h>
0010 
0011 int
0012 fmadds(void *frD, void *frA, void *frB, void *frC)
0013 {
0014     FP_DECL_D(R);
0015     FP_DECL_D(A);
0016     FP_DECL_D(B);
0017     FP_DECL_D(C);
0018     FP_DECL_D(T);
0019     FP_DECL_EX;
0020 
0021 #ifdef DEBUG
0022     printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
0023 #endif
0024 
0025     FP_UNPACK_DP(A, frA);
0026     FP_UNPACK_DP(B, frB);
0027     FP_UNPACK_DP(C, frC);
0028 
0029 #ifdef DEBUG
0030     printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
0031     printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
0032     printk("C: %ld %lu %lu %ld (%ld)\n", C_s, C_f1, C_f0, C_e, C_c);
0033 #endif
0034 
0035     if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
0036         (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
0037                 FP_SET_EXCEPTION(EFLAG_VXIMZ);
0038 
0039     FP_MUL_D(T, A, C);
0040 
0041     if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
0042         FP_SET_EXCEPTION(EFLAG_VXISI);
0043 
0044     FP_ADD_D(R, T, B);
0045 
0046 #ifdef DEBUG
0047     printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
0048 #endif
0049 
0050     __FP_PACK_DS(frD, R);
0051 
0052     return FP_CUR_EXCEPTIONS;
0053 }