Commit 0f2ff2d4c92719be8936179f9ab674f4d1a3fd14

David Schneider 2013-03-26T19:22:02

separate ARM ffi_prepare_args in a version implementing the simple SYSV calling convention and one for the hard-float calling convention

diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index 1fb7199..d3dba9c 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -122,14 +122,14 @@ static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
    value is cif->vfp_used (word bitset of VFP regs used for passing
    arguments). These are only used for the VFP hard-float ABI.
 */
-int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space)
+int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
 {
-  register unsigned int i, vi = 0;
+  register unsigned int i;
   register void **p_argv;
   register char *argp;
   register ffi_type **p_arg;
-
   argp = stack;
+  
 
   if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
     *(void **) argp = ecif->rvalue;
@@ -140,23 +140,19 @@ int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space)
 
   for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
        (i != 0);
-       i--, p_arg++)
+       i--, p_arg++, p_argv++)
     {
-
-      /* Allocated in VFP registers. */
-      if (ecif->cif->abi == FFI_VFP
-	  && vi < ecif->cif->vfp_nargs && vfp_type_p (*p_arg))
-	{
-	  char *vfp_slot = (char *)(vfp_space + ecif->cif->vfp_args[vi++]);
-		ffi_put_arg(p_arg, p_argv, vfp_slot);
-	  p_argv++;
-	  continue;
-	}
     argp = ffi_align(p_arg, argp);
     argp += ffi_put_arg(p_arg, p_argv, argp);
-	  p_argv++;
     }
 
+  return 0;
+}
+
+int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
+{
+  // make sure we are using FFI_VFP
+  FFI_ASSERT(ecif->cif->abi == FFI_VFP);
   /* Indicate the VFP registers used. */
   return ecif->cif->vfp_used;
 }
diff --git a/src/arm/sysv.S b/src/arm/sysv.S
index fb38cd6..de1809b 100644
--- a/src/arm/sysv.S
+++ b/src/arm/sysv.S
@@ -187,7 +187,7 @@ ARM_FUNC_START ffi_call_SYSV
 	@     r1 already set
 
 	@ Call ffi_prep_args(stack, &ecif)
-	bl	CNAME(ffi_prep_args)
+	bl	CNAME(ffi_prep_args_SYSV)
 
 	@ move first 4 parameters in registers
 	ldmia	sp, {r0-r3}
@@ -364,7 +364,7 @@ ARM_FUNC_START ffi_call_VFP
 	sub	r2, fp, #64   @ VFP scratch space
 
 	@ Call ffi_prep_args(stack, &ecif, vfp_space)
-	bl	CNAME(ffi_prep_args)
+	bl	CNAME(ffi_prep_args_VFP)
 
 	@ Load VFP register args if needed
 	cmp	r0, #0