Annotation of OpenXM_contrib/pari-2.2/src/kernel/alpha/asm0.h, Revision 1.1
1.1 ! noro 1: ulong overflow;
! 2: ulong hiremainder;
! 3:
! 4: #define LOCAL_OVERFLOW
! 5: #define LOCAL_HIREMAINDER
! 6: #define SAVE_OVERFLOW
! 7: #define SAVE_HIREMAINDER
! 8:
! 9:
! 10: /* From the PARI source, using gcc __asm__ format. */
! 11:
! 12: #define addll(a, b)\
! 13: ({ register ulong __value, __arg1 = (a), __arg2 = (b); \
! 14: __asm__ volatile ("addq %2,%3,%0\n\tcmpult %4,%2,%1" \
! 15: : "=r" (__value), "=r" (overflow) \
! 16: : "r" (__arg1), "r" (__arg2), "0" ((ulong) 0)); \
! 17: __value; \
! 18: })
! 19:
! 20: #define addllx(a, b)\
! 21: ({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp; \
! 22: __asm__ volatile ("addq %3,%4,%0\n\tcmpult %5,%3,%2\n\taddq %5,%6,%0\n\tcmpult %5,%6,%1\n\taddq %6,%7,%1\n\t" \
! 23: : "=r" (__value), "=r" (overflow), "=r" (__temp) \
! 24: : "r" (__arg1), "r" (__arg2), "0" ((ulong) 0), "1" (overflow), "2" ((ulong) 0)); \
! 25: __value; \
! 26: })
! 27:
! 28: #define subll(a, b)\
! 29: ({ register ulong __value, __arg1 = (a), __arg2 = (b); \
! 30: __asm__ volatile ("subq %2,%3,%0\n\tcmpult %2,%4,%1" \
! 31: : "=r" (__value), "=r" (overflow) \
! 32: : "r" (__arg1), "r" (__arg2), "0" ((ulong)0)); \
! 33: __value; \
! 34: })
! 35:
! 36: #define subllx(a, b)\
! 37: ({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp1, __temp2; \
! 38: __asm__ volatile ("subq %4,%5,%2\n\tcmpult %4,%8,%3\n\tsubq %8,%7,%0\n\tcmpult %8,%6,%1\n\taddq %7,%9,%1\n\t" \
! 39: : "=r" (__value), "=r" (overflow), "=r" (__temp1), "=r" (__temp2) \
! 40: : "r" (__arg1), "r" (__arg2), "0" ((ulong)0), "1" (overflow), "2" ((ulong)0), "3" ((ulong)0)); \
! 41: __value; \
! 42: })
! 43:
! 44: #define shiftl(a, b) \
! 45: ({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp; \
! 46: __asm__ volatile ("subq %5,%4,%2\n\tsll %3,%4,%0\n\tsrl %3,%6,%1\n\t" \
! 47: : "=r" (__value), "=r" (hiremainder), "=r" (__temp) \
! 48: : "r" (__arg1), "r" (__arg2), "n" ((ulong) 64), "2" ((ulong)0)); \
! 49: __value; \
! 50: })
! 51:
! 52: #define shiftlr(a, b) \
! 53: ({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp; \
! 54: __asm__ volatile ("subq %5,%4,%2\n\tsrl %3,%4,%0\n\tsll %3,%6,%1\n\t" \
! 55: : "=r" (__value), "=r" (hiremainder), "=r" (__temp) \
! 56: : "r" (__arg1), "r" (__arg2), "n" ((ulong) 64), "2" ((ulong)0)); \
! 57: __value; \
! 58: })
! 59:
! 60: #define mulll(a, b) \
! 61: ({ register ulong __value, __arg1 = (a), __arg2 = (b); \
! 62: __asm__ volatile ("umulh %2,%3,%1\n\tmulq %2,%3,%0\n\t" \
! 63: : "=r" (__value), "=r" (hiremainder) \
! 64: : "r" (__arg1), "r" (__arg2)); \
! 65: __value; \
! 66: })
! 67:
! 68: #define addmul(a, b) \
! 69: ({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp; \
! 70: __asm__ volatile ("mulq %3,%4,%0\n\tumulh %3,%4,%2\n\taddq %5,%6,%0\n\tcmpult %5,%6,%1\n\taddq %7,%6,%1\n\t" \
! 71: : "=r" (__value), "=r" (hiremainder), "=r" (__temp) \
! 72: : "r" (__arg1), "r" (__arg2), "0" ((ulong) 0), "1" (hiremainder), "2" ((ulong) 0)); \
! 73: __value; \
! 74: })
! 75:
! 76: /*
! 77: The end of the present file is a slight adaptation of source code
! 78: extracted from gmp-3.1.1 (from T. Granlund), files longlong.h and
! 79: gmp-impl.h
! 80:
! 81: Copyright (C) 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000 Free Software
! 82: Foundation, Inc.
! 83: */
! 84:
! 85: extern const unsigned char __clz_tab[];
! 86: extern ulong invert_word(ulong);
! 87:
! 88: #define bfffo(x) \
! 89: ({ \
! 90: ulong __xr = (x); \
! 91: ulong __a; \
! 92: \
! 93: for (__a = 56; __a > 0; __a -= 8) \
! 94: if (((__xr >> __a) & 0xff) != 0) \
! 95: break; \
! 96: 64 - (__clz_tab[__xr >> __a] + __a); \
! 97: })
! 98:
! 99: #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
! 100: do { \
! 101: ulong __x; \
! 102: __x = (al) - (bl); \
! 103: (sh) = (ah) - (bh) - (__x > (al)); \
! 104: (sl) = __x; \
! 105: } while (0)
! 106:
! 107: #define divll(x, y) \
! 108: ({ \
! 109: register ulong _di, _x = (x), _y = (y), _q, _ql, _r; \
! 110: register ulong _xh, _xl, _k, __hire; \
! 111: \
! 112: if (_y & 0x8000000000000000UL) \
! 113: { _k = 0; __hire = hiremainder; } \
! 114: else \
! 115: { \
! 116: _k = bfffo(_y); \
! 117: __hire = (hiremainder << _k) | (_x >> (64 - _k)); \
! 118: _x <<= _k; _y <<= _k; \
! 119: } \
! 120: _di = invert_word(_y); \
! 121: _ql = mulll (__hire, _di); \
! 122: _q = __hire + hiremainder; \
! 123: _xl = mulll(_q, _y); _xh = hiremainder; \
! 124: sub_ddmmss (_xh, _r, __hire, _x, _xh, _xl); \
! 125: if (_xh != 0) \
! 126: { \
! 127: sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; \
! 128: if (_xh != 0) \
! 129: { sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; } \
! 130: } \
! 131: if (_r >= _y) \
! 132: { _r -= _y; _q += 1; } \
! 133: hiremainder = _r >> _k; \
! 134: _q; \
! 135: })
! 136:
! 137:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>