Skip to content

Commit 5a8956e

Browse files
[compiler-rt][libunwind] Support aarch64 without FPU (llvm#111235)
These two libraries don't build for `-march=armv8-a+nofp -mabi=aapcs-soft` as a couple of uses of floating point instructions and registers have crept in. In libunwind, skip save/restore of FPU registers on targets without them. In compiler-rt, fall back to the old C implementation of __arm_sc_memset when the target doesn't have an FPU. --------- Signed-off-by: Keith Packard <keithp@keithp.com>
1 parent 392807e commit 5a8956e

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

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

+2-3
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,7 +236,8 @@ END_COMPILERRT_OUTLINE_FUNCTION(__arm_sc_memcpy)
238236

239237
DEFINE_COMPILERRT_FUNCTION_ALIAS(__arm_sc_memmove, __arm_sc_memcpy)
240238

241-
239+
// This version uses FP registers. Use this only on targets with them
240+
#if defined(__aarch64__) && __ARM_FP != 0
242241
//
243242
// __arm_sc_memset
244243
//

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

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#include <stddef.h>
22

3+
/* The asm version uses FP registers. Use this on targets without them */
4+
#if __ARM_FP == 0
5+
void *__arm_sc_memset(void *dest, int c, size_t n) __arm_streaming_compatible {
6+
unsigned char *destp = (unsigned char *)dest;
7+
unsigned char c8 = (unsigned char)c;
8+
for (size_t i = 0; i < n; ++i)
9+
destp[i] = c8;
10+
11+
return dest;
12+
}
13+
#endif
14+
315
const void *__arm_sc_memchr(const void *src, int c,
416
size_t n) __arm_streaming_compatible {
517
const unsigned char *srcp = (const unsigned char *)src;

libunwind/src/UnwindRegistersRestore.S

+2-2
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto)
658658
ldp x26,x27, [x0, #0x0D0]
659659
ldp x28,x29, [x0, #0x0E0]
660660
ldr x30, [x0, #0x100] // restore pc into lr
661-
661+
#if defined(__ARM_FP) && __ARM_FP != 0
662662
ldp d0, d1, [x0, #0x110]
663663
ldp d2, d3, [x0, #0x120]
664664
ldp d4, d5, [x0, #0x130]
@@ -676,7 +676,7 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto)
676676
ldp d28,d29, [x0, #0x1F0]
677677
ldr d30, [x0, #0x200]
678678
ldr d31, [x0, #0x208]
679-
679+
#endif
680680
// Finally, restore sp. This must be done after the last read from the
681681
// context struct, because it is allocated on the stack, and an exception
682682
// could clobber the de-allocated portion of the stack after sp has been

libunwind/src/UnwindRegistersSave.S

+2
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
746746
str x1, [x0, #0x0F8]
747747
str x30, [x0, #0x100] // store return address as pc
748748
// skip cpsr
749+
#if defined(__ARM_FP) && __ARM_FP != 0
749750
stp d0, d1, [x0, #0x110]
750751
stp d2, d3, [x0, #0x120]
751752
stp d4, d5, [x0, #0x130]
@@ -763,6 +764,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
763764
stp d28,d29, [x0, #0x1F0]
764765
str d30, [x0, #0x200]
765766
str d31, [x0, #0x208]
767+
#endif
766768
mov x0, #0 // return UNW_ESUCCESS
767769
ret
768770

0 commit comments

Comments
 (0)