xref: /openbmc/linux/arch/sparc/lib/U1memcpy.S (revision 293d5b43)
1/* U1memcpy.S: UltraSPARC-I/II/IIi/IIe optimized memcpy.
2 *
3 * Copyright (C) 1997, 2004 David S. Miller (davem@redhat.com)
4 * Copyright (C) 1996, 1997, 1998, 1999 Jakub Jelinek (jj@ultra.linux.cz)
5 */
6
7#ifdef __KERNEL__
8#include <asm/visasm.h>
9#include <asm/asi.h>
10#define GLOBAL_SPARE	g7
11#else
12#define GLOBAL_SPARE	g5
13#define ASI_BLK_P 0xf0
14#define FPRS_FEF  0x04
15#ifdef MEMCPY_DEBUG
16#define VISEntry rd %fprs, %o5; wr %g0, FPRS_FEF, %fprs; \
17		 clr %g1; clr %g2; clr %g3; subcc %g0, %g0, %g0;
18#define VISExit and %o5, FPRS_FEF, %o5; wr %o5, 0x0, %fprs
19#else
20#define VISEntry rd %fprs, %o5; wr %g0, FPRS_FEF, %fprs
21#define VISExit and %o5, FPRS_FEF, %o5; wr %o5, 0x0, %fprs
22#endif
23#endif
24
25#ifndef EX_LD
26#define EX_LD(x)	x
27#endif
28#ifndef EX_LD_FP
29#define EX_LD_FP(x)	x
30#endif
31
32#ifndef EX_ST
33#define EX_ST(x)	x
34#endif
35#ifndef EX_ST_FP
36#define EX_ST_FP(x)	x
37#endif
38
39#ifndef EX_RETVAL
40#define EX_RETVAL(x)	x
41#endif
42
43#ifndef LOAD
44#define LOAD(type,addr,dest)	type [addr], dest
45#endif
46
47#ifndef LOAD_BLK
48#define LOAD_BLK(addr,dest)	ldda [addr] ASI_BLK_P, dest
49#endif
50
51#ifndef STORE
52#define STORE(type,src,addr)	type src, [addr]
53#endif
54
55#ifndef STORE_BLK
56#define STORE_BLK(src,addr)	stda src, [addr] ASI_BLK_P
57#endif
58
59#ifndef FUNC_NAME
60#define FUNC_NAME	memcpy
61#endif
62
63#ifndef PREAMBLE
64#define PREAMBLE
65#endif
66
67#ifndef XCC
68#define XCC xcc
69#endif
70
71#define FREG_FROB(f1, f2, f3, f4, f5, f6, f7, f8, f9)		\
72	faligndata		%f1, %f2, %f48;			\
73	faligndata		%f2, %f3, %f50;			\
74	faligndata		%f3, %f4, %f52;			\
75	faligndata		%f4, %f5, %f54;			\
76	faligndata		%f5, %f6, %f56;			\
77	faligndata		%f6, %f7, %f58;			\
78	faligndata		%f7, %f8, %f60;			\
79	faligndata		%f8, %f9, %f62;
80
81#define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, len, jmptgt)	\
82	EX_LD_FP(LOAD_BLK(%src, %fdest));				\
83	EX_ST_FP(STORE_BLK(%fsrc, %dest));				\
84	add			%src, 0x40, %src;		\
85	subcc			%len, 0x40, %len;		\
86	be,pn			%xcc, jmptgt;			\
87	 add			%dest, 0x40, %dest;		\
88
89#define LOOP_CHUNK1(src, dest, len, branch_dest)		\
90	MAIN_LOOP_CHUNK(src, dest, f0,  f48, len, branch_dest)
91#define LOOP_CHUNK2(src, dest, len, branch_dest)		\
92	MAIN_LOOP_CHUNK(src, dest, f16, f48, len, branch_dest)
93#define LOOP_CHUNK3(src, dest, len, branch_dest)		\
94	MAIN_LOOP_CHUNK(src, dest, f32, f48, len, branch_dest)
95
96#define DO_SYNC			membar	#Sync;
97#define STORE_SYNC(dest, fsrc)				\
98	EX_ST_FP(STORE_BLK(%fsrc, %dest));			\
99	add			%dest, 0x40, %dest;	\
100	DO_SYNC
101
102#define STORE_JUMP(dest, fsrc, target)			\
103	EX_ST_FP(STORE_BLK(%fsrc, %dest));			\
104	add			%dest, 0x40, %dest;	\
105	ba,pt			%xcc, target;		\
106	 nop;
107
108#define FINISH_VISCHUNK(dest, f0, f1, left)	\
109	subcc			%left, 8, %left;\
110	bl,pn			%xcc, 95f;	\
111	 faligndata		%f0, %f1, %f48;	\
112	EX_ST_FP(STORE(std, %f48, %dest));		\
113	add			%dest, 8, %dest;
114
115#define UNEVEN_VISCHUNK_LAST(dest, f0, f1, left)	\
116	subcc			%left, 8, %left;	\
117	bl,pn			%xcc, 95f;		\
118	 fsrc2			%f0, %f1;
119
120#define UNEVEN_VISCHUNK(dest, f0, f1, left)		\
121	UNEVEN_VISCHUNK_LAST(dest, f0, f1, left)	\
122	ba,a,pt			%xcc, 93f;
123
124	.register	%g2,#scratch
125	.register	%g3,#scratch
126
127	.text
128	.align		64
129
130	.globl		FUNC_NAME
131	.type		FUNC_NAME,#function
132FUNC_NAME:		/* %o0=dst, %o1=src, %o2=len */
133	srlx		%o2, 31, %g2
134	cmp		%g2, 0
135	tne		%xcc, 5
136	PREAMBLE
137	mov		%o0, %o4
138	cmp		%o2, 0
139	be,pn		%XCC, 85f
140	 or		%o0, %o1, %o3
141	cmp		%o2, 16
142	blu,a,pn	%XCC, 80f
143	 or		%o3, %o2, %o3
144
145	cmp		%o2, (5 * 64)
146	blu,pt		%XCC, 70f
147	 andcc		%o3, 0x7, %g0
148
149	/* Clobbers o5/g1/g2/g3/g7/icc/xcc.  */
150	VISEntry
151
152	/* Is 'dst' already aligned on an 64-byte boundary? */
153	andcc		%o0, 0x3f, %g2
154	be,pt		%XCC, 2f
155
156	/* Compute abs((dst & 0x3f) - 0x40) into %g2.  This is the number
157	 * of bytes to copy to make 'dst' 64-byte aligned.  We pre-
158	 * subtract this from 'len'.
159	 */
160	 sub		%o0, %o1, %GLOBAL_SPARE
161	sub		%g2, 0x40, %g2
162	sub		%g0, %g2, %g2
163	sub		%o2, %g2, %o2
164	andcc		%g2, 0x7, %g1
165	be,pt		%icc, 2f
166	 and		%g2, 0x38, %g2
167
1681:	subcc		%g1, 0x1, %g1
169	EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3))
170	EX_ST_FP(STORE(stb, %o3, %o1 + %GLOBAL_SPARE))
171	bgu,pt		%XCC, 1b
172	 add		%o1, 0x1, %o1
173
174	add		%o1, %GLOBAL_SPARE, %o0
175
1762:	cmp		%g2, 0x0
177	and		%o1, 0x7, %g1
178	be,pt		%icc, 3f
179	 alignaddr	%o1, %g0, %o1
180
181	EX_LD_FP(LOAD(ldd, %o1, %f4))
1821:	EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6))
183	add		%o1, 0x8, %o1
184	subcc		%g2, 0x8, %g2
185	faligndata	%f4, %f6, %f0
186	EX_ST_FP(STORE(std, %f0, %o0))
187	be,pn		%icc, 3f
188	 add		%o0, 0x8, %o0
189
190	EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4))
191	add		%o1, 0x8, %o1
192	subcc		%g2, 0x8, %g2
193	faligndata	%f6, %f4, %f0
194	EX_ST_FP(STORE(std, %f0, %o0))
195	bne,pt		%icc, 1b
196	 add		%o0, 0x8, %o0
197
198	/* Destination is 64-byte aligned.  */
1993:
200	membar		  #LoadStore | #StoreStore | #StoreLoad
201
202	subcc		%o2, 0x40, %GLOBAL_SPARE
203	add		%o1, %g1, %g1
204	andncc		%GLOBAL_SPARE, (0x40 - 1), %GLOBAL_SPARE
205	srl		%g1, 3, %g2
206	sub		%o2, %GLOBAL_SPARE, %g3
207	andn		%o1, (0x40 - 1), %o1
208	and		%g2, 7, %g2
209	andncc		%g3, 0x7, %g3
210	fsrc2		%f0, %f2
211	sub		%g3, 0x8, %g3
212	sub		%o2, %GLOBAL_SPARE, %o2
213
214	add		%g1, %GLOBAL_SPARE, %g1
215	subcc		%o2, %g3, %o2
216
217	EX_LD_FP(LOAD_BLK(%o1, %f0))
218	add		%o1, 0x40, %o1
219	add		%g1, %g3, %g1
220	EX_LD_FP(LOAD_BLK(%o1, %f16))
221	add		%o1, 0x40, %o1
222	sub		%GLOBAL_SPARE, 0x80, %GLOBAL_SPARE
223	EX_LD_FP(LOAD_BLK(%o1, %f32))
224	add		%o1, 0x40, %o1
225
226	/* There are 8 instances of the unrolled loop,
227	 * one for each possible alignment of the
228	 * source buffer.  Each loop instance is 452
229	 * bytes.
230	 */
231	sll		%g2, 3, %o3
232	sub		%o3, %g2, %o3
233	sllx		%o3, 4, %o3
234	add		%o3, %g2, %o3
235	sllx		%o3, 2, %g2
2361:	rd		%pc, %o3
237	add		%o3, %lo(1f - 1b), %o3
238	jmpl		%o3 + %g2, %g0
239	 nop
240
241	.align		64
2421:	FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16)
243	LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
244	FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32)
245	LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
246	FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0)
247	LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
248	ba,pt		%xcc, 1b+4
249	 faligndata	%f0, %f2, %f48
2501:	FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32)
251	STORE_SYNC(o0, f48)
252	FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0)
253	STORE_JUMP(o0, f48, 40f)
2542:	FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0)
255	STORE_SYNC(o0, f48)
256	FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16)
257	STORE_JUMP(o0, f48, 48f)
2583:	FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16)
259	STORE_SYNC(o0, f48)
260	FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32)
261	STORE_JUMP(o0, f48, 56f)
262
2631:	FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18)
264	LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
265	FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34)
266	LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
267	FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2)
268	LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
269	ba,pt		%xcc, 1b+4
270	 faligndata	%f2, %f4, %f48
2711:	FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34)
272	STORE_SYNC(o0, f48)
273	FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2)
274	STORE_JUMP(o0, f48, 41f)
2752:	FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2)
276	STORE_SYNC(o0, f48)
277	FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18)
278	STORE_JUMP(o0, f48, 49f)
2793:	FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18)
280	STORE_SYNC(o0, f48)
281	FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34)
282	STORE_JUMP(o0, f48, 57f)
283
2841:	FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20)
285	LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
286	FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36)
287	LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
288	FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4)
289	LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
290	ba,pt		%xcc, 1b+4
291	 faligndata	%f4, %f6, %f48
2921:	FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36)
293	STORE_SYNC(o0, f48)
294	FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4)
295	STORE_JUMP(o0, f48, 42f)
2962:	FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4)
297	STORE_SYNC(o0, f48)
298	FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20)
299	STORE_JUMP(o0, f48, 50f)
3003:	FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20)
301	STORE_SYNC(o0, f48)
302	FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36)
303	STORE_JUMP(o0, f48, 58f)
304
3051:	FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22)
306	LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
307	FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38)
308	LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
309	FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6)
310	LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
311	ba,pt		%xcc, 1b+4
312	 faligndata	%f6, %f8, %f48
3131:	FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38)
314	STORE_SYNC(o0, f48)
315	FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6)
316	STORE_JUMP(o0, f48, 43f)
3172:	FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6)
318	STORE_SYNC(o0, f48)
319	FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22)
320	STORE_JUMP(o0, f48, 51f)
3213:	FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22)
322	STORE_SYNC(o0, f48)
323	FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38)
324	STORE_JUMP(o0, f48, 59f)
325
3261:	FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24)
327	LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
328	FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40)
329	LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
330	FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8)
331	LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
332	ba,pt		%xcc, 1b+4
333	 faligndata	%f8, %f10, %f48
3341:	FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40)
335	STORE_SYNC(o0, f48)
336	FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8)
337	STORE_JUMP(o0, f48, 44f)
3382:	FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8)
339	STORE_SYNC(o0, f48)
340	FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24)
341	STORE_JUMP(o0, f48, 52f)
3423:	FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24)
343	STORE_SYNC(o0, f48)
344	FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40)
345	STORE_JUMP(o0, f48, 60f)
346
3471:	FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26)
348	LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
349	FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42)
350	LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
351	FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10)
352	LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
353	ba,pt		%xcc, 1b+4
354	 faligndata	%f10, %f12, %f48
3551:	FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42)
356	STORE_SYNC(o0, f48)
357	FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10)
358	STORE_JUMP(o0, f48, 45f)
3592:	FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10)
360	STORE_SYNC(o0, f48)
361	FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26)
362	STORE_JUMP(o0, f48, 53f)
3633:	FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26)
364	STORE_SYNC(o0, f48)
365	FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42)
366	STORE_JUMP(o0, f48, 61f)
367
3681:	FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28)
369	LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
370	FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44)
371	LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
372	FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12)
373	LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
374	ba,pt		%xcc, 1b+4
375	 faligndata	%f12, %f14, %f48
3761:	FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44)
377	STORE_SYNC(o0, f48)
378	FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12)
379	STORE_JUMP(o0, f48, 46f)
3802:	FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12)
381	STORE_SYNC(o0, f48)
382	FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28)
383	STORE_JUMP(o0, f48, 54f)
3843:	FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28)
385	STORE_SYNC(o0, f48)
386	FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44)
387	STORE_JUMP(o0, f48, 62f)
388
3891:	FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30)
390	LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
391	FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
392	LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
393	FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14)
394	LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
395	ba,pt		%xcc, 1b+4
396	 faligndata	%f14, %f16, %f48
3971:	FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
398	STORE_SYNC(o0, f48)
399	FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14)
400	STORE_JUMP(o0, f48, 47f)
4012:	FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14)
402	STORE_SYNC(o0, f48)
403	FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30)
404	STORE_JUMP(o0, f48, 55f)
4053:	FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30)
406	STORE_SYNC(o0, f48)
407	FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
408	STORE_JUMP(o0, f48, 63f)
409
41040:	FINISH_VISCHUNK(o0, f0,  f2,  g3)
41141:	FINISH_VISCHUNK(o0, f2,  f4,  g3)
41242:	FINISH_VISCHUNK(o0, f4,  f6,  g3)
41343:	FINISH_VISCHUNK(o0, f6,  f8,  g3)
41444:	FINISH_VISCHUNK(o0, f8,  f10, g3)
41545:	FINISH_VISCHUNK(o0, f10, f12, g3)
41646:	FINISH_VISCHUNK(o0, f12, f14, g3)
41747:	UNEVEN_VISCHUNK(o0, f14, f0,  g3)
41848:	FINISH_VISCHUNK(o0, f16, f18, g3)
41949:	FINISH_VISCHUNK(o0, f18, f20, g3)
42050:	FINISH_VISCHUNK(o0, f20, f22, g3)
42151:	FINISH_VISCHUNK(o0, f22, f24, g3)
42252:	FINISH_VISCHUNK(o0, f24, f26, g3)
42353:	FINISH_VISCHUNK(o0, f26, f28, g3)
42454:	FINISH_VISCHUNK(o0, f28, f30, g3)
42555:	UNEVEN_VISCHUNK(o0, f30, f0,  g3)
42656:	FINISH_VISCHUNK(o0, f32, f34, g3)
42757:	FINISH_VISCHUNK(o0, f34, f36, g3)
42858:	FINISH_VISCHUNK(o0, f36, f38, g3)
42959:	FINISH_VISCHUNK(o0, f38, f40, g3)
43060:	FINISH_VISCHUNK(o0, f40, f42, g3)
43161:	FINISH_VISCHUNK(o0, f42, f44, g3)
43262:	FINISH_VISCHUNK(o0, f44, f46, g3)
43363:	UNEVEN_VISCHUNK_LAST(o0, f46, f0,  g3)
434
43593:	EX_LD_FP(LOAD(ldd, %o1, %f2))
436	add		%o1, 8, %o1
437	subcc		%g3, 8, %g3
438	faligndata	%f0, %f2, %f8
439	EX_ST_FP(STORE(std, %f8, %o0))
440	bl,pn		%xcc, 95f
441	 add		%o0, 8, %o0
442	EX_LD_FP(LOAD(ldd, %o1, %f0))
443	add		%o1, 8, %o1
444	subcc		%g3, 8, %g3
445	faligndata	%f2, %f0, %f8
446	EX_ST_FP(STORE(std, %f8, %o0))
447	bge,pt		%xcc, 93b
448	 add		%o0, 8, %o0
449
45095:	brz,pt		%o2, 2f
451	 mov		%g1, %o1
452
4531:	EX_LD_FP(LOAD(ldub, %o1, %o3))
454	add		%o1, 1, %o1
455	subcc		%o2, 1, %o2
456	EX_ST_FP(STORE(stb, %o3, %o0))
457	bne,pt		%xcc, 1b
458	 add		%o0, 1, %o0
459
4602:	membar		#StoreLoad | #StoreStore
461	VISExit
462	retl
463	 mov		EX_RETVAL(%o4), %o0
464
465	.align		64
46670:	/* 16 < len <= (5 * 64) */
467	bne,pn		%XCC, 75f
468	 sub		%o0, %o1, %o3
469
47072:	andn		%o2, 0xf, %GLOBAL_SPARE
471	and		%o2, 0xf, %o2
4721:	EX_LD(LOAD(ldx, %o1 + 0x00, %o5))
473	EX_LD(LOAD(ldx, %o1 + 0x08, %g1))
474	subcc		%GLOBAL_SPARE, 0x10, %GLOBAL_SPARE
475	EX_ST(STORE(stx, %o5, %o1 + %o3))
476	add		%o1, 0x8, %o1
477	EX_ST(STORE(stx, %g1, %o1 + %o3))
478	bgu,pt		%XCC, 1b
479	 add		%o1, 0x8, %o1
48073:	andcc		%o2, 0x8, %g0
481	be,pt		%XCC, 1f
482	 nop
483	EX_LD(LOAD(ldx, %o1, %o5))
484	sub		%o2, 0x8, %o2
485	EX_ST(STORE(stx, %o5, %o1 + %o3))
486	add		%o1, 0x8, %o1
4871:	andcc		%o2, 0x4, %g0
488	be,pt		%XCC, 1f
489	 nop
490	EX_LD(LOAD(lduw, %o1, %o5))
491	sub		%o2, 0x4, %o2
492	EX_ST(STORE(stw, %o5, %o1 + %o3))
493	add		%o1, 0x4, %o1
4941:	cmp		%o2, 0
495	be,pt		%XCC, 85f
496	 nop
497	ba,pt		%xcc, 90f
498	 nop
499
50075:	andcc		%o0, 0x7, %g1
501	sub		%g1, 0x8, %g1
502	be,pn		%icc, 2f
503	 sub		%g0, %g1, %g1
504	sub		%o2, %g1, %o2
505
5061:	EX_LD(LOAD(ldub, %o1, %o5))
507	subcc		%g1, 1, %g1
508	EX_ST(STORE(stb, %o5, %o1 + %o3))
509	bgu,pt		%icc, 1b
510	 add		%o1, 1, %o1
511
5122:	add		%o1, %o3, %o0
513	andcc		%o1, 0x7, %g1
514	bne,pt		%icc, 8f
515	 sll		%g1, 3, %g1
516
517	cmp		%o2, 16
518	bgeu,pt		%icc, 72b
519	 nop
520	ba,a,pt		%xcc, 73b
521
5228:	mov		64, %o3
523	andn		%o1, 0x7, %o1
524	EX_LD(LOAD(ldx, %o1, %g2))
525	sub		%o3, %g1, %o3
526	andn		%o2, 0x7, %GLOBAL_SPARE
527	sllx		%g2, %g1, %g2
5281:	EX_LD(LOAD(ldx, %o1 + 0x8, %g3))
529	subcc		%GLOBAL_SPARE, 0x8, %GLOBAL_SPARE
530	add		%o1, 0x8, %o1
531	srlx		%g3, %o3, %o5
532	or		%o5, %g2, %o5
533	EX_ST(STORE(stx, %o5, %o0))
534	add		%o0, 0x8, %o0
535	bgu,pt		%icc, 1b
536	 sllx		%g3, %g1, %g2
537
538	srl		%g1, 3, %g1
539	andcc		%o2, 0x7, %o2
540	be,pn		%icc, 85f
541	 add		%o1, %g1, %o1
542	ba,pt		%xcc, 90f
543	 sub		%o0, %o1, %o3
544
545	.align		64
54680:	/* 0 < len <= 16 */
547	andcc		%o3, 0x3, %g0
548	bne,pn		%XCC, 90f
549	 sub		%o0, %o1, %o3
550
5511:	EX_LD(LOAD(lduw, %o1, %g1))
552	subcc		%o2, 4, %o2
553	EX_ST(STORE(stw, %g1, %o1 + %o3))
554	bgu,pt		%XCC, 1b
555	 add		%o1, 4, %o1
556
55785:	retl
558	 mov		EX_RETVAL(%o4), %o0
559
560	.align		32
56190:	EX_LD(LOAD(ldub, %o1, %g1))
562	subcc		%o2, 1, %o2
563	EX_ST(STORE(stb, %g1, %o1 + %o3))
564	bgu,pt		%XCC, 90b
565	 add		%o1, 1, %o1
566	retl
567	 mov		EX_RETVAL(%o4), %o0
568
569	.size		FUNC_NAME, .-FUNC_NAME
570