xref: /openbmc/linux/arch/powerpc/math-emu/fsel.c (revision fbb6b31a)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/types.h>
3 #include <linux/errno.h>
4 #include <linux/uaccess.h>
5 
6 #include <asm/sfp-machine.h>
7 #include <math-emu/soft-fp.h>
8 #include <math-emu/double.h>
9 
10 int
11 fsel(u32 *frD, void *frA, u32 *frB, u32 *frC)
12 {
13 	FP_DECL_D(A);
14 	FP_DECL_EX;
15 
16 #ifdef DEBUG
17 	printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
18 #endif
19 
20 	FP_UNPACK_DP(A, frA);
21 
22 #ifdef DEBUG
23 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
24 	printk("B: %08x %08x\n", frB[0], frB[1]);
25 	printk("C: %08x %08x\n", frC[0], frC[1]);
26 #endif
27 
28 	if (A_c == FP_CLS_NAN || (A_c != FP_CLS_ZERO && A_s)) {
29 		frD[0] = frB[0];
30 		frD[1] = frB[1];
31 	} else {
32 		frD[0] = frC[0];
33 		frD[1] = frC[1];
34 	}
35 
36 #ifdef DEBUG
37 	printk("D: %08x.%08x\n", frD[0], frD[1]);
38 #endif
39 
40 	return 0;
41 }
42