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 ENTRY(ffi_closure_SYSV)
44 # we want to build up an areas for the parameters passed
45 # in registers (both floating point and integer)
47 # so first save gpr 3 to gpr 10 (aligned to 4)
58 # next save fpr 1 to fpr 8 (aligned to 8)
69 # set up registers for the routine that actually does the work
70 # get the context pointer from the trampoline
73 # now load up the pointer to the result storage
76 # now load up the pointer to the saved gpr registers
79 # now load up the pointer to the saved fpr registers */
82 # now load up the pointer to the outgoing parameter
83 # stack in the previous frame
84 # i.e. the previous frame pointer + 8
88 bl ffi_closure_helper_SYSV@local
90 # now r3 contains the return type
91 # so use it to look up in a table
92 # so we know how to deal with each type
94 # look up the proper starting point in table
95 # by using return type as offset
97 mflr %r4 # move address of .Lret to r4
98 slwi %r3,%r3,4 # now multiply return type by 16
99 addi %r4, %r4, .Lret_type0 - .Lret
101 add %r3,%r3,%r4 # add contents of table to table address
106 # Each of the ret_typeX code fragments has to be exactly 16 bytes long
107 # (4 instructions). For cache effectiveness we align to a 16 byte boundary
124 # case FFI_TYPE_FLOAT
130 # case FFI_TYPE_DOUBLE
136 # case FFI_TYPE_LONGDOUBLE
142 # case FFI_TYPE_UINT8
148 # case FFI_TYPE_SINT8
154 # case FFI_TYPE_UINT16
160 # case FFI_TYPE_SINT16
166 # case FFI_TYPE_UINT32
172 # case FFI_TYPE_SINT32
178 # case FFI_TYPE_UINT64
184 # case FFI_TYPE_SINT64
190 # case FFI_TYPE_STRUCT
196 # case FFI_TYPE_POINTER
202 # case FFI_TYPE_UINT128
208 # The return types below are only used when the ABI type is FFI_SYSV.
209 # case FFI_SYSV_TYPE_SMALL_STRUCT + 1. One byte struct.
215 # case FFI_SYSV_TYPE_SMALL_STRUCT + 2. Two byte struct.
221 # case FFI_SYSV_TYPE_SMALL_STRUCT + 3. Three byte struct.
227 # case FFI_SYSV_TYPE_SMALL_STRUCT + 4. Four byte struct.
233 # case FFI_SYSV_TYPE_SMALL_STRUCT + 5. Five byte struct.
239 # case FFI_SYSV_TYPE_SMALL_STRUCT + 6. Six byte struct.
245 # case FFI_SYSV_TYPE_SMALL_STRUCT + 7. Seven byte struct.
251 # case FFI_SYSV_TYPE_SMALL_STRUCT + 8. Eight byte struct.
273 END(ffi_closure_SYSV)
275 .section ".eh_frame",EH_FRAME_FLAGS,@progbits
277 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
279 .4byte 0x0 # CIE Identifier Tag
280 .byte 0x1 # CIE Version
281 #if defined _RELOCATABLE || defined __PIC__
282 .ascii "zR\0" # CIE Augmentation
284 .ascii "\0" # CIE Augmentation
286 .uleb128 0x1 # CIE Code Alignment Factor
287 .sleb128 -4 # CIE Data Alignment Factor
288 .byte 0x41 # CIE RA Column
289 #if defined _RELOCATABLE || defined __PIC__
290 .uleb128 0x1 # Augmentation size
291 .byte 0x1b # FDE Encoding (pcrel sdata4)
293 .byte 0xc # DW_CFA_def_cfa
299 .4byte .LEFDE1-.LASFDE1 # FDE Length
301 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
302 #if defined _RELOCATABLE || defined __PIC__
303 .4byte .LFB1-. # FDE initial location
305 .4byte .LFB1 # FDE initial location
307 .4byte .LFE1-.LFB1 # FDE address range
308 #if defined _RELOCATABLE || defined __PIC__
309 .uleb128 0x0 # Augmentation size
311 .byte 0x4 # DW_CFA_advance_loc4
313 .byte 0xe # DW_CFA_def_cfa_offset
315 .byte 0x4 # DW_CFA_advance_loc4
317 .byte 0x11 # DW_CFA_offset_extended_sf
325 #if defined __ELF__ && defined __linux__
326 .section .note.GNU-stack,"",@progbits