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
)
40 ((op_t
*) dstp
)[0] = ((op_t
*) srcp
)[0];
51 a0
= ((op_t
*) srcp
)[0];
52 a1
= ((op_t
*) srcp
)[1];
53 ((op_t
*) dstp
)[0] = a0
;
54 ((op_t
*) dstp
)[1] = a1
;
63 /* _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
64 block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
65 DSTP should be aligned for memory operations on `op_t's, but SRCP must
69 _wordcopy_fwd_dest_aligned (dstp
, srcp
, len
)
78 /* Calculate how to shift a word read at the memory operation
79 aligned srcp to make it aligned for copy. */
82 sh_1
= 8 * (srcp
% OPSIZ
);
83 sh_2
= 8 * OPSIZ
- sh_1
;
85 /* Make SRCP aligned by rounding it down to the beginning of the `op_t'
86 it points in the middle of. */
88 a0
= ((op_t
*) srcp
)[0];
92 a1
= ((op_t
*) srcp
)[1];
93 ((op_t
*) dstp
)[0] = MERGE (a0
, sh_1
, a1
, sh_2
);
109 a1
= ((op_t
*) srcp
)[1];
110 a2
= ((op_t
*) srcp
)[2];
111 ((op_t
*) dstp
)[0] = MERGE (a0
, 8, a1
, (64-8));
112 ((op_t
*) dstp
)[1] = MERGE (a1
, 8, a2
, (64-8));
124 a1
= ((op_t
*) srcp
)[1];
125 a2
= ((op_t
*) srcp
)[2];
126 ((op_t
*) dstp
)[0] = MERGE (a0
, 16, a1
, (64-16));
127 ((op_t
*) dstp
)[1] = MERGE (a1
, 16, a2
, (64-16));
139 a1
= ((op_t
*) srcp
)[1];
140 a2
= ((op_t
*) srcp
)[2];
141 ((op_t
*) dstp
)[0] = MERGE (a0
, 24, a1
, (64-24));
142 ((op_t
*) dstp
)[1] = MERGE (a1
, 24, a2
, (64-24));
154 a1
= ((op_t
*) srcp
)[1];
155 a2
= ((op_t
*) srcp
)[2];
156 ((op_t
*) dstp
)[0] = MERGE (a0
, 32, a1
, (64-32));
157 ((op_t
*) dstp
)[1] = MERGE (a1
, 32, a2
, (64-32));
169 a1
= ((op_t
*) srcp
)[1];
170 a2
= ((op_t
*) srcp
)[2];
171 ((op_t
*) dstp
)[0] = MERGE (a0
, 40, a1
, (64-40));
172 ((op_t
*) dstp
)[1] = MERGE (a1
, 40, a2
, (64-40));
184 a1
= ((op_t
*) srcp
)[1];
185 a2
= ((op_t
*) srcp
)[2];
186 ((op_t
*) dstp
)[0] = MERGE (a0
, 48, a1
, (64-48));
187 ((op_t
*) dstp
)[1] = MERGE (a1
, 48, a2
, (64-48));
199 a1
= ((op_t
*) srcp
)[1];
200 a2
= ((op_t
*) srcp
)[2];
201 ((op_t
*) dstp
)[0] = MERGE (a0
, 56, a1
, (64-56));
202 ((op_t
*) dstp
)[1] = MERGE (a1
, 56, a2
, (64-56));
215 /* _wordcopy_bwd_aligned -- Copy block finishing right before
216 SRCP to block finishing right before DSTP with LEN `op_t' words
217 (not LEN bytes!). Both SRCP and DSTP should be aligned for memory
218 operations on `op_t's. */
221 _wordcopy_bwd_aligned (dstp
, srcp
, len
)
232 ((op_t
*) dstp
)[0] = ((op_t
*) srcp
)[0];
244 a1
= ((op_t
*) srcp
)[1];
245 a0
= ((op_t
*) srcp
)[0];
246 ((op_t
*) dstp
)[1] = a1
;
247 ((op_t
*) dstp
)[0] = a0
;
254 /* _wordcopy_bwd_dest_aligned -- Copy block finishing right
255 before SRCP to block finishing right before DSTP with LEN `op_t'
256 words (not LEN bytes!). DSTP should be aligned for memory
257 operations on `op_t', but SRCP must *not* be aligned. */
260 _wordcopy_bwd_dest_aligned (dstp
, srcp
, len
)
269 /* Calculate how to shift a word read at the memory operation
270 aligned srcp to make it aligned for copy. */
272 align
= srcp
% OPSIZ
;
273 sh_1
= 8 * (srcp
% OPSIZ
);
274 sh_2
= 8 * OPSIZ
- sh_1
;
276 /* Make srcp aligned by rounding it down to the beginning of the op_t
277 it points in the middle of. */
279 a2
= ((op_t
*) srcp
)[0];
285 a1
= ((op_t
*) srcp
)[0];
286 ((op_t
*) dstp
)[0] = MERGE (a1
, sh_1
, a2
, sh_2
);
303 a1
= ((op_t
*) srcp
)[1];
304 a0
= ((op_t
*) srcp
)[0];
305 ((op_t
*) dstp
)[1] = MERGE (a1
, 8, a2
, (64-8));
306 ((op_t
*) dstp
)[0] = MERGE (a0
, 8, a1
, (64-8));
319 a1
= ((op_t
*) srcp
)[1];
320 a0
= ((op_t
*) srcp
)[0];
321 ((op_t
*) dstp
)[1] = MERGE (a1
, 16, a2
, (64-16));
322 ((op_t
*) dstp
)[0] = MERGE (a0
, 16, a1
, (64-16));
335 a1
= ((op_t
*) srcp
)[1];
336 a0
= ((op_t
*) srcp
)[0];
337 ((op_t
*) dstp
)[1] = MERGE (a1
, 24, a2
, (64-24));
338 ((op_t
*) dstp
)[0] = MERGE (a0
, 24, a1
, (64-24));
351 a1
= ((op_t
*) srcp
)[1];
352 a0
= ((op_t
*) srcp
)[0];
353 ((op_t
*) dstp
)[1] = MERGE (a1
, 32, a2
, (64-32));
354 ((op_t
*) dstp
)[0] = MERGE (a0
, 32, a1
, (64-32));
367 a1
= ((op_t
*) srcp
)[1];
368 a0
= ((op_t
*) srcp
)[0];
369 ((op_t
*) dstp
)[1] = MERGE (a1
, 40, a2
, (64-40));
370 ((op_t
*) dstp
)[0] = MERGE (a0
, 40, a1
, (64-40));
383 a1
= ((op_t
*) srcp
)[1];
384 a0
= ((op_t
*) srcp
)[0];
385 ((op_t
*) dstp
)[1] = MERGE (a1
, 48, a2
, (64-48));
386 ((op_t
*) dstp
)[0] = MERGE (a0
, 48, a1
, (64-48));
399 a1
= ((op_t
*) srcp
)[1];
400 a0
= ((op_t
*) srcp
)[0];
401 ((op_t
*) dstp
)[1] = MERGE (a1
, 56, a2
, (64-56));
402 ((op_t
*) dstp
)[0] = MERGE (a0
, 56, a1
, (64-56));