Import mips2 and mips3 files from the 2.0.2 gmp distribution.

Approved by: markm
This commit is contained in:
Warner Losh 1999-03-01 06:27:31 +00:00
parent f2b7551c39
commit 755610de29
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/libgmp/dist/; revision=44365
16 changed files with 1462 additions and 0 deletions

View File

@ -0,0 +1,120 @@
# MIPS2 __mpn_add_n -- Add two limb vectors of the same length > 0 and
# store sum in a third limb vector.
# Copyright (C) 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# s2_ptr $6
# size $7
.text
.align 2
.globl __mpn_add_n
.ent __mpn_add_n
__mpn_add_n:
.set noreorder
.set nomacro
lw $10,0($5)
lw $11,0($6)
addiu $7,$7,-1
and $9,$7,4-1 # number of limbs in first loop
beq $9,$0,.L0 # 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
.end __mpn_add_n

View File

@ -0,0 +1,97 @@
# MIPS __mpn_addmul_1 -- Multiply a limb vector with a single limb and
# add the product to a second limb vector.
# Copyright (C) 1992, 1994, 1996 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# size $6
# s2_limb $7
.text
.align 4
.globl __mpn_addmul_1
.ent __mpn_addmul_1
__mpn_addmul_1:
.set noreorder
.set nomacro
# warm up phase 0
lw $8,0($5)
# warm up phase 1
addiu $5,$5,4
multu $8,$7
addiu $6,$6,-1
beq $6,$0,$LC0
move $2,$0 # zero cy2
addiu $6,$6,-1
beq $6,$0,$LC1
lw $8,0($5) # 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 # add old carry limb to low product limb
multu $8,$7
lw $8,0($5) # load new s1 limb as early as possible
addiu $6,$6,-1 # decrement loop counter
sltu $2,$3,$2 # 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 # add high product limb and carry from addition
# cool 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 # add high product limb and carry from addition
# cool 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 # add high product limb and carry from addition
.end __mpn_addmul_1

View File

@ -0,0 +1,95 @@
# MIPS2 __mpn_lshift --
# Copyright (C) 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# src_ptr $5
# size $6
# cnt $7
.text
.align 2
.globl __mpn_lshift
.ent __mpn_lshift
__mpn_lshift:
.set noreorder
.set nomacro
sll $2,$6,2
addu $5,$5,$2 # make r5 point at end of src
lw $10,-4($5) # load first limb
subu $13,$0,$7
addu $4,$4,$2 # make r4 point at end of res
addiu $6,$6,-1
and $9,$6,4-1 # number of limbs in first loop
beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
srl $2,$10,$13 # 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)
.end __mpn_lshift

View File

@ -0,0 +1,85 @@
# MIPS __mpn_mul_1 -- Multiply a limb vector with a single limb and
# store the product in a second limb vector.
# Copyright (C) 1992, 1994, 1996 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# size $6
# s2_limb $7
.text
.align 4
.globl __mpn_mul_1
.ent __mpn_mul_1
__mpn_mul_1:
.set noreorder
.set nomacro
# warm up phase 0
lw $8,0($5)
# warm up phase 1
addiu $5,$5,4
multu $8,$7
addiu $6,$6,-1
beq $6,$0,$LC0
move $2,$0 # zero cy2
addiu $6,$6,-1
beq $6,$0,$LC1
lw $8,0($5) # load new s1 limb as early as possible
Loop: mflo $10
mfhi $9
addiu $5,$5,4
addu $10,$10,$2 # add old carry limb to low product limb
multu $8,$7
lw $8,0($5) # load new s1 limb as early as possible
addiu $6,$6,-1 # decrement loop counter
sltu $2,$10,$2 # carry from previous addition -> $2
sw $10,0($4)
addiu $4,$4,4
bne $6,$0,Loop
addu $2,$9,$2 # add high product limb and carry from addition
# cool 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 # add high product limb and carry from addition
# cool 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 # add high product limb and carry from addition
.end __mpn_mul_1

View File

@ -0,0 +1,92 @@
# MIPS2 __mpn_rshift --
# Copyright (C) 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# src_ptr $5
# size $6
# cnt $7
.text
.align 2
.globl __mpn_rshift
.ent __mpn_rshift
__mpn_rshift:
.set noreorder
.set nomacro
lw $10,0($5) # load first limb
subu $13,$0,$7
addiu $6,$6,-1
and $9,$6,4-1 # number of limbs in first loop
beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
sll $2,$10,$13 # 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)
.end __mpn_rshift

