mirror of git://gcc.gnu.org/git/gcc.git
re PR testsuite/32843 (libffi.call/return_sc.c)
2007-07-30 Andrew Haley <aph@redhat.com> PR testsuite/32843 * src/x86/ffi.c (ffi_prep_cif_machdep): in x86 case, add code for signed/unsigned int8/16. * src/x86/sysv.S (ffi_call_SYSV): Rewrite to: Use a jump table. Remove code to pop args from the stack after call. Special-case signed/unsigned int8/16. * testsuite/libffi.call/return_sc.c (main): Revert. From-SVN: r127093
This commit is contained in:
parent
2bde7ae91a
commit
387cfbba39
|
@ -1,3 +1,14 @@
|
||||||
|
2007-07-30 Andrew Haley <aph@redhat.com>
|
||||||
|
|
||||||
|
PR testsuite/32843
|
||||||
|
* src/x86/ffi.c (ffi_prep_cif_machdep): in x86 case, add code for
|
||||||
|
signed/unsigned int8/16.
|
||||||
|
* src/x86/sysv.S (ffi_call_SYSV): Rewrite to:
|
||||||
|
Use a jump table.
|
||||||
|
Remove code to pop args from the stack after call.
|
||||||
|
Special-case signed/unsigned int8/16.
|
||||||
|
* testsuite/libffi.call/return_sc.c (main): Revert.
|
||||||
|
|
||||||
2007-07-26 Richard Guenther <rguenther@suse.de>
|
2007-07-26 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
PR testsuite/32843
|
PR testsuite/32843
|
||||||
|
|
|
@ -121,7 +121,12 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
|
||||||
case FFI_TYPE_VOID:
|
case FFI_TYPE_VOID:
|
||||||
#ifdef X86
|
#ifdef X86
|
||||||
case FFI_TYPE_STRUCT:
|
case FFI_TYPE_STRUCT:
|
||||||
|
case FFI_TYPE_UINT8:
|
||||||
|
case FFI_TYPE_UINT16:
|
||||||
|
case FFI_TYPE_SINT8:
|
||||||
|
case FFI_TYPE_SINT16:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case FFI_TYPE_SINT64:
|
case FFI_TYPE_SINT64:
|
||||||
case FFI_TYPE_FLOAT:
|
case FFI_TYPE_FLOAT:
|
||||||
case FFI_TYPE_DOUBLE:
|
case FFI_TYPE_DOUBLE:
|
||||||
|
|
|
@ -59,16 +59,15 @@ ffi_call_SYSV:
|
||||||
|
|
||||||
call *28(%ebp)
|
call *28(%ebp)
|
||||||
|
|
||||||
/* Remove the space we pushed for the args */
|
|
||||||
movl 16(%ebp),%ecx
|
|
||||||
addl %ecx,%esp
|
|
||||||
|
|
||||||
/* Load %ecx with the return type code */
|
/* Load %ecx with the return type code */
|
||||||
movl 20(%ebp),%ecx
|
movl 20(%ebp),%ecx
|
||||||
|
|
||||||
|
/* Protect %esi. We're going to pop it in the epilogue. */
|
||||||
|
pushl %esi
|
||||||
|
|
||||||
/* If the return value pointer is NULL, assume no return value. */
|
/* If the return value pointer is NULL, assume no return value. */
|
||||||
cmpl $0,24(%ebp)
|
cmpl $0,24(%ebp)
|
||||||
jne retint
|
jne 0f
|
||||||
|
|
||||||
/* Even if there is no space for the return value, we are
|
/* Even if there is no space for the return value, we are
|
||||||
obliged to handle floating-point values. */
|
obliged to handle floating-point values. */
|
||||||
|
@ -78,51 +77,84 @@ ffi_call_SYSV:
|
||||||
|
|
||||||
jmp epilogue
|
jmp epilogue
|
||||||
|
|
||||||
retint:
|
0:
|
||||||
cmpl $FFI_TYPE_INT,%ecx
|
call 1f
|
||||||
jne retfloat
|
|
||||||
/* Load %ecx with the pointer to storage for the return value */
|
.Lstore_table:
|
||||||
movl 24(%ebp),%ecx
|
.long noretval-.Lstore_table /* FFI_TYPE_VOID */
|
||||||
movl %eax,0(%ecx)
|
.long retint-.Lstore_table /* FFI_TYPE_INT */
|
||||||
jmp epilogue
|
.long retfloat-.Lstore_table /* FFI_TYPE_FLOAT */
|
||||||
|
.long retdouble-.Lstore_table /* FFI_TYPE_DOUBLE */
|
||||||
|
.long retlongdouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
|
||||||
|
.long retuint8-.Lstore_table /* FFI_TYPE_UINT8 */
|
||||||
|
.long retsint8-.Lstore_table /* FFI_TYPE_SINT8 */
|
||||||
|
.long retuint16-.Lstore_table /* FFI_TYPE_UINT16 */
|
||||||
|
.long retsint16-.Lstore_table /* FFI_TYPE_SINT16 */
|
||||||
|
.long retint-.Lstore_table /* FFI_TYPE_UINT32 */
|
||||||
|
.long retint-.Lstore_table /* FFI_TYPE_SINT32 */
|
||||||
|
.long retint64-.Lstore_table /* FFI_TYPE_UINT64 */
|
||||||
|
.long retint64-.Lstore_table /* FFI_TYPE_SINT64 */
|
||||||
|
.long retstruct-.Lstore_table /* FFI_TYPE_STRUCT */
|
||||||
|
.long retint-.Lstore_table /* FFI_TYPE_POINTER */
|
||||||
|
|
||||||
|
1:
|
||||||
|
pop %esi
|
||||||
|
add (%esi, %ecx, 4), %esi
|
||||||
|
jmp *%esi
|
||||||
|
|
||||||
|
/* Sign/zero extend as appropriate. */
|
||||||
|
retsint8:
|
||||||
|
movsbl %al, %eax
|
||||||
|
jmp retint
|
||||||
|
|
||||||
|
retsint16:
|
||||||
|
movswl %ax, %eax
|
||||||
|
jmp retint
|
||||||
|
|
||||||
|
retuint8:
|
||||||
|
movzbl %al, %eax
|
||||||
|
jmp retint
|
||||||
|
|
||||||
|
retuint16:
|
||||||
|
movzwl %ax, %eax
|
||||||
|
jmp retint
|
||||||
|
|
||||||
retfloat:
|
retfloat:
|
||||||
cmpl $FFI_TYPE_FLOAT,%ecx
|
|
||||||
jne retdouble
|
|
||||||
/* Load %ecx with the pointer to storage for the return value */
|
/* Load %ecx with the pointer to storage for the return value */
|
||||||
movl 24(%ebp),%ecx
|
movl 24(%ebp),%ecx
|
||||||
fstps (%ecx)
|
fstps (%ecx)
|
||||||
jmp epilogue
|
jmp epilogue
|
||||||
|
|
||||||
retdouble:
|
retdouble:
|
||||||
cmpl $FFI_TYPE_DOUBLE,%ecx
|
|
||||||
jne retlongdouble
|
|
||||||
/* Load %ecx with the pointer to storage for the return value */
|
/* Load %ecx with the pointer to storage for the return value */
|
||||||
movl 24(%ebp),%ecx
|
movl 24(%ebp),%ecx
|
||||||
fstpl (%ecx)
|
fstpl (%ecx)
|
||||||
jmp epilogue
|
jmp epilogue
|
||||||
|
|
||||||
retlongdouble:
|
retlongdouble:
|
||||||
cmpl $FFI_TYPE_LONGDOUBLE,%ecx
|
|
||||||
jne retint64
|
|
||||||
/* Load %ecx with the pointer to storage for the return value */
|
/* Load %ecx with the pointer to storage for the return value */
|
||||||
movl 24(%ebp),%ecx
|
movl 24(%ebp),%ecx
|
||||||
fstpt (%ecx)
|
fstpt (%ecx)
|
||||||
jmp epilogue
|
jmp epilogue
|
||||||
|
|
||||||
retint64:
|
retint64:
|
||||||
cmpl $FFI_TYPE_SINT64,%ecx
|
|
||||||
jne retstruct
|
|
||||||
/* Load %ecx with the pointer to storage for the return value */
|
/* Load %ecx with the pointer to storage for the return value */
|
||||||
movl 24(%ebp),%ecx
|
movl 24(%ebp),%ecx
|
||||||
movl %eax,0(%ecx)
|
movl %eax,0(%ecx)
|
||||||
movl %edx,4(%ecx)
|
movl %edx,4(%ecx)
|
||||||
|
jmp epilogue
|
||||||
|
|
||||||
|
retint:
|
||||||
|
/* Load %ecx with the pointer to storage for the return value */
|
||||||
|
movl 24(%ebp),%ecx
|
||||||
|
movl %eax,0(%ecx)
|
||||||
|
|
||||||
retstruct:
|
retstruct:
|
||||||
/* Nothing to do! */
|
/* Nothing to do! */
|
||||||
|
|
||||||
noretval:
|
noretval:
|
||||||
epilogue:
|
epilogue:
|
||||||
|
popl %esi
|
||||||
movl %ebp,%esp
|
movl %ebp,%esp
|
||||||
popl %ebp
|
popl %ebp
|
||||||
ret
|
ret
|
||||||
|
@ -162,7 +194,15 @@ ffi_closure_SYSV:
|
||||||
movl -12(%ebp), %ecx
|
movl -12(%ebp), %ecx
|
||||||
cmpl $FFI_TYPE_INT, %eax
|
cmpl $FFI_TYPE_INT, %eax
|
||||||
je .Lcls_retint
|
je .Lcls_retint
|
||||||
cmpl $FFI_TYPE_FLOAT, %eax
|
|
||||||
|
/* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
|
||||||
|
FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
|
||||||
|
cmpl $FFI_TYPE_UINT64, %eax
|
||||||
|
jge 0f
|
||||||
|
cmpl $FFI_TYPE_UINT8, %eax
|
||||||
|
jge .Lcls_retint
|
||||||
|
|
||||||
|
0: cmpl $FFI_TYPE_FLOAT, %eax
|
||||||
je .Lcls_retfloat
|
je .Lcls_retfloat
|
||||||
cmpl $FFI_TYPE_DOUBLE, %eax
|
cmpl $FFI_TYPE_DOUBLE, %eax
|
||||||
je .Lcls_retdouble
|
je .Lcls_retdouble
|
||||||
|
|
|
@ -30,7 +30,7 @@ int main (void)
|
||||||
sc < (signed char) 127; sc++)
|
sc < (signed char) 127; sc++)
|
||||||
{
|
{
|
||||||
ffi_call(&cif, FFI_FN(return_sc), &rint, values);
|
ffi_call(&cif, FFI_FN(return_sc), &rint, values);
|
||||||
CHECK((signed char) rint == sc);
|
CHECK(rint == (ffi_arg) sc);
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue