* src/powerpc/aix.S: Remove whitespaces.
* src/powerpc/aix_closure.S: Likewise.
* src/powerpc/asm.h: Likewise.
* src/powerpc/ffi.c: Likewise.
* src/powerpc/ffitarget.h: Likewise.
* src/powerpc/linux64.S: Likewise.
* src/powerpc/linux64_closure.S: Likewise.
* src/powerpc/ppc_closure.S: Likewise.
* src/powerpc/sysv.S: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86991
138bc75d-0d04-0410-961f-
82ee72b054a4
+2004-09-02 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/aix.S: Remove whitespaces.
+ * src/powerpc/aix_closure.S: Likewise.
+ * src/powerpc/asm.h: Likewise.
+ * src/powerpc/ffi.c: Likewise.
+ * src/powerpc/ffitarget.h: Likewise.
+ * src/powerpc/linux64.S: Likewise.
+ * src/powerpc/linux64_closure.S: Likewise.
+ * src/powerpc/ppc_closure.S: Likewise.
+ * src/powerpc/sysv.S: Likewise.
+
2004-08-30 Anthony Green <green@redhat.com>
* Makefile.am: Add frv support.
2004-08-30 Anthony Green <green@redhat.com>
* Makefile.am: Add frv support.
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
- .set r0,0
- .set r1,1
- .set r2,2
- .set r3,3
- .set r4,4
- .set r5,5
- .set r6,6
- .set r7,7
- .set r8,8
- .set r9,9
- .set r10,10
- .set r11,11
- .set r12,12
- .set r13,13
- .set r14,14
- .set r15,15
- .set r16,16
- .set r17,17
- .set r18,18
- .set r19,19
- .set r20,20
- .set r21,21
- .set r22,22
- .set r23,23
- .set r24,24
- .set r25,25
- .set r26,26
- .set r27,27
- .set r28,28
- .set r29,29
- .set r30,30
- .set r31,31
- .set f0,0
- .set f1,1
- .set f2,2
- .set f3,3
- .set f4,4
- .set f5,5
- .set f6,6
- .set f7,7
- .set f8,8
- .set f9,9
- .set f10,10
- .set f11,11
- .set f12,12
- .set f13,13
- .set f14,14
- .set f15,15
- .set f16,16
- .set f17,17
- .set f18,18
- .set f19,19
- .set f20,20
- .set f21,21
-
-#define LIBFFI_ASM
+ .set r0,0
+ .set r1,1
+ .set r2,2
+ .set r3,3
+ .set r4,4
+ .set r5,5
+ .set r6,6
+ .set r7,7
+ .set r8,8
+ .set r9,9
+ .set r10,10
+ .set r11,11
+ .set r12,12
+ .set r13,13
+ .set r14,14
+ .set r15,15
+ .set r16,16
+ .set r17,17
+ .set r18,18
+ .set r19,19
+ .set r20,20
+ .set r21,21
+ .set r22,22
+ .set r23,23
+ .set r24,24
+ .set r25,25
+ .set r26,26
+ .set r27,27
+ .set r28,28
+ .set r29,29
+ .set r30,30
+ .set r31,31
+ .set f0,0
+ .set f1,1
+ .set f2,2
+ .set f3,3
+ .set f4,4
+ .set f5,5
+ .set f6,6
+ .set f7,7
+ .set f8,8
+ .set f9,9
+ .set f10,10
+ .set f11,11
+ .set f12,12
+ .set f13,13
+ .set f14,14
+ .set f15,15
+ .set f16,16
+ .set f17,17
+ .set f18,18
+ .set f19,19
+ .set f20,20
+ .set f21,21
+
+#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
#define JUMPTARGET(name) name
#include <fficonfig.h>
#include <ffi.h>
#define JUMPTARGET(name) name
mr r8,r1
/* Allocate the stack space we need. */
mr r8,r1
/* Allocate the stack space we need. */
/* Save registers we use. */
mflr r9
/* Save registers we use. */
mflr r9
lwz r2,4(r12)
lwz r12,0(r12)
mtctr r12 // r12 holds address of _ffi_prep_args
lwz r2,4(r12)
lwz r12,0(r12)
mtctr r12 // r12 holds address of _ffi_prep_args
lwz r2,20(r1)
/* Now do the call. */
lwz r2,20(r1)
/* Now do the call. */
/* -----------------------------------------------------------------------
aix_closure.S - Copyright (c) 2002 2003 Free Software Foundation, Inc.
/* -----------------------------------------------------------------------
aix_closure.S - Copyright (c) 2002 2003 Free Software Foundation, Inc.
- based on darwin_closure.S
+ based on darwin_closure.S
in the parents outgoing area */
stw r3, 200(r1)
stw r4, 204(r1)
in the parents outgoing area */
stw r3, 200(r1)
stw r4, 204(r1)
stw r6, 212(r1)
stw r7, 216(r1)
stw r6, 212(r1)
stw r7, 216(r1)
stw r9, 224(r1)
stw r10, 228(r1)
stw r9, 224(r1)
stw r10, 228(r1)
stfd f6, 96(r1)
stfd f7, 104(r1)
stfd f8, 112(r1)
stfd f6, 96(r1)
stfd f7, 104(r1)
stfd f8, 112(r1)
- stfd f9, 120(r1)
- stfd f10, 128(r1)
- stfd f11, 136(r1)
- stfd f12, 144(r1)
- stfd f13, 152(r1)
+ stfd f9, 120(r1)
+ stfd f10, 128(r1)
+ stfd f11, 136(r1)
+ stfd f12, 144(r1)
+ stfd f13, 152(r1)
/* set up registers for the routine that actually does the work */
/* get the context pointer from the trampoline */
/* set up registers for the routine that actually does the work */
/* get the context pointer from the trampoline */
b L..44
/* case unsigned int16 */
b L..44
/* case unsigned int16 */
addi r5,r5,2
lhz r3,0(r5)
addi r5,r5,2
lhz r3,0(r5)
/* -----------------------------------------------------------------------
asm.h - Copyright (c) 1998 Geoffrey Keating
/* -----------------------------------------------------------------------
asm.h - Copyright (c) 1998 Geoffrey Keating
-
- PowerPC Assembly glue.
- $Id: asm.h,v 1.1.1.1 1998/11/29 16:48:16 green Exp $
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
#ifdef PIC
#define CALL_MCOUNT \
.pushsection; \
#ifdef PIC
#define CALL_MCOUNT \
.pushsection; \
.align ALIGNARG(2); \
0:.long 0; \
.previous; \
mflr %r0; \
.align ALIGNARG(2); \
0:.long 0; \
.previous; \
mflr %r0; \
bl _GLOBAL_OFFSET_TABLE_@local-4; \
mflr %r11; \
lwz %r0,0b@got(%r11); \
bl _GLOBAL_OFFSET_TABLE_@local-4; \
mflr %r11; \
lwz %r0,0b@got(%r11); \
0:.long 0; \
.previous; \
mflr %r0; \
0:.long 0; \
.previous; \
mflr %r0; \
- lis %r11,0b@ha; \
- stw %r0,4(%r1); \
+ lis %r11,0b@ha; \
+ stw %r0,4(%r1); \
addi %r0,%r11,0b@l; \
bl JUMPTARGET(_mcount);
#endif /* PIC */
addi %r0,%r11,0b@l; \
bl JUMPTARGET(_mcount);
#endif /* PIC */
/* Local labels stripped out by the linker. */
#define L(x) .L##x
/* Local labels stripped out by the linker. */
#define L(x) .L##x
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Geoffrey Keating
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Geoffrey Keating
-
- PowerPC Foreign Function Interface
- $Id: ffi.c,v 1.1.1.1 1998/11/29 16:48:16 green Exp $
+ PowerPC Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
| Return address from ffi_call_SYSV 4bytes | higher addresses
|--------------------------------------------|
| Return address from ffi_call_SYSV 4bytes | higher addresses
|--------------------------------------------|
- | Previous backchain pointer 4 | stack pointer here
+ | Previous backchain pointer 4 | stack pointer here
|--------------------------------------------|<+ <<< on entry to
| Saved r28-r31 4*4 | | ffi_call_SYSV
|--------------------------------------------| |
|--------------------------------------------|<+ <<< on entry to
| Saved r28-r31 4*4 | | ffi_call_SYSV
|--------------------------------------------| |
| Current backchain pointer 4 |-/ during
|--------------------------------------------| <<< ffi_call_SYSV
| Current backchain pointer 4 |-/ during
|--------------------------------------------| <<< ffi_call_SYSV
/*@-exportheader@*/
void ffi_prep_args_SYSV(extended_cif *ecif, unsigned *const stack)
/*@-exportheader@*/
void ffi_prep_args_SYSV(extended_cif *ecif, unsigned *const stack)
{
const unsigned bytes = ecif->cif->bytes;
const unsigned flags = ecif->cif->flags;
{
const unsigned bytes = ecif->cif->bytes;
const unsigned flags = ecif->cif->flags;
/* 'stacktop' points at the previous backchain pointer. */
unsigned *const stacktop = stack + (bytes / sizeof(unsigned));
/* 'stacktop' points at the previous backchain pointer. */
unsigned *const stacktop = stack + (bytes / sizeof(unsigned));
/* Deal with return values that are actually pass-by-reference. */
if (flags & FLAG_RETVAL_REFERENCE)
/* Deal with return values that are actually pass-by-reference. */
if (flags & FLAG_RETVAL_REFERENCE)
- {
- *gpr_base++ = (unsigned long)(char *)ecif->rvalue;
- intarg_count++;
- }
+ {
+ *gpr_base++ = (unsigned long)(char *)ecif->rvalue;
+ intarg_count++;
+ }
/* Now for the arguments. */
p_argv = ecif->avalue;
/* Now for the arguments. */
p_argv = ecif->avalue;
- /* whoops: abi states only certain register pairs
- * can be used for passing long long int
- * specifically (r3,r4), (r5,r6), (r7,r8),
- * (r9,r10) and if next arg is long long but
- * not correct starting register of pair then skip
- * until the proper starting register
+ /* whoops: abi states only certain register pairs
+ * can be used for passing long long int
+ * specifically (r3,r4), (r5,r6), (r7,r8),
+ * (r9,r10) and if next arg is long long but
+ * not correct starting register of pair then skip
+ * until the proper starting register
- if (intarg_count%2 != 0)
- {
- intarg_count ++;
- gpr_base++;
- }
+ if (intarg_count%2 != 0)
+ {
+ intarg_count ++;
+ gpr_base++;
+ }
*(long long *)gpr_base = *(long long *)*p_argv;
gpr_base += 2;
}
*(long long *)gpr_base = *(long long *)*p_argv;
gpr_base += 2;
}
struct_copy_size = ((*ptr)->size + 15) & ~0xF;
copy_space -= struct_copy_size;
memcpy(copy_space, (char *)*p_argv, (*ptr)->size);
struct_copy_size = ((*ptr)->size + 15) & ~0xF;
copy_space -= struct_copy_size;
memcpy(copy_space, (char *)*p_argv, (*ptr)->size);
gprvalue = (unsigned long)copy_space;
FFI_ASSERT(copy_space > (char *)next_arg);
gprvalue = (unsigned long)copy_space;
FFI_ASSERT(copy_space > (char *)next_arg);
|--------------------------------------------|
| CR save area 8bytes |
|--------------------------------------------|
|--------------------------------------------|
| CR save area 8bytes |
|--------------------------------------------|
- | Previous backchain pointer 8 | stack pointer here
+ | Previous backchain pointer 8 | stack pointer here
|--------------------------------------------|<+ <<< on entry to
| Saved r28-r31 4*8 | | ffi_call_LINUX64
|--------------------------------------------| |
|--------------------------------------------|<+ <<< on entry to
| Saved r28-r31 4*8 | | ffi_call_LINUX64
|--------------------------------------------| |
| Current backchain pointer 8 |-/ during
|--------------------------------------------| <<< ffi_call_LINUX64
| Current backchain pointer 8 |-/ during
|--------------------------------------------| <<< ffi_call_LINUX64
/*@-exportheader@*/
void hidden ffi_prep_args64(extended_cif *ecif, unsigned long *const stack)
/*@-exportheader@*/
void hidden ffi_prep_args64(extended_cif *ecif, unsigned long *const stack)
/* 'next_arg' points at the space for gpr3, and grows upwards as
we use GPR registers, then continues at rest. */
unsigned long *const gpr_base = stacktop - ASM_NEEDS_REGISTERS64
/* 'next_arg' points at the space for gpr3, and grows upwards as
we use GPR registers, then continues at rest. */
unsigned long *const gpr_base = stacktop - ASM_NEEDS_REGISTERS64
- - NUM_GPR_ARG_REGISTERS64;
+ - NUM_GPR_ARG_REGISTERS64;
unsigned long *const gpr_end = gpr_base + NUM_GPR_ARG_REGISTERS64;
unsigned long *const rest = stack + 6 + NUM_GPR_ARG_REGISTERS64;
unsigned long *next_arg = gpr_base;
unsigned long *const gpr_end = gpr_base + NUM_GPR_ARG_REGISTERS64;
unsigned long *const rest = stack + 6 + NUM_GPR_ARG_REGISTERS64;
unsigned long *next_arg = gpr_base;
case FFI_TYPE_SINT32:
gprvalue = *(signed int *)*p_argv;
goto putgpr;
case FFI_TYPE_SINT32:
gprvalue = *(signed int *)*p_argv;
goto putgpr;
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_POINTER:
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_POINTER:
unsigned type = cif->rtype->type;
if (cif->abi != FFI_LINUX64)
unsigned type = cif->rtype->type;
if (cif->abi != FFI_LINUX64)
/* All the machine-independent calculation of cif->bytes will be wrong.
Redo the calculation for SYSV. */
/* All the machine-independent calculation of cif->bytes will be wrong.
Redo the calculation for SYSV. */
- 32-bit (or less) integer values are returned in gpr3;
- Structures of size <= 4 bytes also returned in gpr3;
- 64-bit integer values and structures between 5 and 8 bytes are returned
- 32-bit (or less) integer values are returned in gpr3;
- Structures of size <= 4 bytes also returned in gpr3;
- 64-bit integer values and structures between 5 and 8 bytes are returned
- Single/double FP values are returned in fpr1;
- Larger structures and long double (if not equivalent to double) values
- Single/double FP values are returned in fpr1;
- Larger structures and long double (if not equivalent to double) values
- are allocated space and a pointer is passed as the first argument.
+ are allocated space and a pointer is passed as the first argument.
For LINUX64:
- integer values in gpr3;
- Structures/Unions by reference;
For LINUX64:
- integer values in gpr3;
- Structures/Unions by reference;
/*@-declundef@*/
/*@-exportheader@*/
/*@-declundef@*/
/*@-exportheader@*/
-extern void ffi_call_SYSV(/*@out@*/ extended_cif *,
- unsigned, unsigned,
- /*@out@*/ unsigned *,
+extern void ffi_call_SYSV(/*@out@*/ extended_cif *,
+ unsigned, unsigned,
+ /*@out@*/ unsigned *,
-extern void hidden ffi_call_LINUX64(/*@out@*/ extended_cif *,
+extern void hidden ffi_call_LINUX64(/*@out@*/ extended_cif *,
unsigned long, unsigned long,
unsigned long, unsigned long,
- /*@out@*/ unsigned long *,
+ /*@out@*/ unsigned long *,
void (*fn)());
/*@=declundef@*/
/*@=exportheader@*/
void (*fn)());
/*@=declundef@*/
/*@=exportheader@*/
-void ffi_call(/*@dependent@*/ ffi_cif *cif,
- void (*fn)(),
- /*@out@*/ void *rvalue,
+void ffi_call(/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
/*@dependent@*/ void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/*@dependent@*/ void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
- if ((rvalue == NULL) &&
+ if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
/*@-sysunrecog@*/
(cif->rtype->type == FFI_TYPE_STRUCT))
{
/*@-sysunrecog@*/
}
else
ecif.rvalue = rvalue;
}
else
ecif.rvalue = rvalue;
{
#ifndef POWERPC64
case FFI_SYSV:
case FFI_GCC_SYSV:
/*@-usedef@*/
{
#ifndef POWERPC64
case FFI_SYSV:
case FFI_GCC_SYSV:
/*@-usedef@*/
- ffi_call_SYSV(&ecif, -cif->bytes,
+ ffi_call_SYSV(&ecif, -cif->bytes,
cif->flags, ecif.rvalue, fn);
/*@=usedef@*/
break;
cif->flags, ecif.rvalue, fn);
/*@=usedef@*/
break;
int i;
char * addr;
for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE) {
int i;
char * addr;
for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE) {
- addr = addr1 + i;
- __asm__ volatile ("icbi 0,%0;" "dcbf 0,%0;" : : "r"(addr) : "memory");
+ addr = addr1 + i;
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%0;" : : "r"(addr) : "memory");
}
addr = addr1 + size - 1;
__asm__ volatile ("icbi 0,%0;" "dcbf 0,%0;" "sync;" "isync;" : : "r"(addr) : "memory");
}
addr = addr1 + size - 1;
__asm__ volatile ("icbi 0,%0;" "dcbf 0,%0;" "sync;" "isync;" : : "r"(addr) : "memory");
-int ffi_closure_helper_SYSV (ffi_closure*, void*, unsigned long*,
+int ffi_closure_helper_SYSV (ffi_closure*, void*, unsigned long*,
ffi_dblfl*, unsigned long*);
ffi_dblfl*, unsigned long*);
-/* Basically the trampoline invokes ffi_closure_SYSV, and on
+/* Basically the trampoline invokes ffi_closure_SYSV, and on
* entry, r11 holds the address of the closure.
* After storing the registers that could possibly contain
* parameters to be passed into the stack frame and setting
* entry, r11 holds the address of the closure.
* After storing the registers that could possibly contain
* parameters to be passed into the stack frame and setting
- * up space for a return value, ffi_closure_SYSV invokes the
+ * up space for a return value, ffi_closure_SYSV invokes the
* following helper function to do most of the work
*/
int
* following helper function to do most of the work
*/
int
-ffi_closure_helper_SYSV (ffi_closure* closure, void * rvalue,
- unsigned long * pgr, ffi_dblfl * pfr,
- unsigned long * pst)
+ffi_closure_helper_SYSV (ffi_closure* closure, void * rvalue,
+ unsigned long * pgr, ffi_dblfl * pfr,
+ unsigned long * pst)
{
/* rvalue is the pointer to space for return value in closure assembly */
/* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
{
/* rvalue is the pointer to space for return value in closure assembly */
/* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
long i, avn;
long nf; /* number of floating registers already used */
long ng; /* number of general registers already used */
long i, avn;
long nf; /* number of floating registers already used */
long ng; /* number of general registers already used */
- ffi_cif * cif;
- double temp;
+ ffi_cif * cif;
+ double temp;
cif = closure->cif;
avalue = alloca(cif->nargs * sizeof(void *));
cif = closure->cif;
avalue = alloca(cif->nargs * sizeof(void *));
i = 0;
avn = cif->nargs;
arg_types = cif->arg_types;
i = 0;
avn = cif->nargs;
arg_types = cif->arg_types;
/* Grab the addresses of the arguments from the stack frame. */
while (i < avn)
{
/* Grab the addresses of the arguments from the stack frame. */
while (i < avn)
{
{
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
{
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
- /* there are 8 gpr registers used to pass values */
- if (ng < 8) {
- avalue[i] = (((char *)pgr)+3);
- ng++;
- pgr++;
- } else {
- avalue[i] = (((char *)pst)+3);
- pst++;
- }
+ /* there are 8 gpr registers used to pass values */
+ if (ng < 8) {
+ avalue[i] = (((char *)pgr)+3);
+ ng++;
+ pgr++;
+ } else {
+ avalue[i] = (((char *)pst)+3);
+ pst++;
+ }
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
- /* there are 8 gpr registers used to pass values */
- if (ng < 8) {
- avalue[i] = (((char *)pgr)+2);
- ng++;
- pgr++;
- } else {
- avalue[i] = (((char *)pst)+2);
- pst++;
- }
+ /* there are 8 gpr registers used to pass values */
+ if (ng < 8) {
+ avalue[i] = (((char *)pgr)+2);
+ ng++;
+ pgr++;
+ } else {
+ avalue[i] = (((char *)pst)+2);
+ pst++;
+ }
break;
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
case FFI_TYPE_POINTER:
/* there are 8 gpr registers used to pass values */
break;
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
case FFI_TYPE_POINTER:
/* there are 8 gpr registers used to pass values */
- if (ng < 8) {
- avalue[i] = pgr;
- ng++;
- pgr++;
- } else {
- avalue[i] = pst;
- pst++;
- }
+ if (ng < 8) {
+ avalue[i] = pgr;
+ ng++;
+ pgr++;
+ } else {
+ avalue[i] = pst;
+ pst++;
+ }
break;
case FFI_TYPE_STRUCT:
break;
case FFI_TYPE_STRUCT:
- /* Structs are passed by reference. The address will appear in a
+ /* Structs are passed by reference. The address will appear in a
gpr if it is one of the first 8 arguments. */
gpr if it is one of the first 8 arguments. */
- if (ng < 8) {
- avalue[i] = (void *) *pgr;
- ng++;
- pgr++;
- } else {
- avalue[i] = (void *) *pst;
- pst++;
- }
+ if (ng < 8) {
+ avalue[i] = (void *) *pgr;
+ ng++;
+ pgr++;
+ } else {
+ avalue[i] = (void *) *pst;
+ pst++;
+ }
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
/* passing long long ints are complex, they must
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
/* passing long long ints are complex, they must
- * be passed in suitable register pairs such as
- * (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
- * and if the entire pair aren't available then the outgoing
- * parameter stack is used for both but an alignment of 8
- * must will be kept. So we must either look in pgr
- * or pst to find the correct address for this type
- * of parameter.
- */
- if (ng < 7) {
- if (ng & 0x01) {
- /* skip r4, r6, r8 as starting points */
- ng++;
- pgr++;
- }
- avalue[i] = pgr;
- ng+=2;
- pgr+=2;
- } else {
- if (((long)pst) & 4) pst++;
- avalue[i] = pst;
- pst+=2;
- }
- break;
+ * be passed in suitable register pairs such as
+ * (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
+ * and if the entire pair aren't available then the outgoing
+ * parameter stack is used for both but an alignment of 8
+ * must will be kept. So we must either look in pgr
+ * or pst to find the correct address for this type
+ * of parameter.
+ */
+ if (ng < 7) {
+ if (ng & 0x01) {
+ /* skip r4, r6, r8 as starting points */
+ ng++;
+ pgr++;
+ }
+ avalue[i] = pgr;
+ ng+=2;
+ pgr+=2;
+ } else {
+ if (((long)pst) & 4) pst++;
+ avalue[i] = pst;
+ pst+=2;
+ }
+ break;
- /* unfortunately float values are stored as doubles
- * in the ffi_closure_SYSV code (since we don't check
- * the type in that routine).
- */
-
- /* there are 8 64bit floating point registers */
-
- if (nf < 8) {
- temp = pfr->d;
- pfr->f = (float)temp;
- avalue[i] = pfr;
- nf++;
- pfr++;
- } else {
+ /* unfortunately float values are stored as doubles
+ * in the ffi_closure_SYSV code (since we don't check
+ * the type in that routine).
+ */
+
+ /* there are 8 64bit floating point registers */
+
+ if (nf < 8) {
+ temp = pfr->d;
+ pfr->f = (float)temp;
+ avalue[i] = pfr;
+ nf++;
+ pfr++;
+ } else {
/* FIXME? here we are really changing the values
/* FIXME? here we are really changing the values
- * stored in the original calling routines outgoing
- * parameter stack. This is probably a really
- * naughty thing to do but...
- */
- avalue[i] = pst;
- nf++;
- pst+=1;
- }
+ * stored in the original calling routines outgoing
+ * parameter stack. This is probably a really
+ * naughty thing to do but...
+ */
+ avalue[i] = pst;
+ nf++;
+ pst+=1;
+ }
break;
case FFI_TYPE_DOUBLE:
/* On the outgoing stack all values are aligned to 8 */
break;
case FFI_TYPE_DOUBLE:
/* On the outgoing stack all values are aligned to 8 */
- /* there are 8 64bit floating point registers */
-
- if (nf < 8) {
- avalue[i] = pfr;
- nf++;
- pfr++;
- } else {
- if (((long)pst) & 4) pst++;
- avalue[i] = pst;
- nf++;
- pst+=2;
- }
+ /* there are 8 64bit floating point registers */
+
+ if (nf < 8) {
+ avalue[i] = pfr;
+ nf++;
+ pfr++;
+ } else {
+ if (((long)pst) & 4) pst++;
+ avalue[i] = pst;
+ nf++;
+ pst+=2;
+ }
-ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
+ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
unsigned long *pst, ffi_dblfl *pfr)
{
/* rvalue is the pointer to space for return value in closure assembly */
unsigned long *pst, ffi_dblfl *pfr)
{
/* rvalue is the pointer to space for return value in closure assembly */
void **avalue;
ffi_type **arg_types;
long i, avn;
void **avalue;
ffi_type **arg_types;
long i, avn;
ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
cif = closure->cif;
ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
cif = closure->cif;
i = 0;
avn = cif->nargs;
arg_types = cif->arg_types;
i = 0;
avn = cif->nargs;
arg_types = cif->arg_types;
/* Grab the addresses of the arguments from the stack frame. */
while (i < avn)
{
/* Grab the addresses of the arguments from the stack frame. */
while (i < avn)
{
avalue[i] = (char *) pst + 7;
pst++;
break;
avalue[i] = (char *) pst + 7;
pst++;
break;
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
avalue[i] = (char *) pst + 6;
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
avalue[i] = (char *) pst + 6;
case FFI_TYPE_FLOAT:
/* unfortunately float values are stored as doubles
case FFI_TYPE_FLOAT:
/* unfortunately float values are stored as doubles
- * in the ffi_closure_LINUX64 code (since we don't check
- * the type in that routine).
- */
+ * in the ffi_closure_LINUX64 code (since we don't check
+ * the type in that routine).
+ */
- /* there are 13 64bit floating point registers */
+ /* there are 13 64bit floating point registers */
{
double temp = pfr->d;
pfr->f = (float) temp;
{
double temp = pfr->d;
pfr->f = (float) temp;
case FFI_TYPE_DOUBLE:
/* On the outgoing stack all values are aligned to 8 */
case FFI_TYPE_DOUBLE:
/* On the outgoing stack all values are aligned to 8 */
- /* there are 13 64bit floating point registers */
+ /* there are 13 64bit floating point registers */
/* -----------------------------------------------------------------------
sysv.h - Copyright (c) 2003 Jakub Jelinek <jakub@redhat.com>
/* -----------------------------------------------------------------------
sysv.h - Copyright (c) 2003 Jakub Jelinek <jakub@redhat.com>
PowerPC64 Assembly glue.
Permission is hereby granted, free of charge, to any person obtaining
PowerPC64 Assembly glue.
Permission is hereby granted, free of charge, to any person obtaining
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <fficonfig.h>
#include <ffi.h>
#include <fficonfig.h>
#include <ffi.h>
.file "linux64_closure.S"
#ifdef __powerpc64__
.file "linux64_closure.S"
#ifdef __powerpc64__
- .hidden ffi_closure_LINUX64, .ffi_closure_LINUX64
- .globl ffi_closure_LINUX64, .ffi_closure_LINUX64
- .section ".opd","aw"
- .align 3
+ .hidden ffi_closure_LINUX64, .ffi_closure_LINUX64
+ .globl ffi_closure_LINUX64, .ffi_closure_LINUX64
+ .section ".opd","aw"
+ .align 3
- .quad .ffi_closure_LINUX64,.TOC.@tocbase,0
- .size ffi_closure_LINUX64,24
- .type .ffi_closure_LINUX64,@function
- .text
+ .quad .ffi_closure_LINUX64,.TOC.@tocbase,0
+ .size ffi_closure_LINUX64,24
+ .type .ffi_closure_LINUX64,@function
+ .text
.ffi_closure_LINUX64:
.LFB1:
# save general regs into parm save area
.ffi_closure_LINUX64:
.LFB1:
# save general regs into parm save area
# so use it to look up in a table
# so we know how to deal with each type
# so use it to look up in a table
# 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
mflr %r4 # move address of .Lret to r4
sldi %r3, %r3, 4 # now multiply return type by 16
# by using return type as offset
mflr %r4 # move address of .Lret to r4
sldi %r3, %r3, 4 # now multiply return type by 16
#include <ffi.h>
#include <powerpc/asm.h>
#include <ffi.h>
#include <powerpc/asm.h>
# we want to build up an areas for the parameters passed
# in registers (both floating point and integer)
# we want to build up an areas for the parameters passed
# in registers (both floating point and integer)
# so first save gpr 3 to gpr 10 (aligned to 4)
stw %r3, 16(%r1)
stw %r4, 20(%r1)
# so first save gpr 3 to gpr 10 (aligned to 4)
stw %r3, 16(%r1)
stw %r4, 20(%r1)
stw %r6, 28(%r1)
stw %r7, 32(%r1)
stw %r6, 28(%r1)
stw %r7, 32(%r1)
stw %r9, 40(%r1)
stw %r10,44(%r1)
stw %r9, 40(%r1)
stw %r10,44(%r1)
# set up registers for the routine that actually does the work
# get the context pointer from the trampoline
mr %r3,%r11
# set up registers for the routine that actually does the work
# get the context pointer from the trampoline
mr %r3,%r11
-
- # now load up the pointer to the result storage
+
+ # now load up the pointer to the result storage
# now load up the pointer to the saved gpr registers
# now load up the pointer to the saved gpr registers
- # now load up the pointer to the saved fpr registers */
- addi %r6,%r1,48
+ # now load up the pointer to the saved fpr registers */
+ addi %r6,%r1,48
- # now load up the pointer to the outgoing parameter
+ # now load up the pointer to the outgoing parameter
# stack in the previous frame
# i.e. the previous frame pointer + 8
addi %r7,%r1,152
# stack in the previous frame
# i.e. the previous frame pointer + 8
addi %r7,%r1,152
bl JUMPTARGET(ffi_closure_helper_SYSV)
# now r3 contains the return type
# so use it to look up in a table
# so we know how to deal with each type
bl JUMPTARGET(ffi_closure_helper_SYSV)
# now r3 contains the return type
# so use it to look up in a table
# 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
addi %r5,%r1,112 # get pointer to results area
bl .Lget_ret_type0_addr # get pointer to .Lret_type0 into LR
# by using return type as offset
addi %r5,%r1,112 # get pointer to results area
bl .Lget_ret_type0_addr # get pointer to .Lret_type0 into LR
# case FFI_TYPE_DOUBLE
.Lret_type3:
# case FFI_TYPE_DOUBLE
.Lret_type3:
b .Lfinish
nop
nop
# case FFI_TYPE_LONGDOUBLE
.Lret_type4:
b .Lfinish
nop
nop
# case FFI_TYPE_LONGDOUBLE
.Lret_type4:
b .Lfinish
nop
nop
# case FFI_TYPE_UINT8
.Lret_type5:
b .Lfinish
nop
nop
# case FFI_TYPE_UINT8
.Lret_type5:
lwz %r0,148(%r1)
mtlr %r0
addi %r1,%r1,144
lwz %r0,148(%r1)
mtlr %r0
addi %r1,%r1,144
/* -----------------------------------------------------------------------
sysv.h - Copyright (c) 1998 Geoffrey Keating
/* -----------------------------------------------------------------------
sysv.h - Copyright (c) 1998 Geoffrey Keating
-
- PowerPC Assembly glue.
- $Id: sysv.S,v 1.1.1.1 1998/11/29 16:48:16 green Exp $
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <fficonfig.h>
#include <ffi.h>
#include <powerpc/asm.h>
#include <fficonfig.h>
#include <ffi.h>
#include <powerpc/asm.h>