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