1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Copyright (C) IBM Corporation, 2012
6 * Author: Anton Blanchard <anton@au.ibm.com>
8 #include <asm/ppc_asm.h>
11 /* 0 == don't use VMX, 1 == use VMX */
12 #define SELFTEST_CASE 0
16 #define LVS(VRT,RA,RB) lvsl VRT,RA,RB
17 #define VPERM(VRT,VRA,VRB,VRC) vperm VRT,VRA,VRB,VRC
19 #define LVS(VRT,RA,RB) lvsr VRT,RA,RB
20 #define VPERM(VRT,VRA,VRB,VRC) vperm VRT,VRB,VRA,VRC
23 _GLOBAL(memcpy_power7)
26 std r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
30 test_feature = SELFTEST_CASE
33 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
37 /* Get the source 8B aligned */
65 stdu r1,-STACKFRAMESIZE(r1)
66 std r14,STK_REG(R14)(r1)
67 std r15,STK_REG(R15)(r1)
68 std r16,STK_REG(R16)(r1)
69 std r17,STK_REG(R17)(r1)
70 std r18,STK_REG(R18)(r1)
71 std r19,STK_REG(R19)(r1)
72 std r20,STK_REG(R20)(r1)
73 std r21,STK_REG(R21)(r1)
74 std r22,STK_REG(R22)(r1)
75 std r0,STACKFRAMESIZE+16(r1)
80 /* Now do cacheline (128B) sized loads and stores. */
121 ld r14,STK_REG(R14)(r1)
122 ld r15,STK_REG(R15)(r1)
123 ld r16,STK_REG(R16)(r1)
124 ld r17,STK_REG(R17)(r1)
125 ld r18,STK_REG(R18)(r1)
126 ld r19,STK_REG(R19)(r1)
127 ld r20,STK_REG(R20)(r1)
128 ld r21,STK_REG(R21)(r1)
129 ld r22,STK_REG(R22)(r1)
130 addi r1,r1,STACKFRAMESIZE
132 /* Up to 127B to go */
156 /* Up to 63B to go */
169 /* Up to 31B to go */
178 9: clrldi r5,r5,(64-4)
180 /* Up to 15B to go */
184 lwz r0,0(r4) /* Less chance of a reject with word ops */
207 15: ld r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
210 .Lunwind_stack_nonvmx_copy:
211 addi r1,r1,STACKFRAMESIZE
215 #ifdef CONFIG_ALTIVEC
217 std r4,-STACKFRAMESIZE+STK_REG(R30)(r1)
218 std r5,-STACKFRAMESIZE+STK_REG(R29)(r1)
220 stdu r1,-STACKFRAMESIZE(r1)
223 ld r0,STACKFRAMESIZE+16(r1)
224 ld r3,STK_REG(R31)(r1)
225 ld r4,STK_REG(R30)(r1)
226 ld r5,STK_REG(R29)(r1)
230 * We prefetch both the source and destination using enhanced touch
231 * instructions. We use a stream ID of 0 for the load side and
232 * 1 for the store side.
236 ori r9,r9,1 /* stream=1 */
238 srdi r7,r5,7 /* length in cachelines, capped at 0x3FF */
242 1: lis r0,0x0E00 /* depth=7 */
245 ori r10,r7,1 /* stream=1 */
247 lis r8,0x8000 /* GO=1 */
255 dcbt 0,r8,0b01010 /* GO */
257 beq cr1,.Lunwind_stack_nonvmx_copy
260 * If source and destination are not relatively aligned we use a
261 * slower permute loop.
264 rldicl. r6,r6,0,(64-4)
265 bne .Lvmx_unaligned_copy
267 /* Get the destination 16B aligned */
298 /* Get the desination 128B aligned */
337 std r14,STK_REG(R14)(r1)
338 std r15,STK_REG(R15)(r1)
339 std r16,STK_REG(R16)(r1)
349 * Now do cacheline sized loads and stores. By this stage the
350 * cacheline stores are also cacheline aligned.
374 ld r14,STK_REG(R14)(r1)
375 ld r15,STK_REG(R15)(r1)
376 ld r16,STK_REG(R16)(r1)
378 /* Up to 127B to go */
409 /* Up to 15B to go */
410 11: clrldi r5,r5,(64-4)
434 15: addi r1,r1,STACKFRAMESIZE
435 ld r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
436 b exit_vmx_ops /* tail call optimise */
438 .Lvmx_unaligned_copy:
439 /* Get the destination 16B aligned */
463 lwz r0,0(r4) /* Less chance of a reject with word ops */
472 /* Get the desination 128B aligned */
482 LVS(v16,0,r4) /* Setup permute control vector */
523 std r14,STK_REG(R14)(r1)
524 std r15,STK_REG(R15)(r1)
525 std r16,STK_REG(R16)(r1)
535 * Now do cacheline sized loads and stores. By this stage the
536 * cacheline stores are also cacheline aligned.
568 ld r14,STK_REG(R14)(r1)
569 ld r15,STK_REG(R15)(r1)
570 ld r16,STK_REG(R16)(r1)
572 /* Up to 127B to go */
610 /* Up to 15B to go */
611 11: clrldi r5,r5,(64-4)
612 addi r4,r4,-16 /* Unwind the +16 load offset */
615 lwz r0,0(r4) /* Less chance of a reject with word ops */
638 15: addi r1,r1,STACKFRAMESIZE
639 ld r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
640 b exit_vmx_ops /* tail call optimise */
641 #endif /* CONFIG_ALTIVEC */