comparison dyncall/dyncall_callvm_arm64.c @ 466:ddfb9577a00e

introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed for upcoming aggregate support (until now only x86 platforms allowed for specifically selecting thiscall mode, given the different conventions on the same platform); also added respective DC_SIGCHAR_CC_THISCALL ('*')
author Tassilo Philipp
date Wed, 02 Feb 2022 18:30:44 +0100
parents 041cb6ad4d50
children 71c884e610f0
comparison
equal deleted inserted replaced
465:e2899b4ff713 466:ddfb9577a00e
4 Library: dyncall 4 Library: dyncall
5 File: dyncall/dyncall_callvm_arm64.c 5 File: dyncall/dyncall_callvm_arm64.c
6 Description: ARM 64-bit ABI implementation 6 Description: ARM 64-bit ABI implementation
7 License: 7 License:
8 8
9 Copyright (c) 2015-2020 Daniel Adler <dadler@uni-goettingen.de>, 9 Copyright (c) 2015-2020 Daniel Adler <dadler@uni-goettingen.de>,
10 Tassilo Philipp <tphilipp@potion-studios.com> 10 Tassilo Philipp <tphilipp@potion-studios.com>
11 11
12 Permission to use, copy, modify, and distribute this software for any 12 Permission to use, copy, modify, and distribute this software for any
13 purpose with or without fee is hereby granted, provided that the above 13 purpose with or without fee is hereby granted, provided that the above
14 copyright notice and this permission notice appear in all copies. 14 copyright notice and this permission notice appear in all copies.
82 static void a_double(DCCallVM* in_p, DCdouble x) 82 static void a_double(DCCallVM* in_p, DCdouble x)
83 { 83 {
84 DCCallVM_arm64* p = (DCCallVM_arm64*)in_p; 84 DCCallVM_arm64* p = (DCCallVM_arm64*)in_p;
85 if (p->f < 8) { 85 if (p->f < 8) {
86 p->u.D[ p->f ] = x; 86 p->u.D[ p->f ] = x;
87 p->f++; 87 p->f++;
88 } else { 88 } else {
89 dcVecAppend(&p->mVecHead, &x, sizeof(DCdouble)); 89 dcVecAppend(&p->mVecHead, &x, sizeof(DCdouble));
90 } 90 }
91 } 91 }
92 92
93 void call(DCCallVM* in_p, DCpointer target) 93 void call(DCCallVM* in_p, DCpointer target)
94 { 94 {
95 DCCallVM_arm64* p = (DCCallVM_arm64*)in_p; 95 DCCallVM_arm64* p = (DCCallVM_arm64*)in_p;
96 96
97 /* 97 /*
98 ** copy 'size' argument is given in number of 16-byte 'pair' blocks. 98 ** copy 'size' argument is given in number of 16-byte 'pair' blocks.
99 */ 99 */
100 100
101 dcCall_arm64(target, dcVecData(&p->mVecHead), ( dcVecSize(&p->mVecHead) + 15 ) & -16, &p->u.S[0]); 101 dcCall_arm64(target, dcVecData(&p->mVecHead), ( dcVecSize(&p->mVecHead) + 15 ) & -16, &p->u.S[0]);
102 } 102 }
103 103
104 static void mode(DCCallVM* in_self, DCint mode); 104 static void mode(DCCallVM* in_self, DCint mode);
105 105
108 &deinit 108 &deinit
109 , &reset 109 , &reset
110 , &mode 110 , &mode
111 , &a_bool 111 , &a_bool
112 , &a_char 112 , &a_char
113 , &a_short 113 , &a_short
114 , &a_int 114 , &a_int
115 , &a_long 115 , &a_long
116 , &a_i64 116 , &a_i64
117 , &a_float 117 , &a_float
118 , &a_double 118 , &a_double
178 case DC_CALL_C_ELLIPSIS_VARARGS: 178 case DC_CALL_C_ELLIPSIS_VARARGS:
179 #ifdef DC__OS_Win64 179 #ifdef DC__OS_Win64
180 vt = &vt_arm64_win_varargs; 180 vt = &vt_arm64_win_varargs;
181 break; 181 break;
182 #endif /* if not win64, use below */ 182 #endif /* if not win64, use below */
183 case DC_CALL_C_DEFAULT: 183 case DC_CALL_C_DEFAULT:
184 case DC_CALL_C_ARM64: 184 case DC_CALL_C_DEFAULT_THIS:
185 case DC_CALL_C_ARM64:
185 vt = &vt_arm64; 186 vt = &vt_arm64;
186 break; 187 break;
187 default: 188 default:
188 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; 189 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE;
189 return; 190 return;
190 } 191 }
191 dc_callvm_base_init(&self->mInterface, vt); 192 dc_callvm_base_init(&self->mInterface, vt);
192 } 193 }
193 194
194 /* Public API. */ 195 /* Public API. */
195 DCCallVM* dcNewCallVM(DCsize size) 196 DCCallVM* dcNewCallVM(DCsize size)
196 { 197 {
197 DCCallVM_arm64* p = (DCCallVM_arm64*)dcAllocMem(sizeof(DCCallVM_arm64)+size); 198 DCCallVM_arm64* p = (DCCallVM_arm64*)dcAllocMem(sizeof(DCCallVM_arm64)+size);
198 199
199 mode((DCCallVM*)p, DC_CALL_C_DEFAULT); 200 mode((DCCallVM*)p, DC_CALL_C_DEFAULT);
200 201