xref: /linux/arch/arc/lib/memcpy-700.S (revision ec7ac6afd07b2d958aab9dfc0a686300b856922a)
15210d1e6SVineet Gupta/*
25210d1e6SVineet Gupta * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
35210d1e6SVineet Gupta *
45210d1e6SVineet Gupta * This program is free software; you can redistribute it and/or modify
55210d1e6SVineet Gupta * it under the terms of the GNU General Public License version 2 as
65210d1e6SVineet Gupta * published by the Free Software Foundation.
75210d1e6SVineet Gupta */
85210d1e6SVineet Gupta
9*ec7ac6afSVineet Gupta#include <linux/linkage.h>
105210d1e6SVineet Gupta
11*ec7ac6afSVineet GuptaENTRY(memcpy)
125210d1e6SVineet Gupta	or	r3,r0,r1
135210d1e6SVineet Gupta	asl_s	r3,r3,30
145210d1e6SVineet Gupta	mov_s	r5,r0
155210d1e6SVineet Gupta	brls.d	r2,r3,.Lcopy_bytewise
165210d1e6SVineet Gupta	sub.f	r3,r2,1
175210d1e6SVineet Gupta	ld_s	r12,[r1,0]
185210d1e6SVineet Gupta	asr.f	lp_count,r3,3
195210d1e6SVineet Gupta	bbit0.d	r3,2,.Lnox4
205210d1e6SVineet Gupta	bmsk_s	r2,r2,1
215210d1e6SVineet Gupta	st.ab	r12,[r5,4]
225210d1e6SVineet Gupta	ld.a	r12,[r1,4]
235210d1e6SVineet Gupta.Lnox4:
245210d1e6SVineet Gupta	lppnz	.Lendloop
255210d1e6SVineet Gupta	ld_s	r3,[r1,4]
265210d1e6SVineet Gupta	st.ab	r12,[r5,4]
275210d1e6SVineet Gupta	ld.a	r12,[r1,8]
285210d1e6SVineet Gupta	st.ab	r3,[r5,4]
295210d1e6SVineet Gupta.Lendloop:
305210d1e6SVineet Gupta	breq	r2,0,.Last_store
315210d1e6SVineet Gupta	ld	r3,[r5,0]
325210d1e6SVineet Gupta#ifdef __LITTLE_ENDIAN__
335210d1e6SVineet Gupta	add3	r2,-1,r2
345210d1e6SVineet Gupta	; uses long immediate
355210d1e6SVineet Gupta	xor_s	r12,r12,r3
365210d1e6SVineet Gupta	bmsk	r12,r12,r2
375210d1e6SVineet Gupta    xor_s	r12,r12,r3
385210d1e6SVineet Gupta#else /* BIG ENDIAN */
395210d1e6SVineet Gupta	sub3	r2,31,r2
405210d1e6SVineet Gupta	; uses long immediate
415210d1e6SVineet Gupta        xor_s	r3,r3,r12
425210d1e6SVineet Gupta        bmsk	r3,r3,r2
435210d1e6SVineet Gupta        xor_s	r12,r12,r3
445210d1e6SVineet Gupta#endif /* ENDIAN */
455210d1e6SVineet Gupta.Last_store:
465210d1e6SVineet Gupta	j_s.d	[blink]
475210d1e6SVineet Gupta	st	r12,[r5,0]
485210d1e6SVineet Gupta
495210d1e6SVineet Gupta	.balign	4
505210d1e6SVineet Gupta.Lcopy_bytewise:
515210d1e6SVineet Gupta	jcs	[blink]
525210d1e6SVineet Gupta	ldb_s	r12,[r1,0]
535210d1e6SVineet Gupta	lsr.f	lp_count,r3
545210d1e6SVineet Gupta	bhs_s	.Lnox1
555210d1e6SVineet Gupta	stb.ab	r12,[r5,1]
565210d1e6SVineet Gupta	ldb.a	r12,[r1,1]
575210d1e6SVineet Gupta.Lnox1:
585210d1e6SVineet Gupta	lppnz	.Lendbloop
595210d1e6SVineet Gupta	ldb_s	r3,[r1,1]
605210d1e6SVineet Gupta	stb.ab	r12,[r5,1]
615210d1e6SVineet Gupta	ldb.a	r12,[r1,2]
625210d1e6SVineet Gupta	stb.ab	r3,[r5,1]
635210d1e6SVineet Gupta.Lendbloop:
645210d1e6SVineet Gupta	j_s.d	[blink]
655210d1e6SVineet Gupta	stb	r12,[r5,0]
66*ec7ac6afSVineet GuptaEND(memcpy)
67