View File

@ -0,0 +1,120 @@
# MIPS2 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
# store difference in a third limb vector.
# Copyright (C) 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# s2_ptr $6
# size $7
.text
.align 2
.globl __mpn_sub_n
.ent __mpn_sub_n
__mpn_sub_n:
.set noreorder
.set nomacro
lw $10,0($5)
lw $11,0($6)
addiu $7,$7,-1
and $9,$7,4-1 # number of limbs in first loop
beq $9,$0,.L0 # 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
.end __mpn_sub_n

View File

@ -0,0 +1,97 @@
# MIPS __mpn_submul_1 -- Multiply a limb vector with a single limb and
# subtract the product from a second limb vector.
# Copyright (C) 1992, 1994, 1996 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# size $6
# s2_limb $7
.text
.align 4
.globl __mpn_submul_1
.ent __mpn_submul_1
__mpn_submul_1:
.set noreorder
.set nomacro
# warm up phase 0
lw $8,0($5)
# warm up phase 1
addiu $5,$5,4
multu $8,$7
addiu $6,$6,-1
beq $6,$0,$LC0
move $2,$0 # zero cy2
addiu $6,$6,-1
beq $6,$0,$LC1
lw $8,0($5) # 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 # add old carry limb to low product limb
multu $8,$7
lw $8,0($5) # load new s1 limb as early as possible
addiu $6,$6,-1 # decrement loop counter
sltu $2,$3,$2 # 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 # add high product limb and carry from addition
# cool 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 # add high product limb and carry from addition
# cool 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 # add high product limb and carry from addition
.end __mpn_submul_1

View File

@ -0,0 +1,23 @@
This directory contains mpn functions optimized for MIPS3. Example of
processors that implement MIPS3 are R4000, R4400, R4600, R4700, and R8000.
RELEVANT OPTIMIZATION ISSUES
1. On the R4000 and R4400, branches, both the plain and the "likely" ones,
take 3 cycles to execute. (The fastest possible loop will take 4 cycles,
because of the delay insn.)
On the R4600, branches takes a single cycle
On the R8000, branches often take no noticable cycles, as they are
executed in a separate function unit..
2. The R4000 and R4400 have a load latency of 4 cycles.
3. On the R4000 and R4400, multiplies take a data-dependent number of
cycles, contrary to the SGI documentation. There seem to be 3 or 4
possible latencies.
STATUS
Good...

View File

@ -0,0 +1,120 @@
# MIPS3 __mpn_add_n -- Add two limb vectors of the same length > 0 and
# store sum in a third limb vector.
# Copyright (C) 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# s2_ptr $6
# size $7
.text
.align 2
.globl __mpn_add_n
.ent __mpn_add_n
__mpn_add_n:
.set noreorder
.set nomacro
ld $10,0($5)
ld $11,0($6)
daddiu $7,$7,-1
and $9,$7,4-1 # number of limbs in first loop
beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
move $2,$0
dsubu $7,$7,$9
.Loop0: daddiu $9,$9,-1
ld $12,8($5)
daddu $11,$11,$2
ld $13,8($6)
sltu $8,$11,$2
daddu $11,$10,$11
sltu $2,$11,$10
sd $11,0($4)
or $2,$2,$8
daddiu $5,$5,8
daddiu $6,$6,8
move $10,$12
move $11,$13
bne $9,$0,.Loop0
daddiu $4,$4,8
.L0: beq $7,$0,.Lend
nop
.Loop: daddiu $7,$7,-4
ld $12,8($5)
daddu $11,$11,$2
ld $13,8($6)
sltu $8,$11,$2
daddu $11,$10,$11
sltu $2,$11,$10
sd $11,0($4)
or $2,$2,$8
ld $10,16($5)
daddu $13,$13,$2
ld $11,16($6)
sltu $8,$13,$2
daddu $13,$12,$13
sltu $2,$13,$12
sd $13,8($4)
or $2,$2,$8
ld $12,24($5)
daddu $11,$11,$2
ld $13,24($6)
sltu $8,$11,$2
daddu $11,$10,$11
sltu $2,$11,$10
sd $11,16($4)
or $2,$2,$8
ld $10,32($5)
daddu $13,$13,$2
ld $11,32($6)
sltu $8,$13,$2
daddu $13,$12,$13
sltu $2,$13,$12
sd $13,24($4)
or $2,$2,$8
daddiu $5,$5,32
daddiu $6,$6,32
bne $7,$0,.Loop
daddiu $4,$4,32
.Lend: daddu $11,$11,$2
sltu $8,$11,$2
daddu $11,$10,$11
sltu $2,$11,$10
sd $11,0($4)
j $31
or $2,$2,$8
.end __mpn_add_n

