[Gmp-commit] /var/hg/gmp: Add s390/64 support, enhance s390/32 support.
mercurial at gmplib.org
mercurial at gmplib.org
Tue Oct 4 00:06:13 CEST 2011
details: /var/hg/gmp/rev/0225fcaacf23
changeset: 14254:0225fcaacf23
user: Torbjorn Granlund <tege at gmplib.org>
date: Tue Oct 04 00:06:08 2011 +0200
description:
Add s390/64 support, enhance s390/32 support.
diffstat:
ChangeLog | 21 ++++
configure.in | 16 ++-
longlong.h | 65 ++++++++++++-
mpn/s390_32/README | 37 +++++++
mpn/s390_32/addmul_1.asm | 82 +++++++++++++++
mpn/s390_32/esame/add_n.asm | 47 +++++++++
mpn/s390_32/esame/addmul_1.asm | 54 ++++++++++
mpn/s390_32/esame/bdiv_dbm1c.asm | 48 +++++++++
mpn/s390_32/esame/mul_1.asm | 48 +++++++++
mpn/s390_32/esame/sub_n.asm | 46 ++++++++
mpn/s390_32/gmp-mparam.h | 200 +++++++++++++++++++++++++++++++++++++++
mpn/s390_32/mul_1.asm | 74 ++++++++++++++
mpn/s390_32/submul_1.asm | 82 +++++++++++++++
mpn/s390_64/add_n.asm | 47 +++++++++
mpn/s390_64/addmul_1.asm | 54 ++++++++++
mpn/s390_64/bdiv_dbm1c.asm | 48 +++++++++
mpn/s390_64/gmp-mparam.h | 200 +++++++++++++++++++++++++++++++++++++++
mpn/s390_64/mul_1.asm | 48 +++++++++
mpn/s390_64/sub_n.asm | 46 ++++++++
19 files changed, 1260 insertions(+), 3 deletions(-)
diffs (truncated from 1364 to 300 lines):
diff -r 0a1ed0805710 -r 0225fcaacf23 ChangeLog
--- a/ChangeLog Mon Oct 03 15:34:25 2011 +0200
+++ b/ChangeLog Tue Oct 04 00:06:08 2011 +0200
@@ -1,3 +1,24 @@
+2011-10-03 Torbjorn Granlund <tege at gmplib.org>
+
+ * configure.in: Support s390x.
+
+ * longlong.h: Add spport for 64-bit s390x.
+
+ * mpn/s390_64/add_n.asm: New file.
+ * mpn/s390_64/sub_n.asm: New file.
+ * mpn/s390_64/mul_1.asm: New file.
+ * mpn/s390_64/addmul_1.asm: New file.
+ * mpn/s390_64/bdiv_dbm1c.asm: New file.
+ * mpn/s390_64/gmp-mparam.h: New file, taken from x86_64.
+
+ * mpn/s390_32: Directory renamed from mpn/s390.
+ * mpn/s390_32/gmp-mparam.h: New file, taken from x86_64.
+ * mpn/s390_32/esame/add_n.asm: New file.
+ * mpn/s390_32/esame/sub_n.asm: New file.
+ * mpn/s390_32/esame/mul_1.asm: New file.
+ * mpn/s390_32/esame/addmul_1.asm: New file.
+ * mpn/s390_32/esame/bdiv_dbm1c.asm: New file.
+
2011-10-03 Niels Möller <nisse at lysator.liu.se>
* tests/mpn/Makefile.am (check_PROGRAMS): Added t-mulmid.
diff -r 0a1ed0805710 -r 0225fcaacf23 configure.in
--- a/configure.in Mon Oct 03 15:34:25 2011 +0200
+++ b/configure.in Tue Oct 04 00:06:08 2011 +0200
@@ -1114,11 +1114,23 @@
;;
- # IBM s/370 and similar
+ # IBM System/390 and z/Architecture
[s3[6-9]0*-*-*])
+ abilist="32"
gcc_cflags="$gcc_cflags $fomit_frame_pointer"
- path="s390"
+ path="s390_32"
extra_functions="udiv_w_sdiv"
+
+ case $host_cpu in
+ s390x)
+ abilist="64 32"
+ cclist_64="gcc"
+ gcc_64_cflags="$gcc_cflags -m64"
+ gcc_32_cflags="$gcc_cflags -m31"
+ path_32="s390_32/esame s390_32"
+ path_64="s390_64"
+ ;;
+ esac
;;
diff -r 0a1ed0805710 -r 0225fcaacf23 longlong.h
--- a/longlong.h Mon Oct 03 15:34:25 2011 +0200
+++ b/longlong.h Tue Oct 04 00:06:08 2011 +0200
@@ -1,7 +1,7 @@
/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
Copyright 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
-2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+2004, 2005, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
This file is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
@@ -677,6 +677,69 @@
} while (0)
#endif
+#if defined (__s390x__) && W_TYPE_SIZE == 64
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (bl) && (UDItype)(bl) < 0x100000000ul) \
+ __asm__ ("algfi\t%1, %5\n\talcgr\t%0, %3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "0" ((UDItype)(ah)), "r" ((UDItype)(bh)), \
+ "%1" ((UDItype)(al)), "n" ((UDItype)(bl))); \
+ else \
+ __asm__ ("algr\t%1, %5\n\talcgr\t%0, %3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "0" ((UDItype)(ah)), "r" ((UDItype)(bh)), \
+ "%1" ((UDItype)(al)), "r" ((UDItype)(bl))); \
+ } while (0)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (bl) && (UDItype)(bl) < 0x100000000ul) \
+ __asm__ ("slgfi\t%1, %n5\n\tslbgr\t%0, %3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "0" ((UDItype)(ah)), "r" ((UDItype)(bh)), \
+ "1" ((UDItype)(al)), "n" ((UDItype)(bl))); \
+ else if (__builtin_constant_p (bl) && -(UDItype)(bl) < 0x100000000ul) \
+ __asm__ ("algfi\t%1, %n5\n\tslbgr\t%0, %3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "0" ((UDItype)(ah)), "r" ((UDItype)(bh)), \
+ "1" ((UDItype)(al)), "n" (-(UDItype)(bl))); \
+ else \
+ __asm__ ("slgr\t%1, %5\n\tslbgr\t%0, %3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "0" ((UDItype)(ah)), "r" ((UDItype)(bh)), \
+ "1" ((UDItype)(al)), "r" ((UDItype)(bl))); \
+ } while (0)
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {unsigned int __attribute__ ((mode(TI))) __ll; \
+ struct {UDItype __h, __l;} __i; \
+ } __x; \
+ __asm__ ("mlgr\t%0, %2" \
+ : "=&r" (__x.__ll) \
+ : "%0" ((UDItype)(m0)), "r" ((UDItype)(m1))); \
+ (xh) = __x.__i.__h; (xl) = __x.__i.__l; \
+ } while (0)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ union {unsigned int __attribute__ ((mode(TI))) __ll; \
+ struct {UDItype __h, __l;} __i; \
+ } __x; \
+ __x.__i.__h = n1; __x.__i.__l = n0; \
+ __asm__ ("dlgr\t%0, %2" \
+ : "=r" (__x.__ll) \
+ : "0" (__x.__ll), "r" (d)); \
+ (q) = __x.__i.__l; (r) = __x.__i.__h; \
+ } while (0)
+#define count_leading_zeros(cnt, x) \
+ do { \
+ union {unsigned int __attribute__ ((mode(TI))) __ll; \
+ struct {UDItype __h, __l;} __i; \
+ } __clr_cnt; \
+ __asm__ ("flogr\t%0, %1" : "=r" (__clr_cnt.__ll) : "r" (x)); \
+ (cnt) = __clr_cnt.__i.__h; \
+ } while (0)
+#endif
+
#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addl %5,%k1\n\tadcl %3,%k0" \
diff -r 0a1ed0805710 -r 0225fcaacf23 mpn/s390_32/README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/s390_32/README Tue Oct 04 00:06:08 2011 +0200
@@ -0,0 +1,37 @@
+All current (2001) S/390 and z/Architecture machines are single-issue,
+but some newer machines have a deep pipeline. Software-pipelining is
+therefore beneficial.
+
+* mpn_add_n, mpn_sub_n: Use code along the lines below. Two-way unrolling
+ would be adequate.
+
+ mp_limb_t
+ mpn_add_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
+ {
+ mp_limb_t a, b, r, cy;
+ mp_size_t i;
+ mp_limb_t mm = -1;
+
+ cy = 0;
+ up += n;
+ vp += n;
+ rp += n;
+ i = -n;
+ do
+ {
+ a = up[i];
+ b = vp[i];
+ r = a + b + cy;
+ rp[i] = r;
+ cy = (((a & b) | ((a | b) & (r ^ mm)))) >> 31;
+ i++;
+ }
+ while (i < 0);
+ return cy;
+ }
+
+* mpn_lshift, mpn_rshift: Use SLDL/SRDL, and two-way unrolling.
+
+* mpn_mul_1, mpn_addmul_1, mpn_submul_1: For machines with just signed
+ multiply (MR), use two loops, similar to the corresponding VAX or
+ POWER functions. Handle carry like for mpn_add_n.
diff -r 0a1ed0805710 -r 0225fcaacf23 mpn/s390_32/addmul_1.asm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/s390_32/addmul_1.asm Tue Oct 04 00:06:08 2011 +0200
@@ -0,0 +1,82 @@
+dnl S/390 mpn_addmul_1 -- Multiply a limb vector with a limb and add the
+dnl result to a second limb vector.
+
+dnl Copyright 2001 Free Software Foundation, Inc.
+
+dnl This file is part of the GNU MP Library.
+
+dnl The GNU MP Library is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU Lesser General Public License as published
+dnl by the Free Software Foundation; either version 3 of the License, or (at
+dnl your option) any later version.
+
+dnl The GNU MP Library is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+dnl License for more details.
+
+dnl You should have received a copy of the GNU Lesser General Public License
+dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+define(`rp',2)
+define(`up',3)
+define(`n',4)
+define(`vlimb',5)
+define(`cylimb',7)
+
+ASM_START()
+PROLOGUE(mpn_addmul_1)
+ stm 6,7,24(15)
+ slr cylimb,cylimb # clear cylimb
+ ltr vlimb,vlimb
+ jnl .Loopp
+
+.Loopn: l 1,0(up) # load from u
+ lr 6,1 #
+ mr 0,vlimb # multiply signed
+ alr 0,6 # add vlimb to phi
+ sra 6,31 # make mask
+ nr 6,vlimb # 0 or vlimb
+ alr 0,6 # conditionally add vlimb to phi
+ alr 1,cylimb # add carry limb to plo
+ brc 8+4,+8 # branch if not carry
+ ahi 0,1 # increment phi
+ l 6,0(rp) # load r limb
+ alr 6,1 # add u limb to plo
+ brc 8+4,+8 # branch if not carry
+ ahi 0,1 # increment phi
+ lr cylimb,0 # new cylimb
+ st 6,0(rp) # store
+ la up,4(,up)
+ la rp,4(,rp)
+ brct n,.Loopn
+
+ lr 2,cylimb
+ lm 6,7,24(15)
+ br 14
+
+.Loopp: l 1,0(up) # load from u
+ lr 6,1 #
+ mr 0,vlimb # multiply signed
+ sra 6,31 # make mask
+ nr 6,vlimb # 0 or vlimb
+ alr 0,6 # conditionally add vlimb to phi
+ alr 1,cylimb # add carry limb to plo
+ brc 8+4,+8 # branch if not carry
+ ahi 0,1 # increment phi
+ l 6,0(rp) # load r limb
+ alr 6,1 # add u limb to plo
+ brc 8+4,+8 # branch if not carry
+ ahi 0,1 # increment phi
+ lr cylimb,0 # new cylimb
+ st 6,0(rp) # store
+ la up,4(,up)
+ la rp,4(,rp)
+ brct n,.Loopp
+
+ lr 2,cylimb
+ lm 6,7,24(15)
+ br 14
+EPILOGUE(mpn_addmul_1)
diff -r 0a1ed0805710 -r 0225fcaacf23 mpn/s390_32/esame/add_n.asm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/s390_32/esame/add_n.asm Tue Oct 04 00:06:08 2011 +0200
@@ -0,0 +1,47 @@
+dnl S/390-32 mpn_add_n for systems with unsigned add/subtract instructions.
+
+dnl Copyright 2011 Free Software Foundation, Inc.
+
+dnl This file is part of the GNU MP Library.
+
+dnl The GNU MP Library is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU Lesser General Public License as published
+dnl by the Free Software Foundation; either version 3 of the License, or (at
+dnl your option) any later version.
+
+dnl The GNU MP Library is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+dnl License for more details.
+
+dnl You should have received a copy of the GNU Lesser General Public License
+dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
+
+
+include(`../config.m4')
+
+C INPUT PARAMETERS
+define(`rp', `%r2')
+define(`up', `%r3')
+define(`vp', `%r4')
+define(`n', `%r5')
+
+ASM_START()
+PROLOGUE(mpn_add_n)
More information about the gmp-commit
mailing list