Commit 8d8369f8 by Andreas Tobler Committed by Andreas Tobler

darwin.S: Cleanup whitespaces, comment formatting.

2003-09-18  Andreas Tobler  <a.tobler@schweiz.ch>

	* src/powerpc/darwin.S: Cleanup whitespaces, comment formatting.
	* src/powerpc/darwin_closure.S: Likewise.
	* src/powerpc/ffi_darwin.c: Likewise.

From-SVN: r71533
parent a6a0f876
2003-09-18 Andreas Tobler <a.tobler@schweiz.ch> 2003-09-18 Andreas Tobler <a.tobler@schweiz.ch>
* src/powerpc/darwin.S: Cleanup whitespaces, comment formatting.
* src/powerpc/darwin_closure.S: Likewise.
* src/powerpc/ffi_darwin.c: Likewise.
2003-09-18 Andreas Tobler <a.tobler@schweiz.ch>
David Edelsohn <edelsohn@gnu.org> David Edelsohn <edelsohn@gnu.org>
* src/types.c (double): Add AIX and Darwin to the right TYPEDEF. * src/types.c (double): Add AIX and Darwin to the right TYPEDEF.
......
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
darwin.S - Copyright (c) 2000 John Hornkvist darwin.S - Copyright (c) 2000 John Hornkvist
PowerPC Assembly glue. PowerPC Assembly glue.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
OTHER DEALINGS IN THE SOFTWARE. OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */ ----------------------------------------------------------------------- */
#define LIBFFI_ASM #define LIBFFI_ASM
#include <ffi.h> #include <ffi.h>
#define JUMPTARGET(name) name #define JUMPTARGET(name) name
#define L(x) x #define L(x) x
...@@ -37,59 +37,59 @@ ...@@ -37,59 +37,59 @@
.text .text
.align 2 .align 2
_ffi_call_DARWIN: _ffi_call_DARWIN:
LFB0: LFB0:
mr r12,r8 /* We only need r12 until the call, mr r12,r8 /* We only need r12 until the call,
so it doesn't have to be saved... */ so it doesn't have to be saved... */
LFB1: LFB1:
/* Save the old stack pointer as AP. */ /* Save the old stack pointer as AP. */
mr r8,r1 mr r8,r1
LCFI0: LCFI0:
/* Allocate the stack space we need. */ /* Allocate the stack space we need. */
stwux r1,r1,r4 stwux r1,r1,r4
/* Save registers we use. */ /* Save registers we use. */
mflr r9 mflr r9
stw r28,-16(r8) stw r28,-16(r8)
stw r29,-12(r8) stw r29,-12(r8)
stw r30, -8(r8) stw r30, -8(r8)
stw r31, -4(r8) stw r31, -4(r8)
stw r9, 8(r8) stw r9, 8(r8)
stw r2, 20(r1) stw r2, 20(r1)
LCFI1: LCFI1:
/* Save arguments over call... */ /* Save arguments over call... */
mr r31,r5 /* flags, */ mr r31,r5 /* flags, */
mr r30,r6 /* rvalue, */ mr r30,r6 /* rvalue, */
mr r29,r7 /* function address, */ mr r29,r7 /* function address, */
mr r28,r8 /* our AP. */ mr r28,r8 /* our AP. */
LCFI2: LCFI2:
/* Call ffi_prep_args. */ /* Call ffi_prep_args. */
mr r4,r1 mr r4,r1
li r9,0 li r9,0
mtctr r12 // r12 holds address of _ffi_prep_args mtctr r12 // r12 holds address of _ffi_prep_args
bctrl bctrl
lwz r2,20(r1) lwz r2,20(r1)
/* Now do the call. */ /* Now do the call.
/* Set up cr1 with bits 4-7 of the flags. */ Set up cr1 with bits 4-7 of the flags. */
mtcrf 0x40,r31 mtcrf 0x40,r31
/* Get the address to call into CTR. */ /* Get the address to call into CTR. */
mtctr r29 mtctr r29
/* Load all those argument registers. */ /* Load all those argument registers.
// We have set up a nice stack frame, just load it into registers. We have set up a nice stack frame, just load it into registers. */
lwz r3, 20+(1*4)(r1) lwz r3, 20+(1*4)(r1)
lwz r4, 20+(2*4)(r1) lwz r4, 20+(2*4)(r1)
lwz r5, 20+(3*4)(r1) lwz r5, 20+(3*4)(r1)
lwz r6, 20+(4*4)(r1) lwz r6, 20+(4*4)(r1)
nop nop
lwz r7, 20+(5*4)(r1) lwz r7, 20+(5*4)(r1)
lwz r8, 20+(6*4)(r1) lwz r8, 20+(6*4)(r1)
lwz r9, 20+(7*4)(r1) lwz r9, 20+(7*4)(r1)
lwz r10,20+(8*4)(r1) lwz r10,20+(8*4)(r1)
L1: L1:
/* Load all the FP registers. */ /* Load all the FP registers. */
bf 6,L2 // 2f + 0x18 bf 6,L2 // 2f + 0x18
...@@ -104,20 +104,20 @@ L1: ...@@ -104,20 +104,20 @@ L1:
lfd f8,-16-(6*8)(r28) lfd f8,-16-(6*8)(r28)
nop nop
lfd f9,-16-(5*8)(r28) lfd f9,-16-(5*8)(r28)
lfd f10,-16-(4*8)(r28) lfd f10,-16-(4*8)(r28)
lfd f11,-16-(3*8)(r28) lfd f11,-16-(3*8)(r28)
lfd f12,-16-(2*8)(r28) lfd f12,-16-(2*8)(r28)
nop nop
lfd f13,-16-(1*8)(r28) lfd f13,-16-(1*8)(r28)
L2: L2:
mr r12,r29 // Put the target address in r12 as specified. mr r12,r29 /* Put the target address in r12 as specified. */
mtctr r12 mtctr r12
nop nop
nop nop
/* Make the call. */ /* Make the call. */
bctrl bctrl
/* Now, deal with the return value. */ /* Now, deal with the return value. */
mtcrf 0x01,r31 mtcrf 0x01,r31
...@@ -147,7 +147,7 @@ L(fp_return_value): ...@@ -147,7 +147,7 @@ L(fp_return_value):
L(float_return_value): L(float_return_value):
stfs f1,0(r30) stfs f1,0(r30)
b L(done_return_value) b L(done_return_value)
LFE1: LFE1:
/* END(_ffi_call_DARWIN) */ /* END(_ffi_call_DARWIN) */
/* Provide a null definition of _ffi_call_AIX. */ /* Provide a null definition of _ffi_call_AIX. */
...@@ -193,26 +193,25 @@ LASFDE1: ...@@ -193,26 +193,25 @@ LASFDE1:
.set L$set$4,LCFI0-LFB1 .set L$set$4,LCFI0-LFB1
.long L$set$4 .long L$set$4
.byte 0xd ; DW_CFA_def_cfa_register .byte 0xd ; DW_CFA_def_cfa_register
.byte 0x08 ; uleb128 0x08 .byte 0x08 ; uleb128 0x08
.byte 0x4 ; DW_CFA_advance_loc4 .byte 0x4 ; DW_CFA_advance_loc4
.set L$set$5,LCFI1-LCFI0 .set L$set$5,LCFI1-LCFI0
.long L$set$5 .long L$set$5
.byte 0x11 ; DW_CFA_offset_extended_sf .byte 0x11 ; DW_CFA_offset_extended_sf
.byte 0x41 ; uleb128 0x41 .byte 0x41 ; uleb128 0x41
.byte 0x7e ; sleb128 -2 .byte 0x7e ; sleb128 -2
.byte 0x9f ; DW_CFA_offset, column 0x1f .byte 0x9f ; DW_CFA_offset, column 0x1f
.byte 0x1 ; uleb128 0x1 .byte 0x1 ; uleb128 0x1
.byte 0x9e ; DW_CFA_offset, column 0x1e .byte 0x9e ; DW_CFA_offset, column 0x1e
.byte 0x2 ; uleb128 0x2 .byte 0x2 ; uleb128 0x2
.byte 0x9d ; DW_CFA_offset, column 0x1d .byte 0x9d ; DW_CFA_offset, column 0x1d
.byte 0x3 ; uleb128 0x3 .byte 0x3 ; uleb128 0x3
.byte 0x9c ; DW_CFA_offset, column 0x1c .byte 0x9c ; DW_CFA_offset, column 0x1c
.byte 0x4 ; uleb128 0x4 .byte 0x4 ; uleb128 0x4
.byte 0x4 ; DW_CFA_advance_loc4 .byte 0x4 ; DW_CFA_advance_loc4
.set L$set$6,LCFI2-LCFI1 .set L$set$6,LCFI2-LCFI1
.long L$set$6 .long L$set$6
.byte 0xd ; DW_CFA_def_cfa_register .byte 0xd ; DW_CFA_def_cfa_register
.byte 0x1c ; uleb128 0x1c .byte 0x1c ; uleb128 0x1c
.align 2 .align 2
LEFDE1: LEFDE1:
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
darwin_closure.S - Copyright (c) 2002 2003 Free Software Foundation, darwin_closure.S - Copyright (c) 2002 2003 Free Software Foundation,
Inc. based on ppc_closure.S Inc. based on ppc_closure.S
PowerPC Assembly glue. PowerPC Assembly glue.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
...@@ -29,40 +29,40 @@ ...@@ -29,40 +29,40 @@
.file "darwin_closure.S" .file "darwin_closure.S"
.text .text
.align 2 .align 2
.globl _ffi_closure_ASM .globl _ffi_closure_ASM
.text .text
.align 2 .align 2
_ffi_closure_ASM: _ffi_closure_ASM:
LFB1: LFB1:
mflr r0 /* extract return address */ mflr r0 /* extract return address */
stw r0, 8(r1) /* save the return address */ stw r0, 8(r1) /* save the return address */
LCFI0: LCFI0:
/* 24 Bytes (Linkage Area) /* 24 Bytes (Linkage Area)
32 Bytes (outgoing parameter area, always reserved) 32 Bytes (outgoing parameter area, always reserved)
104 Bytes (13*8 from FPR) 104 Bytes (13*8 from FPR)
8 Bytes (result) 8 Bytes (result)
168 Bytes */ 168 Bytes */
stwu r1,-176(r1) /* skip over caller save area stwu r1,-176(r1) /* skip over caller save area
keep stack aligned to 16 */ keep stack aligned to 16. */
LCFI1: LCFI1:
/* we want to build up an area for the parameters passed /* We want to build up an area for the parameters passed
in registers (both floating point and integer) */ in registers. (both floating point and integer) */
/* we store gpr 3 to gpr 10 (aligned to 4) /* We store gpr 3 to gpr 10 (aligned to 4)
in the parents outgoing area */ in the parents outgoing area. */
stw r3, 200(r1) stw r3, 200(r1)
stw r4, 204(r1) stw r4, 204(r1)
stw r5, 208(r1) stw r5, 208(r1)
stw r6, 212(r1) stw r6, 212(r1)
stw r7, 216(r1) stw r7, 216(r1)
stw r8, 220(r1) stw r8, 220(r1)
stw r9, 224(r1) stw r9, 224(r1)
stw r10, 228(r1) stw r10, 228(r1)
/* we save fpr 1 to fpr 13 (aligned to 8) */ /* We save fpr 1 to fpr 13. (aligned to 8) */
stfd f1, 56(r1) stfd f1, 56(r1)
stfd f2, 64(r1) stfd f2, 64(r1)
stfd f3, 72(r1) stfd f3, 72(r1)
...@@ -71,45 +71,45 @@ LCFI1: ...@@ -71,45 +71,45 @@ LCFI1:
stfd f6, 96(r1) stfd f6, 96(r1)
stfd f7, 104(r1) stfd f7, 104(r1)
stfd f8, 112(r1) stfd f8, 112(r1)
stfd f9, 120(r1) stfd f9, 120(r1)
stfd f10, 128(r1) stfd f10, 128(r1)
stfd f11, 136(r1) stfd f11, 136(r1)
stfd f12, 144(r1) stfd f12, 144(r1)
stfd f13, 152(r1) stfd f13, 152(r1)
/* set up registers for the routine that actually does the work */ /* Set up registers for the routine that actually does the work
/* get the context pointer from the trampoline */ get the context pointer from the trampoline. */
mr r3,r11 mr r3,r11
/* now load up the pointer to the result storage */ /* Now load up the pointer to the result storage. */
addi r4,r1,160 addi r4,r1,160
/* now load up the pointer to the saved gpr registers */ /* Now load up the pointer to the saved gpr registers. */
addi r5,r1,200 addi r5,r1,200
/* now load up the pointer to the saved fpr registers */ /* Now load up the pointer to the saved fpr registers. */
addi r6,r1,56 addi r6,r1,56
/* make the call */ /* Make the call. */
bl Lffi_closure_helper_DARWIN$stub bl Lffi_closure_helper_DARWIN$stub
/* now r3 contains the return type */ /* Now r3 contains the return type
/* so use it to look up in a table */ so use it to look up in a table
/* so we know how to deal with each type */ so we know how to deal with each type. */
/* look up the proper starting point in table */ /* Look up the proper starting point in table
/* by using return type as offset */ by using return type as offset. */
addi r5,r1,160 /* get pointer to results area */ addi r5,r1,160 /* Get pointer to results area. */
bl Lget_ret_type0_addr /* get pointer to Lret_type0 into LR */ bl Lget_ret_type0_addr /* Get pointer to Lret_type0 into LR. */
mflr r4 /* move to r4 */ mflr r4 /* Move to r4. */
slwi r3,r3,4 /* now multiply return type by 16 */ slwi r3,r3,4 /* Now multiply return type by 16. */
add r3,r3,r4 /* add contents of table to table address */ add r3,r3,r4 /* Add contents of table to table address. */
mtctr r3 mtctr r3
bctr /* jump to it */ bctr /* Jump to it. */
LFE1: LFE1:
/* Each of the ret_typeX code fragments has to be exactly 16 bytes long */ /* Each of the ret_typeX code fragments has to be exactly 16 bytes long
/* (4 instructions). For cache effectiveness we align to a 16 byte boundary */ (4 instructions). For cache effectiveness we align to a 16 byte boundary
/* first. */ first. */
.align 4 .align 4
...@@ -142,21 +142,21 @@ Lret_type2: ...@@ -142,21 +142,21 @@ Lret_type2:
/* case FFI_TYPE_DOUBLE */ /* case FFI_TYPE_DOUBLE */
Lret_type3: Lret_type3:
lfd f1,0(r5) lfd f1,0(r5)
b Lfinish b Lfinish
nop nop
nop nop
/* case FFI_TYPE_LONGDOUBLE */ /* case FFI_TYPE_LONGDOUBLE */
Lret_type4: Lret_type4:
lfd f1,0(r5) lfd f1,0(r5)
b Lfinish b Lfinish
nop nop
nop nop
/* case FFI_TYPE_UINT8 */ /* case FFI_TYPE_UINT8 */
Lret_type5: Lret_type5:
lbz r3,3(r5) lbz r3,3(r5)
b Lfinish b Lfinish
nop nop
nop nop
...@@ -210,7 +210,7 @@ Lret_type12: ...@@ -210,7 +210,7 @@ Lret_type12:
b Lfinish b Lfinish
nop nop
/* case FFI_TYPE_STRUCT */ /* case FFI_TYPE_STRUCT */
Lret_type13: Lret_type13:
b Lfinish b Lfinish
nop nop
...@@ -224,14 +224,14 @@ Lret_type14: ...@@ -224,14 +224,14 @@ Lret_type14:
nop nop
nop nop
/* case done */ /* case done */
Lfinish: Lfinish:
addi r1,r1,176 /* restore stack pointer */ addi r1,r1,176 /* Restore stack pointer. */
lwz r0,8(r1) /* get return address */ lwz r0,8(r1) /* Get return address. */
mtlr r0 /* reset link register */ mtlr r0 /* Reset link register. */
blr blr
/* END(ffi_closure_ASM) */ /* END(ffi_closure_ASM) */
.data .data
.section __TEXT,__eh_frame .section __TEXT,__eh_frame
...@@ -267,7 +267,7 @@ LASFDE1: ...@@ -267,7 +267,7 @@ LASFDE1:
.set L$set$3,LCFI1-LCFI0 .set L$set$3,LCFI1-LCFI0
.long L$set$3 .long L$set$3
.byte 0xe ; DW_CFA_def_cfa_offset .byte 0xe ; DW_CFA_def_cfa_offset
.byte 176,1 ; uleb128 176 .byte 176,1 ; uleb128 176
.byte 0x4 ; DW_CFA_advance_loc4 .byte 0x4 ; DW_CFA_advance_loc4
.set L$set$4,LCFI0-LFB1 .set L$set$4,LCFI0-LFB1
.long L$set$4 .long L$set$4
...@@ -281,19 +281,19 @@ LEFDE1: ...@@ -281,19 +281,19 @@ LEFDE1:
LDFCM0: LDFCM0:
.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
.align 2 .align 2
Lffi_closure_helper_DARWIN$stub: Lffi_closure_helper_DARWIN$stub:
.indirect_symbol _ffi_closure_helper_DARWIN .indirect_symbol _ffi_closure_helper_DARWIN
mflr r0 mflr r0
bcl 20,31,LO$ffi_closure_helper_DARWIN bcl 20,31,LO$ffi_closure_helper_DARWIN
LO$ffi_closure_helper_DARWIN: LO$ffi_closure_helper_DARWIN:
mflr r11 mflr r11
addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN) addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)
mtlr r0 mtlr r0
lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)(r11) lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)(r11)
mtctr r12 mtctr r12
bctr bctr
.data .data
.lazy_symbol_pointer .lazy_symbol_pointer
L_ffi_closure_helper_DARWIN$lazy_ptr: L_ffi_closure_helper_DARWIN$lazy_ptr:
.indirect_symbol _ffi_closure_helper_DARWIN .indirect_symbol _ffi_closure_helper_DARWIN
.long dyld_stub_binding_helper .long dyld_stub_binding_helper
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Geoffrey Keating ffi.c - Copyright (c) 1998 Geoffrey Keating
PowerPC Foreign Function Interface PowerPC Foreign Function Interface
Darwin ABI support (c) 2001 John Hornkvist Darwin ABI support (c) 2001 John Hornkvist
AIX ABI support (c) 2002 Free Software Foundation, Inc. AIX ABI support (c) 2002 Free Software Foundation, Inc.
...@@ -34,12 +34,12 @@ extern void ffi_closure_ASM(void); ...@@ -34,12 +34,12 @@ extern void ffi_closure_ASM(void);
enum { enum {
/* The assembly depends on these exact flags. */ /* The assembly depends on these exact flags. */
FLAG_RETURNS_NOTHING = 1 << (31-30), /* These go in cr7 */ FLAG_RETURNS_NOTHING = 1 << (31-30), /* These go in cr7 */
FLAG_RETURNS_FP = 1 << (31-29), FLAG_RETURNS_FP = 1 << (31-29),
FLAG_RETURNS_64BITS = 1 << (31-28), FLAG_RETURNS_64BITS = 1 << (31-28),
FLAG_ARG_NEEDS_COPY = 1 << (31- 7), FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
FLAG_RETVAL_REFERENCE = 1 << (31- 4) FLAG_RETVAL_REFERENCE = 1 << (31- 4)
}; };
...@@ -58,7 +58,7 @@ enum { ASM_NEEDS_REGISTERS = 4 }; ...@@ -58,7 +58,7 @@ enum { ASM_NEEDS_REGISTERS = 4 };
| Return address from ffi_call_DARWIN | higher addresses | Return address from ffi_call_DARWIN | higher addresses
|--------------------------------------------| |--------------------------------------------|
| Previous backchain pointer 4 | stack pointer here | Previous backchain pointer 4 | stack pointer here
|--------------------------------------------|<+ <<< on entry to |--------------------------------------------|<+ <<< on entry to
| Saved r28-r31 4*4 | | ffi_call_DARWIN | Saved r28-r31 4*4 | | ffi_call_DARWIN
|--------------------------------------------| | |--------------------------------------------| |
...@@ -69,7 +69,7 @@ enum { ASM_NEEDS_REGISTERS = 4 }; ...@@ -69,7 +69,7 @@ enum { ASM_NEEDS_REGISTERS = 4 };
| Reserved 2*4 | | grows | | Reserved 2*4 | | grows |
|--------------------------------------------| | down V |--------------------------------------------| | down V
| Space for callee's LR 4 | | | Space for callee's LR 4 | |
|--------------------------------------------| | lower addresses |--------------------------------------------| | lower addresses
| Saved CR 4 | | | Saved CR 4 | |
|--------------------------------------------| | stack pointer here |--------------------------------------------| | stack pointer here
| Current backchain pointer 4 |-/ during | Current backchain pointer 4 |-/ during
...@@ -93,7 +93,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack) ...@@ -93,7 +93,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
/* 'next_arg' grows up as we put parameters in it. */ /* 'next_arg' grows up as we put parameters in it. */
unsigned *next_arg = stack + 6; // 6 reserved posistions. unsigned *next_arg = stack + 6; /* 6 reserved posistions. */
int i = ecif->cif->nargs; int i = ecif->cif->nargs;
double double_tmp; double double_tmp;
...@@ -108,9 +108,10 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack) ...@@ -108,9 +108,10 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
FFI_ASSERT(((unsigned)(char *)stacktop & 0xF) == 0); FFI_ASSERT(((unsigned)(char *)stacktop & 0xF) == 0);
FFI_ASSERT((bytes & 0xF) == 0); FFI_ASSERT((bytes & 0xF) == 0);
/* Deal with return values that are actually pass-by-reference. */ /* Deal with return values that are actually pass-by-reference.
// Rule: Rule:
// Return values are referenced by r3, so r4 is the first parameter. Return values are referenced by r3, so r4 is the first parameter. */
if (flags & FLAG_RETVAL_REFERENCE) if (flags & FLAG_RETVAL_REFERENCE)
*next_arg++ = (unsigned)(char *)ecif->rvalue; *next_arg++ = (unsigned)(char *)ecif->rvalue;
...@@ -127,28 +128,28 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack) ...@@ -127,28 +128,28 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
double_tmp = *(float *)*p_argv; double_tmp = *(float *)*p_argv;
if (fparg_count >= NUM_FPR_ARG_REGISTERS) if (fparg_count >= NUM_FPR_ARG_REGISTERS)
*(double *)next_arg = double_tmp; *(double *)next_arg = double_tmp;
else else
*fpr_base++ = double_tmp; *fpr_base++ = double_tmp;
next_arg++; next_arg++;
fparg_count++; fparg_count++;
FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
break; break;
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
double_tmp = *(double *)*p_argv; double_tmp = *(double *)*p_argv;
if (fparg_count >= NUM_FPR_ARG_REGISTERS) if (fparg_count >= NUM_FPR_ARG_REGISTERS)
*(double *)next_arg = double_tmp; *(double *)next_arg = double_tmp;
else else
*fpr_base++ = double_tmp; *fpr_base++ = double_tmp;
next_arg += 2; next_arg += 2;
fparg_count++; fparg_count++;
FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
break; break;
case FFI_TYPE_UINT64: case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64: case FFI_TYPE_SINT64:
*(long long *)next_arg = *(long long *)*p_argv; *(long long *)next_arg = *(long long *)*p_argv;
next_arg+=2; next_arg+=2;
break; break;
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
gprvalue = *(unsigned char *)*p_argv; gprvalue = *(unsigned char *)*p_argv;
...@@ -187,7 +188,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack) ...@@ -187,7 +188,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
break; break;
case FFI_TYPE_INT: case FFI_TYPE_INT:
case FFI_TYPE_UINT32: case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32: case FFI_TYPE_SINT32:
case FFI_TYPE_POINTER: case FFI_TYPE_POINTER:
gprvalue = *(unsigned *)*p_argv; gprvalue = *(unsigned *)*p_argv;
...@@ -206,7 +207,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack) ...@@ -206,7 +207,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
//FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); //FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
} }
/* Perform machine dependent cif processing */ /* Perform machine dependent cif processing. */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif) ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{ {
/* All this is for the DARWIN ABI. */ /* All this is for the DARWIN ABI. */
...@@ -220,7 +221,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) ...@@ -220,7 +221,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
/* All the machine-independent calculation of cif->bytes will be wrong. /* All the machine-independent calculation of cif->bytes will be wrong.
Redo the calculation for DARWIN. */ Redo the calculation for DARWIN. */
/* Space for the frame pointer, callee's LR, CR, etc, and for /* Space for the frame pointer, callee's LR, CR, etc, and for
the asm's temp regs. */ the asm's temp regs. */
bytes = (6 + ASM_NEEDS_REGISTERS) * sizeof(long); bytes = (6 + ASM_NEEDS_REGISTERS) * sizeof(long);
...@@ -343,22 +344,22 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) ...@@ -343,22 +344,22 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
/*@-declundef@*/ /*@-declundef@*/
/*@-exportheader@*/ /*@-exportheader@*/
extern void ffi_call_AIX(/*@out@*/ extended_cif *, extern void ffi_call_AIX(/*@out@*/ extended_cif *,
unsigned, unsigned, unsigned, unsigned,
/*@out@*/ unsigned *, /*@out@*/ unsigned *,
void (*fn)(), void (*fn)(),
void (*fn2)()); void (*fn2)());
extern void ffi_call_DARWIN(/*@out@*/ extended_cif *, extern void ffi_call_DARWIN(/*@out@*/ extended_cif *,
unsigned, unsigned, unsigned, unsigned,
/*@out@*/ unsigned *, /*@out@*/ unsigned *,
void (*fn)(), void (*fn)(),
void (*fn2)()); void (*fn2)());
/*@=declundef@*/ /*@=declundef@*/
/*@=exportheader@*/ /*@=exportheader@*/
void ffi_call(/*@dependent@*/ ffi_cif *cif, void ffi_call(/*@dependent@*/ ffi_cif *cif,
void (*fn)(), void (*fn)(),
/*@out@*/ void *rvalue, /*@out@*/ void *rvalue,
/*@dependent@*/ void **avalue) /*@dependent@*/ void **avalue)
{ {
extended_cif ecif; extended_cif ecif;
...@@ -366,10 +367,10 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif, ...@@ -366,10 +367,10 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif,
ecif.cif = cif; ecif.cif = cif;
ecif.avalue = avalue; ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return */ /* If the return value is a struct and we don't have a return
/* value address then we need to make one */ value address then we need to make one. */
if ((rvalue == NULL) && if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT)) (cif->rtype->type == FFI_TYPE_STRUCT))
{ {
/*@-sysunrecog@*/ /*@-sysunrecog@*/
...@@ -379,17 +380,17 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif, ...@@ -379,17 +380,17 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif,
else else
ecif.rvalue = rvalue; ecif.rvalue = rvalue;
switch (cif->abi) switch (cif->abi)
{ {
case FFI_AIX: case FFI_AIX:
/*@-usedef@*/ /*@-usedef@*/
ffi_call_AIX(&ecif, -cif->bytes, ffi_call_AIX(&ecif, -cif->bytes,
cif->flags, ecif.rvalue, fn, ffi_prep_args); cif->flags, ecif.rvalue, fn, ffi_prep_args);
/*@=usedef@*/ /*@=usedef@*/
break; break;
case FFI_DARWIN: case FFI_DARWIN:
/*@-usedef@*/ /*@-usedef@*/
ffi_call_DARWIN(&ecif, -cif->bytes, ffi_call_DARWIN(&ecif, -cif->bytes,
cif->flags, ecif.rvalue, fn, ffi_prep_args); cif->flags, ecif.rvalue, fn, ffi_prep_args);
/*@=usedef@*/ /*@=usedef@*/
break; break;
...@@ -402,8 +403,8 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif, ...@@ -402,8 +403,8 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif,
static void flush_icache(char *); static void flush_icache(char *);
static void flush_range(char *, int); static void flush_range(char *, int);
/* The layout of a function descriptor. A C function pointer really */ /* The layout of a function descriptor. A C function pointer really
/* points to one of these. */ points to one of these. */
typedef struct aix_fd_struct { typedef struct aix_fd_struct {
void *code_pointer; void *code_pointer;
...@@ -411,70 +412,70 @@ typedef struct aix_fd_struct { ...@@ -411,70 +412,70 @@ typedef struct aix_fd_struct {
} aix_fd; } aix_fd;
/* here I'd like to add the stack frame layout we use in darwin_closure.S /* here I'd like to add the stack frame layout we use in darwin_closure.S
* and aix_clsoure.S and aix_clsoure.S
*
* SP previous -> +---------------------------------------+ <--- child frame SP previous -> +---------------------------------------+ <--- child frame
| back chain to caller 4 | | back chain to caller 4 |
+---------------------------------------+ 4 +---------------------------------------+ 4
| saved CR 4 | | saved CR 4 |
+---------------------------------------+ 8 +---------------------------------------+ 8
| saved LR 4 | | saved LR 4 |
+---------------------------------------+ 12 +---------------------------------------+ 12
| reserved for compilers 4 | | reserved for compilers 4 |
+---------------------------------------+ 16 +---------------------------------------+ 16
| reserved for binders 4 | | reserved for binders 4 |
+---------------------------------------+ 20 +---------------------------------------+ 20
| saved TOC pointer 4 | | saved TOC pointer 4 |
+---------------------------------------+ 24 +---------------------------------------+ 24
| always reserved 8*4=32 (previous GPRs)| | always reserved 8*4=32 (previous GPRs)|
| according to the linkage convention | | according to the linkage convention |
| from AIX | | from AIX |
+---------------------------------------+ 56 +---------------------------------------+ 56
| our FPR area 13*8=104 | | our FPR area 13*8=104 |
| f1 | | f1 |
| . | | . |
| f13 | | f13 |
+---------------------------------------+ 160 +---------------------------------------+ 160
| result area 8 | | result area 8 |
+---------------------------------------+ 168 +---------------------------------------+ 168
| alignement to the next multiple of 16 | | alignement to the next multiple of 16 |
SP current --> +---------------------------------------+ 176 <- parent frame SP current --> +---------------------------------------+ 176 <- parent frame
| back chain to caller 4 | | back chain to caller 4 |
+---------------------------------------+ 180 +---------------------------------------+ 180
| saved CR 4 | | saved CR 4 |
+---------------------------------------+ 184 +---------------------------------------+ 184
| saved LR 4 | | saved LR 4 |
+---------------------------------------+ 188 +---------------------------------------+ 188
| reserved for compilers 4 | | reserved for compilers 4 |
+---------------------------------------+ 192 +---------------------------------------+ 192
| reserved for binders 4 | | reserved for binders 4 |
+---------------------------------------+ 196 +---------------------------------------+ 196
| saved TOC pointer 4 | | saved TOC pointer 4 |
+---------------------------------------+ 200 +---------------------------------------+ 200
| always reserved 8*4=32 we store our | | always reserved 8*4=32 we store our |
| GPRs here | | GPRs here |
| r3 | | r3 |
| . | | . |
| r10 | | r10 |
+---------------------------------------+ 232 +---------------------------------------+ 232
| overflow part | | overflow part |
+---------------------------------------+ xxx +---------------------------------------+ xxx
| ???? | | ???? |
+---------------------------------------+ xxx +---------------------------------------+ xxx
*/ */
ffi_status ffi_status
ffi_prep_closure (ffi_closure* closure, ffi_prep_closure (ffi_closure* closure,
ffi_cif* cif, ffi_cif* cif,
void (*fun)(ffi_cif*, void*, void**, void*), void (*fun)(ffi_cif*, void*, void**, void*),
void *user_data) void *user_data)
{ {
unsigned int *tramp; unsigned int *tramp;
struct ffi_aix_trampoline_struct *tramp_aix; struct ffi_aix_trampoline_struct *tramp_aix;
aix_fd *fd; aix_fd *fd;
switch (cif->abi) switch (cif->abi)
{ {
case FFI_DARWIN: case FFI_DARWIN:
FFI_ASSERT (cif->abi == FFI_DARWIN); FFI_ASSERT (cif->abi == FFI_DARWIN);
...@@ -527,12 +528,12 @@ flush_icache(char *addr) ...@@ -527,12 +528,12 @@ flush_icache(char *addr)
{ {
#ifndef _AIX #ifndef _AIX
__asm__ volatile ( __asm__ volatile (
"dcbf 0,%0;" "dcbf 0,%0;"
"sync;" "sync;"
"icbi 0,%0;" "icbi 0,%0;"
"sync;" "sync;"
"isync;" "isync;"
: : "r"(addr) : "memory"); : : "r"(addr) : "memory");
#endif #endif
} }
...@@ -556,12 +557,11 @@ int ffi_closure_helper_DARWIN (ffi_closure*, void*, ...@@ -556,12 +557,11 @@ int ffi_closure_helper_DARWIN (ffi_closure*, void*,
unsigned long*, ffi_dblfl*); unsigned long*, ffi_dblfl*);
/* Basically the trampoline invokes ffi_closure_ASM, and on /* Basically the trampoline invokes ffi_closure_ASM, and on
* entry, r11 holds the address of the closure. entry, r11 holds the address of the closure.
* After storing the registers that could possibly contain After storing the registers that could possibly contain
* parameters to be passed into the stack frame and setting parameters to be passed into the stack frame and setting
* up space for a return value, ffi_closure_ASM invokes the up space for a return value, ffi_closure_ASM invokes the
* following helper function to do most of the work following helper function to do most of the work. */
*/
int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue, int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
unsigned long * pgr, ffi_dblfl * pfr) unsigned long * pgr, ffi_dblfl * pfr)
...@@ -574,8 +574,8 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue, ...@@ -574,8 +574,8 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
void ** avalue; void ** avalue;
ffi_type ** arg_types; ffi_type ** arg_types;
long i, avn; long i, avn;
long nf; /* number of floating registers already used */ long nf; /* number of floating registers already used. */
long ng; /* number of general registers already used */ long ng; /* number of general registers already used. */
ffi_cif * cif; ffi_cif * cif;
double temp; double temp;
unsigned size_al; unsigned size_al;
...@@ -652,10 +652,8 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue, ...@@ -652,10 +652,8 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
break; break;
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
/* a float value consumes a GPR /* A float value consumes a GPR.
* There are 13 64bit floating point registers. */
* here are 13 64bit floating point registers.
*/
if (nf < NUM_FPR_ARG_REGISTERS) if (nf < NUM_FPR_ARG_REGISTERS)
{ {
temp = pfr->d; temp = pfr->d;
...@@ -673,10 +671,8 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue, ...@@ -673,10 +671,8 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
break; break;
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
/* a double value consumes two GPRs /* A double value consumes two GPRs.
* There are 13 64bit floating point registers. */
* There are 13 64bit floating point registers.
*/
if (nf < NUM_FPR_ARG_REGISTERS) if (nf < NUM_FPR_ARG_REGISTERS)
{ {
avalue[i] = pfr; avalue[i] = pfr;
...@@ -691,9 +687,9 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue, ...@@ -691,9 +687,9 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
pgr += 2; pgr += 2;
break; break;
default: default:
FFI_ASSERT(0); FFI_ASSERT(0);
} }
i++; i++;
} }
......
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