1 /* -----------------------------------------------------------------------
2 v8.S - Copyright (c) 1996, 1997, 2003, 2004, 2008 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>
33 #define STACKFRAME 96 /* Minimum stack framesize for SPARC */
34 #define ARGS (64+4) /* Offset of register area in frame */
44 save %sp, -STACKFRAME, %sp
47 sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
48 add %sp, STACKFRAME, %l0 ! %l0 has start of
51 mov %l0, %o0 ! call routine to set up frame
53 mov %i1, %o1 ! (delay)
55 ld [%l0+ARGS], %o0 ! call foreign function
62 mov %l0, %sp ! (delay) switch to frame
63 nop ! STRUCT returning functions skip 12 instead of 8 bytes
65 ! If the return value pointer is NULL, assume no return value.
72 st %o0, [%i4] ! (delay)
74 cmp %i3, FFI_TYPE_FLOAT
76 st %f0, [%i4+0] ! (delay)
78 cmp %i3, FFI_TYPE_DOUBLE
80 st %f0, [%i4+0] ! (delay)
82 cmp %i3, FFI_TYPE_SINT8
84 sll %o0, 24, %o0 ! (delay)
86 cmp %i3, FFI_TYPE_UINT8
88 sll %o0, 24, %o0 ! (delay)
90 cmp %i3, FFI_TYPE_SINT16
92 sll %o0, 16, %o0 ! (delay)
94 cmp %i3, FFI_TYPE_UINT16
96 sll %o0, 16, %o0 ! (delay)
98 cmp %i3, FFI_TYPE_SINT64
100 st %o0, [%i4+0] ! (delay)
141 .size ffi_call_v8,.ffi_call_v8_end-ffi_call_v8
145 #define STACKFRAME 104 /* 16*4 register window +
147 6*4 args backing store +
150 /* ffi_closure_v8(...)
152 Receives the closure argument in %g2. */
156 .globl ffi_closure_v8
159 #ifdef HAVE_AS_REGISTER_PSEUDO_OP
160 .register %g2, #scratch
163 ! Reserve frame space for all arguments in case
164 ! we need to align them on a 8-byte boundary.
165 ld [%g2+FFI_TRAMPOLINE_SIZE], %g1
168 add %g1, STACKFRAME, %g1
169 ! %g1 == STACKFRAME + 8*nargs
174 ! Store all of the potential argument registers in va_list format.
182 ! Call ffi_closure_sparc_inner to do the bulk of the work.
186 call ffi_closure_sparc_inner_v8
189 ! Load up the return value in the proper type.
190 ! See ffi_prep_cif_machdep for the list of cases.
191 cmp %o0, FFI_TYPE_VOID
194 cmp %o0, FFI_TYPE_INT
198 cmp %o0, FFI_TYPE_FLOAT
202 cmp %o0, FFI_TYPE_DOUBLE
206 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
207 cmp %o0, FFI_TYPE_LONGDOUBLE
211 cmp %o0, FFI_TYPE_STRUCT
214 cmp %o0, FFI_TYPE_SINT64
229 .size ffi_closure_v8,.ffi_closure_v8_end-ffi_closure_v8
234 #define uanword uaxword
238 #define uanword uaword
241 #ifdef HAVE_RO_EH_FRAME
242 .section ".eh_frame",#alloc
244 .section ".eh_frame",#alloc,#write
247 .uaword .LLECIE1-.LLSCIE1 ! Length of Common Information Entry
249 .uaword 0x0 ! CIE Identifier Tag
250 .byte 0x1 ! CIE Version
251 .ascii "zR\0" ! CIE Augmentation
252 .byte 0x1 ! uleb128 0x1; CIE Code Alignment Factor
253 .byte 0x80-WS ! sleb128 -WS; CIE Data Alignment Factor
254 .byte 0xf ! CIE RA Column
255 .byte 0x1 ! uleb128 0x1; Augmentation size
256 #ifdef HAVE_AS_SPARC_UA_PCREL
257 .byte 0x1b ! FDE Encoding (pcrel sdata4)
259 .byte 0x50 ! FDE Encoding (aligned absolute)
261 .byte 0xc ! DW_CFA_def_cfa
262 .byte 0xe ! uleb128 0xe
263 .byte 0x0 ! uleb128 0x0
267 .uaword .LLEFDE1-.LLASFDE1 ! FDE Length
269 .uaword .LLASFDE1-.LLframe1 ! FDE CIE offset
270 #ifdef HAVE_AS_SPARC_UA_PCREL
271 .uaword %r_disp32(.LLFB1)
272 .uaword .LLFE1-.LLFB1 ! FDE address range
276 .uanword .LLFE1-.LLFB1 ! FDE address range
278 .byte 0x0 ! uleb128 0x0; Augmentation size
279 .byte 0x4 ! DW_CFA_advance_loc4
280 .uaword .LLCFI0-.LLFB1
281 .byte 0xd ! DW_CFA_def_cfa_register
282 .byte 0x1e ! uleb128 0x1e
283 .byte 0x2d ! DW_CFA_GNU_window_save
284 .byte 0x9 ! DW_CFA_register
285 .byte 0xf ! uleb128 0xf
286 .byte 0x1f ! uleb128 0x1f
290 .uaword .LLEFDE2-.LLASFDE2 ! FDE Length
292 .uaword .LLASFDE2-.LLframe1 ! FDE CIE offset
293 #ifdef HAVE_AS_SPARC_UA_PCREL
294 .uaword %r_disp32(.LLFB2)
295 .uaword .LLFE2-.LLFB2 ! FDE address range
299 .uanword .LLFE2-.LLFB2 ! FDE address range
301 .byte 0x0 ! uleb128 0x0; Augmentation size
302 .byte 0x4 ! DW_CFA_advance_loc4
303 .uaword .LLCFI1-.LLFB2
304 .byte 0xd ! DW_CFA_def_cfa_register
305 .byte 0x1e ! uleb128 0x1e
306 .byte 0x2d ! DW_CFA_GNU_window_save
307 .byte 0x9 ! DW_CFA_register
308 .byte 0xf ! uleb128 0xf
309 .byte 0x1f ! uleb128 0x1f
314 #if defined __ELF__ && defined __linux__
315 .section .note.GNU-stack,"",@progbits