You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/06/07 19:50:06 UTC

[GitHub] andrzej-kaczmarek closed pull request #1170: libc/baselibc: Add optimized memcpy() for Cortex-M

andrzej-kaczmarek closed pull request #1170: libc/baselibc: Add optimized memcpy() for Cortex-M
URL: https://github.com/apache/mynewt-core/pull/1170
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/libc/baselibc/src/memcpy.c b/libc/baselibc/src/memcpy.c
index 5ce206d042..a389739bed 100644
--- a/libc/baselibc/src/memcpy.c
+++ b/libc/baselibc/src/memcpy.c
@@ -19,6 +19,32 @@ void *memcpy(void *dst, const void *src, size_t n)
 	asm volatile ("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb":"+c"
 		      (nq), "+S"(p), "+D"(q)
 		      :"r"((uint32_t) (n & 7)));
+#elif defined(ARCH_cortex_m0) || defined(ARCH_cortex_m3) || defined(ARCH_cortex_m4) || defined(ARCH_cortex_m7)
+        (void)p;
+        (void)q;
+
+#if defined(ARCH_cortex_m3) || defined(ARCH_cortex_m4) || defined(ARCH_cortex_m7)
+        /*
+         * For Cortex-M3/4/7 we can speed up a bit by moving 32-bit words since
+         * it supports unaligned access.
+         */
+        asm (".syntax unified           \n"
+             "       b    test1         \n"
+             "loop1: ldr  r3, [r1, r2]  \n"
+             "       str  r3, [r0, r2]  \n"
+             "test1: subs r2, #4        \n"
+             "       bpl  loop1         \n"
+             "       add  r2, #4        \n"
+            );
+#endif
+
+        asm (".syntax unified           \n"
+             "       b    test2         \n"
+             "loop2: ldrb r3, [r1, r2]  \n"
+             "       strb r3, [r0, r2]  \n"
+             "test2: subs r2, #1        \n"
+             "       bpl  loop2         \n"
+            );
 #else
 	while (n--) {
 		*q++ = *p++;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services