1 /* MN10300 Optimised simple memory to memory copy
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #include <asm/cache.h>
14 .balign L1_CACHE_BYTES
16 ###############################################################################
18 # void *memcpy(void *dst, const void *src, size_t n)
20 ###############################################################################
22 .type memcpy,@function
27 mov (20,sp),d2 # count
30 mov d0,e3 # the return value
33 beq memcpy_done # return if zero-length copy
35 # see if the three parameters are all four-byte aligned
39 bne memcpy_1 # jump if not
41 # we want to transfer as much as we can in chunks of 32 bytes
43 bls memcpy_4_remainder # 4-byte aligned remainder
72 beq memcpy_4_no_remainder
75 # cut 4-7 words down to 0-3
77 bcs memcpy_4_three_or_fewer_words
87 beq memcpy_4_no_remainder
89 # copy the remaining 1, 2 or 3 words
90 memcpy_4_three_or_fewer_words:
93 beq memcpy_4_two_words
103 memcpy_4_no_remainder:
104 # check we copied the correct amount
118 # handle misaligned copying
122 setlb # setlb requires the next insns
123 # to occupy exactly 4 bytes
135 .size memcpy, memcpy_end-memcpy