Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / x86_64 / memset.S
blob7be907192c71670f4e3f86127af148dab6a0f9ab
1 /* memset/bzero -- set memory area to CH/0
2    Optimized version for x86-64.
3    Copyright (C) 2002-2005, 2007, 2008, 2011 Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
20 #include <sysdep.h>
22 #define __STOS_LOWER_BOUNDARY   $8192
23 #define __STOS_UPPER_BOUNDARY   $65536
25         .text
26 #if !defined NOT_IN_libc && !defined USE_MULTIARCH
27 ENTRY(__bzero)
28         mov     %rsi,%rdx       /* Adjust parameter.  */
29         xorl    %esi,%esi       /* Fill with 0s.  */
30         jmp     L(memset_entry)
31 END(__bzero)
32 weak_alias (__bzero, bzero)
33 #endif
35 #if defined PIC && !defined NOT_IN_libc
36 ENTRY_CHK (__memset_chk)
37         cmpq    %rdx, %rcx
38         jb      HIDDEN_JUMPTARGET (__chk_fail)
39 END_CHK (__memset_chk)
40 #endif
41 ENTRY (memset)
42 L(memset_entry):
43         cmp    $0x1,%rdx
44         mov    %rdi,%rax        /* memset returns the dest address.  */
45         jne    L(ck2)
46         mov    %sil,(%rdi)
47         retq
48 L(ck2):
49         mov    $0x101010101010101,%r9
50         mov    %rdx,%r8
51         movzbq %sil,%rdx
52         imul   %r9,%rdx
53 L(now_dw_aligned):
54         cmp    $0x90,%r8
55         jg     L(ck_mem_ops_method)
56 L(now_dw_aligned_small):
57         add    %r8,%rdi
58 #ifndef PIC
59         lea    L(setPxQx)(%rip),%r11
60         jmpq   *(%r11,%r8,8)
61 #else
62         lea    L(Got0)(%rip),%r11
63         lea    L(setPxQx)(%rip),%rcx
64         movswq (%rcx,%r8,2),%rcx
65         lea    (%rcx,%r11,1),%r11
66         jmpq   *%r11
67 #endif
69 L(Got0):
70         retq
72         .pushsection .rodata
73         .balign     16
74 #ifndef PIC
75 L(setPxQx):
76         .quad       L(Got0), L(P1Q0), L(P2Q0), L(P3Q0)
77         .quad       L(P4Q0), L(P5Q0), L(P6Q0), L(P7Q0)
78         .quad       L(P0Q1), L(P1Q1), L(P2Q1), L(P3Q1)
79         .quad       L(P4Q1), L(P5Q1), L(P6Q1), L(P7Q1)
80         .quad       L(P0Q2), L(P1Q2), L(P2Q2), L(P3Q2)
81         .quad       L(P4Q2), L(P5Q2), L(P6Q2), L(P7Q2)
82         .quad       L(P0Q3), L(P1Q3), L(P2Q3), L(P3Q3)
83         .quad       L(P4Q3), L(P5Q3), L(P6Q3), L(P7Q3)
84         .quad       L(P0Q4), L(P1Q4), L(P2Q4), L(P3Q4)
85         .quad       L(P4Q4), L(P5Q4), L(P6Q4), L(P7Q4)
86         .quad       L(P0Q5), L(P1Q5), L(P2Q5), L(P3Q5)
87         .quad       L(P4Q5), L(P5Q5), L(P6Q5), L(P7Q5)
88         .quad       L(P0Q6), L(P1Q6), L(P2Q6), L(P3Q6)
89         .quad       L(P4Q6), L(P5Q6), L(P6Q6), L(P7Q6)
90         .quad       L(P0Q7), L(P1Q7), L(P2Q7), L(P3Q7)
91         .quad       L(P4Q7), L(P5Q7), L(P6Q7), L(P7Q7)
92         .quad       L(P0Q8), L(P1Q8), L(P2Q8), L(P3Q8)
93         .quad       L(P4Q8), L(P5Q8), L(P6Q8), L(P7Q8)
94         .quad       L(P0Q9), L(P1Q9), L(P2Q9), L(P3Q9)
95         .quad       L(P4Q9), L(P5Q9), L(P6Q9), L(P7Q9)
96         .quad       L(P0QA), L(P1QA), L(P2QA), L(P3QA)
97         .quad       L(P4QA), L(P5QA), L(P6QA), L(P7QA)
98         .quad       L(P0QB), L(P1QB), L(P2QB), L(P3QB)
99         .quad       L(P4QB), L(P5QB), L(P6QB), L(P7QB)
100         .quad       L(P0QC), L(P1QC), L(P2QC), L(P3QC)
101         .quad       L(P4QC), L(P5QC), L(P6QC), L(P7QC)
102         .quad       L(P0QD), L(P1QD), L(P2QD), L(P3QD)
103         .quad       L(P4QD), L(P5QD), L(P6QD), L(P7QD)
104         .quad       L(P0QE), L(P1QE), L(P2QE), L(P3QE)
105         .quad       L(P4QE), L(P5QE), L(P6QE), L(P7QE)
106         .quad       L(P0QF), L(P1QF), L(P2QF), L(P3QF)
107         .quad       L(P4QF), L(P5QF), L(P6QF), L(P7QF)
108         .quad       L(P0QG), L(P1QG), L(P2QG), L(P3QG)
109         .quad       L(P4QG), L(P5QG), L(P6QG), L(P7QG)
110         .quad       L(P0QH), L(P1QH), L(P2QH), L(P3QH)
111         .quad       L(P4QH), L(P5QH), L(P6QH), L(P7QH)
112         .quad       L(P0QI)
113 # ifdef USE_EXTRA_TABLE
114         .quad       L(P1QI), L(P2QI), L(P3QI), L(P4QI)
115         .quad       L(P5QI), L(P6QI), L(P7QI)
116 # endif
117 #else
118 L(setPxQx):
119         .short     L(Got0)-L(Got0)
120         .short     L(P1Q0)-L(Got0)
121         .short     L(P2Q0)-L(Got0)
122         .short     L(P3Q0)-L(Got0)
123         .short     L(P4Q0)-L(Got0)
124         .short     L(P5Q0)-L(Got0)
125         .short     L(P6Q0)-L(Got0)
126         .short     L(P7Q0)-L(Got0)
128         .short     L(P0Q1)-L(Got0)
129         .short     L(P1Q1)-L(Got0)
130         .short     L(P2Q1)-L(Got0)
131         .short     L(P3Q1)-L(Got0)
132         .short     L(P4Q1)-L(Got0)
133         .short     L(P5Q1)-L(Got0)
134         .short     L(P6Q1)-L(Got0)
135         .short     L(P7Q1)-L(Got0)
137         .short     L(P0Q2)-L(Got0)
138         .short     L(P1Q2)-L(Got0)
139         .short     L(P2Q2)-L(Got0)
140         .short     L(P3Q2)-L(Got0)
141         .short     L(P4Q2)-L(Got0)
142         .short     L(P5Q2)-L(Got0)
143         .short     L(P6Q2)-L(Got0)
144         .short     L(P7Q2)-L(Got0)
146         .short     L(P0Q3)-L(Got0)
147         .short     L(P1Q3)-L(Got0)
148         .short     L(P2Q3)-L(Got0)
149         .short     L(P3Q3)-L(Got0)
150         .short     L(P4Q3)-L(Got0)
151         .short     L(P5Q3)-L(Got0)
152         .short     L(P6Q3)-L(Got0)
153         .short     L(P7Q3)-L(Got0)
155         .short     L(P0Q4)-L(Got0)
156         .short     L(P1Q4)-L(Got0)
157         .short     L(P2Q4)-L(Got0)
158         .short     L(P3Q4)-L(Got0)
159         .short     L(P4Q4)-L(Got0)
160         .short     L(P5Q4)-L(Got0)
161         .short     L(P6Q4)-L(Got0)
162         .short     L(P7Q4)-L(Got0)
164         .short     L(P0Q5)-L(Got0)
165         .short     L(P1Q5)-L(Got0)
166         .short     L(P2Q5)-L(Got0)
167         .short     L(P3Q5)-L(Got0)
168         .short     L(P4Q5)-L(Got0)
169         .short     L(P5Q5)-L(Got0)
170         .short     L(P6Q5)-L(Got0)
171         .short     L(P7Q5)-L(Got0)
173         .short     L(P0Q6)-L(Got0)
174         .short     L(P1Q6)-L(Got0)
175         .short     L(P2Q6)-L(Got0)
176         .short     L(P3Q6)-L(Got0)
177         .short     L(P4Q6)-L(Got0)
178         .short     L(P5Q6)-L(Got0)
179         .short     L(P6Q6)-L(Got0)
180         .short     L(P7Q6)-L(Got0)
182         .short     L(P0Q7)-L(Got0)
183         .short     L(P1Q7)-L(Got0)
184         .short     L(P2Q7)-L(Got0)
185         .short     L(P3Q7)-L(Got0)
186         .short     L(P4Q7)-L(Got0)
187         .short     L(P5Q7)-L(Got0)
188         .short     L(P6Q7)-L(Got0)
189         .short     L(P7Q7)-L(Got0)
191         .short     L(P0Q8)-L(Got0)
192         .short     L(P1Q8)-L(Got0)
193         .short     L(P2Q8)-L(Got0)
194         .short     L(P3Q8)-L(Got0)
195         .short     L(P4Q8)-L(Got0)
196         .short     L(P5Q8)-L(Got0)
197         .short     L(P6Q8)-L(Got0)
198         .short     L(P7Q8)-L(Got0)
200         .short     L(P0Q9)-L(Got0)
201         .short     L(P1Q9)-L(Got0)
202         .short     L(P2Q9)-L(Got0)
203         .short     L(P3Q9)-L(Got0)
204         .short     L(P4Q9)-L(Got0)
205         .short     L(P5Q9)-L(Got0)
206         .short     L(P6Q9)-L(Got0)
207         .short     L(P7Q9)-L(Got0)
209         .short     L(P0QA)-L(Got0)
210         .short     L(P1QA)-L(Got0)
211         .short     L(P2QA)-L(Got0)
212         .short     L(P3QA)-L(Got0)
213         .short     L(P4QA)-L(Got0)
214         .short     L(P5QA)-L(Got0)
215         .short     L(P6QA)-L(Got0)
216         .short     L(P7QA)-L(Got0)
218         .short     L(P0QB)-L(Got0)
219         .short     L(P1QB)-L(Got0)
220         .short     L(P2QB)-L(Got0)
221         .short     L(P3QB)-L(Got0)
222         .short     L(P4QB)-L(Got0)
223         .short     L(P5QB)-L(Got0)
224         .short     L(P6QB)-L(Got0)
225         .short     L(P7QB)-L(Got0)
227         .short     L(P0QC)-L(Got0)
228         .short     L(P1QC)-L(Got0)
229         .short     L(P2QC)-L(Got0)
230         .short     L(P3QC)-L(Got0)
231         .short     L(P4QC)-L(Got0)
232         .short     L(P5QC)-L(Got0)
233         .short     L(P6QC)-L(Got0)
234         .short     L(P7QC)-L(Got0)
236         .short     L(P0QD)-L(Got0)
237         .short     L(P1QD)-L(Got0)
238         .short     L(P2QD)-L(Got0)
239         .short     L(P3QD)-L(Got0)
240         .short     L(P4QD)-L(Got0)
241         .short     L(P5QD)-L(Got0)
242         .short     L(P6QD)-L(Got0)
243         .short     L(P7QD)-L(Got0)
245         .short     L(P0QE)-L(Got0)
246         .short     L(P1QE)-L(Got0)
247         .short     L(P2QE)-L(Got0)
248         .short     L(P3QE)-L(Got0)
249         .short     L(P4QE)-L(Got0)
250         .short     L(P5QE)-L(Got0)
251         .short     L(P6QE)-L(Got0)
252         .short     L(P7QE)-L(Got0)
254         .short     L(P0QF)-L(Got0)
255         .short     L(P1QF)-L(Got0)
256         .short     L(P2QF)-L(Got0)
257         .short     L(P3QF)-L(Got0)
258         .short     L(P4QF)-L(Got0)
259         .short     L(P5QF)-L(Got0)
260         .short     L(P6QF)-L(Got0)
261         .short     L(P7QF)-L(Got0)
263         .short     L(P0QG)-L(Got0)
264         .short     L(P1QG)-L(Got0)
265         .short     L(P2QG)-L(Got0)
266         .short     L(P3QG)-L(Got0)
267         .short     L(P4QG)-L(Got0)
268         .short     L(P5QG)-L(Got0)
269         .short     L(P6QG)-L(Got0)
270         .short     L(P7QG)-L(Got0)
272         .short     L(P0QH)-L(Got0)
273         .short     L(P1QH)-L(Got0)
274         .short     L(P2QH)-L(Got0)
275         .short     L(P3QH)-L(Got0)
276         .short     L(P4QH)-L(Got0)
277         .short     L(P5QH)-L(Got0)
278         .short     L(P6QH)-L(Got0)
279         .short     L(P7QH)-L(Got0)
281         .short     L(P0QI)-L(Got0)
282 # ifdef USE_EXTRA_TABLE
283         .short     L(P1QI)-L(Got0)
284         .short     L(P2QI)-L(Got0)
285         .short     L(P3QI)-L(Got0)
286         .short     L(P4QI)-L(Got0)
287         .short     L(P5QI)-L(Got0)
288         .short     L(P6QI)-L(Got0)
289         .short     L(P7QI)-L(Got0)
290 # endif
291 #endif
292         .popsection
294         .balign     16
295 #ifdef USE_EXTRA_TABLE
296 L(P1QI): mov    %rdx,-0x91(%rdi)
297 #endif
298 L(P1QH): mov    %rdx,-0x89(%rdi)
299 L(P1QG): mov    %rdx,-0x81(%rdi)
300 #                  .balign     16
301 L(P1QF): mov    %rdx,-0x79(%rdi)
302 L(P1QE): mov    %rdx,-0x71(%rdi)
303 L(P1QD): mov    %rdx,-0x69(%rdi)
304 L(P1QC): mov    %rdx,-0x61(%rdi)
305 L(P1QB): mov    %rdx,-0x59(%rdi)
306 L(P1QA): mov    %rdx,-0x51(%rdi)
307 L(P1Q9): mov    %rdx,-0x49(%rdi)
308 L(P1Q8): mov    %rdx,-0x41(%rdi)
309 L(P1Q7): mov    %rdx,-0x39(%rdi)
310 L(P1Q6): mov    %rdx,-0x31(%rdi)
311 L(P1Q5): mov    %rdx,-0x29(%rdi)
312 L(P1Q4): mov    %rdx,-0x21(%rdi)
313 L(P1Q3): mov    %rdx,-0x19(%rdi)
314 L(P1Q2): mov    %rdx,-0x11(%rdi)
315 L(P1Q1): mov    %rdx,-0x9(%rdi)
316 L(P1Q0): mov    %dl,-0x1(%rdi)
317                 retq
319         .balign     16
320 L(P0QI): mov    %rdx,-0x90(%rdi)
321 L(P0QH): mov    %rdx,-0x88(%rdi)
322 #                  .balign     16
323 L(P0QG): mov    %rdx,-0x80(%rdi)
324 L(P0QF): mov    %rdx,-0x78(%rdi)
325 L(P0QE): mov    %rdx,-0x70(%rdi)
326 L(P0QD): mov    %rdx,-0x68(%rdi)
327 L(P0QC): mov    %rdx,-0x60(%rdi)
328 L(P0QB): mov    %rdx,-0x58(%rdi)
329 L(P0QA): mov    %rdx,-0x50(%rdi)
330 L(P0Q9): mov    %rdx,-0x48(%rdi)
331 L(P0Q8): mov    %rdx,-0x40(%rdi)
332 L(P0Q7): mov    %rdx,-0x38(%rdi)
333 L(P0Q6): mov    %rdx,-0x30(%rdi)
334 L(P0Q5): mov    %rdx,-0x28(%rdi)
335 L(P0Q4): mov    %rdx,-0x20(%rdi)
336 L(P0Q3): mov    %rdx,-0x18(%rdi)
337 L(P0Q2): mov    %rdx,-0x10(%rdi)
338 L(P0Q1): mov    %rdx,-0x8(%rdi)
339 L(P0Q0): retq
342         .balign     16
343 #ifdef USE_EXTRA_TABLE
344 L(P2QI): mov    %rdx,-0x92(%rdi)
345 #endif
346 L(P2QH): mov    %rdx,-0x8a(%rdi)
347 L(P2QG): mov    %rdx,-0x82(%rdi)
348 #                  .balign     16
349 L(P2QF): mov    %rdx,-0x7a(%rdi)
350 L(P2QE): mov    %rdx,-0x72(%rdi)
351 L(P2QD): mov    %rdx,-0x6a(%rdi)
352 L(P2QC): mov    %rdx,-0x62(%rdi)
353 L(P2QB): mov    %rdx,-0x5a(%rdi)
354 L(P2QA): mov    %rdx,-0x52(%rdi)
355 L(P2Q9): mov    %rdx,-0x4a(%rdi)
356 L(P2Q8): mov    %rdx,-0x42(%rdi)
357 L(P2Q7): mov    %rdx,-0x3a(%rdi)
358 L(P2Q6): mov    %rdx,-0x32(%rdi)
359 L(P2Q5): mov    %rdx,-0x2a(%rdi)
360 L(P2Q4): mov    %rdx,-0x22(%rdi)
361 L(P2Q3): mov    %rdx,-0x1a(%rdi)
362 L(P2Q2): mov    %rdx,-0x12(%rdi)
363 L(P2Q1): mov    %rdx,-0xa(%rdi)
364 L(P2Q0): mov    %dx,-0x2(%rdi)
365                 retq
367         .balign     16
368 #ifdef USE_EXTRA_TABLE
369 L(P3QI): mov    %rdx,-0x93(%rdi)
370 #endif
371 L(P3QH): mov    %rdx,-0x8b(%rdi)
372 L(P3QG): mov    %rdx,-0x83(%rdi)
373 #                  .balign     16
374 L(P3QF): mov    %rdx,-0x7b(%rdi)
375 L(P3QE): mov    %rdx,-0x73(%rdi)
376 L(P3QD): mov    %rdx,-0x6b(%rdi)
377 L(P3QC): mov    %rdx,-0x63(%rdi)
378 L(P3QB): mov    %rdx,-0x5b(%rdi)
379 L(P3QA): mov    %rdx,-0x53(%rdi)
380 L(P3Q9): mov    %rdx,-0x4b(%rdi)
381 L(P3Q8): mov    %rdx,-0x43(%rdi)
382 L(P3Q7): mov    %rdx,-0x3b(%rdi)
383 L(P3Q6): mov    %rdx,-0x33(%rdi)
384 L(P3Q5): mov    %rdx,-0x2b(%rdi)
385 L(P3Q4): mov    %rdx,-0x23(%rdi)
386 L(P3Q3): mov    %rdx,-0x1b(%rdi)
387 L(P3Q2): mov    %rdx,-0x13(%rdi)
388 L(P3Q1): mov    %rdx,-0xb(%rdi)
389 L(P3Q0): mov    %dx,-0x3(%rdi)
390                 mov    %dl,-0x1(%rdi)
391                 retq
393         .balign     16
394 #ifdef USE_EXTRA_TABLE
395 L(P4QI): mov    %rdx,-0x94(%rdi)
396 #endif
397 L(P4QH): mov    %rdx,-0x8c(%rdi)
398 L(P4QG): mov    %rdx,-0x84(%rdi)
399 #                  .balign     16
400 L(P4QF): mov    %rdx,-0x7c(%rdi)
401 L(P4QE): mov    %rdx,-0x74(%rdi)
402 L(P4QD): mov    %rdx,-0x6c(%rdi)
403 L(P4QC): mov    %rdx,-0x64(%rdi)
404 L(P4QB): mov    %rdx,-0x5c(%rdi)
405 L(P4QA): mov    %rdx,-0x54(%rdi)
406 L(P4Q9): mov    %rdx,-0x4c(%rdi)
407 L(P4Q8): mov    %rdx,-0x44(%rdi)
408 L(P4Q7): mov    %rdx,-0x3c(%rdi)
409 L(P4Q6): mov    %rdx,-0x34(%rdi)
410 L(P4Q5): mov    %rdx,-0x2c(%rdi)
411 L(P4Q4): mov    %rdx,-0x24(%rdi)
412 L(P4Q3): mov    %rdx,-0x1c(%rdi)
413 L(P4Q2): mov    %rdx,-0x14(%rdi)
414 L(P4Q1): mov    %rdx,-0xc(%rdi)
415 L(P4Q0): mov    %edx,-0x4(%rdi)
416                 retq
418         .balign     16
419 #ifdef USE_EXTRA_TABLE
420 L(P5QI): mov    %rdx,-0x95(%rdi)
421 #endif
422 L(P5QH): mov    %rdx,-0x8d(%rdi)
423 L(P5QG): mov    %rdx,-0x85(%rdi)
424 #                  .balign     16
425 L(P5QF): mov    %rdx,-0x7d(%rdi)
426 L(P5QE): mov    %rdx,-0x75(%rdi)
427 L(P5QD): mov    %rdx,-0x6d(%rdi)
428 L(P5QC): mov    %rdx,-0x65(%rdi)
429 L(P5QB): mov    %rdx,-0x5d(%rdi)
430 L(P5QA): mov    %rdx,-0x55(%rdi)
431 L(P5Q9): mov    %rdx,-0x4d(%rdi)
432 L(P5Q8): mov    %rdx,-0x45(%rdi)
433 L(P5Q7): mov    %rdx,-0x3d(%rdi)
434 L(P5Q6): mov    %rdx,-0x35(%rdi)
435 L(P5Q5): mov    %rdx,-0x2d(%rdi)
436 L(P5Q4): mov    %rdx,-0x25(%rdi)
437 L(P5Q3): mov    %rdx,-0x1d(%rdi)
438 L(P5Q2): mov    %rdx,-0x15(%rdi)
439 L(P5Q1): mov    %rdx,-0xd(%rdi)
440 L(P5Q0): mov    %edx,-0x5(%rdi)
441                 mov    %dl,-0x1(%rdi)
442                 retq
444         .balign     16
445 #ifdef USE_EXTRA_TABLE
446 L(P6QI): mov    %rdx,-0x96(%rdi)
447 #endif
448 L(P6QH): mov    %rdx,-0x8e(%rdi)
449 L(P6QG): mov    %rdx,-0x86(%rdi)
450 #                  .balign     16
451 L(P6QF): mov    %rdx,-0x7e(%rdi)
452 L(P6QE): mov    %rdx,-0x76(%rdi)
453 L(P6QD): mov    %rdx,-0x6e(%rdi)
454 L(P6QC): mov    %rdx,-0x66(%rdi)
455 L(P6QB): mov    %rdx,-0x5e(%rdi)
456 L(P6QA): mov    %rdx,-0x56(%rdi)
457 L(P6Q9): mov    %rdx,-0x4e(%rdi)
458 L(P6Q8): mov    %rdx,-0x46(%rdi)
459 L(P6Q7): mov    %rdx,-0x3e(%rdi)
460 L(P6Q6): mov    %rdx,-0x36(%rdi)
461 L(P6Q5): mov    %rdx,-0x2e(%rdi)
462 L(P6Q4): mov    %rdx,-0x26(%rdi)
463 L(P6Q3): mov    %rdx,-0x1e(%rdi)
464 L(P6Q2): mov    %rdx,-0x16(%rdi)
465 L(P6Q1): mov    %rdx,-0xe(%rdi)
466 L(P6Q0): mov    %edx,-0x6(%rdi)
467                 mov    %dx,-0x2(%rdi)
468                 retq
470         .balign     16
471 #ifdef USE_EXTRA_TABLE
472 L(P7QI): mov    %rdx,-0x97(%rdi)
473 #endif
474 L(P7QH): mov    %rdx,-0x8f(%rdi)
475 L(P7QG): mov    %rdx,-0x87(%rdi)
476 #                  .balign     16
477 L(P7QF): mov    %rdx,-0x7f(%rdi)
478 L(P7QE): mov    %rdx,-0x77(%rdi)
479 L(P7QD): mov    %rdx,-0x6f(%rdi)
480 L(P7QC): mov    %rdx,-0x67(%rdi)
481 L(P7QB): mov    %rdx,-0x5f(%rdi)
482 L(P7QA): mov    %rdx,-0x57(%rdi)
483 L(P7Q9): mov    %rdx,-0x4f(%rdi)
484 L(P7Q8): mov    %rdx,-0x47(%rdi)
485 L(P7Q7): mov    %rdx,-0x3f(%rdi)
486 L(P7Q6): mov    %rdx,-0x37(%rdi)
487 L(P7Q5): mov    %rdx,-0x2f(%rdi)
488 L(P7Q4): mov    %rdx,-0x27(%rdi)
489 L(P7Q3): mov    %rdx,-0x1f(%rdi)
490 L(P7Q2): mov    %rdx,-0x17(%rdi)
491 L(P7Q1): mov    %rdx,-0xf(%rdi)
492 L(P7Q0): mov    %edx,-0x7(%rdi)
493                 mov    %dx,-0x3(%rdi)
494                 mov    %dl,-0x1(%rdi)
495                 retq
497         .balign     16
498 L(ck_mem_ops_method):
500 # align to 16 byte boundary first
501         #test $0xf,%rdi
502         #jz L(aligned_now)
503         mov    $0x10,%r10
504         mov    %rdi,%r9
505         and    $0xf,%r9
506         sub    %r9,%r10
507         and    $0xf,%r10
508         add    %r10,%rdi
509         sub    %r10,%r8
510 #ifndef PIC
511         lea    L(AliPxQx)(%rip),%r11
512         jmpq   *(%r11,%r10,8)
513 #else
514         lea    L(aligned_now)(%rip), %r11
515         lea    L(AliPxQx)(%rip),%rcx
516         movswq (%rcx,%r10,2),%rcx
517         lea    (%rcx,%r11,1),%r11
518         jmpq   *%r11
519 #endif
521         .pushsection .rodata
522         .balign     16
523 #ifndef PIC
524 L(AliPxQx):
525         .quad       L(aligned_now), L(A1Q0), L(A2Q0), L(A3Q0)
526         .quad       L(A4Q0), L(A5Q0), L(A6Q0), L(A7Q0)
527         .quad       L(A0Q1), L(A1Q1), L(A2Q1), L(A3Q1)
528         .quad       L(A4Q1), L(A5Q1), L(A6Q1), L(A7Q1)
529 #else
530 L(AliPxQx):
531         .short     L(aligned_now)-L(aligned_now)
532         .short     L(A1Q0)-L(aligned_now)
533         .short     L(A2Q0)-L(aligned_now)
534         .short     L(A3Q0)-L(aligned_now)
535         .short     L(A4Q0)-L(aligned_now)
536         .short     L(A5Q0)-L(aligned_now)
537         .short     L(A6Q0)-L(aligned_now)
538         .short     L(A7Q0)-L(aligned_now)
540         .short     L(A0Q1)-L(aligned_now)
541         .short     L(A1Q1)-L(aligned_now)
542         .short     L(A2Q1)-L(aligned_now)
543         .short     L(A3Q1)-L(aligned_now)
544         .short     L(A4Q1)-L(aligned_now)
545         .short     L(A5Q1)-L(aligned_now)
546         .short     L(A6Q1)-L(aligned_now)
547         .short     L(A7Q1)-L(aligned_now)
548 #endif
549         .popsection
551         .balign     16
552 L(A5Q1):    mov    %dl,-0xd(%rdi)
553 L(A4Q1):    mov    %edx,-0xc(%rdi)
554 L(A0Q1):    mov    %rdx,-0x8(%rdi)
555 L(A0Q0):    jmp     L(aligned_now)
557         .balign     16
558 L(A1Q1):   mov    %dl,-0x9(%rdi)
559         mov    %rdx,-0x8(%rdi)
560         jmp    L(aligned_now)
562         .balign     16
563 L(A1Q0):   mov    %dl,-0x1(%rdi)
564         jmp    L(aligned_now)
566         .balign     16
567 L(A3Q1):    mov    %dl,-0xb(%rdi)
568 L(A2Q1):    mov    %dx,-0xa(%rdi)
569         mov    %rdx,-0x8(%rdi)
570         jmp    L(aligned_now)
572         .balign     16
573 L(A3Q0):    mov    %dl,-0x3(%rdi)
574 L(A2Q0):    mov    %dx,-0x2(%rdi)
575         jmp    L(aligned_now)
577         .balign     16
578 L(A5Q0):    mov    %dl,-0x5(%rdi)
579 L(A4Q0):    mov    %edx,-0x4(%rdi)
580         jmp    L(aligned_now)
582         .balign     16
583 L(A7Q1):    mov    %dl,-0xf(%rdi)
584 L(A6Q1):    mov    %dx,-0xe(%rdi)
585         mov    %edx,-0xc(%rdi)
586         mov    %rdx,-0x8(%rdi)
587         jmp    L(aligned_now)
589         .balign     16
590 L(A7Q0):    mov    %dl,-0x7(%rdi)
591 L(A6Q0):    mov    %dx,-0x6(%rdi)
592         mov    %edx,-0x4(%rdi)
594 #ifndef USE_MULTIARCH
595         jmp    L(aligned_now)
597 L(SSE_pre):
598 #else
599 L(aligned_now):
600 #endif
601 #if !defined USE_MULTIARCH || defined USE_SSE2
602          # fill RegXMM0 with the pattern
603          movd   %rdx,%xmm0
604          punpcklqdq %xmm0,%xmm0
606          cmp    $0xb0,%r8 # 176
607          jge    L(byte32sse2_pre)
609          add    %r8,%rdi
610 # ifndef PIC
611          lea    L(SSExDx)(%rip),%r9
612          jmpq   *(%r9,%r8,8)
613 # else
614          lea    L(SSE0Q0)(%rip),%r9
615          lea    L(SSExDx)(%rip),%rcx
616          movswq (%rcx,%r8,2),%rcx
617          lea    (%rcx,%r9,1),%r9
618          jmpq   *%r9
619 # endif
621 L(SSE0QB):  movdqa %xmm0,-0xb0(%rdi)
622 L(SSE0QA):  movdqa %xmm0,-0xa0(%rdi)
623 L(SSE0Q9):  movdqa %xmm0,-0x90(%rdi)
624 L(SSE0Q8):  movdqa %xmm0,-0x80(%rdi)
625 L(SSE0Q7):  movdqa %xmm0,-0x70(%rdi)
626 L(SSE0Q6):  movdqa %xmm0,-0x60(%rdi)
627 L(SSE0Q5):  movdqa %xmm0,-0x50(%rdi)
628 L(SSE0Q4):  movdqa %xmm0,-0x40(%rdi)
629 L(SSE0Q3):  movdqa %xmm0,-0x30(%rdi)
630 L(SSE0Q2):  movdqa %xmm0,-0x20(%rdi)
631 L(SSE0Q1):  movdqa %xmm0,-0x10(%rdi)
632 L(SSE0Q0):  retq
634 L(SSE1QB):  movdqa %xmm0,-0xb1(%rdi)
635 L(SSE1QA):  movdqa %xmm0,-0xa1(%rdi)
636 L(SSE1Q9):  movdqa %xmm0,-0x91(%rdi)
637 L(SSE1Q8):  movdqa %xmm0,-0x81(%rdi)
638 L(SSE1Q7):  movdqa %xmm0,-0x71(%rdi)
639 L(SSE1Q6):  movdqa %xmm0,-0x61(%rdi)
640 L(SSE1Q5):  movdqa %xmm0,-0x51(%rdi)
641 L(SSE1Q4):  movdqa %xmm0,-0x41(%rdi)
642 L(SSE1Q3):  movdqa %xmm0,-0x31(%rdi)
643 L(SSE1Q2):  movdqa %xmm0,-0x21(%rdi)
644 L(SSE1Q1):  movdqa %xmm0,-0x11(%rdi)
645 L(SSE1Q0):  mov    %dl,-0x1(%rdi)
646         retq
648 L(SSE2QB):  movdqa %xmm0,-0xb2(%rdi)
649 L(SSE2QA):  movdqa %xmm0,-0xa2(%rdi)
650 L(SSE2Q9):  movdqa %xmm0,-0x92(%rdi)
651 L(SSE2Q8):  movdqa %xmm0,-0x82(%rdi)
652 L(SSE2Q7):  movdqa %xmm0,-0x72(%rdi)
653 L(SSE2Q6):  movdqa %xmm0,-0x62(%rdi)
654 L(SSE2Q5):  movdqa %xmm0,-0x52(%rdi)
655 L(SSE2Q4):  movdqa %xmm0,-0x42(%rdi)
656 L(SSE2Q3):  movdqa %xmm0,-0x32(%rdi)
657 L(SSE2Q2):  movdqa %xmm0,-0x22(%rdi)
658 L(SSE2Q1):  movdqa %xmm0,-0x12(%rdi)
659 L(SSE2Q0):  mov    %dx,-0x2(%rdi)
660         retq
662 L(SSE3QB):  movdqa %xmm0,-0xb3(%rdi)
663 L(SSE3QA):  movdqa %xmm0,-0xa3(%rdi)
664 L(SSE3Q9):  movdqa %xmm0,-0x93(%rdi)
665 L(SSE3Q8):  movdqa %xmm0,-0x83(%rdi)
666 L(SSE3Q7):  movdqa %xmm0,-0x73(%rdi)
667 L(SSE3Q6):  movdqa %xmm0,-0x63(%rdi)
668 L(SSE3Q5):  movdqa %xmm0,-0x53(%rdi)
669 L(SSE3Q4):  movdqa %xmm0,-0x43(%rdi)
670 L(SSE3Q3):  movdqa %xmm0,-0x33(%rdi)
671 L(SSE3Q2):  movdqa %xmm0,-0x23(%rdi)
672 L(SSE3Q1):  movdqa %xmm0,-0x13(%rdi)
673 L(SSE3Q0):  mov    %dx,-0x3(%rdi)
674         mov    %dl,-0x1(%rdi)
675         retq
677 L(SSE4QB):  movdqa %xmm0,-0xb4(%rdi)
678 L(SSE4QA):  movdqa %xmm0,-0xa4(%rdi)
679 L(SSE4Q9):  movdqa %xmm0,-0x94(%rdi)
680 L(SSE4Q8):  movdqa %xmm0,-0x84(%rdi)
681 L(SSE4Q7):  movdqa %xmm0,-0x74(%rdi)
682 L(SSE4Q6):  movdqa %xmm0,-0x64(%rdi)
683 L(SSE4Q5):  movdqa %xmm0,-0x54(%rdi)
684 L(SSE4Q4):  movdqa %xmm0,-0x44(%rdi)
685 L(SSE4Q3):  movdqa %xmm0,-0x34(%rdi)
686 L(SSE4Q2):  movdqa %xmm0,-0x24(%rdi)
687 L(SSE4Q1):  movdqa %xmm0,-0x14(%rdi)
688 L(SSE4Q0):  mov    %edx,-0x4(%rdi)
689         retq
691 L(SSE5QB):  movdqa %xmm0,-0xb5(%rdi)
692 L(SSE5QA):  movdqa %xmm0,-0xa5(%rdi)
693 L(SSE5Q9):  movdqa %xmm0,-0x95(%rdi)
694 L(SSE5Q8):  movdqa %xmm0,-0x85(%rdi)
695 L(SSE5Q7):  movdqa %xmm0,-0x75(%rdi)
696 L(SSE5Q6):  movdqa %xmm0,-0x65(%rdi)
697 L(SSE5Q5):  movdqa %xmm0,-0x55(%rdi)
698 L(SSE5Q4):  movdqa %xmm0,-0x45(%rdi)
699 L(SSE5Q3):  movdqa %xmm0,-0x35(%rdi)
700 L(SSE5Q2):  movdqa %xmm0,-0x25(%rdi)
701 L(SSE5Q1):  movdqa %xmm0,-0x15(%rdi)
702 L(SSE5Q0):  mov    %edx,-0x5(%rdi)
703         mov    %dl,-0x1(%rdi)
704         retq
707 L(SSE6QB):  movdqa %xmm0,-0xb6(%rdi)
708 L(SSE6QA):  movdqa %xmm0,-0xa6(%rdi)
709 L(SSE6Q9):  movdqa %xmm0,-0x96(%rdi)
710 L(SSE6Q8):  movdqa %xmm0,-0x86(%rdi)
711 L(SSE6Q7):  movdqa %xmm0,-0x76(%rdi)
712 L(SSE6Q6):  movdqa %xmm0,-0x66(%rdi)
713 L(SSE6Q5):  movdqa %xmm0,-0x56(%rdi)
714 L(SSE6Q4):  movdqa %xmm0,-0x46(%rdi)
715 L(SSE6Q3):  movdqa %xmm0,-0x36(%rdi)
716 L(SSE6Q2):  movdqa %xmm0,-0x26(%rdi)
717 L(SSE6Q1):  movdqa %xmm0,-0x16(%rdi)
718 L(SSE6Q0):  mov    %edx,-0x6(%rdi)
719         mov    %dx,-0x2(%rdi)
720         retq
722 L(SSE7QB):  movdqa %xmm0,-0xb7(%rdi)
723 L(SSE7QA):  movdqa %xmm0,-0xa7(%rdi)
724 L(SSE7Q9):  movdqa %xmm0,-0x97(%rdi)
725 L(SSE7Q8):  movdqa %xmm0,-0x87(%rdi)
726 L(SSE7Q7):  movdqa %xmm0,-0x77(%rdi)
727 L(SSE7Q6):  movdqa %xmm0,-0x67(%rdi)
728 L(SSE7Q5):  movdqa %xmm0,-0x57(%rdi)
729 L(SSE7Q4):  movdqa %xmm0,-0x47(%rdi)
730 L(SSE7Q3):  movdqa %xmm0,-0x37(%rdi)
731 L(SSE7Q2):  movdqa %xmm0,-0x27(%rdi)
732 L(SSE7Q1):  movdqa %xmm0,-0x17(%rdi)
733 L(SSE7Q0):  mov    %edx,-0x7(%rdi)
734         mov    %dx,-0x3(%rdi)
735         mov    %dl,-0x1(%rdi)
736         retq
738 L(SSE8QB):  movdqa %xmm0,-0xb8(%rdi)
739 L(SSE8QA):  movdqa %xmm0,-0xa8(%rdi)
740 L(SSE8Q9):  movdqa %xmm0,-0x98(%rdi)
741 L(SSE8Q8):  movdqa %xmm0,-0x88(%rdi)
742 L(SSE8Q7):  movdqa %xmm0,-0x78(%rdi)
743 L(SSE8Q6):  movdqa %xmm0,-0x68(%rdi)
744 L(SSE8Q5):  movdqa %xmm0,-0x58(%rdi)
745 L(SSE8Q4):  movdqa %xmm0,-0x48(%rdi)
746 L(SSE8Q3):  movdqa %xmm0,-0x38(%rdi)
747 L(SSE8Q2):  movdqa %xmm0,-0x28(%rdi)
748 L(SSE8Q1):  movdqa %xmm0,-0x18(%rdi)
749 L(SSE8Q0):  mov    %rdx,-0x8(%rdi)
750         retq
752 L(SSE9QB):  movdqa %xmm0,-0xb9(%rdi)
753 L(SSE9QA):  movdqa %xmm0,-0xa9(%rdi)
754 L(SSE9Q9):  movdqa %xmm0,-0x99(%rdi)
755 L(SSE9Q8):  movdqa %xmm0,-0x89(%rdi)
756 L(SSE9Q7):  movdqa %xmm0,-0x79(%rdi)
757 L(SSE9Q6):  movdqa %xmm0,-0x69(%rdi)
758 L(SSE9Q5):  movdqa %xmm0,-0x59(%rdi)
759 L(SSE9Q4):  movdqa %xmm0,-0x49(%rdi)
760 L(SSE9Q3):  movdqa %xmm0,-0x39(%rdi)
761 L(SSE9Q2):  movdqa %xmm0,-0x29(%rdi)
762 L(SSE9Q1):  movdqa %xmm0,-0x19(%rdi)
763 L(SSE9Q0):  mov    %rdx,-0x9(%rdi)
764         mov    %dl,-0x1(%rdi)
765         retq
767 L(SSE10QB): movdqa %xmm0,-0xba(%rdi)
768 L(SSE10QA): movdqa %xmm0,-0xaa(%rdi)
769 L(SSE10Q9): movdqa %xmm0,-0x9a(%rdi)
770 L(SSE10Q8): movdqa %xmm0,-0x8a(%rdi)
771 L(SSE10Q7): movdqa %xmm0,-0x7a(%rdi)
772 L(SSE10Q6): movdqa %xmm0,-0x6a(%rdi)
773 L(SSE10Q5): movdqa %xmm0,-0x5a(%rdi)
774 L(SSE10Q4): movdqa %xmm0,-0x4a(%rdi)
775 L(SSE10Q3): movdqa %xmm0,-0x3a(%rdi)
776 L(SSE10Q2): movdqa %xmm0,-0x2a(%rdi)
777 L(SSE10Q1): movdqa %xmm0,-0x1a(%rdi)
778 L(SSE10Q0): mov    %rdx,-0xa(%rdi)
779         mov    %dx,-0x2(%rdi)
780         retq
782 L(SSE11QB): movdqa %xmm0,-0xbb(%rdi)
783 L(SSE11QA): movdqa %xmm0,-0xab(%rdi)
784 L(SSE11Q9): movdqa %xmm0,-0x9b(%rdi)
785 L(SSE11Q8): movdqa %xmm0,-0x8b(%rdi)
786 L(SSE11Q7): movdqa %xmm0,-0x7b(%rdi)
787 L(SSE11Q6): movdqa %xmm0,-0x6b(%rdi)
788 L(SSE11Q5): movdqa %xmm0,-0x5b(%rdi)
789 L(SSE11Q4): movdqa %xmm0,-0x4b(%rdi)
790 L(SSE11Q3): movdqa %xmm0,-0x3b(%rdi)
791 L(SSE11Q2): movdqa %xmm0,-0x2b(%rdi)
792 L(SSE11Q1): movdqa %xmm0,-0x1b(%rdi)
793 L(SSE11Q0): mov    %rdx,-0xb(%rdi)
794         mov    %dx,-0x3(%rdi)
795         mov    %dl,-0x1(%rdi)
796         retq
798 L(SSE12QB): movdqa %xmm0,-0xbc(%rdi)
799 L(SSE12QA): movdqa %xmm0,-0xac(%rdi)
800 L(SSE12Q9): movdqa %xmm0,-0x9c(%rdi)
801 L(SSE12Q8): movdqa %xmm0,-0x8c(%rdi)
802 L(SSE12Q7): movdqa %xmm0,-0x7c(%rdi)
803 L(SSE12Q6): movdqa %xmm0,-0x6c(%rdi)
804 L(SSE12Q5): movdqa %xmm0,-0x5c(%rdi)
805 L(SSE12Q4): movdqa %xmm0,-0x4c(%rdi)
806 L(SSE12Q3): movdqa %xmm0,-0x3c(%rdi)
807 L(SSE12Q2): movdqa %xmm0,-0x2c(%rdi)
808 L(SSE12Q1): movdqa %xmm0,-0x1c(%rdi)
809 L(SSE12Q0): mov    %rdx,-0xc(%rdi)
810         mov    %edx,-0x4(%rdi)
811         retq
813 L(SSE13QB): movdqa %xmm0,-0xbd(%rdi)
814 L(SSE13QA): movdqa %xmm0,-0xad(%rdi)
815 L(SSE13Q9): movdqa %xmm0,-0x9d(%rdi)
816 L(SSE13Q8): movdqa %xmm0,-0x8d(%rdi)
817 L(SSE13Q7): movdqa %xmm0,-0x7d(%rdi)
818 L(SSE13Q6): movdqa %xmm0,-0x6d(%rdi)
819 L(SSE13Q5): movdqa %xmm0,-0x5d(%rdi)
820 L(SSE13Q4): movdqa %xmm0,-0x4d(%rdi)
821 L(SSE13Q3): movdqa %xmm0,-0x3d(%rdi)
822 L(SSE13Q2): movdqa %xmm0,-0x2d(%rdi)
823 L(SSE13Q1): movdqa %xmm0,-0x1d(%rdi)
824 L(SSE13Q0): mov    %rdx,-0xd(%rdi)
825         mov    %edx,-0x5(%rdi)
826         mov    %dl,-0x1(%rdi)
827         retq
829 L(SSE14QB): movdqa %xmm0,-0xbe(%rdi)
830 L(SSE14QA): movdqa %xmm0,-0xae(%rdi)
831 L(SSE14Q9): movdqa %xmm0,-0x9e(%rdi)
832 L(SSE14Q8): movdqa %xmm0,-0x8e(%rdi)
833 L(SSE14Q7): movdqa %xmm0,-0x7e(%rdi)
834 L(SSE14Q6): movdqa %xmm0,-0x6e(%rdi)
835 L(SSE14Q5): movdqa %xmm0,-0x5e(%rdi)
836 L(SSE14Q4): movdqa %xmm0,-0x4e(%rdi)
837 L(SSE14Q3): movdqa %xmm0,-0x3e(%rdi)
838 L(SSE14Q2): movdqa %xmm0,-0x2e(%rdi)
839 L(SSE14Q1): movdqa %xmm0,-0x1e(%rdi)
840 L(SSE14Q0): mov    %rdx,-0xe(%rdi)
841         mov    %edx,-0x6(%rdi)
842         mov    %dx,-0x2(%rdi)
843         retq
845 L(SSE15QB): movdqa %xmm0,-0xbf(%rdi)
846 L(SSE15QA): movdqa %xmm0,-0xaf(%rdi)
847 L(SSE15Q9): movdqa %xmm0,-0x9f(%rdi)
848 L(SSE15Q8): movdqa %xmm0,-0x8f(%rdi)
849 L(SSE15Q7): movdqa %xmm0,-0x7f(%rdi)
850 L(SSE15Q6): movdqa %xmm0,-0x6f(%rdi)
851 L(SSE15Q5): movdqa %xmm0,-0x5f(%rdi)
852 L(SSE15Q4): movdqa %xmm0,-0x4f(%rdi)
853 L(SSE15Q3): movdqa %xmm0,-0x3f(%rdi)
854 L(SSE15Q2): movdqa %xmm0,-0x2f(%rdi)
855 L(SSE15Q1): movdqa %xmm0,-0x1f(%rdi)
856 L(SSE15Q0): mov    %rdx,-0xf(%rdi)
857         mov    %edx,-0x7(%rdi)
858         mov    %dx,-0x3(%rdi)
859         mov    %dl,-0x1(%rdi)
860         retq
862         .balign     16
863 L(byte32sse2_pre):
865         mov    __x86_64_shared_cache_size(%rip),%r9d  # The largest cache size
866         cmp    %r9,%r8
867         jg     L(sse2_nt_move_pre)
868         #jmp    L(byte32sse2)
869         .balign     16
870 L(byte32sse2):
871         lea    -0x80(%r8),%r8 # 128
872         cmp    $0x80,%r8   # 128
873         movdqa %xmm0,(%rdi)
874         movdqa %xmm0,0x10(%rdi)
875         movdqa %xmm0,0x20(%rdi)
876         movdqa %xmm0,0x30(%rdi)
877         movdqa %xmm0,0x40(%rdi)
878         movdqa %xmm0,0x50(%rdi)
879         movdqa %xmm0,0x60(%rdi)
880         movdqa %xmm0,0x70(%rdi)
882         lea    0x80(%rdi),%rdi
883         jge    L(byte32sse2)
884         add    %r8,%rdi
885 # ifndef PIC
886         lea    L(SSExDx)(%rip),%r11
887         jmpq   *(%r11,%r8,8)
888 # else
889         lea    L(SSE0Q0)(%rip),%r11
890         lea    L(SSExDx)(%rip),%rcx
891         movswq (%rcx,%r8,2),%rcx
892         lea    (%rcx,%r11,1),%r11
893         jmpq   *%r11
894 # endif
896         .balign     16
897 L(sse2_nt_move_pre):
898         cmp    $0x0,%r9
899         je     L(byte32sse2)
900         jmp    L(sse2_nt_move)
902         .balign     16
903 L(sse2_nt_move):
904         lea    -0x80(%r8),%r8
905         cmp    $0x80,%r8
907         movntdq %xmm0,(%rdi)
908         movntdq %xmm0,0x10(%rdi)
909         movntdq %xmm0,0x20(%rdi)
910         movntdq %xmm0,0x30(%rdi)
911         movntdq %xmm0,0x40(%rdi)
912         movntdq %xmm0,0x50(%rdi)
913         movntdq %xmm0,0x60(%rdi)
914         movntdq %xmm0,0x70(%rdi)
916         lea    0x80(%rdi),%rdi
917         jge    L(sse2_nt_move)
918         sfence
919         add    %r8,%rdi
920 # ifndef PIC
921         lea    L(SSExDx)(%rip),%r11
922         jmpq   *(%r11,%r8,8)
923 # else
924         lea    L(SSE0Q0)(%rip),%r11
925         lea    L(SSExDx)(%rip),%rcx
926         movswq (%rcx,%r8,2),%rcx
927         lea   (%rcx,%r11,1),%r11
928         jmpq   *%r11
929 # endif
931         .pushsection .rodata
932         .balign     16
933 # ifndef PIC
934 L(SSExDx):
935         .quad       L(SSE0Q0), L(SSE1Q0), L(SSE2Q0), L(SSE3Q0)
936         .quad       L(SSE4Q0), L(SSE5Q0), L(SSE6Q0), L(SSE7Q0)
937         .quad       L(SSE8Q0), L(SSE9Q0), L(SSE10Q0), L(SSE11Q0)
938         .quad       L(SSE12Q0), L(SSE13Q0), L(SSE14Q0), L(SSE15Q0)
939         .quad       L(SSE0Q1), L(SSE1Q1), L(SSE2Q1), L(SSE3Q1)
940         .quad       L(SSE4Q1), L(SSE5Q1), L(SSE6Q1), L(SSE7Q1)
941         .quad       L(SSE8Q1), L(SSE9Q1), L(SSE10Q1), L(SSE11Q1)
942         .quad       L(SSE12Q1), L(SSE13Q1), L(SSE14Q1), L(SSE15Q1)
943         .quad       L(SSE0Q2), L(SSE1Q2), L(SSE2Q2), L(SSE3Q2)
944         .quad       L(SSE4Q2), L(SSE5Q2), L(SSE6Q2), L(SSE7Q2)
945         .quad       L(SSE8Q2), L(SSE9Q2), L(SSE10Q2), L(SSE11Q2)
946         .quad       L(SSE12Q2), L(SSE13Q2), L(SSE14Q2), L(SSE15Q2)
947         .quad       L(SSE0Q3), L(SSE1Q3), L(SSE2Q3), L(SSE3Q3)
948         .quad       L(SSE4Q3), L(SSE5Q3), L(SSE6Q3), L(SSE7Q3)
949         .quad       L(SSE8Q3), L(SSE9Q3), L(SSE10Q3), L(SSE11Q3)
950         .quad       L(SSE12Q3), L(SSE13Q3), L(SSE14Q3), L(SSE15Q3)
951         .quad       L(SSE0Q4), L(SSE1Q4), L(SSE2Q4), L(SSE3Q4)
952         .quad       L(SSE4Q4), L(SSE5Q4), L(SSE6Q4), L(SSE7Q4)
953         .quad       L(SSE8Q4), L(SSE9Q4), L(SSE10Q4), L(SSE11Q4)
954         .quad       L(SSE12Q4), L(SSE13Q4), L(SSE14Q4), L(SSE15Q4)
955         .quad       L(SSE0Q5), L(SSE1Q5), L(SSE2Q5), L(SSE3Q5)
956         .quad       L(SSE4Q5), L(SSE5Q5), L(SSE6Q5), L(SSE7Q5)
957         .quad       L(SSE8Q5), L(SSE9Q5), L(SSE10Q5), L(SSE11Q5)
958         .quad       L(SSE12Q5), L(SSE13Q5), L(SSE14Q5), L(SSE15Q5)
959         .quad       L(SSE0Q6), L(SSE1Q6), L(SSE2Q6), L(SSE3Q6)
960         .quad       L(SSE4Q6), L(SSE5Q6), L(SSE6Q6), L(SSE7Q6)
961         .quad       L(SSE8Q6), L(SSE9Q6), L(SSE10Q6), L(SSE11Q6)
962         .quad       L(SSE12Q6), L(SSE13Q6), L(SSE14Q6), L(SSE15Q6)
963         .quad       L(SSE0Q7), L(SSE1Q7), L(SSE2Q7), L(SSE3Q7)
964         .quad       L(SSE4Q7), L(SSE5Q7), L(SSE6Q7), L(SSE7Q7)
965         .quad       L(SSE8Q7), L(SSE9Q7), L(SSE10Q7), L(SSE11Q7)
966         .quad       L(SSE12Q7), L(SSE13Q7), L(SSE14Q7), L(SSE15Q7)
967         .quad       L(SSE0Q8), L(SSE1Q8), L(SSE2Q8), L(SSE3Q8)
968         .quad       L(SSE4Q8), L(SSE5Q8), L(SSE6Q8), L(SSE7Q8)
969         .quad       L(SSE8Q8), L(SSE9Q8), L(SSE10Q8), L(SSE11Q8)
970         .quad       L(SSE12Q8), L(SSE13Q8), L(SSE14Q8), L(SSE15Q8)
971         .quad       L(SSE0Q9), L(SSE1Q9), L(SSE2Q9), L(SSE3Q9)
972         .quad       L(SSE4Q9), L(SSE5Q9), L(SSE6Q9), L(SSE7Q9)
973         .quad       L(SSE8Q9), L(SSE9Q9), L(SSE10Q9), L(SSE11Q9)
974         .quad       L(SSE12Q9), L(SSE13Q9), L(SSE14Q9), L(SSE15Q9)
975         .quad       L(SSE0QA), L(SSE1QA), L(SSE2QA), L(SSE3QA)
976         .quad       L(SSE4QA), L(SSE5QA), L(SSE6QA), L(SSE7QA)
977         .quad       L(SSE8QA), L(SSE9QA), L(SSE10QA), L(SSE11QA)
978         .quad       L(SSE12QA), L(SSE13QA), L(SSE14QA), L(SSE15QA)
979         .quad       L(SSE0QB), L(SSE1QB), L(SSE2QB), L(SSE3QB)
980         .quad       L(SSE4QB), L(SSE5QB), L(SSE6QB), L(SSE7QB)
981         .quad       L(SSE8QB), L(SSE9QB), L(SSE10QB), L(SSE11QB)
982         .quad       L(SSE12QB), L(SSE13QB), L(SSE14QB), L(SSE15QB)
983 # else
984 L(SSExDx):
985         .short     L(SSE0Q0) -L(SSE0Q0)
986         .short     L(SSE1Q0) -L(SSE0Q0)
987         .short     L(SSE2Q0) -L(SSE0Q0)
988         .short     L(SSE3Q0) -L(SSE0Q0)
989         .short     L(SSE4Q0) -L(SSE0Q0)
990         .short     L(SSE5Q0) -L(SSE0Q0)
991         .short     L(SSE6Q0) -L(SSE0Q0)
992         .short     L(SSE7Q0) -L(SSE0Q0)
994         .short     L(SSE8Q0) -L(SSE0Q0)
995         .short     L(SSE9Q0) -L(SSE0Q0)
996         .short     L(SSE10Q0)-L(SSE0Q0)
997         .short     L(SSE11Q0)-L(SSE0Q0)
998         .short     L(SSE12Q0)-L(SSE0Q0)
999         .short     L(SSE13Q0)-L(SSE0Q0)
1000         .short     L(SSE14Q0)-L(SSE0Q0)
1001         .short     L(SSE15Q0)-L(SSE0Q0)
1003         .short     L(SSE0Q1) -L(SSE0Q0)
1004         .short     L(SSE1Q1) -L(SSE0Q0)
1005         .short     L(SSE2Q1) -L(SSE0Q0)
1006         .short     L(SSE3Q1) -L(SSE0Q0)
1007         .short     L(SSE4Q1) -L(SSE0Q0)
1008         .short     L(SSE5Q1) -L(SSE0Q0)
1009         .short     L(SSE6Q1) -L(SSE0Q0)
1010         .short     L(SSE7Q1) -L(SSE0Q0)
1012         .short     L(SSE8Q1) -L(SSE0Q0)
1013         .short     L(SSE9Q1) -L(SSE0Q0)
1014         .short     L(SSE10Q1)-L(SSE0Q0)
1015         .short     L(SSE11Q1)-L(SSE0Q0)
1016         .short     L(SSE12Q1)-L(SSE0Q0)
1017         .short     L(SSE13Q1)-L(SSE0Q0)
1018         .short     L(SSE14Q1)-L(SSE0Q0)
1019         .short     L(SSE15Q1)-L(SSE0Q0)
1021         .short     L(SSE0Q2) -L(SSE0Q0)
1022         .short     L(SSE1Q2) -L(SSE0Q0)
1023         .short     L(SSE2Q2) -L(SSE0Q0)
1024         .short     L(SSE3Q2) -L(SSE0Q0)
1025         .short     L(SSE4Q2) -L(SSE0Q0)
1026         .short     L(SSE5Q2) -L(SSE0Q0)
1027         .short     L(SSE6Q2) -L(SSE0Q0)
1028         .short     L(SSE7Q2) -L(SSE0Q0)
1030         .short     L(SSE8Q2) -L(SSE0Q0)
1031         .short     L(SSE9Q2) -L(SSE0Q0)
1032         .short     L(SSE10Q2)-L(SSE0Q0)
1033         .short     L(SSE11Q2)-L(SSE0Q0)
1034         .short     L(SSE12Q2)-L(SSE0Q0)
1035         .short     L(SSE13Q2)-L(SSE0Q0)
1036         .short     L(SSE14Q2)-L(SSE0Q0)
1037         .short     L(SSE15Q2)-L(SSE0Q0)
1039         .short     L(SSE0Q3) -L(SSE0Q0)
1040         .short     L(SSE1Q3) -L(SSE0Q0)
1041         .short     L(SSE2Q3) -L(SSE0Q0)
1042         .short     L(SSE3Q3) -L(SSE0Q0)
1043         .short     L(SSE4Q3) -L(SSE0Q0)
1044         .short     L(SSE5Q3) -L(SSE0Q0)
1045         .short     L(SSE6Q3) -L(SSE0Q0)
1046         .short     L(SSE7Q3) -L(SSE0Q0)
1048         .short     L(SSE8Q3) -L(SSE0Q0)
1049         .short     L(SSE9Q3) -L(SSE0Q0)
1050         .short     L(SSE10Q3)-L(SSE0Q0)
1051         .short     L(SSE11Q3)-L(SSE0Q0)
1052         .short     L(SSE12Q3)-L(SSE0Q0)
1053         .short     L(SSE13Q3)-L(SSE0Q0)
1054         .short     L(SSE14Q3)-L(SSE0Q0)
1055         .short     L(SSE15Q3)-L(SSE0Q0)
1057         .short     L(SSE0Q4) -L(SSE0Q0)
1058         .short     L(SSE1Q4) -L(SSE0Q0)
1059         .short     L(SSE2Q4) -L(SSE0Q0)
1060         .short     L(SSE3Q4) -L(SSE0Q0)
1061         .short     L(SSE4Q4) -L(SSE0Q0)
1062         .short     L(SSE5Q4) -L(SSE0Q0)
1063         .short     L(SSE6Q4) -L(SSE0Q0)
1064         .short     L(SSE7Q4) -L(SSE0Q0)
1066         .short     L(SSE8Q4) -L(SSE0Q0)
1067         .short     L(SSE9Q4) -L(SSE0Q0)
1068         .short     L(SSE10Q4)-L(SSE0Q0)
1069         .short     L(SSE11Q4)-L(SSE0Q0)
1070         .short     L(SSE12Q4)-L(SSE0Q0)
1071         .short     L(SSE13Q4)-L(SSE0Q0)
1072         .short     L(SSE14Q4)-L(SSE0Q0)
1073         .short     L(SSE15Q4)-L(SSE0Q0)
1075         .short     L(SSE0Q5) -L(SSE0Q0)
1076         .short     L(SSE1Q5) -L(SSE0Q0)
1077         .short     L(SSE2Q5) -L(SSE0Q0)
1078         .short     L(SSE3Q5) -L(SSE0Q0)
1079         .short     L(SSE4Q5) -L(SSE0Q0)
1080         .short     L(SSE5Q5) -L(SSE0Q0)
1081         .short     L(SSE6Q5) -L(SSE0Q0)
1082         .short     L(SSE7Q5) -L(SSE0Q0)
1084         .short     L(SSE8Q5) -L(SSE0Q0)
1085         .short     L(SSE9Q5) -L(SSE0Q0)
1086         .short     L(SSE10Q5)-L(SSE0Q0)
1087         .short     L(SSE11Q5)-L(SSE0Q0)
1088         .short     L(SSE12Q5)-L(SSE0Q0)
1089         .short     L(SSE13Q5)-L(SSE0Q0)
1090         .short     L(SSE14Q5)-L(SSE0Q0)
1091         .short     L(SSE15Q5)-L(SSE0Q0)
1093         .short     L(SSE0Q6) -L(SSE0Q0)
1094         .short     L(SSE1Q6) -L(SSE0Q0)
1095         .short     L(SSE2Q6) -L(SSE0Q0)
1096         .short     L(SSE3Q6) -L(SSE0Q0)
1097         .short     L(SSE4Q6) -L(SSE0Q0)
1098         .short     L(SSE5Q6) -L(SSE0Q0)
1099         .short     L(SSE6Q6) -L(SSE0Q0)
1100         .short     L(SSE7Q6) -L(SSE0Q0)
1102         .short     L(SSE8Q6) -L(SSE0Q0)
1103         .short     L(SSE9Q6) -L(SSE0Q0)
1104         .short     L(SSE10Q6)-L(SSE0Q0)
1105         .short     L(SSE11Q6)-L(SSE0Q0)
1106         .short     L(SSE12Q6)-L(SSE0Q0)
1107         .short     L(SSE13Q6)-L(SSE0Q0)
1108         .short     L(SSE14Q6)-L(SSE0Q0)
1109         .short     L(SSE15Q6)-L(SSE0Q0)
1111         .short     L(SSE0Q7) -L(SSE0Q0)
1112         .short     L(SSE1Q7) -L(SSE0Q0)
1113         .short     L(SSE2Q7) -L(SSE0Q0)
1114         .short     L(SSE3Q7) -L(SSE0Q0)
1115         .short     L(SSE4Q7) -L(SSE0Q0)
1116         .short     L(SSE5Q7) -L(SSE0Q0)
1117         .short     L(SSE6Q7) -L(SSE0Q0)
1118         .short     L(SSE7Q7) -L(SSE0Q0)
1120         .short     L(SSE8Q7) -L(SSE0Q0)
1121         .short     L(SSE9Q7) -L(SSE0Q0)
1122         .short     L(SSE10Q7)-L(SSE0Q0)
1123         .short     L(SSE11Q7)-L(SSE0Q0)
1124         .short     L(SSE12Q7)-L(SSE0Q0)
1125         .short     L(SSE13Q7)-L(SSE0Q0)
1126         .short     L(SSE14Q7)-L(SSE0Q0)
1127         .short     L(SSE15Q7)-L(SSE0Q0)
1129         .short     L(SSE0Q8) -L(SSE0Q0)
1130         .short     L(SSE1Q8) -L(SSE0Q0)
1131         .short     L(SSE2Q8) -L(SSE0Q0)
1132         .short     L(SSE3Q8) -L(SSE0Q0)
1133         .short     L(SSE4Q8) -L(SSE0Q0)
1134         .short     L(SSE5Q8) -L(SSE0Q0)
1135         .short     L(SSE6Q8) -L(SSE0Q0)
1136         .short     L(SSE7Q8) -L(SSE0Q0)
1138         .short     L(SSE8Q8) -L(SSE0Q0)
1139         .short     L(SSE9Q8) -L(SSE0Q0)
1140         .short     L(SSE10Q8)-L(SSE0Q0)
1141         .short     L(SSE11Q8)-L(SSE0Q0)
1142         .short     L(SSE12Q8)-L(SSE0Q0)
1143         .short     L(SSE13Q8)-L(SSE0Q0)
1144         .short     L(SSE14Q8)-L(SSE0Q0)
1145         .short     L(SSE15Q8)-L(SSE0Q0)
1147         .short     L(SSE0Q9) -L(SSE0Q0)
1148         .short     L(SSE1Q9) -L(SSE0Q0)
1149         .short     L(SSE2Q9) -L(SSE0Q0)
1150         .short     L(SSE3Q9) -L(SSE0Q0)
1151         .short     L(SSE4Q9) -L(SSE0Q0)
1152         .short     L(SSE5Q9) -L(SSE0Q0)
1153         .short     L(SSE6Q9) -L(SSE0Q0)
1154         .short     L(SSE7Q9) -L(SSE0Q0)
1156         .short     L(SSE8Q9) -L(SSE0Q0)
1157         .short     L(SSE9Q9) -L(SSE0Q0)
1158         .short     L(SSE10Q9)-L(SSE0Q0)
1159         .short     L(SSE11Q9)-L(SSE0Q0)
1160         .short     L(SSE12Q9)-L(SSE0Q0)
1161         .short     L(SSE13Q9)-L(SSE0Q0)
1162         .short     L(SSE14Q9)-L(SSE0Q0)
1163         .short     L(SSE15Q9)-L(SSE0Q0)
1165         .short     L(SSE0QA) -L(SSE0Q0)
1166         .short     L(SSE1QA) -L(SSE0Q0)
1167         .short     L(SSE2QA) -L(SSE0Q0)
1168         .short     L(SSE3QA) -L(SSE0Q0)
1169         .short     L(SSE4QA) -L(SSE0Q0)
1170         .short     L(SSE5QA) -L(SSE0Q0)
1171         .short     L(SSE6QA) -L(SSE0Q0)
1172         .short     L(SSE7QA) -L(SSE0Q0)
1174         .short     L(SSE8QA) -L(SSE0Q0)
1175         .short     L(SSE9QA) -L(SSE0Q0)
1176         .short     L(SSE10QA)-L(SSE0Q0)
1177         .short     L(SSE11QA)-L(SSE0Q0)
1178         .short     L(SSE12QA)-L(SSE0Q0)
1179         .short     L(SSE13QA)-L(SSE0Q0)
1180         .short     L(SSE14QA)-L(SSE0Q0)
1181         .short     L(SSE15QA)-L(SSE0Q0)
1183         .short     L(SSE0QB) -L(SSE0Q0)
1184         .short     L(SSE1QB) -L(SSE0Q0)
1185         .short     L(SSE2QB) -L(SSE0Q0)
1186         .short     L(SSE3QB) -L(SSE0Q0)
1187         .short     L(SSE4QB) -L(SSE0Q0)
1188         .short     L(SSE5QB) -L(SSE0Q0)
1189         .short     L(SSE6QB) -L(SSE0Q0)
1190         .short     L(SSE7QB) -L(SSE0Q0)
1192         .short     L(SSE8QB) -L(SSE0Q0)
1193         .short     L(SSE9QB) -L(SSE0Q0)
1194         .short     L(SSE10QB)-L(SSE0Q0)
1195         .short     L(SSE11QB)-L(SSE0Q0)
1196         .short     L(SSE12QB)-L(SSE0Q0)
1197         .short     L(SSE13QB)-L(SSE0Q0)
1198         .short     L(SSE14QB)-L(SSE0Q0)
1199         .short     L(SSE15QB)-L(SSE0Q0)
1200 # endif
1201         .popsection
1202 #endif /* !defined USE_MULTIARCH || defined USE_SSE2  */
1204         .balign     16
1205 #ifndef USE_MULTIARCH
1206 L(aligned_now):
1208          cmpl   $0x1,__x86_64_preferred_memory_instruction(%rip)
1209          jg     L(SSE_pre)
1210 #endif /* USE_MULTIARCH */
1212 L(8byte_move_try):
1213         cmpq    __STOS_LOWER_BOUNDARY,%r8
1214         jae     L(8byte_stos_try)
1216         .balign     16
1217 L(8byte_move):
1218         movq    %r8,%rcx
1219         shrq    $7,%rcx
1220         jz      L(8byte_move_skip)
1222         .p2align 4
1224 L(8byte_move_loop):
1225         decq    %rcx
1227         movq    %rdx,    (%rdi)
1228         movq    %rdx,  8 (%rdi)
1229         movq    %rdx, 16 (%rdi)
1230         movq    %rdx, 24 (%rdi)
1231         movq    %rdx, 32 (%rdi)
1232         movq    %rdx, 40 (%rdi)
1233         movq    %rdx, 48 (%rdi)
1234         movq    %rdx, 56 (%rdi)
1235         movq    %rdx, 64 (%rdi)
1236         movq    %rdx, 72 (%rdi)
1237         movq    %rdx, 80 (%rdi)
1238         movq    %rdx, 88 (%rdi)
1239         movq    %rdx, 96 (%rdi)
1240         movq    %rdx, 104 (%rdi)
1241         movq    %rdx, 112 (%rdi)
1242         movq    %rdx, 120 (%rdi)
1244         leaq    128 (%rdi),%rdi
1246         jnz     L(8byte_move_loop)
1248 L(8byte_move_skip):
1249         andl    $127,%r8d
1250         lea     (%rdi,%r8,1),%rdi
1252 #ifndef PIC
1253         lea     L(setPxQx)(%rip),%r11
1254         jmpq    *(%r11,%r8,8) # old scheme remained for nonPIC
1255 #else
1256         lea     L(Got0)(%rip),%r11
1257         lea     L(setPxQx)(%rip),%rcx
1258         movswq  (%rcx,%r8,2),%rcx
1259         lea     (%rcx,%r11,1),%r11
1260         jmpq    *%r11
1261 #endif
1263         .balign     16
1264 L(8byte_stos_try):
1265         mov    __x86_64_shared_cache_size(%rip),%r9d // ck largest cache size
1266         cmpq    %r8,%r9         // calculate the lesser of remaining
1267         cmovaq  %r8,%r9         // bytes and largest cache size
1268         jbe     L(8byte_stos)
1270 L(8byte_move_reuse_try):
1271         cmp     __STOS_UPPER_BOUNDARY,%r8
1272         jae     L(8byte_move)
1274         .balign     16
1275 L(8byte_stos):
1276         movq    %r9,%rcx
1277         andq    $-8,%r9
1279         shrq    $3,%rcx
1280         jz      L(8byte_stos_skip)
1282         xchgq   %rax,%rdx
1284         rep
1285         stosq
1287         xchgq   %rax,%rdx
1289 L(8byte_stos_skip):
1290         subq    %r9,%r8
1291         ja      L(8byte_nt_move)
1293         andl    $7,%r8d
1294         lea     (%rdi,%r8,1),%rdi
1295 #ifndef PIC
1296         lea     L(setPxQx)(%rip),%r11
1297         jmpq    *(%r11,%r8,8) # old scheme remained for nonPIC
1298 #else
1299         lea     L(Got0)(%rip),%r11
1300         lea     L(setPxQx)(%rip),%rcx
1301         movswq  (%rcx,%r8,2),%rcx
1302         lea     (%rcx,%r11,1),%r11
1303         jmpq    *%r11
1304 #endif
1306         .balign     16
1307 L(8byte_nt_move):
1308         movq    %r8,%rcx
1309         shrq    $7,%rcx
1310         jz      L(8byte_nt_move_skip)
1312         .balign     16
1313 L(8byte_nt_move_loop):
1314         decq    %rcx
1316         movntiq %rdx,     (%rdi)
1317         movntiq %rdx,   8 (%rdi)
1318         movntiq %rdx,  16 (%rdi)
1319         movntiq %rdx,  24 (%rdi)
1320         movntiq %rdx,  32 (%rdi)
1321         movntiq %rdx,  40 (%rdi)
1322         movntiq %rdx,  48 (%rdi)
1323         movntiq %rdx,  56 (%rdi)
1324         movntiq %rdx,  64 (%rdi)
1325         movntiq %rdx,  72 (%rdi)
1326         movntiq %rdx,  80 (%rdi)
1327         movntiq %rdx,  88 (%rdi)
1328         movntiq %rdx,  96 (%rdi)
1329         movntiq %rdx, 104 (%rdi)
1330         movntiq %rdx, 112 (%rdi)
1331         movntiq %rdx, 120 (%rdi)
1333         leaq    128 (%rdi),%rdi
1335         jnz     L(8byte_nt_move_loop)
1337         sfence
1339 L(8byte_nt_move_skip):
1340         andl    $127,%r8d
1342         lea     (%rdi,%r8,1),%rdi
1343 #ifndef PIC
1344         lea     L(setPxQx)(%rip),%r11
1345         jmpq    *(%r11,%r8,8) # old scheme remained for nonPIC
1346 #else
1347         lea     L(Got0)(%rip),%r11
1348         lea     L(setPxQx)(%rip),%rcx
1349         movswq  (%rcx,%r8,2),%rcx
1350         lea     (%rcx,%r11,1),%r11
1351         jmpq    *%r11
1352 #endif
1354 END (memset)
1355 libc_hidden_builtin_def (memset)
1357 #if defined PIC && !defined NOT_IN_libc && !defined USE_MULTIARCH
1358 strong_alias (__memset_chk, __memset_zero_constant_len_parameter)
1359         .section .gnu.warning.__memset_zero_constant_len_parameter
1360         .string "memset used with constant zero length parameter; this could be due to transposed parameters"
1361 #endif