Debian Codegraph @

mpn/x86_64/core2/logops_n.asm

raw
1 dnl AMD64 logops.
2
3 dnl Copyright 2004-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
34 C c/l c/l c/l good
35 C var-1 var-2 var-3 for cpu?
36 C AMD K8,K9
37 C AMD K10 1.52 1.75 1.75 n
38 C AMD bd1
39 C AMD bd2
40 C AMD bd3
41 C AMD bd4
42 C AMD bt1 2.67 ~2.79 ~2.79 =
43 C AMD bt2 2.15 2.65 2.65 n
44 C AMD zen 1.5 1.5 1.5 =
45 C Intel P4
46 C Intel PNR 2.0 2.0 2.0 =
47 C Intel NHM 2.0 2.0 2.0 =
48 C Intel SBR 1.5 1.5 1.5 y
49 C Intel IBR 1.47 1.48 1.48 y
50 C Intel HWL 1.11 1.35 1.35 y
51 C Intel BWL 1.09 1.30 1.30 y
52 C Intel SKL 1.21 1.27 1.27 y
53 C Intel atom 3.31 3.57 3.57 y
54 C Intel SLM 3.0 3.0 3.0 =
55 C VIA nano
56
57 ifdef(`OPERATION_and_n',`
58 define(`func',`mpn_and_n')
59 define(`VARIANT_1')
60 define(`LOGOP',`and')')
61 ifdef(`OPERATION_andn_n',`
62 define(`func',`mpn_andn_n')
63 define(`VARIANT_2')
64 define(`LOGOP',`and')')
65 ifdef(`OPERATION_nand_n',`
66 define(`func',`mpn_nand_n')
67 define(`VARIANT_3')
68 define(`LOGOP',`and')')
69 ifdef(`OPERATION_ior_n',`
70 define(`func',`mpn_ior_n')
71 define(`VARIANT_1')
72 define(`LOGOP',`or')')
73 ifdef(`OPERATION_iorn_n',`
74 define(`func',`mpn_iorn_n')
75 define(`VARIANT_2')
76 define(`LOGOP',`or')')
77 ifdef(`OPERATION_nior_n',`
78 define(`func',`mpn_nior_n')
79 define(`VARIANT_3')
80 define(`LOGOP',`or')')
81 ifdef(`OPERATION_xor_n',`
82 define(`func',`mpn_xor_n')
83 define(`VARIANT_1')
84 define(`LOGOP',`xor')')
85 ifdef(`OPERATION_xnor_n',`
86 define(`func',`mpn_xnor_n')
87 define(`VARIANT_2')
88 define(`LOGOP',`xor')')
89
90 define(`addptr', `lea $1($2), $2')
91
92 MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n)
93
94 C INPUT PARAMETERS
95 define(`rp',`%rdi')
96 define(`up',`%rsi')
97 define(`vp',`%rdx')
98 define(`n',`%rcx')
99
100 ABI_SUPPORT(DOS64)
101 ABI_SUPPORT(STD64)
102
103 ASM_START()
104
105 ifdef(`VARIANT_1',`
106 TEXT
107 ALIGN(32)
108 PROLOGUE(func)
109 FUNC_ENTRY(4)
110 mov (vp), %r8
111 mov R32(%rcx), R32(%rax)
112 and $3, R32(%rax)
113 je L(b00)
114 cmp $2, R32(%rax)
115 jc L(b01)
116 je L(b10)
117
118 L(b11): LOGOP (up), %r8
119 mov %r8, (rp)
120 inc n
121 addptr( -8, up)
122 addptr( -8, vp)
123 addptr( -8, rp)
124 jmp L(e11)
125 L(b10): add $2, n
126 addptr( -16, up)
127 addptr( -16, vp)
128 addptr( -16, rp)
129 jmp L(e10)
130 L(b01): LOGOP (up), %r8
131 mov %r8, (rp)
132 dec n
133 jz L(ret)
134 addptr( 8, up)
135 addptr( 8, vp)
136 addptr( 8, rp)
137
138 ALIGN(16)
139 L(top): mov (vp), %r8
140 L(b00): mov 8(vp), %r9
141 LOGOP (up), %r8
142 LOGOP 8(up), %r9
143 mov %r8, (rp)
144 mov %r9, 8(rp)
145 L(e11): mov 16(vp), %r8
146 L(e10): mov 24(vp), %r9
147 addptr( 32, vp)
148 LOGOP 16(up), %r8
149 LOGOP 24(up), %r9
150 addptr( 32, up)
151 mov %r8, 16(rp)
152 mov %r9, 24(rp)
153 addptr( 32, rp)
154 sub $4, n
155 jnz L(top)
156
157 L(ret): FUNC_EXIT()
158 ret
159 EPILOGUE()
160 ')
161
162 ifdef(`VARIANT_2',`
163 TEXT
164 ALIGN(32)
165 PROLOGUE(func)
166 FUNC_ENTRY(4)
167 mov (vp), %r8
168 not %r8
169 mov R32(%rcx), R32(%rax)
170 and $3, R32(%rax)
171 je L(b00)
172 cmp $2, R32(%rax)
173 jc L(b01)
174 je L(b10)
175
176 L(b11): LOGOP (up), %r8
177 mov %r8, (rp)
178 inc n
179 addptr( -8, up)
180 addptr( -8, vp)
181 addptr( -8, rp)
182 jmp L(e11)
183 L(b10): add $2, n
184 addptr( -16, up)
185 addptr( -16, vp)
186 addptr( -16, rp)
187 jmp L(e10)
188 L(b01): LOGOP (up), %r8
189 mov %r8, (rp)
190 dec n
191 jz L(ret)
192 addptr( 8, up)
193 addptr( 8, vp)
194 addptr( 8, rp)
195
196 ALIGN(16)
197 L(top): mov (vp), %r8
198 not %r8
199 L(b00): mov 8(vp), %r9
200 not %r9
201 LOGOP (up), %r8
202 LOGOP 8(up), %r9
203 mov %r8, (rp)
204 mov %r9, 8(rp)
205 L(e11): mov 16(vp), %r8
206 not %r8
207 L(e10): mov 24(vp), %r9
208 not %r9
209 addptr( 32, vp)
210 LOGOP 16(up), %r8
211 LOGOP 24(up), %r9
212 addptr( 32, up)
213 mov %r8, 16(rp)
214 mov %r9, 24(rp)
215 addptr( 32, rp)
216 sub $4, n
217 jnz L(top)
218
219 L(ret): FUNC_EXIT()
220 ret
221 EPILOGUE()
222 ')
223
224 ifdef(`VARIANT_3',`
225 TEXT
226 ALIGN(32)
227 PROLOGUE(func)
228 FUNC_ENTRY(4)
229 mov (vp), %r8
230 mov R32(%rcx), R32(%rax)
231 and $3, R32(%rax)
232 je L(b00)
233 cmp $2, R32(%rax)
234 jc L(b01)
235 je L(b10)
236
237 L(b11): LOGOP (up), %r8
238 not %r8
239 mov %r8, (rp)
240 inc n
241 addptr( -8, up)
242 addptr( -8, vp)
243 addptr( -8, rp)
244 jmp L(e11)
245 L(b10): add $2, n
246 addptr( -16, up)
247 addptr( -16, vp)
248 addptr( -16, rp)
249 jmp L(e10)
250 L(b01): LOGOP (up), %r8
251 not %r8
252 mov %r8, (rp)
253 dec n
254 jz L(ret)
255 addptr( 8, up)
256 addptr( 8, vp)
257 addptr( 8, rp)
258
259 ALIGN(16)
260 L(top): mov (vp), %r8
261 L(b00): mov 8(vp), %r9
262 LOGOP (up), %r8
263 not %r8
264 LOGOP 8(up), %r9
265 not %r9
266 mov %r8, (rp)
267 mov %r9, 8(rp)
268 L(e11): mov 16(vp), %r8
269 L(e10): mov 24(vp), %r9
270 addptr( 32, vp)
271 LOGOP 16(up), %r8
272 not %r8
273 LOGOP 24(up), %r9
274 addptr( 32, up)
275 not %r9
276 mov %r8, 16(rp)
277 mov %r9, 24(rp)
278 addptr( 32, rp)
279 sub $4, n
280 jnz L(top)
281
282 L(ret): FUNC_EXIT()
283 ret
284 EPILOGUE()
285 ')