1 /* -----------------------------------------------------------------------
2 v8.S - Copyright (c) 1996, 1997, 2003 Cygnus Solutions
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, 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 CYGNUS SOLUTIONS 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 ----------------------------------------------------------------------- */
29 #define STACKFRAME 96 /* Minimum stack framesize for SPARC */
30 #define ARGS (64+4) /* Offset of register area in frame */
40 save %sp, -STACKFRAME, %sp
43 sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
44 add %sp, STACKFRAME, %l0 ! %l0 has start of
47 mov %l0, %o0 ! call routine to set up frame
49 mov %i1, %o1 ! (delay)
51 ld [%l0+ARGS], %o0 ! call foreign function
58 mov %l0, %sp ! (delay) switch to frame
59 nop ! STRUCT returning functions skip 12 instead of 8 bytes
61 ! If the return value pointer is NULL, assume no return value.
68 st %o0, [%i4] ! (delay)
70 cmp %i3, FFI_TYPE_FLOAT
72 st %f0, [%i4+0] ! (delay)
74 cmp %i3, FFI_TYPE_SINT64
77 cmp %i3, FFI_TYPE_DOUBLE
95 .size ffi_call_V8,.ffi_call_V8_end-ffi_call_V8
98 #define STACKFRAME 104 /* 16*4 register window +
100 6*4 args backing store +
103 /* ffi_closure_v8(...)
105 Receives the closure argument in %g2. */
109 .globl ffi_closure_v8
112 .register %g2, #scratch
114 save %sp, -STACKFRAME, %sp
117 ! Store all of the potential argument registers in va_list format.
125 ! Call ffi_closure_sparc_inner to do the bulk of the work.
129 call ffi_closure_sparc_inner
132 ! Load up the return value in the proper type.
133 cmp %o0, FFI_TYPE_VOID
136 cmp %o0, FFI_TYPE_FLOAT
140 cmp %o0, FFI_TYPE_DOUBLE
144 cmp %o0, FFI_TYPE_SINT64
148 cmp %o0, FFI_TYPE_UINT64
161 .size ffi_closure_v8,.ffi_closure_v8_end-ffi_closure_v8
166 #define uanword uaxword
170 #define uanword uaword
173 .section ".eh_frame",#alloc,#write
175 .uaword .LLECIE1-.LLSCIE1 ! Length of Common Information Entry
177 .uaword 0x0 ! CIE Identifier Tag
178 .byte 0x1 ! CIE Version
179 .ascii "zR\0" ! CIE Augmentation
180 .byte 0x1 ! uleb128 0x1; CIE Code Alignment Factor
181 .byte 0x80-WS ! sleb128 -WS; CIE Data Alignment Factor
182 .byte 0xf ! CIE RA Column
183 .byte 0x1 ! uleb128 0x1; Augmentation size
184 #ifdef HAVE_AS_SPARC_UA_PCREL
185 .byte 0x1b ! FDE Encoding (pcrel sdata4)
187 .byte 0x50 ! FDE Encoding (aligned absolute)
189 .byte 0xc ! DW_CFA_def_cfa
190 .byte 0xe ! uleb128 0xe
191 .byte 0x0 ! uleb128 0x0
195 .uaword .LLEFDE1-.LLASFDE1 ! FDE Length
197 .uaword .LLASFDE1-.LLframe1 ! FDE CIE offset
198 #ifdef HAVE_AS_SPARC_UA_PCREL
199 .uaword %r_disp32(.LLFB1)
200 .uaword .LLFE1-.LLFB1 ! FDE address range
204 .uanword .LLFE1-.LLFB1 ! FDE address range
206 .byte 0x0 ! uleb128 0x0; Augmentation size
207 .byte 0x4 ! DW_CFA_advance_loc4
208 .uaword .LLCFI0-.LLFB1
209 .byte 0xd ! DW_CFA_def_cfa_register
210 .byte 0x1e ! uleb128 0x1e
211 .byte 0x2d ! DW_CFA_GNU_window_save
212 .byte 0x9 ! DW_CFA_register
213 .byte 0xf ! uleb128 0xf
214 .byte 0x1f ! uleb128 0x1f
218 .uaword .LLEFDE2-.LLASFDE2 ! FDE Length
220 .uaword .LLASFDE2-.LLframe1 ! FDE CIE offset
221 #ifdef HAVE_AS_SPARC_UA_PCREL
222 .uaword %r_disp32(.LLFB2)
223 .uaword .LLFE2-.LLFB2 ! FDE address range
227 .uanword .LLFE2-.LLFB2 ! FDE address range
229 .byte 0x0 ! uleb128 0x0; Augmentation size
230 .byte 0x4 ! DW_CFA_advance_loc4
231 .uaword .LLCFI1-.LLFB2
232 .byte 0xd ! DW_CFA_def_cfa_register
233 .byte 0x1e ! uleb128 0x1e
234 .byte 0x2d ! DW_CFA_GNU_window_save
235 .byte 0x9 ! DW_CFA_register
236 .byte 0xf ! uleb128 0xf
237 .byte 0x1f ! uleb128 0x1f