1dnl  HP-PA 1.1 mpn_addmul_1 -- Multiply a limb vector with a limb and add the
2dnl  result to a second limb vector.
3
4dnl  Copyright 1992-1994, 2000-2002 Free Software Foundation, Inc.
5
6dnl  This file is part of the GNU MP Library.
7dnl
8dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9dnl  it under the terms of either:
10dnl
11dnl    * the GNU Lesser General Public License as published by the Free
12dnl      Software Foundation; either version 3 of the License, or (at your
13dnl      option) any later version.
14dnl
15dnl  or
16dnl
17dnl    * the GNU General Public License as published by the Free Software
18dnl      Foundation; either version 2 of the License, or (at your option) any
19dnl      later version.
20dnl
21dnl  or both in parallel, as here.
22dnl
23dnl  The GNU MP Library is distributed in the hope that it will be useful, but
24dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26dnl  for more details.
27dnl
28dnl  You should have received copies of the GNU General Public License and the
29dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
30dnl  see https://www.gnu.org/licenses/.
31
32include(`../config.m4')
33
34C INPUT PARAMETERS
35C res_ptr r26
36C s1_ptr  r25
37C size              r24
38C s2_limb r23
39
40C This runs at 11 cycles/limb on a PA7000.  With the used instructions, it can
41C not become faster due to data cache contention after a store.  On the PA7100
42C it runs at 10 cycles/limb.
43
44C There are some ideas described in mul_1.asm that applies to this code too.
45
46ASM_START()
47PROLOGUE(mpn_addmul_1)
48C         .callinfo frame=64,no_calls
49
50          ldo                 64(%r30),%r30
51          fldws,ma  4(%r25),%fr5
52          stw                 %r23,-16(%r30)                C move s2_limb ...
53          addib,=             -1,%r24,L(just_one_limb)
54           fldws              -16(%r30),%fr4                C ... into fr4
55          add                 %r0,%r0,%r0                   C clear carry
56          xmpyu               %fr4,%fr5,%fr6
57          fldws,ma  4(%r25),%fr7
58          fstds               %fr6,-16(%r30)
59          xmpyu               %fr4,%fr7,%fr8
60          ldw                 -12(%r30),%r19                C least significant limb in product
61          ldw                 -16(%r30),%r28
62
63          fstds               %fr8,-16(%r30)
64          addib,=             -1,%r24,L(end)
65           ldw                -12(%r30),%r1
66
67C Main loop
68LDEF(loop)
69          ldws                0(%r26),%r29
70          fldws,ma  4(%r25),%fr5
71          add                 %r29,%r19,%r19
72          stws,ma             %r19,4(%r26)
73          addc                %r28,%r1,%r19
74          xmpyu               %fr4,%fr5,%fr6
75          ldw                 -16(%r30),%r28
76          fstds               %fr6,-16(%r30)
77          addc                %r0,%r28,%r28
78          addib,<>  -1,%r24,L(loop)
79           ldw                -12(%r30),%r1
80
81LDEF(end)
82          ldw                 0(%r26),%r29
83          add                 %r29,%r19,%r19
84          stws,ma             %r19,4(%r26)
85          addc                %r28,%r1,%r19
86          ldw                 -16(%r30),%r28
87          ldws                0(%r26),%r29
88          addc                %r0,%r28,%r28
89          add                 %r29,%r19,%r19
90          stws,ma             %r19,4(%r26)
91          addc                %r0,%r28,%r28
92          bv                  0(%r2)
93           ldo                -64(%r30),%r30
94
95LDEF(just_one_limb)
96          xmpyu               %fr4,%fr5,%fr6
97          ldw                 0(%r26),%r29
98          fstds               %fr6,-16(%r30)
99          ldw                 -12(%r30),%r1
100          ldw                 -16(%r30),%r28
101          add                 %r29,%r1,%r19
102          stw                 %r19,0(%r26)
103          addc                %r0,%r28,%r28
104          bv                  0(%r2)
105           ldo                -64(%r30),%r30
106EPILOGUE()
107