View File

@ -0,0 +1,97 @@
# MIPS3 __mpn_addmul_1 -- Multiply a limb vector with a single limb and
# add the product to a second limb vector.
# Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# size $6
# s2_limb $7
.text
.align 4
.globl __mpn_addmul_1
.ent __mpn_addmul_1
__mpn_addmul_1:
.set noreorder
.set nomacro
# warm up phase 0
ld $8,0($5)
# warm up phase 1
daddiu $5,$5,8
dmultu $8,$7
daddiu $6,$6,-1
beq $6,$0,$LC0
move $2,$0 # zero cy2
daddiu $6,$6,-1
beq $6,$0,$LC1
ld $8,0($5) # load new s1 limb as early as possible
Loop: ld $10,0($4)
mflo $3
mfhi $9
daddiu $5,$5,8
daddu $3,$3,$2 # add old carry limb to low product limb
dmultu $8,$7
ld $8,0($5) # load new s1 limb as early as possible
daddiu $6,$6,-1 # decrement loop counter
sltu $2,$3,$2 # carry from previous addition -> $2
daddu $3,$10,$3
sltu $10,$3,$10
daddu $2,$2,$10
sd $3,0($4)
daddiu $4,$4,8
bne $6,$0,Loop
daddu $2,$9,$2 # add high product limb and carry from addition
# cool down phase 1
$LC1: ld $10,0($4)
mflo $3
mfhi $9
daddu $3,$3,$2
sltu $2,$3,$2
dmultu $8,$7
daddu $3,$10,$3
sltu $10,$3,$10
daddu $2,$2,$10
sd $3,0($4)
daddiu $4,$4,8
daddu $2,$9,$2 # add high product limb and carry from addition
# cool down phase 0
$LC0: ld $10,0($4)
mflo $3
mfhi $9
daddu $3,$3,$2
sltu $2,$3,$2
daddu $3,$10,$3
sltu $10,$3,$10
daddu $2,$2,$10
sd $3,0($4)
j $31
daddu $2,$9,$2 # add high product limb and carry from addition
.end __mpn_addmul_1

View File

