1 /* _memcopy.c -- subroutines for memory copy functions.
2 Copyright (C) 1991-2012 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, see
19 <http://www.gnu.org/licenses/>. */
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
68 #define fwd_align_merge(align) \
71 a1 = ((op_t *) srcp)[1]; \
72 a2 = ((op_t *) srcp)[2]; \
73 ((op_t *) dstp)[0] = MERGE (a0, align*8, a1, (32-align*8)); \
74 ((op_t *) dstp)[1] = MERGE (a1, align*8, a2, (32-align*8)); \
83 _wordcopy_fwd_dest_aligned (dstp
, srcp
, len
)
92 /* Calculate how to shift a word read at the memory operation
93 aligned srcp to make it aligned for copy. */
96 sh_1
= 8 * (srcp
% OPSIZ
);
97 sh_2
= 8 * OPSIZ
- sh_1
;
99 /* Make SRCP aligned by rounding it down to the beginning of the `op_t'
100 it points in the middle of. */
102 a0
= ((op_t
*) srcp
)[0];
106 a1
= ((op_t
*) srcp
)[1];
107 ((op_t
*) dstp
)[0] = MERGE (a0
, sh_1
, a1
, sh_2
);
133 /* _wordcopy_bwd_aligned -- Copy block finishing right before
134 SRCP to block finishing right before DSTP with LEN `op_t' words
135 (not LEN bytes!). Both SRCP and DSTP should be aligned for memory
136 operations on `op_t's. */
139 _wordcopy_bwd_aligned (dstp
, srcp
, len
)
150 ((op_t
*) dstp
)[0] = ((op_t
*) srcp
)[0];
162 a1
= ((op_t
*) srcp
)[1];
163 a0
= ((op_t
*) srcp
)[0];
164 ((op_t
*) dstp
)[1] = a1
;
165 ((op_t
*) dstp
)[0] = a0
;
172 #define bwd_align_merge(align) \
177 a1 = ((op_t *) srcp)[1]; \
178 a0 = ((op_t *) srcp)[0]; \
179 ((op_t *) dstp)[1] = MERGE (a1, align*8, a2, (32-align*8)); \
180 ((op_t *) dstp)[0] = MERGE (a0, align*8, a1, (32-align*8)); \
186 /* _wordcopy_bwd_dest_aligned -- Copy block finishing right
187 before SRCP to block finishing right before DSTP with LEN `op_t'
188 words (not LEN bytes!). DSTP should be aligned for memory
189 operations on `op_t', but SRCP must *not* be aligned. */
192 _wordcopy_bwd_dest_aligned (dstp
, srcp
, len
)
201 /* Calculate how to shift a word read at the memory operation
202 aligned srcp to make it aligned for copy. */
204 align
= srcp
% OPSIZ
;
205 sh_1
= 8 * (srcp
% OPSIZ
);
206 sh_2
= 8 * OPSIZ
- sh_1
;
208 /* Make srcp aligned by rounding it down to the beginning of the op_t
209 it points in the middle of. */
211 a2
= ((op_t
*) srcp
)[0];
217 a1
= ((op_t
*) srcp
)[0];
218 ((op_t
*) dstp
)[0] = MERGE (a1
, sh_1
, a2
, sh_2
);