C implementation of mod_1_1
Niels Möller
nisse at lysator.liu.se
Tue Mar 1 12:57:16 CET 2011
Torbjorn Granlund <tg at gmplib.org> writes:
> sparc32 should be piece of cake, sparc64 lacks a carry-generating insn,
> making it somewhat hairy.
I hadn't realized that also 64-bit carry propagation was so broken on
the sparc...
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
#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
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?
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).
> 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.
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...
/nisse
--
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
More information about the gmp-devel
mailing list