1 /* -----------------------------------------------------------------------
2 sysv.h - Copyright (c) 2003 Jakub Jelinek <jakub@redhat.com>
3 Copyright (c) 2008 Red Hat, Inc.
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 ``Software''), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 ----------------------------------------------------------------------- */
28 #include <fficonfig.h>
30 #include <powerpc/asm.h>
36 FFI_HIDDEN(ffi_closure_SYSV)
37 ENTRY(ffi_closure_SYSV)
40 .cfi_def_cfa_offset 144
45 # we want to build up an areas for the parameters passed
46 # in registers (both floating point and integer)
48 # so first save gpr 3 to gpr 10 (aligned to 4)
53 # set up registers for the routine that does the work
56 lwz %r3,FFI_TRAMPOLINE_SIZE(%r11)
58 lwz %r4,FFI_TRAMPOLINE_SIZE+4(%r11)
60 lwz %r5,FFI_TRAMPOLINE_SIZE+8(%r11)
70 # next save fpr 1 to fpr 8 (aligned to 8)
81 # pointer to the result storage
84 # pointer to the saved gpr registers
87 # pointer to the saved fpr registers
90 # pointer to the outgoing parameter save area in the previous frame
91 # i.e. the previous frame pointer + 8
95 bl ffi_closure_helper_SYSV@local
97 # now r3 contains the return type
98 # so use it to look up in a table
99 # so we know how to deal with each type
101 # look up the proper starting point in table
102 # by using return type as offset
104 mflr %r4 # move address of .Lret to r4
105 slwi %r3,%r3,4 # now multiply return type by 16
106 addi %r4, %r4, .Lret_type0 - .Lret
108 add %r3,%r3,%r4 # add contents of table to table address
112 # Each of the ret_typeX code fragments has to be exactly 16 bytes long
113 # (4 instructions). For cache effectiveness we align to a 16 byte boundary
120 .cfi_def_cfa_offset 0
122 .cfi_def_cfa_offset 144
130 .cfi_def_cfa_offset 0
132 .cfi_def_cfa_offset 144
134 # case FFI_TYPE_FLOAT
142 .cfi_def_cfa_offset 0
144 .cfi_def_cfa_offset 144
146 # case FFI_TYPE_DOUBLE
154 .cfi_def_cfa_offset 0
156 .cfi_def_cfa_offset 144
158 # case FFI_TYPE_LONGDOUBLE
167 .cfi_def_cfa_offset 0
169 .cfi_def_cfa_offset 144
173 # case FFI_TYPE_UINT8
174 #ifdef __LITTLE_ENDIAN__
181 .cfi_def_cfa_offset 0
183 .cfi_def_cfa_offset 144
185 # case FFI_TYPE_SINT8
186 #ifdef __LITTLE_ENDIAN__
195 # case FFI_TYPE_UINT16
196 #ifdef __LITTLE_ENDIAN__
203 .cfi_def_cfa_offset 0
205 .cfi_def_cfa_offset 144
207 # case FFI_TYPE_SINT16
208 #ifdef __LITTLE_ENDIAN__
215 .cfi_def_cfa_offset 0
217 .cfi_def_cfa_offset 144
219 # case FFI_TYPE_UINT32
223 .cfi_def_cfa_offset 0
225 .cfi_def_cfa_offset 144
227 # case FFI_TYPE_SINT32
231 .cfi_def_cfa_offset 0
233 .cfi_def_cfa_offset 144
235 # case FFI_TYPE_UINT64
241 # case FFI_TYPE_SINT64
247 # case FFI_TYPE_STRUCT
250 .cfi_def_cfa_offset 0
252 .cfi_def_cfa_offset 144
255 # case FFI_TYPE_POINTER
259 .cfi_def_cfa_offset 0
261 .cfi_def_cfa_offset 144
263 # case FFI_TYPE_UINT128
269 # The return types below are only used when the ABI type is FFI_SYSV.
270 # case FFI_SYSV_TYPE_SMALL_STRUCT + 1. One byte struct.
274 .cfi_def_cfa_offset 0
276 .cfi_def_cfa_offset 144
278 # case FFI_SYSV_TYPE_SMALL_STRUCT + 2. Two byte struct.
282 .cfi_def_cfa_offset 0
284 .cfi_def_cfa_offset 144
286 # case FFI_SYSV_TYPE_SMALL_STRUCT + 3. Three byte struct.
288 #ifdef __LITTLE_ENDIAN__
291 .cfi_def_cfa_offset 0
293 .cfi_def_cfa_offset 144
300 # case FFI_SYSV_TYPE_SMALL_STRUCT + 4. Four byte struct.
304 .cfi_def_cfa_offset 0
306 .cfi_def_cfa_offset 144
308 # case FFI_SYSV_TYPE_SMALL_STRUCT + 5. Five byte struct.
311 #ifdef __LITTLE_ENDIAN__
319 # case FFI_SYSV_TYPE_SMALL_STRUCT + 6. Six byte struct.
322 #ifdef __LITTLE_ENDIAN__
330 # case FFI_SYSV_TYPE_SMALL_STRUCT + 7. Seven byte struct.
333 #ifdef __LITTLE_ENDIAN__
341 # case FFI_SYSV_TYPE_SMALL_STRUCT + 8. Eight byte struct.
347 #ifndef __LITTLE_ENDIAN__
356 .cfi_def_cfa_offset 0
358 .cfi_def_cfa_offset 144
365 .cfi_def_cfa_offset 0
368 END(ffi_closure_SYSV)
371 FFI_HIDDEN(ffi_go_closure_sysv)
372 ENTRY(ffi_go_closure_sysv)
375 .cfi_def_cfa_offset 144
392 END(ffi_go_closure_sysv)
394 #if defined __ELF__ && defined __linux__
395 .section .note.GNU-stack,"",@progbits