1 #ifndef _ASM_X86_XOR_64_H
2 #define _ASM_X86_XOR_64_H
7 * x86-64 changes / gcc fixes from Andi Kleen.
8 * Copyright 2002 Andi Kleen, SuSE Labs.
10 * This hasn't been optimized for the hammer yet, but there are likely
11 * no advantages to be gotten from x86-64 here anyways.
16 } __attribute__((aligned(16))) xmm_store_t;
18 /* Doesn't use gcc to save the XMM registers, because there is no easy way to
19 tell it to do a clts before the register saving. */
23 if (!__thread_has_fpu(current)) \
26 "movups %%xmm0,(%1) ;\n\t" \
27 "movups %%xmm1,0x10(%1) ;\n\t" \
28 "movups %%xmm2,0x20(%1) ;\n\t" \
29 "movups %%xmm3,0x30(%1) ;\n\t" \
35 #define XMMS_RESTORE \
39 "movups (%1),%%xmm0 ;\n\t" \
40 "movups 0x10(%1),%%xmm1 ;\n\t" \
41 "movups 0x20(%1),%%xmm2 ;\n\t" \
42 "movups 0x30(%1),%%xmm3 ;\n\t" \
44 : "r" (cr0), "r" (xmm_save) \
46 if (!__thread_has_fpu(current)) \
51 #define OFFS(x) "16*("#x")"
52 #define PF_OFFS(x) "256+16*("#x")"
53 #define PF0(x) " prefetchnta "PF_OFFS(x)"(%[p1]) ;\n"
54 #define LD(x, y) " movaps "OFFS(x)"(%[p1]), %%xmm"#y" ;\n"
55 #define ST(x, y) " movaps %%xmm"#y", "OFFS(x)"(%[p1]) ;\n"
56 #define PF1(x) " prefetchnta "PF_OFFS(x)"(%[p2]) ;\n"
57 #define PF2(x) " prefetchnta "PF_OFFS(x)"(%[p3]) ;\n"
58 #define PF3(x) " prefetchnta "PF_OFFS(x)"(%[p4]) ;\n"
59 #define PF4(x) " prefetchnta "PF_OFFS(x)"(%[p5]) ;\n"
60 #define PF5(x) " prefetchnta "PF_OFFS(x)"(%[p6]) ;\n"
61 #define XO1(x, y) " xorps "OFFS(x)"(%[p2]), %%xmm"#y" ;\n"
62 #define XO2(x, y) " xorps "OFFS(x)"(%[p3]), %%xmm"#y" ;\n"
63 #define XO3(x, y) " xorps "OFFS(x)"(%[p4]), %%xmm"#y" ;\n"
64 #define XO4(x, y) " xorps "OFFS(x)"(%[p5]), %%xmm"#y" ;\n"
65 #define XO5(x, y) " xorps "OFFS(x)"(%[p6]), %%xmm"#y" ;\n"
69 xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
71 unsigned int lines = bytes >> 8;
73 xmm_store_t xmm_save[4];
109 " addq %[inc], %[p1] ;\n"
110 " addq %[inc], %[p2] ;\n"
111 " decl %[cnt] ; jnz 1b"
112 : [p1] "+r" (p1), [p2] "+r" (p2), [cnt] "+r" (lines)
120 xor_sse_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
123 unsigned int lines = bytes >> 8;
124 xmm_store_t xmm_save[4];
167 " addq %[inc], %[p1] ;\n"
168 " addq %[inc], %[p2] ;\n"
169 " addq %[inc], %[p3] ;\n"
170 " decl %[cnt] ; jnz 1b"
171 : [cnt] "+r" (lines),
172 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3)
179 xor_sse_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
180 unsigned long *p3, unsigned long *p4)
182 unsigned int lines = bytes >> 8;
183 xmm_store_t xmm_save[4];
232 " addq %[inc], %[p1] ;\n"
233 " addq %[inc], %[p2] ;\n"
234 " addq %[inc], %[p3] ;\n"
235 " addq %[inc], %[p4] ;\n"
236 " decl %[cnt] ; jnz 1b"
237 : [cnt] "+c" (lines),
238 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4)
246 xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
247 unsigned long *p3, unsigned long *p4, unsigned long *p5)
249 unsigned int lines = bytes >> 8;
250 xmm_store_t xmm_save[4];
305 " addq %[inc], %[p1] ;\n"
306 " addq %[inc], %[p2] ;\n"
307 " addq %[inc], %[p3] ;\n"
308 " addq %[inc], %[p4] ;\n"
309 " addq %[inc], %[p5] ;\n"
310 " decl %[cnt] ; jnz 1b"
311 : [cnt] "+c" (lines),
312 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4),
320 static struct xor_block_template xor_block_sse = {
321 .name = "generic_sse",
328 #undef XOR_TRY_TEMPLATES
329 #define XOR_TRY_TEMPLATES \
331 xor_speed(&xor_block_sse); \
334 /* We force the use of the SSE xor block because it can write around L2.
335 We may also be able to load into the L1 only depending on how the cpu
336 deals with a load to a line that is being prefetched. */
337 #define XOR_SELECT_TEMPLATE(FASTEST) (&xor_block_sse)
339 #endif /* _ASM_X86_XOR_64_H */