folow the ARM hard-float ABI in ffi_prep_incoming_args_VFP

This commit is contained in:
David Schneider
2013-03-27 19:31:04 +01:00
parent b41120981e
commit 9708e7cf09

View File

@@ -446,38 +446,75 @@ ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
{ {
register unsigned int i, vi = 0; register unsigned int i, vi = 0;
register void **p_argv; register void **p_argv;
register char *argp; register char *argp, *regp, *eo_regp;
register ffi_type **p_arg; register ffi_type **p_arg;
char done_with_regs = 0;
char stack_used = 0;
char is_vfp_type;
argp = stack; FFI_ASSERT(cif->abi == FFI_VFP);
regp = stack;
eo_regp = argp = regp + 16;
if ( cif->flags == FFI_TYPE_STRUCT ) { if ( cif->flags == FFI_TYPE_STRUCT ) {
*rvalue = *(void **) argp; *rvalue = *(void **) regp;
argp += 4; regp += 4;
} }
p_argv = avalue; p_argv = avalue;
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
{ {
size_t z; size_t z;
is_vfp_type = vfp_type_p (*p_arg);
if (cif->abi == FFI_VFP if(vi < cif->vfp_nargs && is_vfp_type)
&& vi < cif->vfp_nargs && vfp_type_p (*p_arg)) {
{ *p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]);
*p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]); continue;
continue; }
} else if (!done_with_regs && !is_vfp_type)
argp = ffi_align(p_arg, argp); {
char* tregp = ffi_align(p_arg, regp);
z = (*p_arg)->size; z = (*p_arg)->size;
z = (z < 4)? 4 : z; // pad
/* because we're little endian, this is what it turns into. */ /* if the arguments either fits into the registers or uses registers
* and stack, while we haven't read other things from the stack */
if(tregp + z <= eo_regp || !stack_used)
{
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) tregp;
*p_argv = (void*) argp; p_argv++;
regp = tregp + z;
/* if regp points above the end of the register area */
if(regp >= eo_regp)
{
/* sanity check that we haven't read from the stack area before
* reaching this point */
FFI_ASSERT(argp <= regp);
FFI_ASSERT(argp == stack + 16);
argp = regp;
done_with_regs = 1;
stack_used = 1;
}
continue;
}
}
stack_used = 1;
p_argv++; argp = ffi_align(p_arg, argp);
argp += z;
z = (*p_arg)->size;
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) argp;
p_argv++;
argp += z;
} }
return; return;