1 /* -----------------------------------------------------------------------
2 v8.S - Copyright (c) 1996, 1997, 2003, 2004 Red Hat, Inc.
4 SPARC 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,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25 ----------------------------------------------------------------------- */
28 #include <fficonfig.h>
31 #define STACKFRAME 96 /* Minimum stack framesize for SPARC */
32 #define ARGS (64+4) /* Offset of register area in frame */
42 save %sp, -STACKFRAME, %sp
45 sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
46 add %sp, STACKFRAME, %l0 ! %l0 has start of
49 mov %l0, %o0 ! call routine to set up frame
51 mov %i1, %o1 ! (delay)
53 ld [%l0+ARGS], %o0 ! call foreign function
60 mov %l0, %sp ! (delay) switch to frame
61 nop ! STRUCT returning functions skip 12 instead of 8 bytes
63 ! If the return value pointer is NULL, assume no return value.
70 st %o0, [%i4] ! (delay)
72 cmp %i3, FFI_TYPE_FLOAT
74 st %f0, [%i4+0] ! (delay)
76 cmp %i3, FFI_TYPE_DOUBLE
78 st %f0, [%i4+0] ! (delay)
80 cmp %i3, FFI_TYPE_SINT8
82 sll %o0, 24, %o0 ! (delay)
84 cmp %i3, FFI_TYPE_UINT8
86 sll %o0, 24, %o0 ! (delay)
88 cmp %i3, FFI_TYPE_SINT16
90 sll %o0, 16, %o0 ! (delay)
92 cmp %i3, FFI_TYPE_UINT16
94 sll %o0, 16, %o0 ! (delay)
96 cmp %i3, FFI_TYPE_SINT64
98 st %o0, [%i4+0] ! (delay)
139 .size ffi_call_v8,.ffi_call_v8_end-ffi_call_v8
143 #define STACKFRAME 104 /* 16*4 register window +
145 6*4 args backing store +
148 /* ffi_closure_v8(...)
150 Receives the closure argument in %g2. */
154 .globl ffi_closure_v8
157 #ifdef HAVE_AS_REGISTER_PSEUDO_OP
158 .register %g2, #scratch
161 ! Reserve frame space for all arguments in case
162 ! we need to align them on a 8-byte boundary.
163 ld [%g2+FFI_TRAMPOLINE_SIZE], %g1
166 add %g1, STACKFRAME, %g1
167 ! %g1 == STACKFRAME + 8*nargs
172 ! Store all of the potential argument registers in va_list format.
180 ! Call ffi_closure_sparc_inner to do the bulk of the work.
184 call ffi_closure_sparc_inner_v8
187 ! Load up the return value in the proper type.
188 ! See ffi_prep_cif_machdep for the list of cases.
189 cmp %o0, FFI_TYPE_VOID
192 cmp %o0, FFI_TYPE_INT
196 cmp %o0, FFI_TYPE_FLOAT
200 cmp %o0, FFI_TYPE_DOUBLE
204 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
205 cmp %o0, FFI_TYPE_LONGDOUBLE
209 cmp %o0, FFI_TYPE_STRUCT
212 cmp %o0, FFI_TYPE_SINT64
227 .size ffi_closure_v8,.ffi_closure_v8_end-ffi_closure_v8
232 #define uanword uaxword
236 #define uanword uaword
239 #ifdef HAVE_RO_EH_FRAME
240 .section ".eh_frame",#alloc
242 .section ".eh_frame",#alloc,#write
245 .uaword .LLECIE1-.LLSCIE1 ! Length of Common Information Entry
247 .uaword 0x0 ! CIE Identifier Tag
248 .byte 0x1 ! CIE Version
249 .ascii "zR\0" ! CIE Augmentation
250 .byte 0x1 ! uleb128 0x1; CIE Code Alignment Factor
251 .byte 0x80-WS ! sleb128 -WS; CIE Data Alignment Factor
252 .byte 0xf ! CIE RA Column
253 .byte 0x1 ! uleb128 0x1; Augmentation size
254 #ifdef HAVE_AS_SPARC_UA_PCREL
255 .byte 0x1b ! FDE Encoding (pcrel sdata4)
257 .byte 0x50 ! FDE Encoding (aligned absolute)
259 .byte 0xc ! DW_CFA_def_cfa
260 .byte 0xe ! uleb128 0xe
261 .byte 0x0 ! uleb128 0x0
265 .uaword .LLEFDE1-.LLASFDE1 ! FDE Length
267 .uaword .LLASFDE1-.LLframe1 ! FDE CIE offset
268 #ifdef HAVE_AS_SPARC_UA_PCREL
269 .uaword %r_disp32(.LLFB1)
270 .uaword .LLFE1-.LLFB1 ! FDE address range
274 .uanword .LLFE1-.LLFB1 ! FDE address range
276 .byte 0x0 ! uleb128 0x0; Augmentation size
277 .byte 0x4 ! DW_CFA_advance_loc4
278 .uaword .LLCFI0-.LLFB1
279 .byte 0xd ! DW_CFA_def_cfa_register
280 .byte 0x1e ! uleb128 0x1e
281 .byte 0x2d ! DW_CFA_GNU_window_save
282 .byte 0x9 ! DW_CFA_register
283 .byte 0xf ! uleb128 0xf
284 .byte 0x1f ! uleb128 0x1f
288 .uaword .LLEFDE2-.LLASFDE2 ! FDE Length
290 .uaword .LLASFDE2-.LLframe1 ! FDE CIE offset
291 #ifdef HAVE_AS_SPARC_UA_PCREL
292 .uaword %r_disp32(.LLFB2)
293 .uaword .LLFE2-.LLFB2 ! FDE address range
297 .uanword .LLFE2-.LLFB2 ! FDE address range
299 .byte 0x0 ! uleb128 0x0; Augmentation size
300 .byte 0x4 ! DW_CFA_advance_loc4
301 .uaword .LLCFI1-.LLFB2
302 .byte 0xd ! DW_CFA_def_cfa_register
303 .byte 0x1e ! uleb128 0x1e
304 .byte 0x2d ! DW_CFA_GNU_window_save
305 .byte 0x9 ! DW_CFA_register
306 .byte 0xf ! uleb128 0xf
307 .byte 0x1f ! uleb128 0x1f
311 #if defined __ELF__ && defined __linux__
312 .section .note.GNU-stack,"",@progbits