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, see
18 <http://www.gnu.org/licenses/>. */
20 /* BE VERY CAREFUL IF YOU CHANGE THIS CODE...! */
25 /* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to
26 block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
27 Both SRCP and DSTP should be aligned for memory operations on `op_t's. */
30 _wordcopy_fwd_aligned (dstp
, srcp
, len
)
39 ((op_t
*) dstp
)[0] = ((op_t
*) srcp
)[0];
50 a0
= ((op_t
*) srcp
)[0];
51 a1
= ((op_t
*) srcp
)[1];
52 ((op_t
*) dstp
)[0] = a0
;
53 ((op_t
*) dstp
)[1] = a1
;
62 /* _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
63 block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
64 DSTP should be aligned for memory operations on `op_t's, but SRCP must
68 _wordcopy_fwd_dest_aligned (dstp
, srcp
, len
)
77 /* Calculate how to shift a word read at the memory operation
78 aligned srcp to make it aligned for copy. */
81 sh_1
= 8 * (srcp
% OPSIZ
);
82 sh_2
= 8 * OPSIZ
- sh_1
;
84 /* Make SRCP aligned by rounding it down to the beginning of the `op_t'
85 it points in the middle of. */
87 a0
= ((op_t
*) srcp
)[0];
91 a1
= ((op_t
*) srcp
)[1];
92 ((op_t
*) dstp
)[0] = MERGE (a0
, sh_1
, a1
, sh_2
);
108 a1
= ((op_t
*) srcp
)[1];
109 a2
= ((op_t
*) srcp
)[2];
110 ((op_t
*) dstp
)[0] = MERGE (a0
, 8, a1
, (64-8));
111 ((op_t
*) dstp
)[1] = MERGE (a1
, 8, a2
, (64-8));
123 a1
= ((op_t
*) srcp
)[1];
124 a2
= ((op_t
*) srcp
)[2];
125 ((op_t
*) dstp
)[0] = MERGE (a0
, 16, a1
, (64-16));
126 ((op_t
*) dstp
)[1] = MERGE (a1
, 16, a2
, (64-16));
138 a1
= ((op_t
*) srcp
)[1];
139 a2
= ((op_t
*) srcp
)[2];
140 ((op_t
*) dstp
)[0] = MERGE (a0
, 24, a1
, (64-24));
141 ((op_t
*) dstp
)[1] = MERGE (a1
, 24, a2
, (64-24));
153 a1
= ((op_t
*) srcp
)[1];
154 a2
= ((op_t
*) srcp
)[2];
155 ((op_t
*) dstp
)[0] = MERGE (a0
, 32, a1
, (64-32));
156 ((op_t
*) dstp
)[1] = MERGE (a1
, 32, a2
, (64-32));
168 a1
= ((op_t
*) srcp
)[1];
169 a2
= ((op_t
*) srcp
)[2];
170 ((op_t
*) dstp
)[0] = MERGE (a0
, 40, a1
, (64-40));
171 ((op_t
*) dstp
)[1] = MERGE (a1
, 40, a2
, (64-40));
183 a1
= ((op_t
*) srcp
)[1];
184 a2
= ((op_t
*) srcp
)[2];
185 ((op_t
*) dstp
)[0] = MERGE (a0
, 48, a1
, (64-48));
186 ((op_t
*) dstp
)[1] = MERGE (a1
, 48, a2
, (64-48));
198 a1
= ((op_t
*) srcp
)[1];
199 a2
= ((op_t
*) srcp
)[2];
200 ((op_t
*) dstp
)[0] = MERGE (a0
, 56, a1
, (64-56));
201 ((op_t
*) dstp
)[1] = MERGE (a1
, 56, a2
, (64-56));
214 /* _wordcopy_bwd_aligned -- Copy block finishing right before
215 SRCP to block finishing right before DSTP with LEN `op_t' words
216 (not LEN bytes!). Both SRCP and DSTP should be aligned for memory
217 operations on `op_t's. */
220 _wordcopy_bwd_aligned (dstp
, srcp
, len
)
231 ((op_t
*) dstp
)[0] = ((op_t
*) srcp
)[0];
243 a1
= ((op_t
*) srcp
)[1];
244 a0
= ((op_t
*) srcp
)[0];
245 ((op_t
*) dstp
)[1] = a1
;
246 ((op_t
*) dstp
)[0] = a0
;
253 /* _wordcopy_bwd_dest_aligned -- Copy block finishing right
254 before SRCP to block finishing right before DSTP with LEN `op_t'
255 words (not LEN bytes!). DSTP should be aligned for memory
256 operations on `op_t', but SRCP must *not* be aligned. */
259 _wordcopy_bwd_dest_aligned (dstp
, srcp
, len
)
268 /* Calculate how to shift a word read at the memory operation
269 aligned srcp to make it aligned for copy. */
271 align
= srcp
% OPSIZ
;
272 sh_1
= 8 * (srcp
% OPSIZ
);
273 sh_2
= 8 * OPSIZ
- sh_1
;
275 /* Make srcp aligned by rounding it down to the beginning of the op_t
276 it points in the middle of. */
278 a2
= ((op_t
*) srcp
)[0];
284 a1
= ((op_t
*) srcp
)[0];
285 ((op_t
*) dstp
)[0] = MERGE (a1
, sh_1
, a2
, sh_2
);
302 a1
= ((op_t
*) srcp
)[1];
303 a0
= ((op_t
*) srcp
)[0];
304 ((op_t
*) dstp
)[1] = MERGE (a1
, 8, a2
, (64-8));
305 ((op_t
*) dstp
)[0] = MERGE (a0
, 8, a1
, (64-8));
318 a1
= ((op_t
*) srcp
)[1];
319 a0
= ((op_t
*) srcp
)[0];
320 ((op_t
*) dstp
)[1] = MERGE (a1
, 16, a2
, (64-16));
321 ((op_t
*) dstp
)[0] = MERGE (a0
, 16, a1
, (64-16));
334 a1
= ((op_t
*) srcp
)[1];
335 a0
= ((op_t
*) srcp
)[0];
336 ((op_t
*) dstp
)[1] = MERGE (a1
, 24, a2
, (64-24));
337 ((op_t
*) dstp
)[0] = MERGE (a0
, 24, a1
, (64-24));
350 a1
= ((op_t
*) srcp
)[1];
351 a0
= ((op_t
*) srcp
)[0];
352 ((op_t
*) dstp
)[1] = MERGE (a1
, 32, a2
, (64-32));
353 ((op_t
*) dstp
)[0] = MERGE (a0
, 32, a1
, (64-32));
366 a1
= ((op_t
*) srcp
)[1];
367 a0
= ((op_t
*) srcp
)[0];
368 ((op_t
*) dstp
)[1] = MERGE (a1
, 40, a2
, (64-40));
369 ((op_t
*) dstp
)[0] = MERGE (a0
, 40, a1
, (64-40));
382 a1
= ((op_t
*) srcp
)[1];
383 a0
= ((op_t
*) srcp
)[0];
384 ((op_t
*) dstp
)[1] = MERGE (a1
, 48, a2
, (64-48));
385 ((op_t
*) dstp
)[0] = MERGE (a0
, 48, a1
, (64-48));
398 a1
= ((op_t
*) srcp
)[1];
399 a0
= ((op_t
*) srcp
)[0];
400 ((op_t
*) dstp
)[1] = MERGE (a1
, 56, a2
, (64-56));
401 ((op_t
*) dstp
)[0] = MERGE (a0
, 56, a1
, (64-56));