[project @ 1998-06-05 14:44:05 by simonm]
authorsimonm <unknown>
Fri, 5 Jun 1998 14:44:05 +0000 (14:44 +0000)
committersimonm <unknown>
Fri, 5 Jun 1998 14:44:05 +0000 (14:44 +0000)
Initial revision

ghc/rts/gmp/mpn/powerpc32/add_n.s [new file with mode: 0644]
ghc/rts/gmp/mpn/powerpc32/addmul_1.s [new file with mode: 0644]
ghc/rts/gmp/mpn/powerpc32/lshift.s [new file with mode: 0644]
ghc/rts/gmp/mpn/powerpc32/mul_1.s [new file with mode: 0644]
ghc/rts/gmp/mpn/powerpc32/rshift.s [new file with mode: 0644]
ghc/rts/gmp/mpn/powerpc32/sub_n.s [new file with mode: 0644]
ghc/rts/gmp/mpn/powerpc32/submul_1.s [new file with mode: 0644]

diff --git a/ghc/rts/gmp/mpn/powerpc32/add_n.s b/ghc/rts/gmp/mpn/powerpc32/add_n.s
new file mode 100644 (file)
index 0000000..7739a4a
--- /dev/null
@@ -0,0 +1,55 @@
+# PowerPC-32 __mpn_add_n -- Add two limb vectors of equal, non-zero length.
+
+# 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      r3
+# s1_ptr       r4
+# s2_ptr       r5
+# size         r6
+
+       .toc
+       .extern __mpn_add_n[DS]
+       .extern .__mpn_add_n
+.csect [PR]
+       .align 2
+       .globl __mpn_add_n
+       .globl .__mpn_add_n
+       .csect __mpn_add_n[DS]
+__mpn_add_n:
+       .long .__mpn_add_n, TOC[tc0], 0
+       .csect [PR]
+.__mpn_add_n:
+       mtctr   6               # copy size into CTR
+       lwz     8,0(4)          # load least significant s1 limb
+       lwz     0,0(5)          # load least significant s2 limb
+       addi    3,3,-4          # offset res_ptr, it's updated before used
+       addc    7,0,8           # add least significant limbs, set cy
+       bdz     Lend            # If done, skip loop
+Loop:  lwzu    8,4(4)          # load s1 limb and update s1_ptr
+       lwzu    0,4(5)          # load s2 limb and update s2_ptr
+       stwu    7,4(3)          # store previous limb in load latency slot
+       adde    7,0,8           # add new limbs with cy, set cy
+       bdnz    Loop            # decrement CTR and loop back
+Lend:  stw     7,4(3)          # store ultimate result limb
+       li      3,0             # load cy into ...
+       addze   3,3             # ... return value register
+       blr
diff --git a/ghc/rts/gmp/mpn/powerpc32/addmul_1.s b/ghc/rts/gmp/mpn/powerpc32/addmul_1.s
new file mode 100644 (file)
index 0000000..6ecd53b
--- /dev/null
@@ -0,0 +1,68 @@
+# PowerPC-32 __mpn_addmul_1 -- Multiply a limb vector with a limb and add
+# the result to a second 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      r3
+# s1_ptr       r4
+# size         r5
+# s2_limb      r6
+
+# This is a fairly straightforward implementation.  The timing of the PC601
+# is hard to understand, so I will wait to optimize this until I have some
+# hardware to play with.
+
+# The code trivially generalizes to 64 bit limbs for the PC620.
+
+       .toc
+       .csect .__mpn_addmul_1[PR]
+       .align 2
+       .globl __mpn_addmul_1
+       .globl .__mpn_addmul_1
+       .csect __mpn_addmul_1[DS]
+__mpn_addmul_1:
+       .long .__mpn_addmul_1[PR], TOC[tc0], 0
+       .csect .__mpn_addmul_1[PR]
+.__mpn_addmul_1:
+       mtctr   5
+
+       lwz     0,0(4)
+       mullw   7,0,6
+       mulhwu  10,0,6
+       lwz     9,0(3)
+       addc    8,7,9
+       addi    3,3,-4
+       bdz     Lend
+
+Loop:  lwzu    0,4(4)
+       stwu    8,4(3)
+       mullw   8,0,6
+       adde    7,8,10
+       mulhwu  10,0,6
+       lwz     9,4(3)
+       addze   10,10
+       addc    8,7,9
+       bdnz    Loop
+
+Lend:  stw     8,4(3)
+       addze   3,10
+       blr
diff --git a/ghc/rts/gmp/mpn/powerpc32/lshift.s b/ghc/rts/gmp/mpn/powerpc32/lshift.s
new file mode 100644 (file)
index 0000000..9eef2ee
--- /dev/null
@@ -0,0 +1,67 @@
+# PowerPC-32 __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      r3
+# s1_ptr       r4
+# size         r5
+# cnt          r6
+
+       .toc
+.csect .text[PR]
+       .align  2
+       .globl  __mpn_lshift
+       .globl  .__mpn_lshift
+       .csect  __mpn_lshift[DS]
+__mpn_lshift:
+       .long   .__mpn_lshift,  TOC[tc0],       0
+       .csect  .text[PR]
+.__mpn_lshift:
+       mtctr   5               # copy size into CTR
+       slwi    0,5,2
+       add     7,3,0           # make r7 point at end of res
+       add     4,4,0           # make r4 point at end of s1
+       subfic  8,6,32
+       lwzu    11,-4(4)        # load first s1 limb
+       srw     3,11,8          # compute function return value
+       bdz     Lend1
+
+Loop:  lwzu    10,-4(4)
+       slw     9,11,6
+       srw     12,10,8
+       or      9,9,12
+       stwu    9,-4(7)
+       bdz     Lend2
+       lwzu    11,-4(4)
+       slw     9,10,6
+       srw     12,11,8
+       or      9,9,12
+       stwu    9,-4(7)
+       bdnz    Loop
+
+Lend1: slw     0,11,6
+       stw     0,-4(7)
+       blr
+
+Lend2: slw     0,10,6
+       stw     0,-4(7)
+       blr
diff --git a/ghc/rts/gmp/mpn/powerpc32/mul_1.s b/ghc/rts/gmp/mpn/powerpc32/mul_1.s
new file mode 100644 (file)
index 0000000..dc13cac
--- /dev/null
@@ -0,0 +1,64 @@
+# PowerPC-32 __mpn_mul_1 -- Multiply a limb vector with a limb and store
+# the result in a second limb vector.
+
+# Copyright (C) 1993, 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      r3
+# s1_ptr       r4
+# size         r5
+# s2_limb      r6
+
+# This is a fairly straightforward implementation.  The timing of the PC601
+# is hard to understand, so I will wait to optimize this until I have some
+# hardware to play with.
+
+# The code trivially generalizes to 64 bit limbs for the PC620.
+
+       .toc
+       .csect .__mpn_mul_1[PR]
+       .align 2
+       .globl __mpn_mul_1
+       .globl .__mpn_mul_1
+       .csect __mpn_mul_1[DS]
+__mpn_mul_1:
+       .long .__mpn_mul_1[PR], TOC[tc0], 0
+       .csect .__mpn_mul_1[PR]
+.__mpn_mul_1:
+       mtctr   5
+
+       lwz     0,0(4)
+       mullw   7,0,6
+       mulhwu  10,0,6
+       addi    3,3,-4          # adjust res_ptr
+       addic   5,5,0           # clear cy with dummy insn
+       bdz     Lend
+
+Loop:  lwzu    0,4(4)
+       stwu    7,4(3)
+       mullw   8,0,6
+       adde    7,8,10
+       mulhwu  10,0,6
+       bdnz    Loop
+
+Lend:  stw     7,4(3)
+       addze   3,10
+       blr
diff --git a/ghc/rts/gmp/mpn/powerpc32/rshift.s b/ghc/rts/gmp/mpn/powerpc32/rshift.s
new file mode 100644 (file)
index 0000000..4059270
--- /dev/null
@@ -0,0 +1,65 @@
+# PowerPC-32 __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      r3
+# s1_ptr       r4
+# size         r5
+# cnt          r6
+
+       .toc
+.csect .text[PR]
+       .align  2
+       .globl  __mpn_rshift
+       .globl  .__mpn_rshift
+       .csect  __mpn_rshift[DS]
+__mpn_rshift:
+       .long   .__mpn_rshift,  TOC[tc0],       0
+       .csect  .text[PR]
+.__mpn_rshift:
+       mtctr   5               # copy size into CTR
+       addi    7,3,-4          # move adjusted res_ptr to free return reg
+       subfic  8,6,32
+       lwz     11,0(4)         # load first s1 limb
+       slw     3,11,8          # compute function return value
+       bdz     Lend1
+
+Loop:  lwzu    10,4(4)
+       srw     9,11,6
+       slw     12,10,8
+       or      9,9,12
+       stwu    9,4(7)
+       bdz     Lend2
+       lwzu    11,4(4)
+       srw     9,10,6
+       slw     12,11,8
+       or      9,9,12
+       stwu    9,4(7)
+       bdnz    Loop
+
+Lend1: srw     0,11,6
+       stw     0,4(7)
+       blr
+
+Lend2: srw     0,10,6
+       stw     0,4(7)
+       blr
diff --git a/ghc/rts/gmp/mpn/powerpc32/sub_n.s b/ghc/rts/gmp/mpn/powerpc32/sub_n.s
new file mode 100644 (file)
index 0000000..2d00d36
--- /dev/null
@@ -0,0 +1,56 @@
+# PowerPC-32  __mpn_sub_n -- Subtract two limb vectors of the same length > 0
+# and store difference in a third 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      r3
+# s1_ptr       r4
+# s2_ptr       r5
+# size         r6
+
+       .toc
+       .extern __mpn_sub_n[DS]
+       .extern .__mpn_sub_n
+.csect [PR]
+       .align 2
+       .globl __mpn_sub_n
+       .globl .__mpn_sub_n
+       .csect __mpn_sub_n[DS]
+__mpn_sub_n:
+       .long .__mpn_sub_n, TOC[tc0], 0
+       .csect [PR]
+.__mpn_sub_n:
+       mtctr   6               # copy size into CTR
+       lwz     8,0(4)          # load least significant s1 limb
+       lwz     0,0(5)          # load least significant s2 limb
+       addi    3,3,-4          # offset res_ptr, it's updated before used
+       subfc   7,0,8           # add least significant limbs, set cy
+       bdz     Lend            # If done, skip loop
+Loop:  lwzu    8,4(4)          # load s1 limb and update s1_ptr
+       lwzu    0,4(5)          # load s2 limb and update s2_ptr
+       stwu    7,4(3)          # store previous limb in load latency slot
+       subfe   7,0,8           # add new limbs with cy, set cy
+       bdnz    Loop            # decrement CTR and loop back
+Lend:  stw     7,4(3)          # store ultimate result limb
+       subfe   3,0,0           # load !cy into ...
+       subfic  3,3,0           # ... return value register
+       blr
diff --git a/ghc/rts/gmp/mpn/powerpc32/submul_1.s b/ghc/rts/gmp/mpn/powerpc32/submul_1.s
new file mode 100644 (file)
index 0000000..78467cc
--- /dev/null
@@ -0,0 +1,70 @@
+# PowerPC-32 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract
+# the result from a second 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      r3
+# s1_ptr       r4
+# size         r5
+# s2_limb      r6
+
+# This is a fairly straightforward implementation.  The timing of the PC601
+# is hard to understand, so I will wait to optimize this until I have some
+# hardware to play with.
+
+# The code trivially generalizes to 64 bit limbs for the PC620.
+
+       .toc
+       .csect .__mpn_submul_1[PR]
+       .align 2
+       .globl __mpn_submul_1
+       .globl .__mpn_submul_1
+       .csect __mpn_submul_1[DS]
+__mpn_submul_1:
+       .long .__mpn_submul_1[PR], TOC[tc0], 0
+       .csect .__mpn_submul_1[PR]
+.__mpn_submul_1:
+       mtctr   5
+
+       lwz     0,0(4)
+       mullw   7,0,6
+       mulhwu  10,0,6
+       lwz     9,0(3)
+       subfc   8,7,9
+       addc    7,7,8           # invert cy (r7 is junk)
+       addi    3,3,-4
+       bdz     Lend
+
+Loop:  lwzu    0,4(4)
+       stwu    8,4(3)
+       mullw   8,0,6
+       adde    7,8,10
+       mulhwu  10,0,6
+       lwz     9,4(3)
+       addze   10,10
+       subfc   8,7,9
+       addc    7,7,8           # invert cy (r7 is junk)
+       bdnz    Loop
+
+Lend:  stw     8,4(3)
+       addze   3,10
+       blr