xref: /linux/arch/arc/lib/memcpy-700.S (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*d2912cb1SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */
25210d1e6SVineet Gupta/*
35210d1e6SVineet Gupta * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
45210d1e6SVineet Gupta */
55210d1e6SVineet Gupta
6ec7ac6afSVineet Gupta#include <linux/linkage.h>
75210d1e6SVineet Gupta
886effd0dSVineet GuptaENTRY_CFI(memcpy)
95210d1e6SVineet Gupta	or	r3,r0,r1
105210d1e6SVineet Gupta	asl_s	r3,r3,30
115210d1e6SVineet Gupta	mov_s	r5,r0
125210d1e6SVineet Gupta	brls.d	r2,r3,.Lcopy_bytewise
135210d1e6SVineet Gupta	sub.f	r3,r2,1
145210d1e6SVineet Gupta	ld_s	r12,[r1,0]
155210d1e6SVineet Gupta	asr.f	lp_count,r3,3
165210d1e6SVineet Gupta	bbit0.d	r3,2,.Lnox4
175210d1e6SVineet Gupta	bmsk_s	r2,r2,1
185210d1e6SVineet Gupta	st.ab	r12,[r5,4]
195210d1e6SVineet Gupta	ld.a	r12,[r1,4]
205210d1e6SVineet Gupta.Lnox4:
215210d1e6SVineet Gupta	lppnz	.Lendloop
225210d1e6SVineet Gupta	ld_s	r3,[r1,4]
235210d1e6SVineet Gupta	st.ab	r12,[r5,4]
245210d1e6SVineet Gupta	ld.a	r12,[r1,8]
255210d1e6SVineet Gupta	st.ab	r3,[r5,4]
265210d1e6SVineet Gupta.Lendloop:
275210d1e6SVineet Gupta	breq	r2,0,.Last_store
285210d1e6SVineet Gupta	ld	r3,[r5,0]
295210d1e6SVineet Gupta#ifdef __LITTLE_ENDIAN__
305210d1e6SVineet Gupta	add3	r2,-1,r2
315210d1e6SVineet Gupta	; uses long immediate
325210d1e6SVineet Gupta	xor_s	r12,r12,r3
335210d1e6SVineet Gupta	bmsk	r12,r12,r2
345210d1e6SVineet Gupta    xor_s	r12,r12,r3
355210d1e6SVineet Gupta#else /* BIG ENDIAN */
365210d1e6SVineet Gupta	sub3	r2,31,r2
375210d1e6SVineet Gupta	; uses long immediate
385210d1e6SVineet Gupta        xor_s	r3,r3,r12
395210d1e6SVineet Gupta        bmsk	r3,r3,r2
405210d1e6SVineet Gupta        xor_s	r12,r12,r3
415210d1e6SVineet Gupta#endif /* ENDIAN */
425210d1e6SVineet Gupta.Last_store:
435210d1e6SVineet Gupta	j_s.d	[blink]
445210d1e6SVineet Gupta	st	r12,[r5,0]
455210d1e6SVineet Gupta
465210d1e6SVineet Gupta	.balign	4
475210d1e6SVineet Gupta.Lcopy_bytewise:
485210d1e6SVineet Gupta	jcs	[blink]
495210d1e6SVineet Gupta	ldb_s	r12,[r1,0]
505210d1e6SVineet Gupta	lsr.f	lp_count,r3
515210d1e6SVineet Gupta	bhs_s	.Lnox1
525210d1e6SVineet Gupta	stb.ab	r12,[r5,1]
535210d1e6SVineet Gupta	ldb.a	r12,[r1,1]
545210d1e6SVineet Gupta.Lnox1:
555210d1e6SVineet Gupta	lppnz	.Lendbloop
565210d1e6SVineet Gupta	ldb_s	r3,[r1,1]
575210d1e6SVineet Gupta	stb.ab	r12,[r5,1]
585210d1e6SVineet Gupta	ldb.a	r12,[r1,2]
595210d1e6SVineet Gupta	stb.ab	r3,[r5,1]
605210d1e6SVineet Gupta.Lendbloop:
615210d1e6SVineet Gupta	j_s.d	[blink]
625210d1e6SVineet Gupta	stb	r12,[r5,0]
6386effd0dSVineet GuptaEND_CFI(memcpy)
64