Upload Tizen:Base source
[external/gmp.git] / mpn / pa32 / hppa1_1 / pa7100 / submul_1.asm
1 dnl  HP-PA 7100/7200 mpn_submul_1 -- Multiply a limb vector with a limb and
2 dnl  subtract the result from 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_submul_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         sub      s0,lo0,s0
69         add      s0,lo0,%r0                     C invert cy
70         addib,< -1,size_param,L(few_limbs)
71         stws,ma  s0,4(res_ptr)
72
73 C start software pipeline ----------------------------------------------------
74 LDEF(0)
75         fldds,ma 8(s1_ptr),%fr4
76         fldds,ma 8(s1_ptr),%fr8
77
78         xmpyu    %fr4L,%fr31R,%fr5
79         xmpyu    %fr4R,%fr31R,%fr6
80         xmpyu    %fr8L,%fr31R,%fr9
81         xmpyu    %fr8R,%fr31R,%fr10
82
83         fstds    %fr5,-16(%r31)
84         fstds    %fr6,-8(%r31)
85         fstds    %fr9,0(%r31)
86         fstds    %fr10,8(%r31)
87
88         ldws   -16(%r31),hi0
89         ldws   -12(%r31),lo0
90         ldws    -8(%r31),hi1
91         ldws    -4(%r31),lo1
92         ldws     0(%r31),hi2
93         ldws     4(%r31),lo2
94         ldws     8(%r31),hi3
95         ldws    12(%r31),lo3
96
97         addc     lo0,cylimb,lo0
98         addc     lo1,hi0,lo1
99         addc     lo2,hi1,lo2
100         addc     lo3,hi2,lo3
101
102         addib,<  -4,size_param,L(end)
103         addc     %r0,hi3,cylimb                 C propagate carry into cylimb
104 C main loop ------------------------------------------------------------------
105 LDEF(loop)
106         fldds,ma 8(s1_ptr),%fr4
107         fldds,ma 8(s1_ptr),%fr8
108
109         ldws     0(res_ptr),s0
110         xmpyu    %fr4L,%fr31R,%fr5
111         ldws     4(res_ptr),s1
112         xmpyu    %fr4R,%fr31R,%fr6
113         ldws     8(res_ptr),s2
114         xmpyu    %fr8L,%fr31R,%fr9
115         ldws    12(res_ptr),s3
116         xmpyu    %fr8R,%fr31R,%fr10
117
118         fstds    %fr5,-16(%r31)
119         sub      s0,lo0,s0
120         fstds    %fr6,-8(%r31)
121         subb     s1,lo1,s1
122         fstds    %fr9,0(%r31)
123         subb     s2,lo2,s2
124         fstds    %fr10,8(%r31)
125         subb     s3,lo3,s3
126         subb     %r0,%r0,lo0                    C these two insns ...
127         add      lo0,lo0,%r0                    C ... just invert cy
128
129         ldws   -16(%r31),hi0
130         ldws   -12(%r31),lo0
131         ldws    -8(%r31),hi1
132         ldws    -4(%r31),lo1
133         ldws     0(%r31),hi2
134         ldws     4(%r31),lo2
135         ldws     8(%r31),hi3
136         ldws    12(%r31),lo3
137
138         addc     lo0,cylimb,lo0
139         stws,ma  s0,4(res_ptr)
140         addc     lo1,hi0,lo1
141         stws,ma  s1,4(res_ptr)
142         addc     lo2,hi1,lo2
143         stws,ma  s2,4(res_ptr)
144         addc     lo3,hi2,lo3
145         stws,ma  s3,4(res_ptr)
146
147         addib,>= -4,size_param,L(loop)
148         addc     %r0,hi3,cylimb                 C propagate carry into cylimb
149 C finish software pipeline ---------------------------------------------------
150 LDEF(end)
151         ldws     0(res_ptr),s0
152         ldws     4(res_ptr),s1
153         ldws     8(res_ptr),s2
154         ldws    12(res_ptr),s3
155
156         sub      s0,lo0,s0
157         stws,ma  s0,4(res_ptr)
158         subb     s1,lo1,s1
159         stws,ma  s1,4(res_ptr)
160         subb     s2,lo2,s2
161         stws,ma  s2,4(res_ptr)
162         subb     s3,lo3,s3
163         stws,ma  s3,4(res_ptr)
164         subb     %r0,%r0,lo0                    C these two insns ...
165         add      lo0,lo0,%r0                    C ... invert cy
166
167 C restore callee-saves registers ---------------------------------------------
168         ldw     -96(%r30),%r3
169         ldw     -92(%r30),%r4
170         ldw     -88(%r30),%r5
171         ldw     -84(%r30),%r6
172         ldw     -80(%r30),%r7
173
174 LDEF(few_limbs)
175         addib,=,n 4,size_param,L(ret)
176
177 LDEF(loop2)
178         fldws,ma 4(s1_ptr),%fr4
179         ldws     0(res_ptr),s0
180         xmpyu    %fr4,%fr31R,%fr5
181         fstds    %fr5,-16(%r30)
182         ldws    -16(%r30),hi0
183         ldws    -12(%r30),lo0
184         addc     lo0,cylimb,lo0
185         addc     %r0,hi0,cylimb
186         sub      s0,lo0,s0
187         add      s0,lo0,%r0                     C invert cy
188         stws,ma  s0,4(res_ptr)
189         addib,<> -1,size_param,L(loop2)
190         nop
191
192 LDEF(ret)
193         addc     %r0,cylimb,cylimb
194         bv       0(%r2)
195         ldo      -128(%r30),%r30
196 EPILOGUE(mpn_submul_1)