1 /* _memcopy.c -- subroutines for memory copy functions.
2 Copyright (C) 1991, 1996 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Torbjorn Granlund (tege@sics.se).
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 /* BE VERY CAREFUL IF YOU CHANGE THIS CODE...! */
26 /* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to
27 block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
28 Both SRCP and DSTP should be aligned for memory operations on `op_t's. */
31 _wordcopy_fwd_aligned (dstp
, srcp
, len
)
41 a0
= ((op_t
*) srcp
)[0];
47 a1
= ((op_t
*) srcp
)[0];
53 a0
= ((op_t
*) srcp
)[0];
59 a1
= ((op_t
*) srcp
)[0];
65 a0
= ((op_t
*) srcp
)[0];
71 a1
= ((op_t
*) srcp
)[0];
78 if (OP_T_THRES
<= 3 * OPSIZ
&& len
== 0)
80 a0
= ((op_t
*) srcp
)[0];
85 a1
= ((op_t
*) srcp
)[0];
89 if (OP_T_THRES
<= 3 * OPSIZ
&& len
== 0)
91 goto do8
; /* No-op. */
97 a0
= ((op_t
*) srcp
)[0];
98 ((op_t
*) dstp
)[0] = a1
;
100 a1
= ((op_t
*) srcp
)[1];
101 ((op_t
*) dstp
)[1] = a0
;
103 a0
= ((op_t
*) srcp
)[2];
104 ((op_t
*) dstp
)[2] = a1
;
106 a1
= ((op_t
*) srcp
)[3];
107 ((op_t
*) dstp
)[3] = a0
;
109 a0
= ((op_t
*) srcp
)[4];
110 ((op_t
*) dstp
)[4] = a1
;
112 a1
= ((op_t
*) srcp
)[5];
113 ((op_t
*) dstp
)[5] = a0
;
115 a0
= ((op_t
*) srcp
)[6];
116 ((op_t
*) dstp
)[6] = a1
;
118 a1
= ((op_t
*) srcp
)[7];
119 ((op_t
*) dstp
)[7] = a0
;
127 /* This is the right position for do0. Please don't move
130 ((op_t
*) dstp
)[0] = a1
;
133 /* _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
134 block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
135 DSTP should be aligned for memory operations on `op_t's, but SRCP must
139 _wordcopy_fwd_dest_aligned (dstp
, srcp
, len
)
147 /* Calculate how to shift a word read at the memory operation
148 aligned srcp to make it aligned for copy. */
150 sh_1
= 8 * (srcp
% OPSIZ
);
151 sh_2
= 8 * OPSIZ
- sh_1
;
153 /* Make SRCP aligned by rounding it down to the beginning of the `op_t'
154 it points in the middle of. */
160 a1
= ((op_t
*) srcp
)[0];
161 a2
= ((op_t
*) srcp
)[1];
167 a0
= ((op_t
*) srcp
)[0];
168 a1
= ((op_t
*) srcp
)[1];
174 if (OP_T_THRES
<= 3 * OPSIZ
&& len
== 0)
176 a3
= ((op_t
*) srcp
)[0];
177 a0
= ((op_t
*) srcp
)[1];
183 a2
= ((op_t
*) srcp
)[0];
184 a3
= ((op_t
*) srcp
)[1];
188 if (OP_T_THRES
<= 3 * OPSIZ
&& len
== 0)
190 goto do4
; /* No-op. */
196 a0
= ((op_t
*) srcp
)[0];
197 ((op_t
*) dstp
)[0] = MERGE (a2
, sh_1
, a3
, sh_2
);
199 a1
= ((op_t
*) srcp
)[1];
200 ((op_t
*) dstp
)[1] = MERGE (a3
, sh_1
, a0
, sh_2
);
202 a2
= ((op_t
*) srcp
)[2];
203 ((op_t
*) dstp
)[2] = MERGE (a0
, sh_1
, a1
, sh_2
);
205 a3
= ((op_t
*) srcp
)[3];
206 ((op_t
*) dstp
)[3] = MERGE (a1
, sh_1
, a2
, sh_2
);
214 /* This is the right position for do0. Please don't move
217 ((op_t
*) dstp
)[0] = MERGE (a2
, sh_1
, a3
, sh_2
);
220 /* _wordcopy_bwd_aligned -- Copy block finishing right before
221 SRCP to block finishing right before DSTP with LEN `op_t' words
222 (not LEN bytes!). Both SRCP and DSTP should be aligned for memory
223 operations on `op_t's. */
226 _wordcopy_bwd_aligned (dstp
, srcp
, len
)
238 a0
= ((op_t
*) srcp
)[1];
244 a1
= ((op_t
*) srcp
)[2];
250 a0
= ((op_t
*) srcp
)[3];
256 a1
= ((op_t
*) srcp
)[4];
262 a0
= ((op_t
*) srcp
)[5];
268 a1
= ((op_t
*) srcp
)[6];
273 if (OP_T_THRES
<= 3 * OPSIZ
&& len
== 0)
277 a0
= ((op_t
*) srcp
)[7];
282 a1
= ((op_t
*) srcp
)[8];
284 if (OP_T_THRES
<= 3 * OPSIZ
&& len
== 0)
286 goto do8
; /* No-op. */
292 a0
= ((op_t
*) srcp
)[7];
293 ((op_t
*) dstp
)[7] = a1
;
295 a1
= ((op_t
*) srcp
)[6];
296 ((op_t
*) dstp
)[6] = a0
;
298 a0
= ((op_t
*) srcp
)[5];
299 ((op_t
*) dstp
)[5] = a1
;
301 a1
= ((op_t
*) srcp
)[4];
302 ((op_t
*) dstp
)[4] = a0
;
304 a0
= ((op_t
*) srcp
)[3];
305 ((op_t
*) dstp
)[3] = a1
;
307 a1
= ((op_t
*) srcp
)[2];
308 ((op_t
*) dstp
)[2] = a0
;
310 a0
= ((op_t
*) srcp
)[1];
311 ((op_t
*) dstp
)[1] = a1
;
313 a1
= ((op_t
*) srcp
)[0];
314 ((op_t
*) dstp
)[0] = a0
;
322 /* This is the right position for do0. Please don't move
325 ((op_t
*) dstp
)[7] = a1
;
328 /* _wordcopy_bwd_dest_aligned -- Copy block finishing right
329 before SRCP to block finishing right before DSTP with LEN `op_t'
330 words (not LEN bytes!). DSTP should be aligned for memory
331 operations on `op_t', but SRCP must *not* be aligned. */
334 _wordcopy_bwd_dest_aligned (dstp
, srcp
, len
)
342 /* Calculate how to shift a word read at the memory operation
343 aligned srcp to make it aligned for copy. */
345 sh_1
= 8 * (srcp
% OPSIZ
);
346 sh_2
= 8 * OPSIZ
- sh_1
;
348 /* Make srcp aligned by rounding it down to the beginning of the op_t
349 it points in the middle of. */
358 a2
= ((op_t
*) srcp
)[2];
359 a1
= ((op_t
*) srcp
)[1];
365 a3
= ((op_t
*) srcp
)[3];
366 a2
= ((op_t
*) srcp
)[2];
370 if (OP_T_THRES
<= 3 * OPSIZ
&& len
== 0)
374 a0
= ((op_t
*) srcp
)[4];
375 a3
= ((op_t
*) srcp
)[3];
380 a1
= ((op_t
*) srcp
)[5];
381 a0
= ((op_t
*) srcp
)[4];
383 if (OP_T_THRES
<= 3 * OPSIZ
&& len
== 0)
385 goto do4
; /* No-op. */
391 a3
= ((op_t
*) srcp
)[3];
392 ((op_t
*) dstp
)[3] = MERGE (a0
, sh_1
, a1
, sh_2
);
394 a2
= ((op_t
*) srcp
)[2];
395 ((op_t
*) dstp
)[2] = MERGE (a3
, sh_1
, a0
, sh_2
);
397 a1
= ((op_t
*) srcp
)[1];
398 ((op_t
*) dstp
)[1] = MERGE (a2
, sh_1
, a3
, sh_2
);
400 a0
= ((op_t
*) srcp
)[0];
401 ((op_t
*) dstp
)[0] = MERGE (a1
, sh_1
, a2
, sh_2
);
409 /* This is the right position for do0. Please don't move
412 ((op_t
*) dstp
)[3] = MERGE (a0
, sh_1
, a1
, sh_2
);