Tizen 2.1 base
[external/gmp.git] / mpn / pa32 / hppa1_1 / pa7100 / addmul_1.asm
1 dnl  HP-PA 7100/7200 mpn_addmul_1 -- Multiply a limb vector with a limb and
2 dnl  add the result to a second limb vector.
3
4 dnl  Copyright 1995, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5
6 dnl  This file is part of the GNU MP Library.
7
8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl  it under the terms of the GNU Lesser General Public License as published
10 dnl  by the Free Software Foundation; either version 3 of the License, or (at
11 dnl  your option) any later version.
12
13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 dnl  License for more details.
17
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21 include(`../config.m4')
22
23 C INPUT PARAMETERS
24 define(`res_ptr',`%r26')
25 define(`s1_ptr',`%r25')
26 define(`size_param',`%r24')
27 define(`s2_limb',`%r23')
28
29 define(`cylimb',`%r28')
30 define(`s0',`%r19')
31 define(`s1',`%r20')
32 define(`s2',`%r3')
33 define(`s3',`%r4')
34 define(`lo0',`%r21')
35 define(`lo1',`%r5')
36 define(`lo2',`%r6')
37 define(`lo3',`%r7')
38 define(`hi0',`%r22')
39 define(`hi1',`%r23')                            C safe to reuse
40 define(`hi2',`%r29')
41 define(`hi3',`%r1')
42
43 ASM_START()
44 PROLOGUE(mpn_addmul_1)
45 C       .callinfo       frame=128,no_calls
46
47         ldo     128(%r30),%r30
48         stws    s2_limb,-16(%r30)
49         add      %r0,%r0,cylimb                 C clear cy and cylimb
50         addib,< -4,size_param,L(few_limbs)
51         fldws   -16(%r30),%fr31R
52
53         ldo     -112(%r30),%r31
54         stw     %r3,-96(%r30)
55         stw     %r4,-92(%r30)
56         stw     %r5,-88(%r30)
57         stw     %r6,-84(%r30)
58         stw     %r7,-80(%r30)
59
60         bb,>=,n  s1_ptr,29,L(0)
61
62         fldws,ma 4(s1_ptr),%fr4
63         ldws     0(res_ptr),s0
64         xmpyu    %fr4,%fr31R,%fr5
65         fstds    %fr5,-16(%r31)
66         ldws    -16(%r31),cylimb
67         ldws    -12(%r31),lo0
68         add      s0,lo0,s0
69         addib,< -1,size_param,L(few_limbs)
70         stws,ma  s0,4(res_ptr)
71
72 C start software pipeline ----------------------------------------------------
73 LDEF(0)
74         fldds,ma 8(s1_ptr),%fr4
75         fldds,ma 8(s1_ptr),%fr8
76
77         xmpyu    %fr4L,%fr31R,%fr5
78         xmpyu    %fr4R,%fr31R,%fr6
79         xmpyu    %fr8L,%fr31R,%fr9
80         xmpyu    %fr8R,%fr31R,%fr10
81
82         fstds    %fr5,-16(%r31)
83         fstds    %fr6,-8(%r31)
84         fstds    %fr9,0(%r31)
85         fstds    %fr10,8(%r31)
86
87         ldws   -16(%r31),hi0
88         ldws   -12(%r31),lo0
89         ldws    -8(%r31),hi1
90         ldws    -4(%r31),lo1
91         ldws     0(%r31),hi2
92         ldws     4(%r31),lo2
93         ldws     8(%r31),hi3
94         ldws    12(%r31),lo3
95
96         addc     lo0,cylimb,lo0
97         addc     lo1,hi0,lo1
98         addc     lo2,hi1,lo2
99         addc     lo3,hi2,lo3
100
101         addib,<  -4,size_param,L(end)
102         addc     %r0,hi3,cylimb                 C propagate carry into cylimb
103 C main loop ------------------------------------------------------------------
104 LDEF(loop)
105         fldds,ma 8(s1_ptr),%fr4
106         fldds,ma 8(s1_ptr),%fr8
107
108         ldws     0(res_ptr),s0
109         xmpyu    %fr4L,%fr31R,%fr5
110         ldws     4(res_ptr),s1
111         xmpyu    %fr4R,%fr31R,%fr6
112         ldws     8(res_ptr),s2
113         xmpyu    %fr8L,%fr31R,%fr9
114         ldws    12(res_ptr),s3
115         xmpyu    %fr8R,%fr31R,%fr10
116
117         fstds    %fr5,-16(%r31)
118         add      s0,lo0,s0
119         fstds    %fr6,-8(%r31)
120         addc     s1,lo1,s1
121         fstds    %fr9,0(%r31)
122         addc     s2,lo2,s2
123         fstds    %fr10,8(%r31)
124         addc     s3,lo3,s3
125
126         ldws   -16(%r31),hi0
127         ldws   -12(%r31),lo0
128         ldws    -8(%r31),hi1
129         ldws    -4(%r31),lo1
130         ldws     0(%r31),hi2
131         ldws     4(%r31),lo2
132         ldws     8(%r31),hi3
133         ldws    12(%r31),lo3
134
135         addc     lo0,cylimb,lo0
136         stws,ma  s0,4(res_ptr)
137         addc     lo1,hi0,lo1
138         stws,ma  s1,4(res_ptr)
139         addc     lo2,hi1,lo2
140         stws,ma  s2,4(res_ptr)
141         addc     lo3,hi2,lo3
142         stws,ma  s3,4(res_ptr)
143
144         addib,>= -4,size_param,L(loop)
145         addc     %r0,hi3,cylimb                 C propagate carry into cylimb
146 C finish software pipeline ---------------------------------------------------
147 LDEF(end)
148         ldws     0(res_ptr),s0
149         ldws     4(res_ptr),s1
150         ldws     8(res_ptr),s2
151         ldws    12(res_ptr),s3
152
153         add      s0,lo0,s0
154         stws,ma  s0,4(res_ptr)
155         addc     s1,lo1,s1
156         stws,ma  s1,4(res_ptr)
157         addc     s2,lo2,s2
158         stws,ma  s2,4(res_ptr)
159         addc     s3,lo3,s3
160         stws,ma  s3,4(res_ptr)
161
162 C restore callee-saves registers ---------------------------------------------
163         ldw     -96(%r30),%r3
164         ldw     -92(%r30),%r4
165         ldw     -88(%r30),%r5
166         ldw     -84(%r30),%r6
167         ldw     -80(%r30),%r7
168
169 LDEF(few_limbs)
170         addib,=,n 4,size_param,L(ret)
171
172 LDEF(loop2)
173         fldws,ma 4(s1_ptr),%fr4
174         ldws     0(res_ptr),s0
175         xmpyu    %fr4,%fr31R,%fr5
176         fstds    %fr5,-16(%r30)
177         ldws    -16(%r30),hi0
178         ldws    -12(%r30),lo0
179         addc     lo0,cylimb,lo0
180         addc     %r0,hi0,cylimb
181         add      s0,lo0,s0
182         stws,ma  s0,4(res_ptr)
183         addib,<> -1,size_param,L(loop2)
184         nop
185
186 LDEF(ret)
187         addc     %r0,cylimb,cylimb
188         bv       0(%r2)
189         ldo      -128(%r30),%r30
190 EPILOGUE(mpn_addmul_1)