comparison dyncall/dyncall_callvm_ppc64.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 ad5f9803f52f
children 71c884e610f0
comparison
equal deleted inserted replaced
465:e2899b4ff713 466:ddfb9577a00e
1 /* 1 /*
2 2
3 Package: dyncall 3 Package: dyncall
4 Library: dyncall 4 Library: dyncall
5 File: dyncall/dyncall_callvm_ppc64.c 5 File: dyncall/dyncall_callvm_ppc64.c
6 Description: 6 Description:
7 License: 7 License:
8 8
9 Copyright (c) 2014-2015 Masanori Mitsugi <mitsugi@linux.vnet.ibm.com> 9 Copyright (c) 2014-2015 Masanori Mitsugi <mitsugi@linux.vnet.ibm.com>
10 2020 Tassilo Philipp <tphilipp@potion-studios.com> 10 2020 Tassilo Philipp <tphilipp@potion-studios.com>
11 11
12 12
13 Permission to use, copy, modify, and distribute this software for any 13 Permission to use, copy, modify, and distribute this software for any
14 purpose with or without fee is hereby granted, provided that the above 14 purpose with or without fee is hereby granted, provided that the above
15 copyright notice and this permission notice appear in all copies. 15 copyright notice and this permission notice appear in all copies.
16 16
43 #include "dyncall_alloc.h" 43 #include "dyncall_alloc.h"
44 #include "dyncall_macros.h" 44 #include "dyncall_macros.h"
45 #include "dyncall_types.h" 45 #include "dyncall_types.h"
46 46
47 47
48 /* 48 /*
49 ** PowerPC 64-bit calling convention call 49 ** PowerPC 64-bit calling convention call
50 ** 50 **
51 ** - hybrid return-type call (bool ... pointer) 51 ** - hybrid return-type call (bool ... pointer)
52 ** 52 **
53 */ 53 */
202 #if DC__ABI_PPC64_ELF_V == 2 202 #if DC__ABI_PPC64_ELF_V == 2
203 static void dc_callvm_argLongLong_ppc64_ellipsis(DCCallVM* in_self, DClonglong L) 203 static void dc_callvm_argLongLong_ppc64_ellipsis(DCCallVM* in_self, DClonglong L)
204 { 204 {
205 DCCallVM_ppc64* self = (DCCallVM_ppc64*)in_self; 205 DCCallVM_ppc64* self = (DCCallVM_ppc64*)in_self;
206 206
207 if (dcVecSize(&self->mVecHead) == 0) 207 if (dcVecSize(&self->mVecHead) == 0)
208 dcVecSkip(&self->mVecHead,(sizeof(DClonglong))*(self->mIntRegs)); 208 dcVecSkip(&self->mVecHead,(sizeof(DClonglong))*(self->mIntRegs));
209 209
210 if (self->mIntRegs < 8) 210 if (self->mIntRegs < 8)
211 self->mRegData.mIntData[self->mIntRegs++] = L; 211 self->mRegData.mIntData[self->mIntRegs++] = L;
212 212
213 /* push on stack */ 213 /* push on stack */
214 dcVecAppend(&self->mVecHead,&L,sizeof(DClonglong)); 214 dcVecAppend(&self->mVecHead,&L,sizeof(DClonglong));
215 } 215 }
257 int size = dcVecSize(&self->mVecHead); 257 int size = dcVecSize(&self->mVecHead);
258 258
259 if (size < 64) { 259 if (size < 64) {
260 dcVecSkip(&self->mVecHead, 64-size); 260 dcVecSkip(&self->mVecHead, 64-size);
261 } 261 }
262 262
263 dcCall_ppc64( target, &self->mRegData, dcVecSize(&self->mVecHead) , dcVecData(&self->mVecHead)); 263 dcCall_ppc64( target, &self->mRegData, dcVecSize(&self->mVecHead) , dcVecData(&self->mVecHead));
264 } 264 }
265 265
266 void dc_callvm_call_ppc64_syscall(DCCallVM* in_self, DCpointer target) 266 void dc_callvm_call_ppc64_syscall(DCCallVM* in_self, DCpointer target)
267 { 267 {
362 DCCallVM_ppc64* self = (DCCallVM_ppc64*) in_self; 362 DCCallVM_ppc64* self = (DCCallVM_ppc64*) in_self;
363 DCCallVM_vt* vt; 363 DCCallVM_vt* vt;
364 364
365 switch(mode) { 365 switch(mode) {
366 case DC_CALL_C_DEFAULT: 366 case DC_CALL_C_DEFAULT:
367 case DC_CALL_C_PPC64: 367 case DC_CALL_C_DEFAULT_THIS:
368 case DC_CALL_C_PPC64:
368 case DC_CALL_C_ELLIPSIS: 369 case DC_CALL_C_ELLIPSIS:
369 #if DC__ABI_PPC64_ELF_V == 2 370 #if DC__ABI_PPC64_ELF_V == 2
370 vt = &gVT_ppc64; 371 vt = &gVT_ppc64;
371 break; 372 break;
372 case DC_CALL_C_ELLIPSIS_VARARGS: 373 case DC_CALL_C_ELLIPSIS_VARARGS:
381 case DC_CALL_SYS_DEFAULT: 382 case DC_CALL_SYS_DEFAULT:
382 case DC_CALL_SYS_PPC64: 383 case DC_CALL_SYS_PPC64:
383 vt = &gVT_ppc64_syscall; 384 vt = &gVT_ppc64_syscall;
384 break; 385 break;
385 386
386 default: 387 default:
387 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; 388 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE;
388 return; 389 return;
389 } 390 }
390 391
391 dc_callvm_base_init(&self->mInterface, vt); 392 dc_callvm_base_init(&self->mInterface, vt);
392 } 393 }
393 394
394 /* Public API. */ 395 /* Public API. */
395 DCCallVM* dcNewCallVM(DCsize size) 396 DCCallVM* dcNewCallVM(DCsize size)