1 /* _memcopy.c -- subroutines for memory copy functions.
2 Copyright (C) 1991, 1996, 2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Torbjorn Granlund (tege@sics.se).
5 Updated for POWER6 by Steven Munroe (sjmunroe@us.ibm.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, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 /* BE VERY CAREFUL IF YOU CHANGE THIS CODE...! */
27 /* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to
28 block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
29 Both SRCP and DSTP should be aligned for memory operations on `op_t's. */
32 _wordcopy_fwd_aligned (dstp
, srcp
, len
)
41 ((op_t
*) dstp
)[0] = ((op_t
*) srcp
)[0];
52 a0
= ((op_t
*) srcp
)[0];
53 a1
= ((op_t
*) srcp
)[1];
54 ((op_t
*) dstp
)[0] = a0
;
55 ((op_t
*) dstp
)[1] = a1
;
64 /* _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
65 block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
66 DSTP should be aligned for memory operations on `op_t's, but SRCP must
70 _wordcopy_fwd_dest_aligned (dstp
, srcp
, len
)
79 /* Calculate how to shift a word read at the memory operation
80 aligned srcp to make it aligned for copy. */
83 sh_1
= 8 * (srcp
% OPSIZ
);
84 sh_2
= 8 * OPSIZ
- sh_1
;
86 /* Make SRCP aligned by rounding it down to the beginning of the `op_t'
87 it points in the middle of. */
89 a0
= ((op_t
*) srcp
)[0];
93 a1
= ((op_t
*) srcp
)[1];
94 ((op_t
*) dstp
)[0] = MERGE (a0
, sh_1
, a1
, sh_2
);
110 a1
= ((op_t
*) srcp
)[1];
111 a2
= ((op_t
*) srcp
)[2];
112 ((op_t
*) dstp
)[0] = MERGE (a0
, 8, a1
, (32-8));
113 ((op_t
*) dstp
)[1] = MERGE (a1
, 8, a2
, (32-8));
125 a1
= ((op_t
*) srcp
)[1];
126 a2
= ((op_t
*) srcp
)[2];
127 ((op_t
*) dstp
)[0] = MERGE (a0
, 16, a1
, (32-16));
128 ((op_t
*) dstp
)[1] = MERGE (a1
, 16, a2
, (32-16));
140 a1
= ((op_t
*) srcp
)[1];
141 a2
= ((op_t
*) srcp
)[2];
142 ((op_t
*) dstp
)[0] = MERGE (a0
, 24, a1
, (32-24));
143 ((op_t
*) dstp
)[1] = MERGE (a1
, 24, a2
, (32-24));
156 /* _wordcopy_bwd_aligned -- Copy block finishing right before
157 SRCP to block finishing right before DSTP with LEN `op_t' words
158 (not LEN bytes!). Both SRCP and DSTP should be aligned for memory
159 operations on `op_t's. */
162 _wordcopy_bwd_aligned (dstp
, srcp
, len
)
173 ((op_t
*) dstp
)[0] = ((op_t
*) srcp
)[0];
185 a1
= ((op_t
*) srcp
)[1];
186 a0
= ((op_t
*) srcp
)[0];
187 ((op_t
*) dstp
)[1] = a1
;
188 ((op_t
*) dstp
)[0] = a0
;
195 /* _wordcopy_bwd_dest_aligned -- Copy block finishing right
196 before SRCP to block finishing right before DSTP with LEN `op_t'
197 words (not LEN bytes!). DSTP should be aligned for memory
198 operations on `op_t', but SRCP must *not* be aligned. */
201 _wordcopy_bwd_dest_aligned (dstp
, srcp
, len
)
210 /* Calculate how to shift a word read at the memory operation
211 aligned srcp to make it aligned for copy. */
213 align
= srcp
% OPSIZ
;
214 sh_1
= 8 * (srcp
% OPSIZ
);
215 sh_2
= 8 * OPSIZ
- sh_1
;
217 /* Make srcp aligned by rounding it down to the beginning of the op_t
218 it points in the middle of. */
220 a2
= ((op_t
*) srcp
)[0];
226 a1
= ((op_t
*) srcp
)[0];
227 ((op_t
*) dstp
)[0] = MERGE (a1
, sh_1
, a2
, sh_2
);
244 a1
= ((op_t
*) srcp
)[1];
245 a0
= ((op_t
*) srcp
)[0];
246 ((op_t
*) dstp
)[1] = MERGE (a1
, 8, a2
, (32-8));
247 ((op_t
*) dstp
)[0] = MERGE (a0
, 8, a1
, (32-8));
260 a1
= ((op_t
*) srcp
)[1];
261 a0
= ((op_t
*) srcp
)[0];
262 ((op_t
*) dstp
)[1] = MERGE (a1
, 16, a2
, (32-16));
263 ((op_t
*) dstp
)[0] = MERGE (a0
, 16, a1
, (32-16));
276 a1
= ((op_t
*) srcp
)[1];
277 a0
= ((op_t
*) srcp
)[0];
278 ((op_t
*) dstp
)[1] = MERGE (a1
, 24, a2
, (32-24));
279 ((op_t
*) dstp
)[0] = MERGE (a0
, 24, a1
, (32-24));