Commit 583a92e8 by SUGIOKA Toshinobu Committed by Kaz Kojima

sysv.S (ffi_call_SYSV): Stop argument popping correctly on sh3.

	* src/sh/sysv.S (ffi_call_SYSV): Stop argument popping correctly
	on sh3.
	(ffi_closure_SYSV): Change the stack layout for sh3 struct argument.
	* src/sh/ffi.c (ffi_prep_args): Fix sh3 argument copy, when it is
	partially on register.
	(ffi_closure_helper_SYSV): Likewise.
	(ffi_prep_cif_machdep): Don't set too many cif->flags.

From-SVN: r102298
parent 46a2c9d2
2005-07-22 SUGIOKA Toshinobu <sugioka@itonet.co.jp>
* src/sh/sysv.S (ffi_call_SYSV): Stop argument popping correctly
on sh3.
(ffi_closure_SYSV): Change the stack layout for sh3 struct argument.
* src/sh/ffi.c (ffi_prep_args): Fix sh3 argument copy, when it is
partially on register.
(ffi_closure_helper_SYSV): Likewise.
(ffi_prep_cif_machdep): Don't set too many cif->flags.
2005-07-20 Kaz Kojima <kkojima@gcc.gnu.org> 2005-07-20 Kaz Kojima <kkojima@gcc.gnu.org>
* src/sh/ffi.c (ffi_call): Handle small structures correctly. * src/sh/ffi.c (ffi_call): Handle small structures correctly.
......
...@@ -210,15 +210,11 @@ void ffi_prep_args(char *stack, extended_cif *ecif) ...@@ -210,15 +210,11 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
#if defined(__SH4__) #if defined(__SH4__)
if (greg + n - 1 >= NGREGARG) if (greg + n - 1 >= NGREGARG)
continue; continue;
greg += n;
#else #else
if (greg >= NGREGARG) if (greg >= NGREGARG)
continue; continue;
else if (greg + n - 1 >= NGREGARG)
greg = NGREGARG;
else
greg += n;
#endif #endif
greg += n;
memcpy (argp, *p_argv, z); memcpy (argp, *p_argv, z);
argp += n * sizeof (int); argp += n * sizeof (int);
} }
...@@ -380,9 +376,8 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) ...@@ -380,9 +376,8 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
if (greg >= NGREGARG) if (greg >= NGREGARG)
continue; continue;
else if (greg + n - 1 >= NGREGARG) else if (greg + n - 1 >= NGREGARG)
greg = NGREGARG; n = NGREGARG - greg;
else greg += n;
greg += n;
for (m = 0; m < n; m++) for (m = 0; m < n; m++)
cif->flags += FFI_TYPE_INT << (2 * j++); cif->flags += FFI_TYPE_INT << (2 * j++);
} }
...@@ -628,15 +623,11 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue, ...@@ -628,15 +623,11 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
#if defined(__SH4__) #if defined(__SH4__)
if (greg + n - 1 >= NGREGARG) if (greg + n - 1 >= NGREGARG)
continue; continue;
greg += n;
#else #else
if (greg >= NGREGARG) if (greg >= NGREGARG)
continue; continue;
else if (greg + n - 1 >= NGREGARG)
greg = NGREGARG;
else
greg += n;
#endif #endif
greg += n;
avalue[i] = pgr; avalue[i] = pgr;
pgr += n; pgr += n;
} }
...@@ -720,7 +711,8 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue, ...@@ -720,7 +711,8 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
#if (! defined(__SH4__)) #if (! defined(__SH4__))
else if (greg < NGREGARG) else if (greg < NGREGARG)
{ {
greg = NGREGARG; greg += n;
pst += greg - NGREGARG;
continue; continue;
} }
#endif #endif
......
...@@ -401,6 +401,9 @@ L_pop_d: ...@@ -401,6 +401,9 @@ L_pop_d:
mov.l @r15+,r7 mov.l @r15+,r7
L_pass_i: L_pass_i:
cmp/eq #FFI_TYPE_INT,r0
bf L_call_it
mov #8,r0 mov #8,r0
cmp/hs r0,r2 cmp/hs r0,r2
bt/s 2f bt/s 2f
...@@ -492,39 +495,42 @@ L_epilogue: ...@@ -492,39 +495,42 @@ L_epilogue:
ENTRY(ffi_closure_SYSV) ENTRY(ffi_closure_SYSV)
.LFB2: .LFB2:
mov.l r14,@-r15 mov.l r7,@-r15
.LCFI7: .LCFI7:
mov.l r6,@-r15
.LCFI8:
mov.l r5,@-r15
.LCFI9:
mov.l r4,@-r15
.LCFIA:
mov.l r14,@-r15
.LCFIB:
sts.l pr,@-r15 sts.l pr,@-r15
/* Stack layout: /* Stack layout:
... xx bytes (on stack parameters)
32 bytes (floating register parameters, SH-4 only)
16 bytes (register parameters) 16 bytes (register parameters)
4 bytes (saved frame pointer)
4 bytes (saved return address)
32 bytes (floating register parameters, SH-4 only)
8 bytes (result) 8 bytes (result)
4 bytes (pad) 4 bytes (pad)
4 bytes (5th arg) 4 bytes (5th arg)
<- new stack pointer <- new stack pointer
*/ */
.LCFI8: .LCFIC:
#if defined(__SH4__) #if defined(__SH4__)
add #-64,r15 add #-48,r15
#else #else
add #-32,r15 add #-16,r15
#endif #endif
.LCFI9: .LCFID:
mov r15,r14 mov r15,r14
.LCFIA: .LCFIE:
mov r14,r1
add #32,r1
mov.l r7,@-r1
mov.l r6,@-r1
mov.l r5,@-r1
mov.l r4,@-r1
mov r1,r6
#if defined(__SH4__) #if defined(__SH4__)
mov r14,r1 mov r14,r1
add #64,r1 add #48,r1
#ifdef __LITTLE_ENDIAN__ #ifdef __LITTLE_ENDIAN__
fmov.s fr10,@-r1 fmov.s fr10,@-r1
fmov.s fr11,@-r1 fmov.s fr11,@-r1
...@@ -545,6 +551,11 @@ ENTRY(ffi_closure_SYSV) ...@@ -545,6 +551,11 @@ ENTRY(ffi_closure_SYSV)
fmov.s fr4,@-r1 fmov.s fr4,@-r1
#endif #endif
mov r1,r7 mov r1,r7
mov r14,r6
add #56,r6
#else
mov r14,r6
add #24,r6
#endif #endif
bt/s 10f bt/s 10f
...@@ -678,13 +689,14 @@ L_case_uh: ...@@ -678,13 +689,14 @@ L_case_uh:
L_case_v: L_case_v:
#if defined(__SH4__) #if defined(__SH4__)
add #64,r15 add #48,r15
#else #else
add #32,r15 add #16,r15
#endif #endif
lds.l @r15+,pr lds.l @r15+,pr
mov.l @r15+,r14
rts rts
mov.l @r15+,r14 add #16,r15
.LFE2: .LFE2:
.ffi_closure_SYSV_end: .ffi_closure_SYSV_end:
.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
...@@ -788,21 +800,45 @@ __FRAME_BEGIN__: ...@@ -788,21 +800,45 @@ __FRAME_BEGIN__:
.byte 0x4 /* DW_CFA_advance_loc4 */ .byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFI8-.LCFI7 .4byte .LCFI8-.LCFI7
.byte 0xe /* DW_CFA_def_cfa_offset */ .byte 0xe /* DW_CFA_def_cfa_offset */
.byte 0x8 /* uleb128 0x8 */ .byte 0x8 /* uleb128 0x4 */
.byte 0x4 /* DW_CFA_advance_loc4 */ .byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFI9-.LCFI8 .4byte .LCFI9-.LCFI8
.byte 0xe /* DW_CFA_def_cfa_offset */ .byte 0xe /* DW_CFA_def_cfa_offset */
.byte 0xc /* uleb128 0x4 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFIA-.LCFI9
.byte 0xe /* DW_CFA_def_cfa_offset */
.byte 0x10 /* uleb128 0x4 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFIB-.LCFIA
.byte 0xe /* DW_CFA_def_cfa_offset */
.byte 0x14 /* uleb128 0x4 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFIC-.LCFIB
.byte 0xe /* DW_CFA_def_cfa_offset */
.byte 0x18 /* uleb128 0x4 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFID-.LCFIC
.byte 0xe /* DW_CFA_def_cfa_offset */
#if defined(__SH4__) #if defined(__SH4__)
.byte 8+64 /* uleb128 8+64 */ .byte 24+48 /* uleb128 24+48 */
#else #else
.byte 8+32 /* uleb128 8+32 */ .byte 24+16 /* uleb128 24+16 */
#endif #endif
.byte 0x91 /* DW_CFA_offset, column 0x11 */ .byte 0x91 /* DW_CFA_offset, column 0x11 */
.byte 0x2 .byte 0x6 /* uleb128 0x6 */
.byte 0x8e /* DW_CFA_offset, column 0xe */ .byte 0x8e /* DW_CFA_offset, column 0xe */
.byte 0x1 .byte 0x5 /* uleb128 0x5 */
.byte 0x8b /* DW_CFA_offset, column 0xb */
.byte 0x4 /* uleb128 0x4 */
.byte 0x8a /* DW_CFA_offset, column 0xa */
.byte 0x3 /* uleb128 0x3 */
.byte 0x89 /* DW_CFA_offset, column 0x9 */
.byte 0x2 /* uleb128 0x2 */
.byte 0x88 /* DW_CFA_offset, column 0x8 */
.byte 0x1 /* uleb128 0x1 */
.byte 0x4 /* DW_CFA_advance_loc4 */ .byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFIA-.LCFI9 .4byte .LCFIE-.LCFID
.byte 0xd /* DW_CFA_def_cfa_register */ .byte 0xd /* DW_CFA_def_cfa_register */
.byte 0xe /* uleb128 0xe */ .byte 0xe /* uleb128 0xe */
.align 2 .align 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment