1 /* -----------------------------------------------------------------------
2 arcompact.S - Copyright (c) 2013 Synposys, Inc. (www.synopsys.com)
4 ARCompact Foreign Function Interface
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 ``Software''), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24 ----------------------------------------------------------------------- */
27 #include <fficonfig.h>
29 #ifdef HAVE_MACHINE_ASM_H
30 #include <machine/asm.h>
33 #define ENTRY(x) .globl CNAME(x)` .type CNAME(x),%function` CNAME(x):
38 /* R0: ffi_prep_args */
44 ENTRY(ffi_call_ARCompact)
46 st.a fp, [sp, -4] /* fp + 20, fp */
47 push_s blink /* fp + 16, blink */
48 st.a r4, [sp, -4] /* fp + 12, ecif.rvalue */
49 push_s r3 /* fp + 8, fig->flags */
50 st.a r5, [sp, -4] /* fp + 4, fn */
51 push_s r2 /* fp + 0, cif->bytes */
54 /* Make room for all of the new args. */
57 /* Place all of the ffi_prep_args in position. */
58 /* ffi_prep_args(char *stack, extended_cif *ecif) */
65 ld.ab r12, [fp, 4] /* cif->bytes */
66 ld.ab r11, [fp, 4] /* fn */
68 /* Move first 8 parameters in registers... */
78 /* ...and adjust the stack. */
81 /* Call the function. */
86 pop_s r3 /* fig->flags, return type */
87 pop_s r2 /* ecif.rvalue, pointer for return value */
89 /* If the return value pointer is NULL, assume no return value. */
90 breq.d r2, 0, epilogue
94 brne r3, FFI_TYPE_INT, return_double
99 brne r3, FFI_TYPE_DOUBLE, epilogue
107 ENTRY(ffi_closure_ARCompact)
117 /* pointer to arguments */
120 /* return value goes here */
126 bl.d ffi_closure_inner_ARCompact
127 mov_s r0, r8 /* codeloc, set by trampoline */
131 /* set return value to r1:r0 */