From ca2ebae012d6cdcc19d0a01f54f3dad614de8e68 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Thu, 24 Dec 2020 16:28:01 +0100 Subject: Configure the correct archiver to build runtime/libcompcert.a - Use `${toolprefix}ar` instead of `ar` so as to match the choice of C compiler (as proposed by Michael Soegtrop in PR #380) - Use the Diab archiver `dar` if configured for powerpc-eabi-diab Closes: #380 --- runtime/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/Makefile b/runtime/Makefile index 6777995d..beb105a6 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -48,7 +48,7 @@ endif $(LIB): $(OBJS) rm -f $(LIB) - ar rcs $(LIB) $(OBJS) + $(ARCHIVER) $(LIB) $(OBJS) %.o: %.s $(CASMRUNTIME) -o $@ $^ -- cgit From c50680bb86564fe61db61e6140a418ccc7d36677 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Wed, 23 Dec 2020 15:54:51 +0100 Subject: AArch64: macOS port This commit adds support for macOS (and probably iOS) running on AArch64 / ARM 64-bit / "Apple silicon" processors. --- runtime/aarch64/sysdeps.h | 20 +++++++++++++++++++ runtime/aarch64/vararg.S | 50 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/aarch64/sysdeps.h b/runtime/aarch64/sysdeps.h index 0cee9ae3..e688961a 100644 --- a/runtime/aarch64/sysdeps.h +++ b/runtime/aarch64/sysdeps.h @@ -34,6 +34,25 @@ // System dependencies +#if defined(SYS_macosx) + +#define GLOB(x) _##x + +#define FUNCTION(f) FUNCTION f + +.macro FUNCTION name + .text + .globl _\name + .align 4 +_\name: +.endm + +#define ENDFUNCTION(f) + +#else + +#define GLOB(x) x + #define FUNCTION(f) \ .text; \ .balign 16; \ @@ -43,3 +62,4 @@ f: #define ENDFUNCTION(f) \ .type f, @function; .size f, . - f +#endif diff --git a/runtime/aarch64/vararg.S b/runtime/aarch64/vararg.S index b7347d65..488d3459 100644 --- a/runtime/aarch64/vararg.S +++ b/runtime/aarch64/vararg.S @@ -36,7 +36,8 @@ #include "sysdeps.h" -// typedef struct __va_list { +// For the standard ABI: +// struct __va_list { // void *__stack; // next stack parameter // void *__gr_top; // top of the save area for int regs // void *__vr_top; // top of the save area for float regs @@ -44,10 +45,18 @@ // int__vr_offs; // offset from gr_top to next FP reg // } // typedef struct __va_list va_list; // struct passed by reference + +// For the Apple ABI: +// typedef char * va_list; // a single pointer passed by reference +// // points to the next parameter, always on stack + +// In both cases: // unsigned int __compcert_va_int32(va_list * ap); // unsigned long long __compcert_va_int64(va_list * ap); // double __compcert_va_float64(va_list * ap); +#ifdef ABI_standard + FUNCTION(__compcert_va_int32) ldr w1, [x0, #24] // w1 = gr_offs cbz w1, 1f @@ -72,14 +81,14 @@ FUNCTION(__compcert_va_int64) cbz w1, 1f // gr_offs is not zero: load from int save area and update gr_offs ldr x2, [x0, #8] // x2 = gr_top - ldr x2, [x2, w1, sxtw] // w2 = the next long integer + ldr x2, [x2, w1, sxtw] // x2 = the next long integer add w1, w1, #8 str w1, [x0, #24] // update gr_offs mov x0, x2 ret // gr_offs is zero: load from stack save area and update stack pointer 1: ldr x1, [x0, #0] // x1 = stack - ldr x2, [x1, #0] // w2 = the next long integer + ldr x2, [x1, #0] // x2 = the next long integer add x1, x1, #8 str x1, [x0, #0] // update stack mov x0, x2 @@ -103,7 +112,40 @@ FUNCTION(__compcert_va_float64) ret ENDFUNCTION(__compcert_va_float64) +#endif + +#ifdef ABI_apple + +FUNCTION(__compcert_va_int32) + ldr x1, [x0, #0] // x1 = stack pointer + ldr w2, [x1, #0] // w2 = the next integer + add x1, x1, #8 + str x1, [x0, #0] // update stack + mov w0, w2 + ret +ENDFUNCTION(__compcert_va_int32) + +FUNCTION(__compcert_va_int64) + ldr x1, [x0, #0] // x1 = stack pointer + ldr x2, [x1, #0] // x2 = the next long integer + add x1, x1, #8 + str x1, [x0, #0] // update stack + mov x0, x2 + ret +ENDFUNCTION(__compcert_va_int64) + +FUNCTION(__compcert_va_float64) + ldr x1, [x0, #0] // x1 = stack pointer + ldr d0, [x1, #0] // d0 = the next float + add x1, x1, #8 + str x1, [x0, #0] // update stack + ret +ENDFUNCTION(__compcert_va_float64) + +#endif + // Right now we pass structs by reference. This is not ABI conformant. FUNCTION(__compcert_va_composite) - b __compcert_va_int64 + b GLOB(__compcert_va_int64) ENDFUNCTION(__compcert_va_composite) + -- cgit From ab62e1bed37d2efe4d2a9e0139839bae21b1cdd9 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 18 Jan 2021 19:56:44 +0100 Subject: "macosx" is now called "macos" The configure script still accepts "macosx" for backward compatibility, but every other part of CompCert now uses "macos". --- runtime/aarch64/sysdeps.h | 2 +- runtime/x86_32/sysdeps.h | 2 +- runtime/x86_64/sysdeps.h | 2 +- runtime/x86_64/vararg.S | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/aarch64/sysdeps.h b/runtime/aarch64/sysdeps.h index e688961a..b098cf1c 100644 --- a/runtime/aarch64/sysdeps.h +++ b/runtime/aarch64/sysdeps.h @@ -34,7 +34,7 @@ // System dependencies -#if defined(SYS_macosx) +#if defined(SYS_macos) #define GLOB(x) _##x diff --git a/runtime/x86_32/sysdeps.h b/runtime/x86_32/sysdeps.h index 9d957a88..973bbe2f 100644 --- a/runtime/x86_32/sysdeps.h +++ b/runtime/x86_32/sysdeps.h @@ -48,7 +48,7 @@ f: #endif -#if defined(SYS_macosx) +#if defined(SYS_macos) #define GLOB(x) _##x #define FUNCTION(f) \ diff --git a/runtime/x86_64/sysdeps.h b/runtime/x86_64/sysdeps.h index aacef8f0..9031d5d0 100644 --- a/runtime/x86_64/sysdeps.h +++ b/runtime/x86_64/sysdeps.h @@ -48,7 +48,7 @@ f: #endif -#if defined(SYS_macosx) +#if defined(SYS_macos) #define GLOB(x) _##x #define FUNCTION(f) \ diff --git a/runtime/x86_64/vararg.S b/runtime/x86_64/vararg.S index c5225b34..d3634e4d 100644 --- a/runtime/x86_64/vararg.S +++ b/runtime/x86_64/vararg.S @@ -38,7 +38,7 @@ // ELF ABI -#if defined(SYS_linux) || defined(SYS_bsd) || defined(SYS_macosx) +#if defined(SYS_linux) || defined(SYS_bsd) || defined(SYS_macos) // typedef struct { // unsigned int gp_offset; -- cgit