summaryrefslogtreecommitdiff
path: root/src/moxie
diff options
context:
space:
mode:
authorAnthony Green <green@moxielogic.com>2012-11-06 16:00:40 -0500
committerAnthony Green <green@moxielogic.com>2012-11-06 16:00:40 -0500
commitf680b598b7bdde325ac9349e8c35151c228bf2df (patch)
treec685eab0826a3767d4313576158d70b2be3a4e03 /src/moxie
parentdfadfb19853c57c8623c436d0ef2bdafab24b433 (diff)
downloadlibffi-f680b598b7bdde325ac9349e8c35151c228bf2df.tar.gz
Add missing aarch64 configury bits
Diffstat (limited to 'src/moxie')
-rw-r--r--src/moxie/eabi.S104
-rw-r--r--src/moxie/ffi.c28
-rw-r--r--src/moxie/ffitarget.h4
3 files changed, 28 insertions, 108 deletions
diff --git a/src/moxie/eabi.S b/src/moxie/eabi.S
index 379ea4b..7e2143b 100644
--- a/src/moxie/eabi.S
+++ b/src/moxie/eabi.S
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
- eabi.S - Copyright (c) 2004 Anthony Green
+ eabi.S - Copyright (c) 2012 Anthony Green
- FR-V Assembly glue.
+ Moxie Assembly glue.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -34,95 +34,31 @@
.globl ffi_call_EABI
.type ffi_call_EABI, @function
- # gr8 : ffi_prep_args
- # gr9 : &ecif
- # gr10: cif->bytes
- # gr11: fig->flags
- # gr12: ecif.rvalue
- # gr13: fn
+ # $r0 : ffi_prep_args
+ # $r1 : &ecif
+ # $r2 : cif->bytes
+ # $r3 : fig->flags
+ # $r4 : ecif.rvalue
+ # $r5 : fn
ffi_call_EABI:
- addi sp, #-80, sp
- sti fp, @(sp, #24)
- addi sp, #24, fp
- movsg lr, gr5
+ dec $sp, 24
- /* Make room for the new arguments. */
- /* subi sp, fp, gr10 */
-
- /* Store return address and incoming args on stack. */
- sti gr5, @(fp, #8)
- sti gr8, @(fp, #-4)
- sti gr9, @(fp, #-8)
- sti gr10, @(fp, #-12)
- sti gr11, @(fp, #-16)
- sti gr12, @(fp, #-20)
- sti gr13, @(fp, #-24)
-
- sub sp, gr10, sp
+ /* Store incoming args on stack. */
+ sto.l 0($sp), $r0
+ sto.l 4($sp), $r1
+ sto.l 8($sp), $r2
+ sto.l 12($sp), $r3
+ sto.l 16($sp), $r4
+ sto.l 20($sp), $r5
/* Call ffi_prep_args. */
- ldi @(fp, #-4), gr4
- addi sp, #0, gr8
- ldi @(fp, #-8), gr9
-#ifdef __FRV_FDPIC__
- ldd @(gr4, gr0), gr14
- calll @(gr14, gr0)
-#else
- calll @(gr4, gr0)
-#endif
-
- /* ffi_prep_args returns the new stack pointer. */
- mov gr8, gr4
-
- ldi @(sp, #0), gr8
- ldi @(sp, #4), gr9
- ldi @(sp, #8), gr10
- ldi @(sp, #12), gr11
- ldi @(sp, #16), gr12
- ldi @(sp, #20), gr13
-
- /* Always copy the return value pointer into the hidden
- parameter register. This is only strictly necessary
- when we're returning an aggregate type, but it doesn't
- hurt to do this all the time, and it saves a branch. */
- ldi @(fp, #-20), gr3
+ jsr $r0
- /* Use the ffi_prep_args return value for the new sp. */
- mov gr4, sp
-
/* Call the target function. */
- ldi @(fp, -24), gr4
-#ifdef __FRV_FDPIC__
- ldd @(gr4, gr0), gr14
- calll @(gr14, gr0)
-#else
- calll @(gr4, gr0)
-#endif
-
- /* Store the result. */
- ldi @(fp, #-16), gr10 /* fig->flags */
- ldi @(fp, #-20), gr4 /* ecif.rvalue */
-
- /* Is the return value stored in two registers? */
- cmpi gr10, #8, icc0
- bne icc0, 0, .L2
- /* Yes, save them. */
- sti gr8, @(gr4, #0)
- sti gr9, @(gr4, #4)
- bra .L3
-.L2:
- /* Is the return value a structure? */
- cmpi gr10, #-1, icc0
- beq icc0, 0, .L3
- /* No, save a 4 byte return value. */
- sti gr8, @(gr4, #0)
-.L3:
+ jsr $r5
- /* Restore the stack, and return. */
- ldi @(fp, 8), gr5
- ld @(fp, gr0), fp
- addi sp,#80,sp
- jmpl @(gr5,gr0)
+ /* Return. */
+ ret
.size ffi_call_EABI, .-ffi_call_EABI
diff --git a/src/moxie/ffi.c b/src/moxie/ffi.c
index 54cbbb9..11abb00 100644
--- a/src/moxie/ffi.c
+++ b/src/moxie/ffi.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
- ffi.c - Copyright (C) 2009 Anthony Green
+ ffi.c - Copyright (C) 2012 Anthony Green
Moxie Foreign Function Interface
@@ -56,17 +56,6 @@ void *ffi_prep_args(char *stack, extended_cif *ecif)
z = sizeof(void*);
*(void **) argp = *p_argv;
}
- /* if ((*p_arg)->type == FFI_TYPE_FLOAT)
- {
- if (count > 24)
- {
- // This is going on the stack. Turn it into a double.
- *(double *) argp = (double) *(float*)(* p_argv);
- z = sizeof(double);
- }
- else
- *(void **) argp = *(void **)(* p_argv);
- } */
else if (z < sizeof(int))
{
z = sizeof(int);
@@ -167,12 +156,12 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
/* This function is called by a trampoline. The trampoline stows a
pointer to the ffi_closure object in gr7. We must save this
pointer in a place that will persist while we do our work. */
- register ffi_closure *creg __asm__ ("gr7");
+ register ffi_closure *creg __asm__ ("$r7");
ffi_closure *closure = creg;
/* Arguments that don't fit in registers are found on the stack
at a fixed offset above the current frame pointer. */
- register char *frame_pointer __asm__ ("fp");
+ register char *frame_pointer __asm__ ("$fp");
char *stack_args = frame_pointer + 16;
/* Lay the register arguments down in a continuous chunk of memory. */
@@ -226,7 +215,7 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
/* The caller allocates space for the return structure, and
passes a pointer to this space in gr3. Use this value directly
as the return value. */
- register void *return_struct_ptr __asm__("gr3");
+ register void *return_struct_ptr __asm__("$r0");
(closure->fun) (cif, return_struct_ptr, avalue, closure->user_data);
}
else
@@ -237,9 +226,9 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
/* Functions return 4-byte or smaller results in gr8. 8-byte
values also use gr9. We fill the both, even for small return
- values, just to avoid a branch. */
+ values, just to avoid a branch. */ /*
asm ("ldi @(%0, #0), gr8" : : "r" (&rvalue));
- asm ("ldi @(%0, #0), gr9" : : "r" (&((int *) &rvalue)[1]));
+ asm ("ldi @(%0, #0), gr9" : : "r" (&((int *) &rvalue)[1])); */
}
}
@@ -267,10 +256,5 @@ ffi_prep_closure_loc (ffi_closure* closure,
closure->fun = fun;
closure->user_data = user_data;
- /* Cache flushing. */
- for (i = 0; i < FFI_TRAMPOLINE_SIZE; i++)
- __asm__ volatile ("dcf @(%0,%1)\n\tici @(%2,%1)" :: "r" (tramp), "r" (i),
- "r" (codeloc));
-
return FFI_OK;
}
diff --git a/src/moxie/ffitarget.h b/src/moxie/ffitarget.h
index f5305d1..93fae39 100644
--- a/src/moxie/ffitarget.h
+++ b/src/moxie/ffitarget.h
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------*-C-*-
- ffitarget.h - Copyright (c) 2009 Anthony Green
+ ffitarget.h - Copyright (c) 2012 Anthony Green
Target configuration macros for Moxie
Permission is hereby granted, free of charge, to any person obtaining
@@ -47,7 +47,7 @@ typedef enum ffi_abi {
/* ---- Definitions for closures ----------------------------------------- */
-#define FFI_CLOSURES 0
+#define FFI_CLOSURES 1
#define FFI_NATIVE_RAW_API 0
/* Trampolines are 5 4-byte instructions long. */