Debian Codegraph @

mpn/x86_64/zen/aorrlsh_n.asm

raw
1 dnl AMD64 mpn_addlsh_n, mpn_rsblsh_n.
2
3 dnl Copyright 2017 Free Software Foundation, Inc.
4
5 dnl This file is part of the GNU MP Library.
6 dnl
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of either:
9 dnl
10 dnl * the GNU Lesser General Public License as published by the Free
11 dnl Software Foundation; either version 3 of the License, or (at your
12 dnl option) any later version.
13 dnl
14 dnl or
15 dnl
16 dnl * the GNU General Public License as published by the Free Software
17 dnl Foundation; either version 2 of the License, or (at your option) any
18 dnl later version.
19 dnl
20 dnl or both in parallel, as here.
21 dnl
22 dnl The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 dnl for more details.
26 dnl
27 dnl You should have received copies of the GNU General Public License and the
28 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
29 dnl see https://www.gnu.org/licenses/.
30
31 include(`../config.m4')
32
33 C cycles/limb
34 C AMD K8,K9 n/a
35 C AMD K10 n/a
36 C AMD bd1 n/a
37 C AMD bd2 n/a
38 C AMD bd3 n/a
39 C AMD bd4 2.31
40 C AMD zn1 1.69
41 C AMD zn2 1.55
42 C AMD zn3 1.36
43 C AMD bt1 n/a
44 C AMD bt2 n/a
45 C Intel P4 n/a
46 C Intel PNR n/a
47 C Intel NHM n/a
48 C Intel SBR n/a
49 C Intel IBR n/a
50 C Intel HWL 2.08
51 C Intel BWL 1.78
52 C Intel SKL 1.78
53 C Intel atom n/a
54 C Intel SLM n/a
55 C VIA nano n/a
56
57 C TODO
58 C * Perhaps avoid using jrcxz by using dec n + jnz.
59
60 define(`rp', `%rdi')
61 define(`up', `%rsi')
62 define(`vp', `%rdx')
63 define(`n', `%rcx')
64 define(`cnt', `%r8')
65
66 define(`tnc', `%r9')
67
68 ifdef(`OPERATION_addlsh_n',`
69 define(ADCSBB, `adc')
70 define(func, mpn_addlsh_n)
71 ')
72 ifdef(`OPERATION_rsblsh_n',`
73 define(ADCSBB, `sbb')
74 define(func, mpn_rsblsh_n)
75 ')
76
77 MULFUNC_PROLOGUE(mpn_addlsh_n mpn_rsblsh_n)
78
79 ABI_SUPPORT(DOS64)
80 ABI_SUPPORT(STD64)
81
82 ASM_START()
83 TEXT
84 ALIGN(32)
85 PROLOGUE(func)
86 FUNC_ENTRY(4)
87 IFDOS(` mov 56(%rsp), %r8d ')
88
89 mov (vp), %r10
90
91 mov R32(n), R32(%rax)
92 shr $3, n
93 xor R32(tnc), R32(tnc)
94 sub cnt, tnc
95 and $7, R32(%rax)
96
97 lea L(tab)(%rip), %r11
98 ifdef(`PIC',`
99 movslq (%r11,%rax,4), %rax
100 add %r11, %rax
101 jmp *%rax
102 ',`
103 jmp *(%r11,%rax,8)
104 ')
105
106 L(0): lea 32(up), up
107 lea 32(vp), vp
108 lea 32(rp), rp
109 xor R32(%r11), R32(%r11)
110 jmp L(e0)
111
112 L(7): mov %r10, %r11
113 lea 24(up), up
114 lea 24(vp), vp
115 lea 24(rp), rp
116 xor R32(%r10), R32(%r10)
117 jmp L(e7)
118
119 L(6): lea 16(up), up
120 lea 16(vp), vp
121 lea 16(rp), rp
122 xor R32(%r11), R32(%r11)
123 jmp L(e6)
124
125 L(5): mov %r10, %r11
126 lea 8(up), up
127 lea 8(vp), vp
128 lea 8(rp), rp
129 xor R32(%r10), R32(%r10)
130 jmp L(e5)
131
132 L(end): ADCSBB 24(up), %rax
133 mov %rax, -40(rp)
134 shrx( tnc, %r11, %rax)
135 ADCSBB n, %rax
136 FUNC_EXIT()
137 ret
138
139 ALIGN(32)
140 L(top): jrcxz L(end)
141 mov -32(vp), %r10
142 ADCSBB 24(up), %rax
143 lea 64(up), up
144 shrx( tnc, %r11, %r11)
145 mov %rax, -40(rp)
146 L(e0): dec n
147 shlx( cnt, %r10, %rax)
148 lea (%r11,%rax), %rax
149 mov -24(vp), %r11
150 ADCSBB -32(up), %rax
151 shrx( tnc, %r10, %r10)
152 mov %rax, -32(rp)
153 L(e7): shlx( cnt, %r11, %rax)
154 lea (%r10,%rax), %rax
155 mov -16(vp), %r10
156 ADCSBB -24(up), %rax
157 shrx( tnc, %r11, %r11)
158 mov %rax, -24(rp)
159 L(e6): shlx( cnt, %r10, %rax)
160 lea (%r11,%rax), %rax
161 mov -8(vp), %r11
162 ADCSBB -16(up), %rax
163 shrx( tnc, %r10, %r10)
164 mov %rax, -16(rp)
165 L(e5): shlx( cnt, %r11, %rax)
166 lea (%r10,%rax), %rax
167 mov (vp), %r10
168 ADCSBB -8(up), %rax
169 shrx( tnc, %r11, %r11)
170 mov %rax, -8(rp)
171 L(e4): shlx( cnt, %r10, %rax)
172 lea (%r11,%rax), %rax
173 mov 8(vp), %r11
174 ADCSBB (up), %rax
175 shrx( tnc, %r10, %r10)
176 mov %rax, (rp)
177 L(e3): shlx( cnt, %r11, %rax)
178 lea (%r10,%rax), %rax
179 mov 16(vp), %r10
180 ADCSBB 8(up), %rax
181 shrx( tnc, %r11, %r11)
182 mov %rax, 8(rp)
183 L(e2): shlx( cnt, %r10, %rax)
184 lea (%r11,%rax), %rax
185 mov 24(vp), %r11
186 ADCSBB 16(up), %rax
187 lea 64(vp), vp
188 shrx( tnc, %r10, %r10)
189 mov %rax, 16(rp)
190 lea 64(rp), rp
191 L(e1): shlx( cnt, %r11, %rax)
192 lea (%r10,%rax), %rax
193 jmp L(top)
194
195 L(4): xor R32(%r11), R32(%r11)
196 jmp L(e4)
197
198 L(3): mov %r10, %r11
199 lea -8(up), up
200 lea -8(vp), vp
201 lea -8(rp), rp
202 xor R32(%r10), R32(%r10)
203 jmp L(e3)
204
205 L(2): lea -16(up), up
206 lea -16(vp), vp
207 lea -16(rp), rp
208 xor R32(%r11), R32(%r11)
209 jmp L(e2)
210
211 L(1): mov %r10, %r11
212 lea -24(up), up
213 lea 40(vp), vp
214 lea 40(rp), rp
215 xor R32(%r10), R32(%r10)
216 jmp L(e1)
217 EPILOGUE()
218 JUMPTABSECT
219 ALIGN(8)
220 L(tab): JMPENT( L(0), L(tab))
221 JMPENT( L(1), L(tab))
222 JMPENT( L(2), L(tab))
223 JMPENT( L(3), L(tab))
224 JMPENT( L(4), L(tab))
225 JMPENT( L(5), L(tab))
226 JMPENT( L(6), L(tab))
227 JMPENT( L(7), L(tab))