1 /* -----------------------------------------------------------------------
2 v9.S - Copyright (c) 2000, 2003, 2004, 2008 Red Hat, Inc.
4 SPARC 64-bit 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 176 /* Minimum stack framesize for SPARC 64-bit */
34 #define STACK_BIAS 2047
35 #define ARGS (128) /* Offset of register area in frame */
45 save %sp, -STACKFRAME, %sp
48 sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
49 add %sp, STACKFRAME+STACK_BIAS, %l0 ! %l0 has start of
52 mov %l0, %o0 ! call routine to set up frame
54 mov %i1, %o1 ! (delay)
56 ldx [%l0+ARGS], %o0 ! call foreign function
60 ldd [%l0+ARGS+16], %f4
61 ldd [%l0+ARGS+24], %f6
62 ldd [%l0+ARGS+32], %f8
63 ldd [%l0+ARGS+40], %f10
64 ldd [%l0+ARGS+48], %f12
65 ldd [%l0+ARGS+56], %f14
66 ldd [%l0+ARGS+64], %f16
67 ldd [%l0+ARGS+72], %f18
68 ldd [%l0+ARGS+80], %f20
69 ldd [%l0+ARGS+88], %f22
70 ldd [%l0+ARGS+96], %f24
71 ldd [%l0+ARGS+104], %f26
72 ldd [%l0+ARGS+112], %f28
73 ldd [%l0+ARGS+120], %f30
75 1: ldx [%l0+ARGS+8], %o1
76 ldx [%l0+ARGS+16], %o2
77 ldx [%l0+ARGS+24], %o3
78 ldx [%l0+ARGS+32], %o4
79 ldx [%l0+ARGS+40], %o5
81 sub %l0, STACK_BIAS, %sp ! (delay) switch to frame
83 ! If the return value pointer is NULL, assume no return value.
89 stx %o0, [%i4+0] ! (delay)
91 cmp %i3, FFI_TYPE_FLOAT
93 st %f0, [%i4+0] ! (delay)
95 cmp %i3, FFI_TYPE_DOUBLE
97 std %f0, [%i4+0] ! (delay)
99 cmp %i3, FFI_TYPE_STRUCT
102 cmp %i3, FFI_TYPE_LONGDOUBLE
112 /* This will not work correctly for unions. */
126 .size ffi_call_v9,.ffi_call_v9_end-ffi_call_v9
130 #define STACKFRAME 336 /* 16*8 register window +
131 6*8 args backing store +
133 #define FP %fp+STACK_BIAS
135 /* ffi_closure_v9(...)
137 Receives the closure argument in %g1. */
141 .globl ffi_closure_v9
145 save %sp, -STACKFRAME, %sp
148 ! Store all of the potential argument registers in va_list format.
156 ! Store possible floating point argument registers too.
174 ! Call ffi_closure_sparc_inner to do the bulk of the work.
176 add %fp, STACK_BIAS-160, %o1
177 add %fp, STACK_BIAS+128, %o2
178 call ffi_closure_sparc_inner_v9
179 add %fp, STACK_BIAS-128, %o3
181 ! Load up the return value in the proper type.
182 ! See ffi_prep_cif_machdep for the list of cases.
183 cmp %o0, FFI_TYPE_VOID
186 cmp %o0, FFI_TYPE_INT
189 cmp %o0, FFI_TYPE_FLOAT
193 cmp %o0, FFI_TYPE_DOUBLE
197 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
198 cmp %o0, FFI_TYPE_LONGDOUBLE
199 be,a,pn %icc, longdouble1
219 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
228 .size ffi_closure_v9,.ffi_closure_v9_end-ffi_closure_v9
230 #ifdef HAVE_RO_EH_FRAME
231 .section ".eh_frame",#alloc
233 .section ".eh_frame",#alloc,#write
236 .uaword .LLECIE1-.LLSCIE1 ! Length of Common Information Entry
238 .uaword 0x0 ! CIE Identifier Tag
239 .byte 0x1 ! CIE Version
240 .ascii "zR\0" ! CIE Augmentation
241 .byte 0x1 ! uleb128 0x1; CIE Code Alignment Factor
242 .byte 0x78 ! sleb128 -8; CIE Data Alignment Factor
243 .byte 0xf ! CIE RA Column
244 .byte 0x1 ! uleb128 0x1; Augmentation size
245 #ifdef HAVE_AS_SPARC_UA_PCREL
246 .byte 0x1b ! FDE Encoding (pcrel sdata4)
248 .byte 0x50 ! FDE Encoding (aligned absolute)
250 .byte 0xc ! DW_CFA_def_cfa
251 .byte 0xe ! uleb128 0xe
252 .byte 0xff,0xf ! uleb128 0x7ff
256 .uaword .LLEFDE1-.LLASFDE1 ! FDE Length
258 .uaword .LLASFDE1-.LLframe1 ! FDE CIE offset
259 #ifdef HAVE_AS_SPARC_UA_PCREL
260 .uaword %r_disp32(.LLFB1)
261 .uaword .LLFE1-.LLFB1 ! FDE address range
265 .uaxword .LLFE1-.LLFB1 ! FDE address range
267 .byte 0x0 ! uleb128 0x0; Augmentation size
268 .byte 0x4 ! DW_CFA_advance_loc4
269 .uaword .LLCFI0-.LLFB1
270 .byte 0xd ! DW_CFA_def_cfa_register
271 .byte 0x1e ! uleb128 0x1e
272 .byte 0x2d ! DW_CFA_GNU_window_save
273 .byte 0x9 ! DW_CFA_register
274 .byte 0xf ! uleb128 0xf
275 .byte 0x1f ! uleb128 0x1f
279 .uaword .LLEFDE2-.LLASFDE2 ! FDE Length
281 .uaword .LLASFDE2-.LLframe1 ! FDE CIE offset
282 #ifdef HAVE_AS_SPARC_UA_PCREL
283 .uaword %r_disp32(.LLFB2)
284 .uaword .LLFE2-.LLFB2 ! FDE address range
288 .uaxword .LLFE2-.LLFB2 ! FDE address range
290 .byte 0x0 ! uleb128 0x0; Augmentation size
291 .byte 0x4 ! DW_CFA_advance_loc4
292 .uaword .LLCFI1-.LLFB2
293 .byte 0xd ! DW_CFA_def_cfa_register
294 .byte 0x1e ! uleb128 0x1e
295 .byte 0x2d ! DW_CFA_GNU_window_save
296 .byte 0x9 ! DW_CFA_register
297 .byte 0xf ! uleb128 0xf
298 .byte 0x1f ! uleb128 0x1f
304 .section .note.GNU-stack,"",@progbits