📄 longlong.h
字号:
__asm__ ("! Inlined udiv_qrnnd\n" \" mov 32,%%g1\n" \" subcc %1,%2,%%g0\n" \"1: bcs 5f\n" \" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \" sub %1,%2,%1 ! this kills msb of n\n" \" addx %1,%1,%1 ! so this can't give carry\n" \" subcc %%g1,1,%%g1\n" \"2: bne 1b\n" \" subcc %1,%2,%%g0\n" \" bcs 3f\n" \" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \" b 3f\n" \" sub %1,%2,%1 ! this kills msb of n\n" \"4: sub %1,%2,%1\n" \"5: addxcc %1,%1,%1\n" \" bcc 2b\n" \" subcc %%g1,1,%%g1\n" \"! Got carry from n. Subtract next step to cancel this carry.\n" \" bne 4b\n" \" addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb\n" \" sub %1,%2,%1\n" \"3: xnor %0,0,%0\n" \" ! End of inline udiv_qrnnd" \ : "=&r" ((USItype) (__q)), \ "=&r" ((USItype) (__r)) \ : "r" ((USItype) (__d)), \ "1" ((USItype) (__n1)), \ "0" ((USItype) (__n0)) : "g1" __AND_CLOBBER_CC)#define UDIV_TIME (3+7*32) /* 7 instructions/iteration. 32 iterations. */#endif /* __sparclite__ */#endif /* __sparc_v8__ */#endif /* sparc32 */#if ((defined (__sparc__) && defined (__arch64__)) || defined (__sparcv9)) \ && W_TYPE_SIZE == 64#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addcc %r4,%5,%1\n\t" \ "add %r2,%3,%0\n\t" \ "bcs,a,pn %%xcc, 1f\n\t" \ "add %0, 1, %0\n" \ "1:" \ : "=r" ((UDItype)(sh)), \ "=&r" ((UDItype)(sl)) \ : "%rJ" ((UDItype)(ah)), \ "rI" ((UDItype)(bh)), \ "%rJ" ((UDItype)(al)), \ "rI" ((UDItype)(bl)) \ __CLOBBER_CC)#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subcc %r4,%5,%1\n\t" \ "sub %r2,%3,%0\n\t" \ "bcs,a,pn %%xcc, 1f\n\t" \ "sub %0, 1, %0\n\t" \ "1:" \ : "=r" ((UDItype)(sh)), \ "=&r" ((UDItype)(sl)) \ : "rJ" ((UDItype)(ah)), \ "rI" ((UDItype)(bh)), \ "rJ" ((UDItype)(al)), \ "rI" ((UDItype)(bl)) \ __CLOBBER_CC)#define umul_ppmm(wh, wl, u, v) \ do { \ UDItype tmp1, tmp2, tmp3, tmp4; \ __asm__ __volatile__ ( \ "srl %7,0,%3\n\t" \ "mulx %3,%6,%1\n\t" \ "srlx %6,32,%2\n\t" \ "mulx %2,%3,%4\n\t" \ "sllx %4,32,%5\n\t" \ "srl %6,0,%3\n\t" \ "sub %1,%5,%5\n\t" \ "srlx %5,32,%5\n\t" \ "addcc %4,%5,%4\n\t" \ "srlx %7,32,%5\n\t" \ "mulx %3,%5,%3\n\t" \ "mulx %2,%5,%5\n\t" \ "sethi %%hi(0x80000000),%2\n\t" \ "addcc %4,%3,%4\n\t" \ "srlx %4,32,%4\n\t" \ "add %2,%2,%2\n\t" \ "movcc %%xcc,%%g0,%2\n\t" \ "addcc %5,%4,%5\n\t" \ "sllx %3,32,%3\n\t" \ "add %1,%3,%1\n\t" \ "add %5,%2,%0" \ : "=r" ((UDItype)(wh)), \ "=&r" ((UDItype)(wl)), \ "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \ : "r" ((UDItype)(u)), \ "r" ((UDItype)(v)) \ __CLOBBER_CC); \ } while (0)#define UMUL_TIME 96#define UDIV_TIME 230#endif /* sparc64 */#if defined (__vax__) && W_TYPE_SIZE == 32#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl2 %5,%1\n\tadwc %3,%0" \ : "=g" ((USItype) (sh)), \ "=&g" ((USItype) (sl)) \ : "%0" ((USItype) (ah)), \ "g" ((USItype) (bh)), \ "%1" ((USItype) (al)), \ "g" ((USItype) (bl)))#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl2 %5,%1\n\tsbwc %3,%0" \ : "=g" ((USItype) (sh)), \ "=&g" ((USItype) (sl)) \ : "0" ((USItype) (ah)), \ "g" ((USItype) (bh)), \ "1" ((USItype) (al)), \ "g" ((USItype) (bl)))#define umul_ppmm(xh, xl, m0, m1) \ do { \ union { \ UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __xx; \ USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("emul %1,%2,$0,%0" \ : "=r" (__xx.__ll) \ : "g" (__m0), \ "g" (__m1)); \ (xh) = __xx.__i.__h; \ (xl) = __xx.__i.__l; \ (xh) += ((((SItype) __m0 >> 31) & __m1) \ + (((SItype) __m1 >> 31) & __m0)); \ } while (0)#define sdiv_qrnnd(q, r, n1, n0, d) \ do { \ union {DItype __ll; \ struct {SItype __l, __h;} __i; \ } __xx; \ __xx.__i.__h = n1; __xx.__i.__l = n0; \ __asm__ ("ediv %3,%2,%0,%1" \ : "=g" (q), "=g" (r) \ : "g" (__xx.__ll), "g" (d)); \ } while (0)#endif /* __vax__ */#if defined (__z8000__) && W_TYPE_SIZE == 16#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \ : "=r" ((unsigned int)(sh)), \ "=&r" ((unsigned int)(sl)) \ : "%0" ((unsigned int)(ah)), \ "r" ((unsigned int)(bh)), \ "%1" ((unsigned int)(al)), \ "rQR" ((unsigned int)(bl)))#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \ : "=r" ((unsigned int)(sh)), \ "=&r" ((unsigned int)(sl)) \ : "0" ((unsigned int)(ah)), \ "r" ((unsigned int)(bh)), \ "1" ((unsigned int)(al)), \ "rQR" ((unsigned int)(bl)))#define umul_ppmm(xh, xl, m0, m1) \ do { \ union {long int __ll; \ struct {unsigned int __h, __l;} __i; \ } __xx; \ unsigned int __m0 = (m0), __m1 = (m1); \ __asm__ ("mult %S0,%H3" \ : "=r" (__xx.__i.__h), \ "=r" (__xx.__i.__l) \ : "%1" (__m0), \ "rQR" (__m1)); \ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \ (xh) += ((((signed int) __m0 >> 15) & __m1) \ + (((signed int) __m1 >> 15) & __m0)); \ } while (0)#endif /* __z8000__ */#endif /* __GNUC__ *//* If this machine has no inline assembler, use C macros. */#if !defined (add_ssaaaa)#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ UWtype __x; \ __x = (al) + (bl); \ (sh) = (ah) + (bh) + (__x < (al)); \ (sl) = __x; \ } while (0)#endif#if !defined (sub_ddmmss)#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ UWtype __x; \ __x = (al) - (bl); \ (sh) = (ah) - (bh) - (__x > (al)); \ (sl) = __x; \ } while (0)#endif#if !defined (umul_ppmm)#define umul_ppmm(w1, w0, u, v) \ do { \ UWtype __x0, __x1, __x2, __x3; \ UHWtype __ul, __vl, __uh, __vh; \ \ __ul = __ll_lowpart (u); \ __uh = __ll_highpart (u); \ __vl = __ll_lowpart (v); \ __vh = __ll_highpart (v); \ \ __x0 = (UWtype) __ul * __vl; \ __x1 = (UWtype) __ul * __vh; \ __x2 = (UWtype) __uh * __vl; \ __x3 = (UWtype) __uh * __vh; \ \ __x1 += __ll_highpart (__x0);/* this can't give carry */ \ __x1 += __x2; /* but this indeed can */ \ if (__x1 < __x2) /* did we get it? */ \ __x3 += __ll_B; /* yes, add it in the proper pos. */ \ \ (w1) = __x3 + __ll_highpart (__x1); \ (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \ } while (0)#endif#if !defined (__umulsidi3)#define __umulsidi3(u, v) \ ({DWunion __w; \ umul_ppmm (__w.s.high, __w.s.low, u, v); \ __w.ll; })#endif/* Define this unconditionally, so it can be used for debugging. */#define __udiv_qrnnd_c(q, r, n1, n0, d) \ do { \ UWtype __d1, __d0, __q1, __q0; \ UWtype __r1, __r0, __m; \ __d1 = __ll_highpart (d); \ __d0 = __ll_lowpart (d); \ \ __r1 = (n1) % __d1; \ __q1 = (n1) / __d1; \ __m = (UWtype) __q1 * __d0; \ __r1 = __r1 * __ll_B | __ll_highpart (n0); \ if (__r1 < __m) \ { \ __q1--, __r1 += (d); \ if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\ if (__r1 < __m) \ __q1--, __r1 += (d); \ } \ __r1 -= __m; \ \ __r0 = __r1 % __d1; \ __q0 = __r1 / __d1; \ __m = (UWtype) __q0 * __d0; \ __r0 = __r0 * __ll_B | __ll_lowpart (n0); \ if (__r0 < __m) \ { \ __q0--, __r0 += (d); \ if (__r0 >= (d)) \ if (__r0 < __m) \ __q0--, __r0 += (d); \ } \ __r0 -= __m; \ \ (q) = (UWtype) __q1 * __ll_B | __q0; \ (r) = __r0; \ } while (0)/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through __udiv_w_sdiv (defined in libgcc or elsewhere). */#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)#define udiv_qrnnd(q, r, nh, nl, d) \ do { \ USItype __r; \ (q) = __udiv_w_sdiv (&__r, nh, nl, d); \ (r) = __r; \ } while (0)#endif/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */#if !defined (udiv_qrnnd)#define UDIV_NEEDS_NORMALIZATION 1#define udiv_qrnnd __udiv_qrnnd_c#endif#if !defined (count_leading_zeros)extern const UQItype __clz_tab[];#define count_leading_zeros(count, x) \ do { \ UWtype __xr = (x); \ UWtype __a; \ \ if (W_TYPE_SIZE <= 32) \ { \ __a = __xr < ((UWtype)1<<2*__BITS4) \ ? (__xr < ((UWtype)1<<__BITS4) ? 0 : __BITS4) \ : (__xr < ((UWtype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \ } \ else \ { \ for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \ if (((__xr >> __a) & 0xff) != 0) \ break; \ } \ \ (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \ } while (0)#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE#endif#if !defined (count_trailing_zeros)/* Define count_trailing_zeros using count_leading_zeros. The latter might be defined in asm, but if it is not, the C version above is good enough. */#define count_trailing_zeros(count, x) \ do { \ UWtype __ctz_x = (x); \ UWtype __ctz_c; \ count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \ (count) = W_TYPE_SIZE - 1 - __ctz_c; \ } while (0)#endif#ifndef UDIV_NEEDS_NORMALIZATION#define UDIV_NEEDS_NORMALIZATION 0#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -