Bill Allombert on Mon, 07 Nov 2011 00:18:29 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: UMULL support on ARM/Android


On Wed, Oct 26, 2011 at 03:30:39PM -0400, Charles Boyd wrote:
> Hi,
> 
> I received the following answer to the question (which came up a few weeks
> ago on this mailing list) about UMULL on ARM/Android platform:
> 
> The simple answer is yes, UMULL will be available.  There is some detail

Please find my attempt at a ARM level0 kernel.
The attached file should be copied to src/kernel/arm/asm0.h
and you should use ./Configure --kernel=arm-auto
(i.e set kernlvl0 to 'arm' in pari.cfg) to activate it.

This should improve performance a bit, especially without GMP.

Cheers,
Bill.
/* $Id: asm0.h 12466 2010-06-24 14:53:41Z kb $

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. */
/*
ASM addll mulll bfffo
NOASM divll
*/
#ifdef ASMINLINE
#define LOCAL_HIREMAINDER  register ulong hiremainder
#define LOCAL_OVERFLOW     register ulong overflow

#define addll(a, b) \
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
 __asm__ ("adds %0,%2,%3\n\tadc %1,%4,%4\n\t" \
   : "=&r" (__value), "=&r" (overflow) \
   : "r" (__arg1), "r" (__arg2), "r" ((ulong)0): "cc"); \
 __value; \
})

#define addllx(a, b) \
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
 __asm__ ("subs %1,%4,#1\n\tadcs %0,%2,%3\n\tadc %1,%5,%5\n\t" \
   : "=&r" (__value), "=&r" (overflow) \
   : "r" (__arg1), "r" (__arg2), "r" (overflow), "r" ((ulong)0) \
   : "cc"); \
 __value; \
})

#define subll(a, b) \
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
 __asm__ ("subs %0,%2,%3\n\tadc %1,%4,%4\n\trsb %1,%1,#1\n\t" \
   : "=&r" (__value), "=&r" (overflow) \
   : "r" (__arg1), "r" (__arg2), "r" ((ulong)0) \
   : "cc"); \
 __value; \
})

#define subllx(a, b) \
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
 __asm__ ("rsbs %1,%4,%5\n\tsbcs %0,%2,%3\n\tadc %1,%5,%5\n\trsb %1,%1,#1\n\t" \
   : "=&r" (__value), "=&r" (overflow) \
   : "r" (__arg1), "r" (__arg2), "r" (overflow), "r" ((ulong)0) \
   : "cc"); \
 __value; \
})

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

#define addmul(a, b) \
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
 __asm__ ("umlal %0,%1,%2,%3\n\t" \
   : "=&r" (__value), "=&r" (hiremainder) \
   : "r" (__arg1), "r" (__arg2), "1" ((ulong) 0), "0" (hiremainder)); \
 __value; \
})

#define bfffo(a) \
__extension__ ({ \
  ulong __arg1 = (a), __value; \
  __asm__ ("clz %0,%1\n\t" \
           : "=&r" (__value) \
           : "r" (__arg1)); \
  __value; \
})

#endif