diff options
author | tege <tege@gmplib.org> | 2002-02-19 00:37:21 +0100 |
---|---|---|
committer | tege <tege@gmplib.org> | 2002-02-19 00:37:21 +0100 |
commit | 29d90bfe15b1a0a8a1e930b91f3b09c2a91c0b76 (patch) | |
tree | 7c399d2afea99782cb0fcc25df595758c7f2ed8d /mpn/mips32 | |
parent | ae36d9c96da7f0437a79f07d9413a45c1c95e088 (diff) | |
download | gmp-29d90bfe15b1a0a8a1e930b91f3b09c2a91c0b76.tar.gz |
Asm-ify 32-bit mips code.
Move from `mips2' to `mips32' directory.
Diffstat (limited to 'mpn/mips32')
-rw-r--r-- | mpn/mips32/add_n.asm | 115 | ||||
-rw-r--r-- | mpn/mips32/addmul_1.asm | 92 | ||||
-rw-r--r-- | mpn/mips32/gmp-mparam.h | 65 | ||||
-rw-r--r-- | mpn/mips32/lshift.asm | 90 | ||||
-rw-r--r-- | mpn/mips32/mips.m4 | 71 | ||||
-rw-r--r-- | mpn/mips32/mul_1.asm | 80 | ||||
-rw-r--r-- | mpn/mips32/rshift.asm | 87 | ||||
-rw-r--r-- | mpn/mips32/sub_n.asm | 114 | ||||
-rw-r--r-- | mpn/mips32/submul_1.asm | 92 | ||||
-rw-r--r-- | mpn/mips32/umul.asm | 36 |
10 files changed, 842 insertions, 0 deletions
diff --git a/mpn/mips32/add_n.asm b/mpn/mips32/add_n.asm new file mode 100644 index 000000000..a16a3a8aa --- /dev/null +++ b/mpn/mips32/add_n.asm @@ -0,0 +1,115 @@ +dnl MIPS32 mpn_add_n -- Add two limb vectors of the same length > 0 and store +dnl sum in a third limb vector. + +dnl Copyright 1995, 2000, 2002 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') + +C INPUT PARAMETERS +C res_ptr $4 +C s1_ptr $5 +C s2_ptr $6 +C size $7 + +ASM_START() +PROLOGUE(mpn_add_n) + + lw $10,0($5) + lw $11,0($6) + + addiu $7,$7,-1 + and $9,$7,4-1 C number of limbs in first loop + beq $9,$0,.L0 C if multiple of 4 limbs, skip first loop + move $2,$0 + + subu $7,$7,$9 + +.Loop0: addiu $9,$9,-1 + lw $12,4($5) + addu $11,$11,$2 + lw $13,4($6) + sltu $8,$11,$2 + addu $11,$10,$11 + sltu $2,$11,$10 + sw $11,0($4) + or $2,$2,$8 + + addiu $5,$5,4 + addiu $6,$6,4 + move $10,$12 + move $11,$13 + bne $9,$0,.Loop0 + addiu $4,$4,4 + +.L0: beq $7,$0,.Lend + nop + +.Loop: addiu $7,$7,-4 + + lw $12,4($5) + addu $11,$11,$2 + lw $13,4($6) + sltu $8,$11,$2 + addu $11,$10,$11 + sltu $2,$11,$10 + sw $11,0($4) + or $2,$2,$8 + + lw $10,8($5) + addu $13,$13,$2 + lw $11,8($6) + sltu $8,$13,$2 + addu $13,$12,$13 + sltu $2,$13,$12 + sw $13,4($4) + or $2,$2,$8 + + lw $12,12($5) + addu $11,$11,$2 + lw $13,12($6) + sltu $8,$11,$2 + addu $11,$10,$11 + sltu $2,$11,$10 + sw $11,8($4) + or $2,$2,$8 + + lw $10,16($5) + addu $13,$13,$2 + lw $11,16($6) + sltu $8,$13,$2 + addu $13,$12,$13 + sltu $2,$13,$12 + sw $13,12($4) + or $2,$2,$8 + + addiu $5,$5,16 + addiu $6,$6,16 + + bne $7,$0,.Loop + addiu $4,$4,16 + +.Lend: addu $11,$11,$2 + sltu $8,$11,$2 + addu $11,$10,$11 + sltu $2,$11,$10 + sw $11,0($4) + j $31 + or $2,$2,$8 +EPILOGUE(mpn_add_n) diff --git a/mpn/mips32/addmul_1.asm b/mpn/mips32/addmul_1.asm new file mode 100644 index 000000000..dc1860713 --- /dev/null +++ b/mpn/mips32/addmul_1.asm @@ -0,0 +1,92 @@ +dnl MIPS32 mpn_addmul_1 -- Multiply a limb vector with a single limb and add +dnl the product to a second limb vector. + +dnl Copyright 1992, 1994, 1996, 2000, 2002 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') + +C INPUT PARAMETERS +C res_ptr $4 +C s1_ptr $5 +C size $6 +C s2_limb $7 + +ASM_START() +PROLOGUE(mpn_addmul_1) + +C feed-in phase 0 + lw $8,0($5) + +C feed-in phase 1 + addiu $5,$5,4 + multu $8,$7 + + addiu $6,$6,-1 + beq $6,$0,$LC0 + move $2,$0 C zero cy2 + + addiu $6,$6,-1 + beq $6,$0,$LC1 + lw $8,0($5) C load new s1 limb as early as possible + +Loop: lw $10,0($4) + mflo $3 + mfhi $9 + addiu $5,$5,4 + addu $3,$3,$2 C add old carry limb to low product limb + multu $8,$7 + lw $8,0($5) C load new s1 limb as early as possible + addiu $6,$6,-1 C decrement loop counter + sltu $2,$3,$2 C carry from previous addition -> $2 + addu $3,$10,$3 + sltu $10,$3,$10 + addu $2,$2,$10 + sw $3,0($4) + addiu $4,$4,4 + bne $6,$0,Loop + addu $2,$9,$2 C add high product limb and carry from addition + +C wind-down phase 1 +$LC1: lw $10,0($4) + mflo $3 + mfhi $9 + addu $3,$3,$2 + sltu $2,$3,$2 + multu $8,$7 + addu $3,$10,$3 + sltu $10,$3,$10 + addu $2,$2,$10 + sw $3,0($4) + addiu $4,$4,4 + addu $2,$9,$2 C add high product limb and carry from addition + +C wind-down phase 0 +$LC0: lw $10,0($4) + mflo $3 + mfhi $9 + addu $3,$3,$2 + sltu $2,$3,$2 + addu $3,$10,$3 + sltu $10,$3,$10 + addu $2,$2,$10 + sw $3,0($4) + j $31 + addu $2,$9,$2 C add high product limb and carry from addition +EPILOGUE(mpn_addmul_1) diff --git a/mpn/mips32/gmp-mparam.h b/mpn/mips32/gmp-mparam.h new file mode 100644 index 000000000..ff4d941a6 --- /dev/null +++ b/mpn/mips32/gmp-mparam.h @@ -0,0 +1,65 @@ +/* gmp-mparam.h -- Compiler/machine parameter header file. + +Copyright 1991, 1993, 1994, 1999, 2000, 2001, 2002 Free Software Foundation, +Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library 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 Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +for more details. + +You should have received a copy of the GNU Lesser General Public License along +with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free +Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +USA. */ + + +#define BITS_PER_MP_LIMB 32 +#define BYTES_PER_MP_LIMB 4 + + +/* Generated by tuneup.c, 2002-02-17, system compiler (R3000) */ + +#define KARATSUBA_MUL_THRESHOLD 18 +#define TOOM3_MUL_THRESHOLD 65 + +#define BASECASE_SQR_THRESHOLD 12 +#define KARATSUBA_SQR_THRESHOLD 49 +#define TOOM3_SQR_THRESHOLD 56 + +#define SB_PREINV_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DC_THRESHOLD 29 +#define POWM_THRESHOLD 146 + +#define GCD_ACCEL_THRESHOLD 3 +#define GCDEXT_THRESHOLD 47 +#define JACOBI_BASE_METHOD 2 + +#define DIVREM_1_NORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIVREM_1_UNNORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define MOD_1_NORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define MOD_1_UNNORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define USE_PREINV_DIVREM_1 0 +#define USE_PREINV_MOD_1 0 +#define DIVREM_2_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIVEXACT_1_THRESHOLD 0 /* always */ +#define MODEXACT_1_ODD_THRESHOLD 0 /* always */ + +#define GET_STR_BASECASE_THRESHOLD 11 +#define GET_STR_PRECOMPUTE_THRESHOLD 17 +#define SET_STR_THRESHOLD 3014 + +#define FFT_MUL_TABLE { 496, 928, 1664, 4608, 14336, 40960, 0 } +#define FFT_MODF_MUL_THRESHOLD 624 +#define FFT_MUL_THRESHOLD 4864 + +#define FFT_SQR_TABLE { 464, 800, 1664, 3584, 10240, 40960, 0 } +#define FFT_MODF_SQR_THRESHOLD 496 +#define FFT_SQR_THRESHOLD 4352 diff --git a/mpn/mips32/lshift.asm b/mpn/mips32/lshift.asm new file mode 100644 index 000000000..06be6443f --- /dev/null +++ b/mpn/mips32/lshift.asm @@ -0,0 +1,90 @@ +dnl MIPS32 mpn_lshift -- Left shift. + +dnl Copyright 1995, 2000, 2002 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') + +C INPUT PARAMETERS +C res_ptr $4 +C src_ptr $5 +C size $6 +C cnt $7 + +ASM_START() +PROLOGUE(mpn_lshift) + sll $2,$6,2 + addu $5,$5,$2 C make r5 point at end of src + lw $10,-4($5) C load first limb + subu $13,$0,$7 + addu $4,$4,$2 C make r4 point at end of res + addiu $6,$6,-1 + and $9,$6,4-1 C number of limbs in first loop + beq $9,$0,.L0 C if multiple of 4 limbs, skip first loop + srl $2,$10,$13 C compute function result + + subu $6,$6,$9 + +.Loop0: lw $3,-8($5) + addiu $4,$4,-4 + addiu $5,$5,-4 + addiu $9,$9,-1 + sll $11,$10,$7 + srl $12,$3,$13 + move $10,$3 + or $8,$11,$12 + bne $9,$0,.Loop0 + sw $8,0($4) + +.L0: beq $6,$0,.Lend + nop + +.Loop: lw $3,-8($5) + addiu $4,$4,-16 + addiu $6,$6,-4 + sll $11,$10,$7 + srl $12,$3,$13 + + lw $10,-12($5) + sll $14,$3,$7 + or $8,$11,$12 + sw $8,12($4) + srl $9,$10,$13 + + lw $3,-16($5) + sll $11,$10,$7 + or $8,$14,$9 + sw $8,8($4) + srl $12,$3,$13 + + lw $10,-20($5) + sll $14,$3,$7 + or $8,$11,$12 + sw $8,4($4) + srl $9,$10,$13 + + addiu $5,$5,-16 + or $8,$14,$9 + bgtz $6,.Loop + sw $8,0($4) + +.Lend: sll $8,$10,$7 + j $31 + sw $8,-4($4) +EPILOGUE(mpn_lshift) diff --git a/mpn/mips32/mips.m4 b/mpn/mips32/mips.m4 new file mode 100644 index 000000000..ef57de148 --- /dev/null +++ b/mpn/mips32/mips.m4 @@ -0,0 +1,71 @@ +divert(-1) + +dnl m4 macros for MIPS assembly code. + + +dnl Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +dnl +dnl This file is part of the GNU MP Library. +dnl +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 +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 +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. + + +dnl Usage: ASM_START() +define(`ASM_START', +m4_assert_numargs(0) +` .set noreorder + .set nomacro') + +dnl Usage: X(value) +define(`X', +m4_assert_numargs(1) +`0x$1') + +dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo) +dnl EPILOGUE_cpu(GSYM_PREFIX`'foo) + +define(`PROLOGUE_cpu', +m4_assert_numargs(1) +` .text + .align 4 + .globl $1 + .ent $1 +$1:') + +define(`EPILOGUE_cpu', +m4_assert_numargs(1) +` .end $1') + + +dnl Usage: r0 ... r31 +dnl f0 ... f31 +dnl +dnl Map register names r0 to $0, and f0 to $f0, etc. +dnl +dnl defreg() is used to protect the $ in $0 (otherwise it would represent a +dnl macro argument). Double quoting is used to protect the f0 in $f0 +dnl (otherwise it would be an infinite recursion). + +forloop(i,0,31,`defreg(`r'i,$i)') +forloop(i,0,31,`deflit(`f'i,``$f''i)') + + +dnl Usage: ASM_END() +define(`ASM_END', +m4_assert_numargs(0) +) + +divert diff --git a/mpn/mips32/mul_1.asm b/mpn/mips32/mul_1.asm new file mode 100644 index 000000000..6cd520c68 --- /dev/null +++ b/mpn/mips32/mul_1.asm @@ -0,0 +1,80 @@ +dnl MIPS32 mpn_mul_1 -- Multiply a limb vector with a single limb and store +dnl the product in a second limb vector. + +dnl Copyright 1992, 1994, 1996, 2000, 2002 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') + +C INPUT PARAMETERS +C res_ptr $4 +C s1_ptr $5 +C size $6 +C s2_limb $7 + +ASM_START() +PROLOGUE(mpn_mul_1) + +C feed-in phase 0 + lw $8,0($5) + +C feed-in phase 1 + addiu $5,$5,4 + multu $8,$7 + + addiu $6,$6,-1 + beq $6,$0,$LC0 + move $2,$0 C zero cy2 + + addiu $6,$6,-1 + beq $6,$0,$LC1 + lw $8,0($5) C load new s1 limb as early as possible + +Loop: mflo $10 + mfhi $9 + addiu $5,$5,4 + addu $10,$10,$2 C add old carry limb to low product limb + multu $8,$7 + lw $8,0($5) C load new s1 limb as early as possible + addiu $6,$6,-1 C decrement loop counter + sltu $2,$10,$2 C carry from previous addition -> $2 + sw $10,0($4) + addiu $4,$4,4 + bne $6,$0,Loop + addu $2,$9,$2 C add high product limb and carry from addition + +C wind-down phase 1 +$LC1: mflo $10 + mfhi $9 + addu $10,$10,$2 + sltu $2,$10,$2 + multu $8,$7 + sw $10,0($4) + addiu $4,$4,4 + addu $2,$9,$2 C add high product limb and carry from addition + +C wind-down phase 0 +$LC0: mflo $10 + mfhi $9 + addu $10,$10,$2 + sltu $2,$10,$2 + sw $10,0($4) + j $31 + addu $2,$9,$2 C add high product limb and carry from addition +EPILOGUE(mpn_mul_1) diff --git a/mpn/mips32/rshift.asm b/mpn/mips32/rshift.asm new file mode 100644 index 000000000..c92d50f05 --- /dev/null +++ b/mpn/mips32/rshift.asm @@ -0,0 +1,87 @@ +dnl MIPS32 mpn_rshift -- Right shift. + +dnl Copyright 1995, 2000, 2002 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') + +C INPUT PARAMETERS +C res_ptr $4 +C src_ptr $5 +C size $6 +C cnt $7 + +ASM_START() +PROLOGUE(mpn_rshift) + lw $10,0($5) C load first limb + subu $13,$0,$7 + addiu $6,$6,-1 + and $9,$6,4-1 C number of limbs in first loop + beq $9,$0,.L0 C if multiple of 4 limbs, skip first loop + sll $2,$10,$13 C compute function result + + subu $6,$6,$9 + +.Loop0: lw $3,4($5) + addiu $4,$4,4 + addiu $5,$5,4 + addiu $9,$9,-1 + srl $11,$10,$7 + sll $12,$3,$13 + move $10,$3 + or $8,$11,$12 + bne $9,$0,.Loop0 + sw $8,-4($4) + +.L0: beq $6,$0,.Lend + nop + +.Loop: lw $3,4($5) + addiu $4,$4,16 + addiu $6,$6,-4 + srl $11,$10,$7 + sll $12,$3,$13 + + lw $10,8($5) + srl $14,$3,$7 + or $8,$11,$12 + sw $8,-16($4) + sll $9,$10,$13 + + lw $3,12($5) + srl $11,$10,$7 + or $8,$14,$9 + sw $8,-12($4) + sll $12,$3,$13 + + lw $10,16($5) + srl $14,$3,$7 + or $8,$11,$12 + sw $8,-8($4) + sll $9,$10,$13 + + addiu $5,$5,16 + or $8,$14,$9 + bgtz $6,.Loop + sw $8,-4($4) + +.Lend: srl $8,$10,$7 + j $31 + sw $8,0($4) +EPILOGUE(mpn_rshift) diff --git a/mpn/mips32/sub_n.asm b/mpn/mips32/sub_n.asm new file mode 100644 index 000000000..44738c61c --- /dev/null +++ b/mpn/mips32/sub_n.asm @@ -0,0 +1,114 @@ +dnl MIPS32 mpn_sub_n -- Subtract two limb vectors of the same length > 0 and +dnl store difference in a third limb vector. + +dnl Copyright 1995, 2000, 2002 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') + +C INPUT PARAMETERS +C res_ptr $4 +C s1_ptr $5 +C s2_ptr $6 +C size $7 + +ASM_START() +PROLOGUE(mpn_sub_n) + lw $10,0($5) + lw $11,0($6) + + addiu $7,$7,-1 + and $9,$7,4-1 C number of limbs in first loop + beq $9,$0,.L0 C if multiple of 4 limbs, skip first loop + move $2,$0 + + subu $7,$7,$9 + +.Loop0: addiu $9,$9,-1 + lw $12,4($5) + addu $11,$11,$2 + lw $13,4($6) + sltu $8,$11,$2 + subu $11,$10,$11 + sltu $2,$10,$11 + sw $11,0($4) + or $2,$2,$8 + + addiu $5,$5,4 + addiu $6,$6,4 + move $10,$12 + move $11,$13 + bne $9,$0,.Loop0 + addiu $4,$4,4 + +.L0: beq $7,$0,.Lend + nop + +.Loop: addiu $7,$7,-4 + + lw $12,4($5) + addu $11,$11,$2 + lw $13,4($6) + sltu $8,$11,$2 + subu $11,$10,$11 + sltu $2,$10,$11 + sw $11,0($4) + or $2,$2,$8 + + lw $10,8($5) + addu $13,$13,$2 + lw $11,8($6) + sltu $8,$13,$2 + subu $13,$12,$13 + sltu $2,$12,$13 + sw $13,4($4) + or $2,$2,$8 + + lw $12,12($5) + addu $11,$11,$2 + lw $13,12($6) + sltu $8,$11,$2 + subu $11,$10,$11 + sltu $2,$10,$11 + sw $11,8($4) + or $2,$2,$8 + + lw $10,16($5) + addu $13,$13,$2 + lw $11,16($6) + sltu $8,$13,$2 + subu $13,$12,$13 + sltu $2,$12,$13 + sw $13,12($4) + or $2,$2,$8 + + addiu $5,$5,16 + addiu $6,$6,16 + + bne $7,$0,.Loop + addiu $4,$4,16 + +.Lend: addu $11,$11,$2 + sltu $8,$11,$2 + subu $11,$10,$11 + sltu $2,$10,$11 + sw $11,0($4) + j $31 + or $2,$2,$8 +EPILOGUE(mpn_sub_n) diff --git a/mpn/mips32/submul_1.asm b/mpn/mips32/submul_1.asm new file mode 100644 index 000000000..968531361 --- /dev/null +++ b/mpn/mips32/submul_1.asm @@ -0,0 +1,92 @@ +dnl MIPS32 mpn_submul_1 -- Multiply a limb vector with a single limb and +dnl subtract the product from a second limb vector. + +dnl Copyright 1992, 1994, 1996, 2000, 2002 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') + +C INPUT PARAMETERS +C res_ptr $4 +C s1_ptr $5 +C size $6 +C s2_limb $7 + +ASM_START() +PROLOGUE(mpn_submul_1) + +C feed-in phase 0 + lw $8,0($5) + +C feed-in phase 1 + addiu $5,$5,4 + multu $8,$7 + + addiu $6,$6,-1 + beq $6,$0,$LC0 + move $2,$0 C zero cy2 + + addiu $6,$6,-1 + beq $6,$0,$LC1 + lw $8,0($5) C load new s1 limb as early as possible + +Loop: lw $10,0($4) + mflo $3 + mfhi $9 + addiu $5,$5,4 + addu $3,$3,$2 C add old carry limb to low product limb + multu $8,$7 + lw $8,0($5) C load new s1 limb as early as possible + addiu $6,$6,-1 C decrement loop counter + sltu $2,$3,$2 C carry from previous addition -> $2 + subu $3,$10,$3 + sgtu $10,$3,$10 + addu $2,$2,$10 + sw $3,0($4) + addiu $4,$4,4 + bne $6,$0,Loop + addu $2,$9,$2 C add high product limb and carry from addition + +C wind-down phase 1 +$LC1: lw $10,0($4) + mflo $3 + mfhi $9 + addu $3,$3,$2 + sltu $2,$3,$2 + multu $8,$7 + subu $3,$10,$3 + sgtu $10,$3,$10 + addu $2,$2,$10 + sw $3,0($4) + addiu $4,$4,4 + addu $2,$9,$2 C add high product limb and carry from addition + +C wind-down phase 0 +$LC0: lw $10,0($4) + mflo $3 + mfhi $9 + addu $3,$3,$2 + sltu $2,$3,$2 + subu $3,$10,$3 + sgtu $10,$3,$10 + addu $2,$2,$10 + sw $3,0($4) + j $31 + addu $2,$9,$2 C add high product limb and carry from addition +EPILOGUE(mpn_submul_1) diff --git a/mpn/mips32/umul.asm b/mpn/mips32/umul.asm new file mode 100644 index 000000000..e0476de20 --- /dev/null +++ b/mpn/mips32/umul.asm @@ -0,0 +1,36 @@ +dnl MIPS32 umul_ppmm -- longlong.h support. + +dnl Copyright 1999, 2002 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') + +C INPUT PARAMETERS +C plp $4 +C u $5 +C v $6 + +ASM_START() +PROLOGUE(mpn_umul_ppmm) + multu $5,$6 + mflo $3 + mfhi $2 + j $31 + sw $3,0($4) +EPILOGUE(mpn_umul_ppmm) |