Annotation of OpenXM_contrib/pari-2.2/src/kernel/alpha/asm1.h, Revision 1.1
1.1 ! noro 1: /* $Id: asm1.h,v 1.2 2001/12/05 20:00:00 karim Exp $
! 2:
! 3: Copyright (C) 2000 The PARI group.
! 4:
! 5: This file is part of the PARI/GP package.
! 6:
! 7: PARI/GP is free software; you can redistribute it and/or modify it under the
! 8: terms of the GNU General Public License as published by the Free Software
! 9: Foundation. It is distributed in the hope that it will be useful, but WITHOUT
! 10: ANY WARRANTY WHATSOEVER.
! 11:
! 12: Check the License for details. You should have received a copy of it, along
! 13: with the package; see the file 'COPYING'. If not, write to the Free Software
! 14: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
! 15:
! 16: /* This file is a slight adaptation of source code extracted from gmp-3.1.1
! 17: (from T. Granlund), files longlong.h and gmp-impl.h
! 18:
! 19: Copyright (C) 2000 Free Software Foundation, Inc. */
! 20:
! 21: extern const unsigned char __clz_tab[];
! 22: extern ulong invert_word(ulong);
! 23:
! 24: #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
! 25: do { \
! 26: ulong __x; \
! 27: __x = (al) - (bl); \
! 28: (sh) = (ah) - (bh) - (__x > (al)); \
! 29: (sl) = __x; \
! 30: } while (0)
! 31:
! 32: #ifdef __GNUC__
! 33:
! 34: #define bfffo(x) \
! 35: ({ \
! 36: ulong __xr = (x); \
! 37: ulong __a; \
! 38: \
! 39: for (__a = 56; __a > 0; __a -= 8) \
! 40: if (((__xr >> __a) & 0xff) != 0) \
! 41: break; \
! 42: 64 - (__clz_tab[__xr >> __a] + __a); \
! 43: })
! 44:
! 45: #define divll(x, y) \
! 46: ({ \
! 47: register ulong _di, _x = (x), _y = (y), _q, _ql, _r; \
! 48: register ulong _xh, _xl, _k, __hire; \
! 49: \
! 50: if (_y & 0x8000000000000000UL) \
! 51: { _k = 0; __hire = hiremainder; } \
! 52: else \
! 53: { \
! 54: _k = bfffo(_y); \
! 55: __hire = (hiremainder << _k) | (_x >> (64 - _k)); \
! 56: _x <<= _k; _y <<= _k; \
! 57: } \
! 58: _di = invert_word(_y); \
! 59: _ql = mulll (__hire, _di); \
! 60: _q = __hire + hiremainder; \
! 61: _xl = mulll(_q, _y); _xh = hiremainder; \
! 62: sub_ddmmss (_xh, _r, __hire, _x, _xh, _xl); \
! 63: if (_xh != 0) \
! 64: { \
! 65: sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; \
! 66: if (_xh != 0) \
! 67: { sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; } \
! 68: } \
! 69: if (_r >= _y) \
! 70: { _r -= _y; _q += 1; } \
! 71: hiremainder = _r >> _k; \
! 72: _q; \
! 73: })
! 74:
! 75: #else /* __GNUC__ */
! 76:
! 77: static int
! 78: bfffo(ulong x)
! 79: {
! 80: ulong __xr = (x);
! 81: ulong __a;
! 82:
! 83: for (__a = 56; __a > 0; __a -= 8)
! 84: if (((__xr >> __a) & 0xff) != 0)
! 85: break;
! 86: return 64 - (__clz_tab[__xr >> __a] + __a);
! 87: }
! 88:
! 89: static ulong
! 90: divll(ulong x, ulong y)
! 91: {
! 92: register ulong _di, _x = (x), _y = (y), _q, _ql, _r;
! 93: register ulong _xh, _xl, _k, __hire;
! 94:
! 95: if (_y & 0x8000000000000000UL)
! 96: { _k = 0; __hire = hiremainder; }
! 97: else
! 98: {
! 99: _k = bfffo(_y);
! 100: __hire = (hiremainder << _k) | (_x >> (64 - _k));
! 101: _x <<= _k; _y <<= _k;
! 102: }
! 103: _di = invert_word(_y);
! 104: _ql = mulll (__hire, _di);
! 105: _q = __hire + hiremainder;
! 106: _xl = mulll(_q, _y); _xh = hiremainder;
! 107: sub_ddmmss (_xh, _r, __hire, _x, _xh, _xl);
! 108: if (_xh != 0)
! 109: {
! 110: sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1;
! 111: if (_xh != 0)
! 112: { sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; }
! 113: }
! 114: if (_r >= _y)
! 115: { _r -= _y; _q += 1; }
! 116: hiremainder = _r >> _k;
! 117: return _q;
! 118: }
! 119:
! 120: #endif /* __GNUC__ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>