Mercurial > pub > dyncall > dyncall
changeset 651:cab0031c6691
- arm64 files:
* // to /* comments */ (b/c dyncall supports pre-c99 toolchains, in this case it's more for consistency reasons throughout dyncall, as arm64 is newer than 1999)
* removed comment with dead link
* cosmetics
- portasm readme addition
author | Tassilo Philipp |
---|---|
date | Thu, 07 Mar 2024 10:34:10 +0100 |
parents | 4e40299cc673 |
children | e7ffb0fb1520 |
files | dyncall/dyncall_call_arm64.S dyncall/dyncall_callvm_arm64.c dyncall/dyncall_callvm_arm64.h dyncallback/dyncall_callback_arm64.S portasm/README.txt |
diffstat | 5 files changed, 91 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/dyncall/dyncall_call_arm64.S Thu Mar 07 10:23:16 2024 +0100 +++ b/dyncall/dyncall_call_arm64.S Thu Mar 07 10:34:10 2024 +0100 @@ -38,31 +38,30 @@ */ TEXTAREA -// -// DynCall Back-End arm64 -// -// Supported ABIs: -// - 'ARM 64-bit AArch64 PCS' (@dadler: work in progress) -// -// Useful Links: -// - http://lxr.free-electrons.com/source/arch/arm64/kernel/stacktrace.c +/* + DynCall Back-End arm64 + + Supported ABIs: + - 'ARM 64-bit AArch64 PCS' (@dadler: work in progress) +*/ GLOBAL_C(dcCall_arm64) ENTRY_C(dcCall_arm64) ALIGN(2) -// input: -// x0: target (address of target) -// x1: data (address of stack copy data) -// x2: size (number of 'pair' 16-byte units) -// x3: regdata (address of register data) +/* input: + x0: target (address of target) + x1: data (address of stack copy data) + x2: size (number of 'pair' 16-byte units) + x3: regdata (address of register data) +*/ -// prolog: - - stp x29, x30, [sp, #-16]! // allocate frame +/* prolog: */ + + stp x29, x30, [sp, #-16]! /* allocate frame */ mov x29, sp -// load 64-bit floating-point registers +/* load 64-bit floating-point registers */ ldr d0, [x3,#0 ] ldr d1, [x3,#8 ] @@ -73,35 +72,35 @@ ldr d6, [x3,#48] ldr d7, [x3,#56] -// copy to stack - - sub sp, sp, x2 // create call-frame +/* copy to stack */ + + sub sp, sp, x2 /* create call-frame */ - eor x4, x4, x4 // x4: cnt = 0 + eor x4, x4, x4 /* x4: cnt = 0 */ - mov x5, x1 // x5: read pointer = data - mov x6, sp // x6: write pointer = sp + mov x5, x1 /* x5: read pointer = data */ + mov x6, sp /* x6: write pointer = sp */ LABELDEF(next) cmp x4, x2 b.ge LABELUSE(done) - - ldp x7, x9, [x5], #16 // get pair from data - stp x7, x9, [x6], #16 // put to stack - add x4, x4, 16 // advance 16 bytes + + ldp x7, x9, [x5], #16 /* get pair from data */ + stp x7, x9, [x6], #16 /* put to stack */ + add x4, x4, 16 /* advance 16 bytes */ b LABELUSE(next) LABELDEF(done) - -// rescue temp int registers + +/* rescue temp int registers */ - mov x9 , x0 // x9: target - add x10, x3, 64 // x3: integer reg buffer + mov x9 , x0 /* x9: target */ + add x10, x3, 64 /* x3: integer reg buffer */ -// load 64-bit integer registers ( 8 x 64-bit ) - - // load register set +/* load 64-bit integer registers ( 8 x 64-bit ) */ + + /* load register set */ ldr x0, [x10, #0] ldr x1, [x10, #8] @@ -111,12 +110,12 @@ ldr x5, [x10, #40] ldr x6, [x10, #48] ldr x7, [x10, #56] - -// call target: - + +/* call target: */ + blr x9 -// epilog: +/* epilog: */ mov sp, x29 ldp x29, x30, [sp], 16
--- a/dyncall/dyncall_callvm_arm64.c Thu Mar 07 10:23:16 2024 +0100 +++ b/dyncall/dyncall_callvm_arm64.c Thu Mar 07 10:34:10 2024 +0100 @@ -59,11 +59,11 @@ } } -static void a_bool (DCCallVM* self, DCbool x) { a_i64(self, (DClonglong)x); } -static void a_char (DCCallVM* self, DCchar x) { a_i64(self, x); } -static void a_short (DCCallVM* self, DCshort x) { a_i64(self, x); } -static void a_int (DCCallVM* self, DCint x) { a_i64(self, x); } -static void a_long (DCCallVM* self, DClong x) { a_i64(self, x); } +static void a_bool (DCCallVM* self, DCbool x) { a_i64(self, (DClonglong)x); } +static void a_char (DCCallVM* self, DCchar x) { a_i64(self, x); } +static void a_short (DCCallVM* self, DCshort x) { a_i64(self, x); } +static void a_int (DCCallVM* self, DCint x) { a_i64(self, x); } +static void a_long (DCCallVM* self, DClong x) { a_i64(self, x); } static void a_pointer (DCCallVM* self, DCpointer x) { a_i64(self, (DClonglong) x ); } static void a_float(DCCallVM* in_p, DCfloat x)
--- a/dyncall/dyncall_callvm_arm64.h Thu Mar 07 10:23:16 2024 +0100 +++ b/dyncall/dyncall_callvm_arm64.h Thu Mar 07 10:34:10 2024 +0100 @@ -32,14 +32,14 @@ typedef struct { DCCallVM mInterface; - unsigned int i; /* int register counter */ - unsigned int f; /* float register counter */ - union { /* float register buffer */ + unsigned int i; /* int register counter */ + unsigned int f; /* float register counter */ + union { /* float register buffer */ DCfloat S[16]; DCdouble D[8]; } u; unsigned long long I[8]; /* int register buffer */ - DCVecHead mVecHead; /* argument buffer head */ + DCVecHead mVecHead; /* argument buffer head */ } DCCallVM_arm64; #endif /* DYNCALL_CALLVM_ARM64_DEBIAN_H */
--- a/dyncallback/dyncall_callback_arm64.S Thu Mar 07 10:23:16 2024 +0100 +++ b/dyncallback/dyncall_callback_arm64.S Thu Mar 07 10:34:10 2024 +0100 @@ -6,7 +6,7 @@ Description: Callback Thunk - Implementation for ARM64 / ARMv8 / AAPCS64 License: - Copyright (c) 2015-2020 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2015-2024 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -26,12 +26,13 @@ #include "../portasm/portasm-arm64.S" BEGIN_ASM -// struct DCCallback -// type off size -// ---------|------|------ -// DCThunk | 0 | 32 -// handler | 32 | 8 -// userdata | 40 | 8 +/* struct DCCallback + type off size + ---------|------|------ + DCThunk | 0 | 32 + handler | 32 | 8 + userdata | 40 | 8 +*/ TEXTAREA @@ -39,26 +40,27 @@ ENTRY_C(dcCallbackThunkEntry) ALIGN(4) -// input: -// x9: DCCallback* pcb -// x0..x7 ?? GP regs -// d0..d7 ?? FP/SIMD regs -// sp... ?? arguments on stack -// -// locals: -// type off size -// ---------|------|------ -// Frame 0 16 -// DCArgs 16 168 -// DCValue 184 16 -// -// size 200 -// aligned 208 -// +/* input: + x9: DCCallback* pcb + x0..x7 ?? GP regs + d0..d7 ?? FP/SIMD regs + sp... ?? arguments on stack + + locals: + type off size + ---------|------|------ + Frame 0 16 + DCArgs 16 168 + DCValue 184 16 + + size 200 + aligned 208 + -// locals: -// x10: sp -// x11: DCArgs* args + locals: + x10: sp + x11: DCArgs* args +*/ mov x10, sp stp x29, x30, [sp, #-208 ]! @@ -66,7 +68,7 @@ add x11, x29 , #16 -// save integer registers +/* save integer registers */ stp x0, x1, [x11, #0 ] stp x2, x3, [x11, #16] @@ -79,17 +81,18 @@ stp d6, d7, [x11, #112] eor x12, x12, x12 - stp x10,x12,[x11, #128] // sp=sp, i=0, f=0 - - str x12, [x11, #144] // s=0, reserved=0 + stp x10,x12,[x11, #128] /* sp=sp, i=0, f=0 */ + + str x12, [x11, #144] /* s=0, reserved=0 */ -// call handler: -// args: -// x0: DCCallback* pcb -// x1: DCArgs* args -// x2: DCValue* result -// x3: void* userdata +/* call handler: + args: + x0: DCCallback* pcb + x1: DCArgs* args + x2: DCValue* result + x3: void* userdata +*/ mov x0 , x9 add x1 , x29 , #16
--- a/portasm/README.txt Thu Mar 07 10:23:16 2024 +0100 +++ b/portasm/README.txt Thu Mar 07 10:34:10 2024 +0100 @@ -13,10 +13,12 @@ Supported Architectures and Tool-chains: ---------------------------------------- -- x86: gas, apple as, masm -- x64: gas, apple as, masm -- ppc: gas, apple as -- arm: gas, apple as +- x86: gas, apple as, masm +- x64: gas, apple as, masm +- ppc: gas, apple as +- ppc64: gas, apple as +- arm: gas, apple as +- arm64: gas, apple as Usage: