1 /* Optimized memcpy implementation for PowerPC476.
2 Copyright (C) 2010-2023 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 <https://www.gnu.org/licenses/>. */
24 r3:destination address
28 Save return address in r0.
29 If destinationn and source are unaligned and copy count is greater than 256
30 then copy 0-3 bytes to make destination aligned.
31 If 32 or more bytes to copy we use 32 byte copy loop.
32 Finaly we copy 0-31 extra bytes. */
35 /* Check if bytes to copy are greater than 256 and if
36 source and destination are unaligned */
39 ble L(string_count_loop)
42 beq L(string_count_loop)
45 beq L(string_count_loop)
49 L(unaligned_bytecopy_loop): /* Align destination by coping 0-3 bytes */
54 bdnz L(unaligned_bytecopy_loop)
56 beq L(preword2_count_loop)
59 L(word8_count_loop_no_dcbt): /* Copy 32 bytes at a time */
79 bdnz L(word8_count_loop_no_dcbt)
81 L(preword2_count_loop): /* Copy remaining 0-31 bytes */
90 L(string_count_loop): /* Copy odd 0-31 bytes */
94 beq L(pre_string_copy)
101 L(pre_string_copy): /* Check how many 32 byte chunks to copy */
106 L(word4_count_loop_no_dcbt): /* Copy 32 bytes at a time */
124 bdnz L(word4_count_loop_no_dcbt)
130 libc_hidden_builtin_def (memcpy)