Skip to content

Commit afdaba6

Browse files
committed
[compiler-rt] Support aarch64 targets without FPU
Fall back to the old C implementation of __arm_sc_memset when the target doesn't have an FPU. Signed-off-by: Keith Packard <[email protected]>
1 parent 08ed820 commit afdaba6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

compiler-rt/lib/builtins/aarch64/sme-libc-mem-routines.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
#include "../assembly.h"
88

9-
#ifdef __aarch64__
10-
119
#define L(l) .L ## l
1210

1311
//
@@ -238,6 +236,7 @@ END_COMPILERRT_OUTLINE_FUNCTION(__arm_sc_memcpy)
238236

239237
DEFINE_COMPILERRT_FUNCTION_ALIAS(__arm_sc_memmove, __arm_sc_memcpy)
240238

239+
#if defined(__aarch64__) && __ARM_FP != 0
241240

242241
//
243242
// __arm_sc_memset

compiler-rt/lib/builtins/aarch64/sme-libc-routines.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
#include <stddef.h>
22

3+
#if __ARM_FP == 0
4+
// WARNING: When building the scalar versions of these functions you need to
5+
// use the compiler flag "-mllvm -disable-loop-idiom-all" to prevent clang
6+
// from recognising a loop idiom and planting calls to memcpy!
7+
8+
void *__arm_sc_memset(void *dest, int c, size_t n) __arm_streaming_compatible {
9+
unsigned char *destp = (unsigned char *)dest;
10+
unsigned char c8 = (unsigned char)c;
11+
for (size_t i = 0; i < n; ++i)
12+
destp[i] = c8;
13+
14+
return dest;
15+
}
16+
#endif
17+
318
const void *__arm_sc_memchr(const void *src, int c,
419
size_t n) __arm_streaming_compatible {
520
const unsigned char *srcp = (const unsigned char *)src;

0 commit comments

Comments
 (0)