xref: /openbmc/u-boot/arch/sh/lib/movmem.S (revision 78a88f79)
1/* SPDX-License-Identifier: GPL-2.0+ */
2/* Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3   2004, 2005, 2006
4   Free Software Foundation, Inc.
5 */
6
7!! libgcc routines for the Renesas / SuperH SH CPUs.
8!! Contributed by Steve Chamberlain.
9!! sac@cygnus.com
10
11!! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
12!! recoded in assembly by Toshiyasu Morita
13!! tm@netcom.com
14
15/* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
16   ELF local label prefixes by J"orn Rennecke
17   amylaar@cygnus.com  */
18
19	.text
20	.balign	4
21	.global	__movmem
22	.global __movstr
23	.set __movstr, __movmem
24	/* This would be a lot simpler if r6 contained the byte count
25	   minus 64, and we wouldn't be called here for a byte count of 64.  */
26__movmem:
27	sts.l	pr,@-r15
28	shll2	r6
29	bsr	__movmemSI52+2
30	mov.l	@(48,r5),r0
31	.balign	4
32movmem_loop: /* Reached with rts */
33	mov.l	@(60,r5),r0
34	add	#-64,r6
35	mov.l	r0,@(60,r4)
36	tst	r6,r6
37	mov.l	@(56,r5),r0
38	bt	movmem_done
39	mov.l	r0,@(56,r4)
40	cmp/pl	r6
41	mov.l	@(52,r5),r0
42	add	#64,r5
43	mov.l	r0,@(52,r4)
44	add	#64,r4
45	bt	__movmemSI52
46! done all the large groups, do the remainder
47! jump to movmem+
48	mova	__movmemSI4+4,r0
49	add	r6,r0
50	jmp	@r0
51movmem_done: ! share slot insn, works out aligned.
52	lds.l	@r15+,pr
53	mov.l	r0,@(56,r4)
54	mov.l	@(52,r5),r0
55	rts
56	mov.l	r0,@(52,r4)
57	.balign	4
58
59	.global	__movmemSI64
60	.global __movstrSI64
61	.set	__movstrSI64, __movmemSI64
62__movmemSI64:
63	mov.l	@(60,r5),r0
64	mov.l	r0,@(60,r4)
65	.global	__movmemSI60
66	.global __movstrSI60
67	.set	__movstrSI60, __movmemSI60
68__movmemSI60:
69	mov.l	@(56,r5),r0
70	mov.l	r0,@(56,r4)
71	.global	__movmemSI56
72	.global __movstrSI56
73	.set	__movstrSI56, __movmemSI56
74__movmemSI56:
75	mov.l	@(52,r5),r0
76	mov.l	r0,@(52,r4)
77	.global	__movmemSI52
78	.global __movstrSI52
79	.set	__movstrSI52, __movmemSI52
80__movmemSI52:
81	mov.l	@(48,r5),r0
82	mov.l	r0,@(48,r4)
83	.global	__movmemSI48
84	.global	__movstrSI48
85	.set	__movstrSI48, __movmemSI48
86__movmemSI48:
87	mov.l	@(44,r5),r0
88	mov.l	r0,@(44,r4)
89	.global	__movmemSI44
90	.global	__movstrSI44
91	.set	__movstrSI44, __movmemSI44
92__movmemSI44:
93	mov.l	@(40,r5),r0
94	mov.l	r0,@(40,r4)
95	.global	__movmemSI40
96	.global __movstrSI40
97	.set	__movstrSI40, __movmemSI40
98__movmemSI40:
99	mov.l	@(36,r5),r0
100	mov.l	r0,@(36,r4)
101	.global	__movmemSI36
102	.global	__movstrSI36
103	.set	__movstrSI36, __movmemSI36
104__movmemSI36:
105	mov.l	@(32,r5),r0
106	mov.l	r0,@(32,r4)
107	.global	__movmemSI32
108	.global	__movstrSI32
109	.set	__movstrSI32, __movmemSI32
110__movmemSI32:
111	mov.l	@(28,r5),r0
112	mov.l	r0,@(28,r4)
113	.global	__movmemSI28
114	.global	__movstrSI28
115	.set	__movstrSI28, __movmemSI28
116__movmemSI28:
117	mov.l	@(24,r5),r0
118	mov.l	r0,@(24,r4)
119	.global	__movmemSI24
120	.global	__movstrSI24
121	.set	__movstrSI24, __movmemSI24
122__movmemSI24:
123	mov.l	@(20,r5),r0
124	mov.l	r0,@(20,r4)
125	.global	__movmemSI20
126	.global	__movstrSI20
127	.set	__movstrSI20, __movmemSI20
128__movmemSI20:
129	mov.l	@(16,r5),r0
130	mov.l	r0,@(16,r4)
131	.global	__movmemSI16
132	.global	__movstrSI16
133	.set	__movstrSI16, __movmemSI16
134__movmemSI16:
135	mov.l	@(12,r5),r0
136	mov.l	r0,@(12,r4)
137	.global	__movmemSI12
138	.global	__movstrSI12
139	.set	__movstrSI12, __movmemSI12
140__movmemSI12:
141	mov.l	@(8,r5),r0
142	mov.l	r0,@(8,r4)
143	.global	__movmemSI8
144	.global	__movstrSI8
145	.set	__movstrSI8, __movmemSI8
146__movmemSI8:
147	mov.l	@(4,r5),r0
148	mov.l	r0,@(4,r4)
149	.global	__movmemSI4
150	.global	__movstrSI4
151	.set	__movstrSI4, __movmemSI4
152__movmemSI4:
153	mov.l	@(0,r5),r0
154	rts
155	mov.l	r0,@(0,r4)
156
157	.global	__movmem_i4_even
158	.global	__movstr_i4_even
159	.set	__movstr_i4_even, __movmem_i4_even
160
161	.global	__movmem_i4_odd
162	.global	__movstr_i4_odd
163	.set	__movstr_i4_odd, __movmem_i4_odd
164
165	.global	__movmemSI12_i4
166	.global	__movstrSI12_i4
167	.set	__movstrSI12_i4, __movmemSI12_i4
168
169	.p2align	5
170L_movmem_2mod4_end:
171	mov.l	r0,@(16,r4)
172	rts
173	mov.l	r1,@(20,r4)
174
175	.p2align	2
176
177__movmem_i4_even:
178	mov.l	@r5+,r0
179	bra	L_movmem_start_even
180	mov.l	@r5+,r1
181
182__movmem_i4_odd:
183	mov.l	@r5+,r1
184	add	#-4,r4
185	mov.l	@r5+,r2
186	mov.l	@r5+,r3
187	mov.l	r1,@(4,r4)
188	mov.l	r2,@(8,r4)
189
190L_movmem_loop:
191	mov.l	r3,@(12,r4)
192	dt	r6
193	mov.l	@r5+,r0
194	bt/s	L_movmem_2mod4_end
195	mov.l	@r5+,r1
196	add	#16,r4
197L_movmem_start_even:
198	mov.l	@r5+,r2
199	mov.l	@r5+,r3
200	mov.l	r0,@r4
201	dt	r6
202	mov.l	r1,@(4,r4)
203	bf/s	L_movmem_loop
204	mov.l	r2,@(8,r4)
205	rts
206	mov.l	r3,@(12,r4)
207
208	.p2align	4
209__movmemSI12_i4:
210	mov.l	@r5,r0
211	mov.l	@(4,r5),r1
212	mov.l	@(8,r5),r2
213	mov.l	r0,@r4
214	mov.l	r1,@(4,r4)
215	rts
216	mov.l	r2,@(8,r4)
217