2 * arch/sparc64/math-emu/sfp-util.h
4 * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz)
5 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/types.h>
12 #include <asm/byteorder.h>
14 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
15 __asm__ ("addcc %4,%5,%1\n\t" \
17 "bcs,a,pn %%xcc, 1f\n\t" \
22 : "r" ((UDItype)(ah)), \
23 "r" ((UDItype)(bh)), \
24 "r" ((UDItype)(al)), \
28 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
29 __asm__ ("subcc %4,%5,%1\n\t" \
31 "bcs,a,pn %%xcc, 1f\n\t" \
36 : "r" ((UDItype)(ah)), \
37 "r" ((UDItype)(bh)), \
38 "r" ((UDItype)(al)), \
42 #define umul_ppmm(wh, wl, u, v) \
44 UDItype tmp1, tmp2, tmp3, tmp4; \
45 __asm__ __volatile__ ( \
54 "addcc %4,%5,%4\n\t" \
58 "sethi %%hi(0x80000000),%2\n\t" \
59 "addcc %4,%3,%4\n\t" \
62 "movcc %%xcc,%%g0,%2\n\t" \
63 "addcc %5,%4,%5\n\t" \
69 "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
70 : "r" ((UDItype)(u)), \
75 #define udiv_qrnnd(q, r, n1, n0, d) \
77 UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \
83 __m = (UWtype) __q1 * __d0; \
84 __r1 = (__r1 << 32) | (n0 >> 32); \
87 __q1--, __r1 += (d); \
88 if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */ \
90 __q1--, __r1 += (d); \
96 __m = (UWtype) __q0 * __d0; \
97 __r0 = (__r0 << 32) | ((USItype)n0); \
100 __q0--, __r0 += (d); \
103 __q0--, __r0 += (d); \
107 (q) = (UWtype) (__q1 << 32) | __q0; \
111 #define UDIV_NEEDS_NORMALIZATION 1
117 #define __BYTE_ORDER __BIG_ENDIAN
119 #define __BYTE_ORDER __LITTLE_ENDIAN