1 /* Optimized memcpy implementation for PowerPC476.
2 Copyright (C) 2010 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
26 r3:destination address
30 Save return address in r0.
31 If destinationn and source are unaligned and copy count is greater than 256
32 then copy 0-3 bytes to make destination aligned.
33 If 32 or more bytes to copy we use 32 byte copy loop.
34 Finaly we copy 0-31 extra bytes. */
36 EALIGN (BP_SYM (memcpy), 5, 0)
37 /* Check if bytes to copy are greater than 256 and if
38 source and destination are unaligned */
41 ble L(string_count_loop)
44 beq L(string_count_loop)
47 beq L(string_count_loop)
51 L(unaligned_bytecopy_loop): /* Align destination by coping 0-3 bytes */
56 bdnz L(unaligned_bytecopy_loop)
58 beq L(preword2_count_loop)
61 L(word8_count_loop_no_dcbt): /* Copy 32 bytes at a time */
81 bdnz L(word8_count_loop_no_dcbt)
83 L(preword2_count_loop): /* Copy remaining 0-31 bytes */
92 L(string_count_loop): /* Copy odd 0-31 bytes */
96 beq L(pre_string_copy)
103 L(pre_string_copy): /* Check how many 32 byte chunck to copy */
108 L(word4_count_loop_no_dcbt): /* Copy 32 bytes at a time */
126 bdnz L(word4_count_loop_no_dcbt)
131 END (BP_SYM (memcpy))
132 libc_hidden_builtin_def (memcpy)