1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Based on linux/arch/arm/lib/memmove.S */
10 * Prototype: void *memmove(void *dest, const void *src, size_t n);
14 * If the memory regions don't overlap, we simply branch to memcpy which is
15 * normally a bit faster. Otherwise the copy is done going downwards. This
16 * is a transposition of the code from copy_template.S but with the copy
17 * occurring in the opposite direction.
26 stmfd sp!, {r0, r4, lr}
41 CALGN( ands ip, r0, #31 )
42 CALGN( sbcnes r4, ip, r2 ) @ C is always set here
45 CALGN( subs r2, r2, ip ) @ C is set here
46 CALGN( rsb ip, ip, #32 )
47 CALGN( add pc, r4, ip )
50 2: PLD( subs r2, r2, #96 )
56 3: PLD( pld [r1, #-128] )
57 4: ldmdb r1!, {r3, r4, r5, r6, r7, r8, ip, lr}
59 stmdb r0!, {r3, r4, r5, r6, r7, r8, ip, lr}
66 addne pc, pc, ip @ C is always clear here
90 7: ldmfd sp!, {r5 - r8}
92 8: movs r2, r2, lsl #31
99 ldmfd sp!, {r0, r4, pc}
102 ldrbgt r3, [r1, #-1]!
103 ldrbge r4, [r1, #-1]!
105 strbgt r3, [r0, #-1]!
106 strbge r4, [r0, #-1]!
120 .macro backward_copy_shift push pull
125 CALGN( ands ip, r0, #31 )
126 CALGN( sbcnes r4, ip, r2 ) @ C is always set here
127 CALGN( subcc r2, r2, ip )
130 11: stmfd sp!, {r5 - r9}
133 PLD( subs r2, r2, #96 )
134 PLD( pld [r1, #-32] )
136 PLD( pld [r1, #-64] )
137 PLD( pld [r1, #-96] )
139 12: PLD( pld [r1, #-128] )
140 13: ldmdb r1!, {r7, r8, r9, ip}
141 mov lr, r3, push #\push
143 ldmdb r1!, {r3, r4, r5, r6}
144 orr lr, lr, ip, pull #\pull
145 mov ip, ip, push #\push
146 orr ip, ip, r9, pull #\pull
147 mov r9, r9, push #\push
148 orr r9, r9, r8, pull #\pull
149 mov r8, r8, push #\push
150 orr r8, r8, r7, pull #\pull
151 mov r7, r7, push #\push
152 orr r7, r7, r6, pull #\pull
153 mov r6, r6, push #\push
154 orr r6, r6, r5, pull #\pull
155 mov r5, r5, push #\push
156 orr r5, r5, r4, pull #\pull
157 mov r4, r4, push #\push
158 orr r4, r4, r3, pull #\pull
159 stmdb r0!, {r4 - r9, ip, lr}
169 15: mov lr, r3, push #\push
172 orr lr, lr, r3, pull #\pull
178 16: add r1, r1, #(\pull / 8)
184 backward_copy_shift push=8 pull=24
186 17: backward_copy_shift push=16 pull=16
188 18: backward_copy_shift push=24 pull=8