[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
Fri Jan 12 01:07:16 PST 2024


================
@@ -0,0 +1,98 @@
+// REQUIRES: linux, aarch64-target-arch, sme-available
+// RUN: %clang_builtins %s %librt -o %t && %run %t
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define N 1024
+
+static uint8_t dst[N], src[N];
+
+extern void *__arm_sc_memcpy(void *, const void *, size_t);
+extern void *__arm_sc_memset(void *, int, size_t);
+extern void *__arm_sc_memmove(void *, const void *, size_t);
+extern void *__arm_sc_memchr(const void *, int, size_t);
+
+void init(void) {
+  for (int i = 0; i < N; i++) {
+    src[i] = i * 2;
+    dst[i] = i + 1;
+  }
+}
+
+void reinit_dst(int n) {
----------------
sdesmalen-arm wrote:

I think it's worth making this a .cpp file so that you can have a class with a constructor to do the `init` and have a `sum` method, rather than having to call functions like `reinit_dst`. We can reduce the sizes of the arrays a bit more to reduce runtime of the test, which makes the impact of reinitialising the entire array negligible.

In general I'd like to see a more structured way to test these routines, where we can see that some of the edge-cases are being tested. At the moment it looks like you've stripped the timing functionality from this file.

https://github.com/llvm/llvm-project/pull/77496


More information about the llvm-commits mailing list