[BACK]Return to asm0.h CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari-2.2 / src / kernel / alpha

File: [local] / OpenXM_contrib / pari-2.2 / src / kernel / alpha / Attic / asm0.h (download)

Revision 1.2, Wed Sep 11 07:26:59 2002 UTC (21 years, 10 months ago) by noro
Branch: MAIN
CVS Tags: RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2
Changes since 1.1: +28 -63 lines

Upgraded pari-2.2 to pari-2.2.4.

/* $Id: asm0.h,v 1.3 2001/10/12 20:27:09 karim Exp $

Copyright (C) 2000  The PARI group.

This file is part of the PARI/GP package.

PARI/GP is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation. It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY WHATSOEVER.

Check the License for details. You should have received a copy of it, along
with the package; see the file 'COPYING'. If not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

ulong overflow;
ulong hiremainder;

#define LOCAL_OVERFLOW
#define LOCAL_HIREMAINDER
#define SAVE_OVERFLOW
#define SAVE_HIREMAINDER

#ifndef ASMINLINE
BEGINEXTERN
  extern long addll(ulong a, ulong b);
  extern long addllx(ulong a, ulong b);
  extern long subll(ulong a, ulong b);
  extern long subllx(ulong a, ulong b);
  extern long shiftl(ulong x, ulong y);
  extern long shiftlr(ulong x, ulong y);
  extern long mulll(ulong x, ulong y);
  extern long addmul(ulong x, ulong y);
ENDEXTERN

#else /* ASMINLINE */
/* From the PARI source, using gcc __asm__ format. */

#define addll(a, b)\
({ register ulong __value, __arg1 = (a), __arg2 = (b); \
  __asm__ volatile ("addq %2,%3,%0\n\tcmpult %4,%2,%1" \
   : "=r" (__value), "=r" (overflow) \
   : "r" (__arg1), "r" (__arg2), "0" ((ulong) 0)); \
  __value; \
})

#define addllx(a, b)\
({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp; \
 __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" \
   : "=r" (__value), "=r" (overflow), "=r" (__temp) \
   : "r" (__arg1), "r" (__arg2), "0" ((ulong) 0), "1" (overflow), "2" ((ulong) 0)); \
__value; \
})

#define subll(a, b)\
({ register ulong __value, __arg1 = (a), __arg2 = (b); \
  __asm__ volatile ("subq %2,%3,%0\n\tcmpult %2,%4,%1" \
   : "=r" (__value), "=r" (overflow) \
   : "r" (__arg1), "r" (__arg2), "0" ((ulong)0)); \
  __value; \
})

#define subllx(a, b)\
({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp1, __temp2; \
__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" \
   : "=r" (__value), "=r" (overflow), "=r" (__temp1), "=r" (__temp2)  \
   : "r" (__arg1), "r" (__arg2), "0" ((ulong)0), "1" (overflow), "2" ((ulong)0), "3" ((ulong)0)); \
 __value; \
})

#define shiftl(a, b) \
({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp; \
 __asm__ volatile ("subq %5,%4,%2\n\tsll %3,%4,%0\n\tsrl %3,%6,%1\n\t" \
   : "=r" (__value), "=r" (hiremainder), "=r" (__temp) \
   : "r" (__arg1), "r" (__arg2), "n" ((ulong) 64), "2" ((ulong)0)); \
 __value; \
})

#define shiftlr(a, b) \
({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp; \
 __asm__ volatile ("subq %5,%4,%2\n\tsrl %3,%4,%0\n\tsll %3,%6,%1\n\t" \
   : "=r" (__value), "=r" (hiremainder), "=r" (__temp) \
   : "r" (__arg1), "r" (__arg2), "n" ((ulong) 64), "2" ((ulong)0)); \
 __value; \
})

#define mulll(a, b) \
({ register ulong __value, __arg1 = (a), __arg2 = (b); \
 __asm__ volatile ("umulh %2,%3,%1\n\tmulq %2,%3,%0\n\t" \
   : "=r" (__value), "=r" (hiremainder) \
   : "r" (__arg1), "r" (__arg2)); \
 __value; \
})

#define addmul(a, b) \
({ register ulong __value, __arg1 = (a), __arg2 = (b), __temp; \
 __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" \
   : "=r" (__value), "=r" (hiremainder), "=r" (__temp) \
   : "r" (__arg1), "r" (__arg2), "0" ((ulong) 0), "1" (hiremainder), "2" ((ulong) 0)); \
 __value; \
})
#endif