diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2016-04-21 01:25:29 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-06-30 03:24:42 +0200 |
commit | ee92c0fe5c1b9d59508273916e2c9a75b68dbc13 (patch) | |
tree | 65a22258b12f84325910fc2ad47e2b02696ef593 /libc/string/nds32/memcpy.S | |
parent | dd46699e46decb7273f44dc2cbf307f096dc39e8 (diff) |
nds32: add support for new architecture
Add support for Andes Technology NDS32 architecture.
See here http://www.andestech.com/en/index/index.htm for more
informaton. Verification of the port from an older uClibc
port was done on a sponsored AG101p board.
The testsuite only has 5 errors, three are related to
an existing bug in dlclose() with LT.old, also happening
on cris32 and m68k.
Failures to fallocate/posix_fallocate are unresolved.
Thanks to Andes Technology sponsoring the hardware and
being very helpful while doing the uClibc-ng porting.
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Diffstat (limited to 'libc/string/nds32/memcpy.S')
-rw-r--r-- | libc/string/nds32/memcpy.S | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/libc/string/nds32/memcpy.S b/libc/string/nds32/memcpy.S new file mode 100644 index 000000000..4f285b5ee --- /dev/null +++ b/libc/string/nds32/memcpy.S @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2016 Andes Technology, Inc. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sysdep.h> +!========================================================== +! void *memcpy(void *dst, const void *src, int n); +! +! dst: $r0 +! src: $r1 +! n : $r2 +! ret: $r0 - pointer to the memory area dst. +!========================================================== +.weak memcpy +ENTRY(memcpy) + move $r5, $r0 + beq $r0, $r1, .Lquit_memcpy + beqz $r2, .Lquit_memcpy + srli $r3, $r2, #5 ! check if len < cache-line size 32 + beqz $r3, .Lword_copy_entry + andi $r4, $r0, #0x3 ! check byte-align + beqz $r4, .Lunalign_word_copy_entry + + addi $r4, $r4, #-4 + abs $r4, $r4 ! check how many un-align byte to copy + sub $r2, $r2, $r4 ! update $R2 + +.Lunalign_byte_copy: + lbi.bi $r3, [$r1], #1 + addi $r4, $r4, #-1 + sbi.bi $r3, [$r0], #1 + bnez $r4, .Lunalign_byte_copy + beqz $r2, .Lquit_memcpy + +.Lunalign_word_copy_entry: + andi $r3, $r0, 0x1f ! check cache-line unaligncount + beqz $r3, .Lcache_copy + + addi $r3, $r3, #-32 + abs $r3, $r3 + sub $r2, $r2, $r3 ! update $R2 + +.Lunalign_word_copy: + lmw.bim $r4, [$r1], $r4 + addi $r3, $r3, #-4 + smw.bim $r4, [$r0], $r4 + bnez $r3, .Lunalign_word_copy + beqz $r2, .Lquit_memcpy + + addi $r3, $r2, #-32 ! to check $r2 < cache_line, than go to .Lword_copy + bltz $r3, .Lword_copy_entry +.Lcache_copy: + srli $r3, $r2, #5 + beqz $r3, .Lword_copy_entry + pushm $r6, $r13 +.L3: + lmw.bim $r6, [$r1], $r13 + addi $r3, $r3, #-1 + smw.bim $r6, [$r0], $r13 + bnez $r3, .L3 + popm $r6, $r13 + +.Lword_copy_entry: + andi $r2, $r2, #31 + beqz $r2, .Lquit_memcpy + srli $r3, $r2, #2 + beqz $r3, .Lbyte_copy +.Lword_copy: + lmw.bim $r4, [$r1], $r4 + addi $r3, $r3, #-1 + smw.bim $r4, [$r0], $r4 + bnez $r3, .Lword_copy + andi $r2, $r2, #3 + beqz $r2, .Lquit_memcpy + +.Lbyte_copy: + lbi.bi $r3, [$r1], #1 + addi $r2, $r2, #-1 + sbi.bi $r3, [$r0], #1 + bnez $r2, .Lbyte_copy + +.Lquit_memcpy: + move $r0, $r5 + ret + +END(memcpy) +libc_hidden_def(memcpy) |