[compiler-rt] [AArch64][compiler-rt] Add memcpy, memset, memmove, memchr simple imp… (PR #77496)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 10 07:08:04 PST 2024
================
@@ -0,0 +1,102 @@
+#include <stdlib.h>
+
+// WARNING: When building the scalar versions of these functions you need to
+// use the compiler flag "-mllvm -disable-loop-idiom-all" to prevent clang
+// from recognising a loop idiom and planting calls to memcpy!
+
+static void *
+__arm_sc_memcpy_fwd(void *dest, const void *src,
+ size_t n) __arm_streaming_compatible __arm_preserves_za {
+ unsigned char *destp = (unsigned char *)dest;
+ const unsigned char *srcp = (const unsigned char *)src;
+
+ for (size_t i = 0; i < n; i++) {
+ destp[i] = srcp[i];
+ }
+
+ return dest;
+}
+
+// If dest and src overlap then behaviour is undefined, hence we can add the
+// restrict keywords here. This also matches the definition of the libc memcpy
+// according to the man page.
+void *__arm_sc_memcpy(void *__restrict__ dest, const void *__restrict__ src,
+ size_t n) __arm_streaming_compatible __arm_preserves_za {
----------------
sdesmalen-arm wrote:
The compiler building compiler-rt may not support `__arm_streaming_compatible`. You'll want to check for the SME attributes when configuring the project with cmake.
I'd also suggest removing `__arm_preserves_za` in anticipation of [this ACLE PR](https://github.com/ARM-software/acle/pull/276/files#diff-516526d4a18101dc85300bc2033d0f86dc46c505b7510a7694baabea851aedfaR11872) landing.
https://github.com/llvm/llvm-project/pull/77496
More information about the llvm-commits
mailing list