diff options
author | tege <tege@gmplib.org> | 2001-12-10 15:46:10 +0100 |
---|---|---|
committer | tege <tege@gmplib.org> | 2001-12-10 15:46:10 +0100 |
commit | 3d3993fca711c944b6121535b55395b6cf18aaeb (patch) | |
tree | 39a8fd0ffe75887db86f22b47684ac626ef7aee3 /mpn | |
parent | 315a0b77186f709fa8287b6e3f0903f86d7bbe1f (diff) | |
download | gmp-3d3993fca711c944b6121535b55395b6cf18aaeb.tar.gz |
*** empty log message ***
Diffstat (limited to 'mpn')
-rw-r--r-- | mpn/s390/README | 37 | ||||
-rw-r--r-- | mpn/s390/addmul_1.asm | 84 | ||||
-rw-r--r-- | mpn/s390/mul_1.asm | 76 | ||||
-rw-r--r-- | mpn/s390/submul_1.asm | 84 |
4 files changed, 281 insertions, 0 deletions
diff --git a/mpn/s390/README b/mpn/s390/README new file mode 100644 index 000000000..59519ba53 --- /dev/null +++ b/mpn/s390/README @@ -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 --git a/mpn/s390/addmul_1.asm b/mpn/s390/addmul_1.asm new file mode 100644 index 000000000..bb8206ce6 --- /dev/null +++ b/mpn/s390/addmul_1.asm @@ -0,0 +1,84 @@ +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 2.1 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; see the file COPYING.LIB. If not, write to +dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +dnl MA 02111-1307, USA. + +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 + 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 + 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 --git a/mpn/s390/mul_1.asm b/mpn/s390/mul_1.asm new file mode 100644 index 000000000..4e8e36a21 --- /dev/null +++ b/mpn/s390/mul_1.asm @@ -0,0 +1,76 @@ +dnl S/390 mpn_mul_1 -- Multiply a limb vector with a limb and store the +dnl result in 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 2.1 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; see the file COPYING.LIB. If not, write to +dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +dnl MA 02111-1307, USA. + +include(`../config.m4') + +define(`rp',2) +define(`up',3) +define(`n',4) +define(`vlimb',5) +define(`cylimb',7) + +ASM_START() +PROLOGUE(mpn_mul_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 + lr cylimb,0 # new cylimb + st 1,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 + lr cylimb,0 # new cylimb + st 1,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_mul_1) diff --git a/mpn/s390/submul_1.asm b/mpn/s390/submul_1.asm new file mode 100644 index 000000000..7c7a1bfba --- /dev/null +++ b/mpn/s390/submul_1.asm @@ -0,0 +1,84 @@ +dnl S/390 mpn_submul_1 -- Multiply a limb vector with a limb and subtract the +dnl result from 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 2.1 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; see the file COPYING.LIB. If not, write to +dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +dnl MA 02111-1307, USA. + +include(`../config.m4') + +define(`rp',2) +define(`up',3) +define(`n',4) +define(`vlimb',5) +define(`cylimb',7) + +ASM_START() +PROLOGUE(mpn_submul_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 + slr 6,1 # add u limb to plo + brc 2+1,+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 + slr 6,1 # add u limb to plo + brc 2+1,+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_submul_1) |