1 /* Copy SIZE bytes from SRC to DEST.
3 Copyright (C) 2001-2015 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
35 .register %g2,#scratch
36 .register %g3,#scratch
37 .register %g6,#scratch
41 ENTRY(__mempcpy_ultra3)
46 /* Special/non-trivial issues of this code:
48 * 1) %o5 is preserved from VISEntryHalf to VISExitHalf
49 * 2) Only low 32 FPU registers are used so that only the
50 * lower half of the FPU register set is dirtied by this
51 * code. This is especially important in the kernel.
52 * 3) This code never prefetches cachelines past the end
53 * of the source buffer.
55 * The cheetah's flexible spine, oversized liver, enlarged heart,
56 * slender muscular body, and claws make it the swiftest hunter
57 * in Africa and the fastest animal on land. Can reach speeds
58 * of up to 2.4GB per second.
61 ENTRY(__memcpy_ultra3)
63 100: /* %o0=dst, %o1=src, %o2=len */
70 bleu,a,pn %XCC, small_copy
74 blu,pt %XCC, medium_copy
80 /* Here len >= 256 and condition codes reflect execution
81 * of "andcc %o0, 0x7, %g2", done by caller.
85 /* Is 'dst' already aligned on an 64-byte boundary? */
88 /* Compute abs((dst & 0x3f) - 0x40) into %g2. This is the number
89 * of bytes to copy to make 'dst' 64-byte aligned. We pre-
90 * subtract this from 'len'.
96 /* Copy %g2 bytes from src to dst, one byte at a time. */
97 1: ldub [%o1 + 0x00], %o3
108 alignaddr %o1, %g0, %o1
112 prefetch [%o1 + 0x000], #one_read
113 prefetch [%o1 + 0x040], #one_read
114 andn %o2, (0x40 - 1), %o4
115 prefetch [%o1 + 0x080], #one_read
116 prefetch [%o1 + 0x0c0], #one_read
117 ldd [%o1 + 0x000], %f0
118 prefetch [%o1 + 0x100], #one_read
119 ldd [%o1 + 0x008], %f2
120 prefetch [%o1 + 0x140], #one_read
121 ldd [%o1 + 0x010], %f4
122 prefetch [%o1 + 0x180], #one_read
123 faligndata %f0, %f2, %f16
124 ldd [%o1 + 0x018], %f6
125 faligndata %f2, %f4, %f18
126 ldd [%o1 + 0x020], %f8
127 faligndata %f4, %f6, %f20
128 ldd [%o1 + 0x028], %f10
129 faligndata %f6, %f8, %f22
131 ldd [%o1 + 0x030], %f12
132 faligndata %f8, %f10, %f24
133 ldd [%o1 + 0x038], %f14
134 faligndata %f10, %f12, %f26
135 ldd [%o1 + 0x040], %f0
144 ldd [%o1 + 0x008], %f2
145 faligndata %f12, %f14, %f28
146 ldd [%o1 + 0x010], %f4
147 faligndata %f14, %f0, %f30
148 stda %f16, [%o0] ASI_BLK_P
149 ldd [%o1 + 0x018], %f6
150 faligndata %f0, %f2, %f16
152 ldd [%o1 + 0x020], %f8
153 faligndata %f2, %f4, %f18
154 ldd [%o1 + 0x028], %f10
155 faligndata %f4, %f6, %f20
156 ldd [%o1 + 0x030], %f12
157 faligndata %f6, %f8, %f22
158 ldd [%o1 + 0x038], %f14
159 faligndata %f8, %f10, %f24
161 ldd [%o1 + 0x040], %f0
162 prefetch [%o1 + 0x180], #one_read
163 faligndata %f10, %f12, %f26
169 /* Finally we copy the last full 64-byte block. */
171 ldd [%o1 + 0x008], %f2
172 faligndata %f12, %f14, %f28
173 ldd [%o1 + 0x010], %f4
174 faligndata %f14, %f0, %f30
175 stda %f16, [%o0] ASI_BLK_P
176 ldd [%o1 + 0x018], %f6
177 faligndata %f0, %f2, %f16
178 ldd [%o1 + 0x020], %f8
179 faligndata %f2, %f4, %f18
180 ldd [%o1 + 0x028], %f10
181 faligndata %f4, %f6, %f20
182 ldd [%o1 + 0x030], %f12
183 faligndata %f6, %f8, %f22
184 ldd [%o1 + 0x038], %f14
185 faligndata %f8, %f10, %f24
189 ldd [%o1 + 0x040], %f0
190 1: faligndata %f10, %f12, %f26
191 faligndata %f12, %f14, %f28
192 faligndata %f14, %f0, %f30
193 stda %f16, [%o0] ASI_BLK_P
198 /* Now we copy the (len modulo 64) bytes at the end.
199 * Note how we borrow the %f0 loaded above.
201 * Also notice how this code is careful not to perform a
202 * load past the end of the src buffer.
213 ldd [%o1 + 0x00], %f0
215 1: ldd [%o1 + 0x08], %f2
219 faligndata %f0, %f2, %f8
220 std %f8, [%o0 + 0x00]
223 ldd [%o1 + 0x08], %f0
227 faligndata %f2, %f0, %f8
228 std %f8, [%o0 + 0x00]
232 /* If anything is left, we copy it one byte at a time.
233 * Note that %g1 is (src & 0x3) saved above before the
234 * alignaddr was performed.
244 bne,pn %icc, small_copy_unaligned
252 1: andcc %o2, 0x4, %g0
259 1: andcc %o2, 0x2, %g0
266 1: andcc %o2, 0x1, %g0
273 medium_copy: /* 16 < len <= 64 */
274 bne,pn %XCC, small_copy_unaligned
280 1: subcc %o4, 0x8, %o4
295 ba,pt %xcc, small_copy_unaligned
298 small_copy: /* 0 < len <= 16 */
300 bne,pn %XCC, small_copy_unaligned
307 bgu,pt %XCC, small_copy_aligned
314 small_copy_unaligned:
318 bgu,pt %XCC, small_copy_unaligned