remove empty dir
[ghc-hetmet.git] / rts / gmp / mpn / hppa / hppa1_1 / pa7100 / addmul_1.S
1 ; HP-PA 7100/7200 __gmpn_addmul_1 -- Multiply a limb vector with a limb and
2 ; add the result to a second limb vector.
3
4 ; Copyright (C) 1995, 2000 Free Software Foundation, Inc.
5
6 ; This file is part of the GNU MP Library.
7
8 ; The GNU MP Library is free software; you can redistribute it and/or modify
9 ; it under the terms of the GNU Lesser General Public License as published by
10 ; the Free Software Foundation; either version 2.1 of the License, or (at your
11 ; option) any later version.
12
13 ; The GNU MP Library is distributed in the hope that it will be useful, but
14 ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 ; License for more details.
17
18 ; You should have received a copy of the GNU Lesser General Public License
19 ; along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20 ; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 ; MA 02111-1307, USA.
22
23 ; INPUT PARAMETERS
24 #define res_ptr %r26
25 #define s1_ptr  %r25
26 #define size    %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                            /* safe to reuse */
40 #define hi2     %r29
41 #define hi3     %r1
42
43         .code
44         .export         __gmpn_addmul_1
45 __gmpn_addmul_1
46         .proc
47         .callinfo       frame=128,no_calls
48         .entry
49
50         ldo     128(%r30),%r30
51         stws    s2_limb,-16(%r30)
52         add      %r0,%r0,cylimb                 ; clear cy and cylimb
53         addib,< -4,size,L$few_limbs
54         fldws   -16(%r30),%fr31R
55
56         ldo     -112(%r30),%r31
57         stw     %r3,-96(%r30)
58         stw     %r4,-92(%r30)
59         stw     %r5,-88(%r30)
60         stw     %r6,-84(%r30)
61         stw     %r7,-80(%r30)
62
63         bb,>=,n  s1_ptr,29,L$0
64
65         fldws,ma 4(s1_ptr),%fr4
66         ldws     0(res_ptr),s0
67         xmpyu    %fr4,%fr31R,%fr5
68         fstds    %fr5,-16(%r31)
69         ldws    -16(%r31),cylimb
70         ldws    -12(%r31),lo0
71         add      s0,lo0,s0
72         addib,< -1,size,L$few_limbs
73         stws,ma  s0,4(res_ptr)
74
75 ; start software pipeline ----------------------------------------------------
76 L$0     fldds,ma 8(s1_ptr),%fr4
77         fldds,ma 8(s1_ptr),%fr8
78
79         xmpyu    %fr4L,%fr31R,%fr5
80         xmpyu    %fr4R,%fr31R,%fr6
81         xmpyu    %fr8L,%fr31R,%fr9
82         xmpyu    %fr8R,%fr31R,%fr10
83
84         fstds    %fr5,-16(%r31)
85         fstds    %fr6,-8(%r31)
86         fstds    %fr9,0(%r31)
87         fstds    %fr10,8(%r31)
88
89         ldws   -16(%r31),hi0
90         ldws   -12(%r31),lo0
91         ldws    -8(%r31),hi1
92         ldws    -4(%r31),lo1
93         ldws     0(%r31),hi2
94         ldws     4(%r31),lo2
95         ldws     8(%r31),hi3
96         ldws    12(%r31),lo3
97
98         addc     lo0,cylimb,lo0
99         addc     lo1,hi0,lo1
100         addc     lo2,hi1,lo2
101         addc     lo3,hi2,lo3
102
103         addib,<  -4,size,L$end
104         addc     %r0,hi3,cylimb                 ; propagate carry into cylimb
105 ; main loop ------------------------------------------------------------------
106 L$loop  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         add      s0,lo0,s0
120         fstds    %fr6,-8(%r31)
121         addc     s1,lo1,s1
122         fstds    %fr9,0(%r31)
123         addc     s2,lo2,s2
124         fstds    %fr10,8(%r31)
125         addc     s3,lo3,s3
126
127         ldws   -16(%r31),hi0
128         ldws   -12(%r31),lo0
129         ldws    -8(%r31),hi1
130         ldws    -4(%r31),lo1
131         ldws     0(%r31),hi2
132         ldws     4(%r31),lo2
133         ldws     8(%r31),hi3
134         ldws    12(%r31),lo3
135
136         addc     lo0,cylimb,lo0
137         stws,ma  s0,4(res_ptr)
138         addc     lo1,hi0,lo1
139         stws,ma  s1,4(res_ptr)
140         addc     lo2,hi1,lo2
141         stws,ma  s2,4(res_ptr)
142         addc     lo3,hi2,lo3
143         stws,ma  s3,4(res_ptr)
144
145         addib,>= -4,size,L$loop
146         addc     %r0,hi3,cylimb                 ; propagate carry into cylimb
147 ; finish software pipeline ---------------------------------------------------
148 L$end   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 ; 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 L$few_limbs
170         addib,=,n 4,size,L$ret
171 L$loop2 fldws,ma 4(s1_ptr),%fr4
172         ldws     0(res_ptr),s0
173         xmpyu    %fr4,%fr31R,%fr5
174         fstds    %fr5,-16(%r30)
175         ldws    -16(%r30),hi0
176         ldws    -12(%r30),lo0
177         addc     lo0,cylimb,lo0
178         addc     %r0,hi0,cylimb
179         add      s0,lo0,s0
180         stws,ma  s0,4(res_ptr)
181         addib,<> -1,size,L$loop2
182         nop
183
184 L$ret   addc     %r0,cylimb,cylimb
185         bv       0(%r2)
186         ldo      -128(%r30),%r30
187
188         .exit
189         .procend