ffi.c (ffi_prep_closure): Set T bit in trampoline for the function returning a structure pointed with R2.

* src/sh/ffi.c (ffi_prep_closure): Set T bit in trampoline for
	the function returning a structure pointed with R2.
	* src/sh/sysv.S (ffi_closure_SYSV): Use R2 as the pointer to
	the structure return value if T bit set.  Emit position
	independent code and EH data if PIC.

From-SVN: r89254
This commit is contained in:
Kaz Kojima 2004-10-18 23:12:20 +00:00
parent 6e7a355c16
commit e0d3b4528f
3 changed files with 60 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2004-10-18 Kaz Kojima <kkojima@gcc.gnu.org>
* src/sh/ffi.c (ffi_prep_closure): Set T bit in trampoline for
the function returning a structure pointed with R2.
* src/sh/sysv.S (ffi_closure_SYSV): Use R2 as the pointer to
the structure return value if T bit set. Emit position
independent code and EH data if PIC.
2004-10-13 Kazuhiro Inaoka <inaoka.kazuhiro@renesas.com>
* Makefile.am: Add m32r support.

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2002, 2003 Kaz Kojima
ffi.c - Copyright (c) 2002, 2003, 2004 Kaz Kojima
SuperH Foreign Function Interface
@ -471,16 +471,22 @@ ffi_prep_closure (ffi_closure* closure,
void *user_data)
{
unsigned int *tramp;
unsigned short insn;
FFI_ASSERT (cif->abi == FFI_GCC_SYSV);
tramp = (unsigned int *) &closure->tramp[0];
/* Set T bit if the function returns a struct pointed with R2. */
insn = (return_type (cif->rtype) == FFI_TYPE_STRUCT
? 0x0018 /* sett */
: 0x0008 /* clrt */);
#ifdef __LITTLE_ENDIAN__
tramp[0] = 0xd301d202;
tramp[1] = 0x0009422b;
tramp[0] = 0xd301d102;
tramp[1] = 0x0000412b | (insn << 16);
#else
tramp[0] = 0xd202d301;
tramp[1] = 0x422b0009;
tramp[0] = 0xd102d301;
tramp[1] = 0x412b0000 | insn;
#endif
*(void **) &tramp[2] = (void *)closure; /* ctx */
*(void **) &tramp[3] = (void *)ffi_closure_SYSV; /* funaddr */

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2002, 2003 Kaz Kojima
sysv.S - Copyright (c) 2002, 2003, 2004 Kaz Kojima
SuperH Foreign Function Interface
@ -553,9 +553,12 @@ ENTRY(ffi_closure_SYSV)
mov r1,r7
#endif
bt/s 10f
mov r2, r5
mov r14,r1
add #8,r1
mov r1,r5
10:
mov r14,r1
#if defined(__SH4__)
@ -565,7 +568,15 @@ ENTRY(ffi_closure_SYSV)
#endif
mov.l r1,@r14
#ifdef PIC
mov.l L_got,r1
mova L_got,r0
add r0,r1
mov.l L_helper,r0
add r1,r0
#else
mov.l L_helper,r0
#endif
jsr @r0
mov r3,r4
@ -579,8 +590,15 @@ ENTRY(ffi_closure_SYSV)
add #8,r2
0:
.align 2
#ifdef PIC
L_got:
.long _GLOBAL_OFFSET_TABLE_
L_helper:
.long ffi_closure_helper_SYSV@GOTOFF
#else
L_helper:
.long ffi_closure_helper_SYSV
#endif
L_table:
.short L_case_v - 0b /* FFI_TYPE_VOID */
.short L_case_i - 0b /* FFI_TYPE_INT */
@ -683,10 +701,18 @@ __FRAME_BEGIN__:
.LSCIE1:
.4byte 0x0 /* CIE Identifier Tag */
.byte 0x1 /* CIE Version */
#ifdef PIC
.ascii "zR\0" /* CIE Augmentation */
#else
.byte 0x0 /* CIE Augmentation */
#endif
.byte 0x1 /* uleb128 0x1; CIE Code Alignment Factor */
.byte 0x7c /* sleb128 -4; CIE Data Alignment Factor */
.byte 0x11 /* CIE RA Column */
#ifdef PIC
.uleb128 0x1 /* Augmentation size */
.byte 0x10 /* FDE Encoding (pcrel) */
#endif
.byte 0xc /* DW_CFA_def_cfa */
.byte 0xf /* uleb128 0xf */
.byte 0x0 /* uleb128 0x0 */
@ -696,8 +722,15 @@ __FRAME_BEGIN__:
.4byte .LEFDE1-.LASFDE1 /* FDE Length */
.LASFDE1:
.4byte .LASFDE1-__FRAME_BEGIN__ /* FDE CIE offset */
#ifdef PIC
.4byte .LFB1-. /* FDE initial location */
#else
.4byte .LFB1 /* FDE initial location */
#endif
.4byte .LFE1-.LFB1 /* FDE address range */
#ifdef PIC
.uleb128 0x0 /* Augmentation size */
#endif
.byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFI0-.LFB1
.byte 0xe /* DW_CFA_def_cfa_offset */
@ -745,8 +778,15 @@ __FRAME_BEGIN__:
.4byte .LEFDE3-.LASFDE3 /* FDE Length */
.LASFDE3:
.4byte .LASFDE3-__FRAME_BEGIN__ /* FDE CIE offset */
#ifdef PIC
.4byte .LFB2-. /* FDE initial location */
#else
.4byte .LFB2 /* FDE initial location */
#endif
.4byte .LFE2-.LFB2 /* FDE address range */
#ifdef PIC
.uleb128 0x0 /* Augmentation size */
#endif
.byte 0x4 /* DW_CFA_advance_loc4 */
.4byte .LCFI7-.LFB2
.byte 0xe /* DW_CFA_def_cfa_offset */