Annotation of OpenXM_contrib/pari/src/kernel/sparcv8/level0.h, Revision 1.1
1.1 ! maekawa 1: /* $Id: level0.h,v 1.1.1.1 1999/09/16 13:47:58 karim Exp $ */
! 2:
! 3: /* This file defines some "level 0" kernel functions for SPARC V8 */
! 4: /* These functions can be inline, with gcc */
! 5: /* If not gcc, they are defined externally with "level0.s" */
! 6: /* This file is common to SuperSparc and MicroSparc */
! 7: /* */
! 8: /* These following symbols can be inlined */
! 9: /* overflow hiremainder */
! 10: /* addll addllx subll subllx shiftl shiftlr mulll addmul */
! 11: /* */
! 12: /* These functions are always in level0.s */
! 13: /* The following symbols are always defined in this file : */
! 14: /* divll bfffo (& tabshi) */
! 15: /* But divll have to use hiremainder, so it is different when */
! 16: /* hiremainder is inline or not */
! 17: /* If libpari.so is compiled with gcc, you should compile all */
! 18: /* files with gcc */
! 19:
! 20: #define LOCAL_OVERFLOW
! 21: #define SAVE_OVERFLOW
! 22: #define LOCAL_HIREMAINDER
! 23: #define SAVE_HIREMAINDER
! 24:
! 25: BEGINEXTERN
! 26: extern long divll(unsigned long x, unsigned long y);
! 27: extern int bfffo(unsigned long x);
! 28: ENDEXTERN
! 29:
! 30: #ifndef ASMINLINE
! 31: BEGINEXTERN
! 32: extern unsigned long hiremainder, overflow;
! 33: extern long addll(unsigned long a, unsigned long b);
! 34: extern long addllx(unsigned long a, unsigned long b);
! 35: extern long subll(unsigned long a, unsigned long b);
! 36: extern long subllx(unsigned long a, unsigned long b);
! 37: extern long shiftl(unsigned long x, unsigned long y);
! 38: extern long shiftlr(unsigned long x, unsigned long y);
! 39: extern long mulll(unsigned long x, unsigned long y);
! 40: extern long addmul(unsigned long x, unsigned long y);
! 41: ENDEXTERN
! 42:
! 43: #else /* ASMINLINE */
! 44:
! 45: register unsigned long hiremainder __asm__("%g5");
! 46: register unsigned long overflow __asm__("%g6");
! 47:
! 48: #define addll(a,b) \
! 49: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 50: __asm__ ( "addcc %2,%3,%0; \
! 51: addx %%g0,%%g0,%1" \
! 52: : "=r" (__value), "=r" (overflow) \
! 53: : "r" (__arg1), "r" (__arg2) \
! 54: : "%g6","cc"); \
! 55: __value; })
! 56:
! 57: #define addllx(a,b) \
! 58: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 59: __asm__ ( "subcc %%g0,%%g6,%%g0; \
! 60: addxcc %2,%3,%0; \
! 61: addx %%g0,%%g0,%1" \
! 62: : "=r" (__value), "=r" (overflow) \
! 63: : "r" (__arg1), "r" (__arg2) \
! 64: : "%g6","cc"); \
! 65: __value; })
! 66:
! 67: #define subll(a,b) \
! 68: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 69: __asm__ ( "subcc %2,%3,%0; \
! 70: addx %%g0,%%g0,%1" \
! 71: : "=r" (__value), "=r" (overflow) \
! 72: : "r" (__arg1), "r" (__arg2) \
! 73: : "%g6","cc"); \
! 74: __value; })
! 75:
! 76: #define subllx(a,b) \
! 77: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 78: __asm__ ( "subcc %%g0,%%g6,%%g0; \
! 79: subxcc %2,%3,%0; \
! 80: addx %%g0,%%g0,%1" \
! 81: : "=r" (__value), "=r" (overflow) \
! 82: : "r" (__arg1), "r" (__arg2) \
! 83: : "%g6","cc"); \
! 84: __value; })
! 85:
! 86: #define shiftl(a,b) \
! 87: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 88: __asm__ ( "neg %3,%%o4; \
! 89: srl %2,%%o4,%1; \
! 90: sll %2,%3,%0" \
! 91: : "=r" (__value), "=r" (hiremainder) \
! 92: : "r" (__arg1), "r" (__arg2) \
! 93: : "%o4","%g5"); \
! 94: __value; })
! 95:
! 96: #define shiftl2(a,b,c) \
! 97: ({ unsigned long __value, __arg1 = (a), __arg2 = (b), __arg3 = (c); \
! 98: __asm__ ( "srl %2,%4,%1; \
! 99: sll %2,%3,%0" \
! 100: : "=r" (__value), "=r" (hiremainder) \
! 101: : "r" (__arg1), "r" (__arg2), "r" (__arg3) \
! 102: : "%g5"); \
! 103: __value; })
! 104:
! 105: #define shiftlr(a,b) \
! 106: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 107: __asm__ ( "neg %3,%%o4; \
! 108: sll %2,%%o4,%1; \
! 109: srl %2,%3,%0" \
! 110: : "=r" (__value), "=r" (hiremainder) \
! 111: : "r" (__arg1), "r" (__arg2) \
! 112: : "%o4","%g5"); \
! 113: __value; })
! 114:
! 115: #define shiftlr1(a) \
! 116: ({ unsigned long __value, __arg1 = (a); \
! 117: __asm__ ( "sll %2,31,%1; \
! 118: srl %2,1,%0" \
! 119: : "=r" (__value), "=r" (hiremainder) \
! 120: : "r" (__arg1) \
! 121: : "%g5"); \
! 122: __value; })
! 123:
! 124: #define shiftlr2(a,b,c) \
! 125: ({ unsigned long __value, __arg1 = (a), __arg2 = (b), __arg3 = (c); \
! 126: __asm__ ( "sll %2,%4,%1; \
! 127: srl %2,%3,%0" \
! 128: : "=r" (__value), "=r" (hiremainder) \
! 129: : "r" (__arg1), "r" (__arg2), "r" (__arg3) \
! 130: : "%g5"); \
! 131: __value; })
! 132:
! 133: #define mulll(a,b) \
! 134: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 135: __asm__ ( "umul %2,%3,%0; \
! 136: rd %%y,%1" \
! 137: : "=r" (__value), "=r" (hiremainder) \
! 138: : "r" (__arg1), "r" (__arg2) \
! 139: : "%g5"); \
! 140: __value;})
! 141:
! 142: #define addmul(a,b) \
! 143: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 144: __asm__ ( "umul %2,%3,%0; \
! 145: rd %%y,%%o4; \
! 146: addcc %0,%%g5,%0; \
! 147: addx %%g0,%%o4,%1" \
! 148: : "=r" (__value), "=r" (hiremainder) \
! 149: : "r" (__arg1), "r" (__arg2) \
! 150: : "%o4","%g5","cc"); \
! 151: __value;})
! 152:
! 153: #define divllasm(a,b) \
! 154: ({ unsigned long __value, __arg1 = (a), __arg2 = (b); \
! 155: __asm__( "wr %%g5,%%g0,%%y;\
! 156: mov %2,%%o4;\
! 157: udivcc %2,%3,%0;\
! 158: bvc 1f;\
! 159: umul %0,%3,%%o5;\
! 160: mov 47,%%o0;\
! 161: call err,1;\
! 162: nop ;\
! 163: 1: sub %%o4,%%o5,%1"\
! 164: : "=r" (__value), "=r" (hiremainder) \
! 165: : "r" (__arg1), "r" (__arg2) \
! 166: : "%o4","%o5","%g5","cc"); \
! 167: __value;})
! 168:
! 169: #endif /* ASMINLINE */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>