@ -0,0 +1,27 @@
/* gmp-mparam.h -- Compiler/machine parameter header file.
Copyright (C) 1991, 1993, 1994 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 Library General Public License as published by
the Free Software Foundation; either version 2 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 Library General Public
License for more details.
You should have received a copy of the GNU Library 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 64
#define BYTES_PER_MP_LIMB 8
#define BITS_PER_LONGINT 32
#define BITS_PER_INT 32
#define BITS_PER_SHORTINT 16
#define BITS_PER_CHAR 8

View File

@ -0,0 +1,95 @@
# MIPS3 __mpn_lshift --
# Copyright (C) 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# src_ptr $5
# size $6
# cnt $7
.text
.align 2
.globl __mpn_lshift
.ent __mpn_lshift
__mpn_lshift:
.set noreorder
.set nomacro
dsll $2,$6,3
daddu $5,$5,$2 # make r5 point at end of src
ld $10,-8($5) # load first limb
dsubu $13,$0,$7
daddu $4,$4,$2 # make r4 point at end of res
daddiu $6,$6,-1
and $9,$6,4-1 # number of limbs in first loop
beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
dsrl $2,$10,$13 # compute function result
dsubu $6,$6,$9
.Loop0: ld $3,-16($5)
daddiu $4,$4,-8
daddiu $5,$5,-8
daddiu $9,$9,-1
dsll $11,$10,$7
dsrl $12,$3,$13
move $10,$3
or $8,$11,$12
bne $9,$0,.Loop0
sd $8,0($4)
.L0: beq $6,$0,.Lend
nop
.Loop: ld $3,-16($5)
daddiu $4,$4,-32
daddiu $6,$6,-4
dsll $11,$10,$7
dsrl $12,$3,$13
ld $10,-24($5)
dsll $14,$3,$7
or $8,$11,$12
sd $8,24($4)
dsrl $9,$10,$13
ld $3,-32($5)
dsll $11,$10,$7
or $8,$14,$9
sd $8,16($4)
dsrl $12,$3,$13
ld $10,-40($5)
dsll $14,$3,$7
or $8,$11,$12
sd $8,8($4)
dsrl $9,$10,$13
daddiu $5,$5,-32
or $8,$14,$9
bgtz $6,.Loop
sd $8,0($4)
.Lend: dsll $8,$10,$7
j $31
sd $8,-8($4)
.end __mpn_lshift

View File

@ -0,0 +1,85 @@
# MIPS3 __mpn_mul_1 -- Multiply a limb vector with a single limb and
# store the product in a second limb vector.
# Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# size $6
# s2_limb $7
.text
.align 4
.globl __mpn_mul_1
.ent __mpn_mul_1
__mpn_mul_1:
.set noreorder
.set nomacro
# warm up phase 0
ld $8,0($5)
# warm up phase 1
daddiu $5,$5,8
dmultu $8,$7
daddiu $6,$6,-1
beq $6,$0,$LC0
move $2,$0 # zero cy2
daddiu $6,$6,-1
beq $6,$0,$LC1
ld $8,0($5) # load new s1 limb as early as possible
Loop: mflo $10
mfhi $9
daddiu $5,$5,8
daddu $10,$10,$2 # add old carry limb to low product limb
dmultu $8,$7
ld $8,0($5) # load new s1 limb as early as possible
daddiu $6,$6,-1 # decrement loop counter
sltu $2,$10,$2 # carry from previous addition -> $2
sd $10,0($4)
daddiu $4,$4,8
bne $6,$0,Loop
daddu $2,$9,$2 # add high product limb and carry from addition
# cool down phase 1
$LC1: mflo $10
mfhi $9
daddu $10,$10,$2
sltu $2,$10,$2
dmultu $8,$7
sd $10,0($4)
daddiu $4,$4,8
daddu $2,$9,$2 # add high product limb and carry from addition
# cool down phase 0
$LC0: mflo $10
mfhi $9
daddu $10,$10,$2
sltu $2,$10,$2
sd $10,0($4)
j $31
daddu $2,$9,$2 # add high product limb and carry from addition
.end __mpn_mul_1

View File

@ -0,0 +1,92 @@
# MIPS3 __mpn_rshift --
# Copyright (C) 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# src_ptr $5
# size $6
# cnt $7
.text
.align 2
.globl __mpn_rshift
.ent __mpn_rshift
__mpn_rshift:
.set noreorder
.set nomacro
ld $10,0($5) # load first limb
dsubu $13,$0,$7
daddiu $6,$6,-1
and $9,$6,4-1 # number of limbs in first loop
beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
dsll $2,$10,$13 # compute function result
dsubu $6,$6,$9
.Loop0: ld $3,8($5)
daddiu $4,$4,8
daddiu $5,$5,8
daddiu $9,$9,-1
dsrl $11,$10,$7
dsll $12,$3,$13
move $10,$3
or $8,$11,$12
bne $9,$0,.Loop0
sd $8,-8($4)
.L0: beq $6,$0,.Lend
nop
.Loop: ld $3,8($5)
daddiu $4,$4,32
daddiu $6,$6,-4
dsrl $11,$10,$7
dsll $12,$3,$13
ld $10,16($5)
dsrl $14,$3,$7
or $8,$11,$12
sd $8,-32($4)
dsll $9,$10,$13
ld $3,24($5)
dsrl $11,$10,$7
or $8,$14,$9
sd $8,-24($4)
dsll $12,$3,$13
ld $10,32($5)
dsrl $14,$3,$7
or $8,$11,$12
sd $8,-16($4)
dsll $9,$10,$13
daddiu $5,$5,32
or $8,$14,$9
bgtz $6,.Loop
sd $8,-8($4)
.Lend: dsrl $8,$10,$7
j $31
sd $8,0($4)
.end __mpn_rshift

View File

@ -0,0 +1,120 @@
# MIPS3 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
# store difference in a third limb vector.
# Copyright (C) 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# s2_ptr $6
# size $7
.text
.align 2
.globl __mpn_sub_n
.ent __mpn_sub_n
__mpn_sub_n:
.set noreorder
.set nomacro
ld $10,0($5)
ld $11,0($6)
daddiu $7,$7,-1
and $9,$7,4-1 # number of limbs in first loop
beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
move $2,$0
dsubu $7,$7,$9
.Loop0: daddiu $9,$9,-1
ld $12,8($5)
daddu $11,$11,$2
ld $13,8($6)
sltu $8,$11,$2
dsubu $11,$10,$11
sltu $2,$10,$11
sd $11,0($4)
or $2,$2,$8
daddiu $5,$5,8
daddiu $6,$6,8
move $10,$12
move $11,$13
bne $9,$0,.Loop0
daddiu $4,$4,8
.L0: beq $7,$0,.Lend
nop
.Loop: daddiu $7,$7,-4
ld $12,8($5)
daddu $11,$11,$2
ld $13,8($6)
sltu $8,$11,$2
dsubu $11,$10,$11
sltu $2,$10,$11
sd $11,0($4)
or $2,$2,$8
ld $10,16($5)
daddu $13,$13,$2
ld $11,16($6)
sltu $8,$13,$2
dsubu $13,$12,$13
sltu $2,$12,$13
sd $13,8($4)
or $2,$2,$8
ld $12,24($5)
daddu $11,$11,$2
ld $13,24($6)
sltu $8,$11,$2
dsubu $11,$10,$11
sltu $2,$10,$11
sd $11,16($4)
or $2,$2,$8
ld $10,32($5)
daddu $13,$13,$2
ld $11,32($6)
sltu $8,$13,$2
dsubu $13,$12,$13
sltu $2,$12,$13
sd $13,24($4)
or $2,$2,$8
daddiu $5,$5,32
daddiu $6,$6,32
bne $7,$0,.Loop
daddiu $4,$4,32
.Lend: daddu $11,$11,$2
sltu $8,$11,$2
dsubu $11,$10,$11
sltu $2,$10,$11
sd $11,0($4)
j $31
or $2,$2,$8
.end __mpn_sub_n

View File

@ -0,0 +1,97 @@
# MIPS3 __mpn_submul_1 -- Multiply a limb vector with a single limb and
# subtract the product from a second limb vector.
# Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by
# the Free Software Foundation; either version 2 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 Library General Public
# License for more details.
# You should have received a copy of the GNU Library 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.
# INPUT PARAMETERS
# res_ptr $4
# s1_ptr $5
# size $6
# s2_limb $7
.text
.align 4
.globl __mpn_submul_1
.ent __mpn_submul_1
__mpn_submul_1:
.set noreorder
.set nomacro
# warm up phase 0
ld $8,0($5)
# warm up phase 1
daddiu $5,$5,8
dmultu $8,$7
daddiu $6,$6,-1
beq $6,$0,$LC0
move $2,$0 # zero cy2
daddiu $6,$6,-1
beq $6,$0,$LC1
ld $8,0($5) # load new s1 limb as early as possible
Loop: ld $10,0($4)
mflo $3
mfhi $9
daddiu $5,$5,8
daddu $3,$3,$2 # add old carry limb to low product limb
dmultu $8,$7
ld $8,0($5) # load new s1 limb as early as possible
daddiu $6,$6,-1 # decrement loop counter
sltu $2,$3,$2 # carry from previous addition -> $2
dsubu $3,$10,$3
sgtu $10,$3,$10
daddu $2,$2,$10
sd $3,0($4)
daddiu $4,$4,8
bne $6,$0,Loop
daddu $2,$9,$2 # add high product limb and carry from addition
# cool down phase 1
$LC1: ld $10,0($4)
mflo $3
mfhi $9
daddu $3,$3,$2
sltu $2,$3,$2
dmultu $8,$7
dsubu $3,$10,$3
sgtu $10,$3,$10
daddu $2,$2,$10
sd $3,0($4)
daddiu $4,$4,8
daddu $2,$9,$2 # add high product limb and carry from addition
# cool down phase 0
$LC0: ld $10,0($4)
mflo $3
mfhi $9
daddu $3,$3,$2
sltu $2,$3,$2
dsubu $3,$10,$3
sgtu $10,$3,$10
daddu $2,$2,$10
sd $3,0($4)
j $31
daddu $2,$9,$2 # add high product limb and carry from addition
.end __mpn_submul_1