1 /* Copy SIZE bytes from SRC to DEST.
3 Copyright (C) 2001, 2003 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by David S. Miller (davem@redhat.com)
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
23 #define ASI_BLK_P 0xf0
25 #define VISEntryHalf rd %fprs, %o5; wr %g0, FPRS_FEF, %fprs
26 #define VISExitHalf and %o5, FPRS_FEF, %o5; wr %o5, 0x0, %fprs
33 #if !defined NOT_IN_libc
35 .register %g2,#scratch
36 .register %g3,#scratch
37 .register %g6,#scratch
41 /* Special/non-trivial issues of this code:
43 * 1) %o5 is preserved from VISEntryHalf to VISExitHalf
44 * 2) Only low 32 FPU registers are used so that only the
45 * lower half of the FPU register set is dirtied by this
46 * code. This is especially important in the kernel.
47 * 3) This code never prefetches cachelines past the end
48 * of the source buffer.
50 * The cheetah's flexible spine, oversized liver, enlarged heart,
51 * slender muscular body, and claws make it the swiftest hunter
52 * in Africa and the fastest animal on land. Can reach speeds
53 * of up to 2.4GB per second.
56 ENTRY(__memcpy_ultra3)
58 100: /* %o0=dst, %o1=src, %o2=len */
64 bleu,a,pn %XCC, small_copy
68 blu,pt %XCC, medium_copy
74 /* Here len >= 256 and condition codes reflect execution
75 * of "andcc %o0, 0x7, %g2", done by caller.
79 /* Is 'dst' already aligned on an 64-byte boundary? */
82 /* Compute abs((dst & 0x3f) - 0x40) into %g2. This is the number
83 * of bytes to copy to make 'dst' 64-byte aligned. We pre-
84 * subtract this from 'len'.
90 /* Copy %g2 bytes from src to dst, one byte at a time. */
91 1: ldub [%o1 + 0x00], %o3
102 alignaddr %o1, %g0, %o1
106 prefetch [%o1 + 0x000], #one_read
107 prefetch [%o1 + 0x040], #one_read
108 andn %o2, (0x40 - 1), %o4
109 prefetch [%o1 + 0x080], #one_read
110 prefetch [%o1 + 0x0c0], #one_read
111 ldd [%o1 + 0x000], %f0
112 prefetch [%o1 + 0x100], #one_read
113 ldd [%o1 + 0x008], %f2
114 prefetch [%o1 + 0x140], #one_read
115 ldd [%o1 + 0x010], %f4
116 prefetch [%o1 + 0x180], #one_read
117 faligndata %f0, %f2, %f16
118 ldd [%o1 + 0x018], %f6
119 faligndata %f2, %f4, %f18
120 ldd [%o1 + 0x020], %f8
121 faligndata %f4, %f6, %f20
122 ldd [%o1 + 0x028], %f10
123 faligndata %f6, %f8, %f22
125 ldd [%o1 + 0x030], %f12
126 faligndata %f8, %f10, %f24
127 ldd [%o1 + 0x038], %f14
128 faligndata %f10, %f12, %f26
129 ldd [%o1 + 0x040], %f0
138 ldd [%o1 + 0x008], %f2
139 faligndata %f12, %f14, %f28
140 ldd [%o1 + 0x010], %f4
141 faligndata %f14, %f0, %f30
142 stda %f16, [%o0] ASI_BLK_P
143 ldd [%o1 + 0x018], %f6
144 faligndata %f0, %f2, %f16
146 ldd [%o1 + 0x020], %f8
147 faligndata %f2, %f4, %f18
148 ldd [%o1 + 0x028], %f10
149 faligndata %f4, %f6, %f20
150 ldd [%o1 + 0x030], %f12
151 faligndata %f6, %f8, %f22
152 ldd [%o1 + 0x038], %f14
153 faligndata %f8, %f10, %f24
155 ldd [%o1 + 0x040], %f0
156 prefetch [%o1 + 0x180], #one_read
157 faligndata %f10, %f12, %f26
163 /* Finally we copy the last full 64-byte block. */
165 ldd [%o1 + 0x008], %f2
166 faligndata %f12, %f14, %f28
167 ldd [%o1 + 0x010], %f4
168 faligndata %f14, %f0, %f30
169 stda %f16, [%o0] ASI_BLK_P
170 ldd [%o1 + 0x018], %f6
171 faligndata %f0, %f2, %f16
172 ldd [%o1 + 0x020], %f8
173 faligndata %f2, %f4, %f18
174 ldd [%o1 + 0x028], %f10
175 faligndata %f4, %f6, %f20
176 ldd [%o1 + 0x030], %f12
177 faligndata %f6, %f8, %f22
178 ldd [%o1 + 0x038], %f14
179 faligndata %f8, %f10, %f24
183 ldd [%o1 + 0x040], %f0
184 1: faligndata %f10, %f12, %f26
185 faligndata %f12, %f14, %f28
186 faligndata %f14, %f0, %f30
187 stda %f16, [%o0] ASI_BLK_P
192 /* Now we copy the (len modulo 64) bytes at the end.
193 * Note how we borrow the %f0 loaded above.
195 * Also notice how this code is careful not to perform a
196 * load past the end of the src buffer.
207 ldd [%o1 + 0x00], %f0
209 1: ldd [%o1 + 0x08], %f2
213 faligndata %f0, %f2, %f8
214 std %f8, [%o0 + 0x00]
217 ldd [%o1 + 0x08], %f0
221 faligndata %f2, %f0, %f8
222 std %f8, [%o0 + 0x00]
226 /* If anything is left, we copy it one byte at a time.
227 * Note that %g1 is (src & 0x3) saved above before the
228 * alignaddr was performed.
238 bne,pn %icc, small_copy_unaligned
246 1: andcc %o2, 0x4, %g0
253 1: andcc %o2, 0x2, %g0
260 1: andcc %o2, 0x1, %g0
267 medium_copy: /* 16 < len <= 64 */
268 bne,pn %XCC, small_copy_unaligned
274 1: subcc %o4, 0x8, %o4
289 ba,pt %xcc, small_copy_unaligned
292 small_copy: /* 0 < len <= 16 */
294 bne,pn %XCC, small_copy_unaligned
301 bgu,pt %XCC, small_copy_aligned
308 small_copy_unaligned:
312 bgu,pt %XCC, small_copy_unaligned