1 /* MN10300 Optimised simple memory to memory copy, with support for overlapping
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public Licence
9 * as published by the Free Software Foundation; either version
10 * 2 of the Licence, or (at your option) any later version.
12 #include <asm/cache.h>
15 .balign L1_CACHE_BYTES
17 ###############################################################################
19 # void *memmove(void *dst, const void *src, size_t n)
21 ###############################################################################
23 .type memmove,@function
25 # fall back to memcpy if dst < src to work bottom up
33 mov (20,sp),d2 # count
34 add d0,d2,a0 # dst end
35 add d1,d2,a1 # src end
36 mov d0,e3 # the return value
39 beq memmove_done # return if zero-length copy
41 # see if the three parameters are all four-byte aligned
45 bne memmove_1 # jump if not
47 # we want to transfer as much as we can in chunks of 32 bytes
50 bls memmove_4_remainder # 4-byte aligned remainder
88 beq memmove_4_no_remainder
91 # cut 4-7 words down to 0-3
93 bcs memmove_4_three_or_fewer_words
107 beq memmove_4_no_remainder
109 # copy the remaining 1, 2 or 3 words
110 memmove_4_three_or_fewer_words:
112 bcs memmove_4_one_word
113 beq memmove_4_two_words
126 memmove_4_no_remainder:
127 # check we copied the correct amount
139 # handle misaligned copying
144 setlb # setlb requires the next insns
145 # to occupy exactly 4 bytes
160 .size memmove, memmove_end-memmove