C implementation of mod_1_1
Torbjorn Granlund
tg at gmplib.org
Wed Mar 2 11:01:02 CET 2011
nisse at lysator.liu.se (Niels Möller) writes:
Does the following look reasonable? It's based on some cargo-culting of
the macros in longlong.h; I don't understand the subtleties with gcc
inline asm and the various register attributes.
#if defined (__sparc__) && W_TYPE_SIZE == 32
#define add_mssaaaa(m, sh, sl, ah, al, bh, bl) \
__asm__ ("addcc %r5,%6,%2\n\taddxcc %r3,%4,%1\n\tsubx %%g0,%%g0,%0" \
: "=r" (m), "=r" (sh), "=&r" (sl) \
: "rJ" (ah), "rI" (bh),"%rJ" (al), "rI" (bl) \
__CLOBBER_CC)
#endif
This looks OK.
#if defined (__sparc__) && W_TYPE_SIZE == 64
#define add_mssaaaa(m, sh, sl, ah, al, bh, bl) \
__asm__ ( \
"addcc %r4,%5,%1\n" \
" addccc %r6,%7,%%g0\n" \
" addc %r2,%3,%0\n" \
" addccc %r8,%r9,%%g0\n" \
" subcc %%g0,%%g0,%0" \
: "=r" (sh), "=&r" (sl) \
: "rJ" (ah), "rI" (bh), "%rJ" (al), "rI" (bl), \
"%rJ" ((al) >> 32), "rI" ((bl) >> 32), \
"%rJ" ((ah) >> 32), "rI" ((bh) >> 32), \
__CLOBBER_CC)
#endif
Perhaps do some tab/space cleanup inside the asm string.
I'd sort the input operands so that high operands come first
cnsistently, i.e., swap the lines comtaining ' >> 32'.
Is subcc %g0,%g0,m the best way to get the carry flag to a mask? Or can
one use some other construction to make use the CCR.xcc bit?
There is also a movcc, conditional move. It can take xcc and icc as
input. I don't recall if it takes immediate operands as input.
The 64-bit attempt above uses an awful lot of registers, maybe I should
look into the signbit logic (but I suspect it's a bit hairy to get right
if you also have carry in)? If we get the carry result into the signbit
position, we should get the mask easily using srax (arithmetic 64-bit
right shift).
Or perhaps ignore sparc64 as too broken to be worth it...
> Unfortunately, the venerable mc68040 system of the GMP test array has a
> dead PSU. I got it to boot with a lab PSU setup, but I have not found
> the time to repair the PSU yet... Some may argue that GMP for m68k is
> not critically important.
I don't know what applications current 68k processors (under the name
"coldfire" if I have understood it correctly) are used for.
Embedded. They lack GMP's avourite insn, 32x32->64 multiply, I think.
One possibility is to install the aranym atari emulator and install
debian's m68k port. I've heard that some of debian's m68k build machines
are setup that way. Benchmark and tuning results might of course be of
somewhat questionable value...
Yes, things would run too fast to be realistic. :-)
--
Torbjörn
More information about the gmp-devel
mailing list