1 /* SPDX-License-Identifier: GPL-2.0 */
3 * arch/sparc64/math-emu/sfp-util.h
5 * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz)
6 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
10 #include <linux/kernel.h>
11 #include <linux/sched.h>
12 #include <linux/types.h>
13 #include <asm/byteorder.h>
15 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
16 __asm__ ("addcc %4,%5,%1\n\t" \
18 "bcs,a,pn %%xcc, 1f\n\t" \
23 : "r" ((UDItype)(ah)), \
24 "r" ((UDItype)(bh)), \
25 "r" ((UDItype)(al)), \
29 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
30 __asm__ ("subcc %4,%5,%1\n\t" \
32 "bcs,a,pn %%xcc, 1f\n\t" \
37 : "r" ((UDItype)(ah)), \
38 "r" ((UDItype)(bh)), \
39 "r" ((UDItype)(al)), \
43 #define umul_ppmm(wh, wl, u, v) \
45 UDItype tmp1, tmp2, tmp3, tmp4; \
46 __asm__ __volatile__ ( \
55 "addcc %4,%5,%4\n\t" \
59 "sethi %%hi(0x80000000),%2\n\t" \
60 "addcc %4,%3,%4\n\t" \
63 "movcc %%xcc,%%g0,%2\n\t" \
64 "addcc %5,%4,%5\n\t" \
70 "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
71 : "r" ((UDItype)(u)), \
76 #define udiv_qrnnd(q, r, n1, n0, d) \
78 UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \
84 __m = (UWtype) __q1 * __d0; \
85 __r1 = (__r1 << 32) | (n0 >> 32); \
88 __q1--, __r1 += (d); \
89 if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */ \
91 __q1--, __r1 += (d); \
97 __m = (UWtype) __q0 * __d0; \
98 __r0 = (__r0 << 32) | ((USItype)n0); \
101 __q0--, __r0 += (d); \
104 __q0--, __r0 += (d); \
108 (q) = (UWtype) (__q1 << 32) | __q0; \
112 #define UDIV_NEEDS_NORMALIZATION 1
118 #define __BYTE_ORDER __BIG_ENDIAN
120 #define __BYTE_ORDER __LITTLE_ENDIAN