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
136
# case FFI_TYPE_DOUBLE
148
# case FFI_TYPE_LONGDOUBLE
161
# case FFI_TYPE_UINT8
167
# case FFI_TYPE_SINT8
173
# case FFI_TYPE_UINT16
179
# case FFI_TYPE_SINT16
185
# case FFI_TYPE_UINT32
191
# case FFI_TYPE_SINT32
197
# case FFI_TYPE_UINT64
203
# case FFI_TYPE_SINT64
209
# case FFI_TYPE_STRUCT
215
# case FFI_TYPE_POINTER
221
# case FFI_TYPE_UINT128
227
# The return types below are only used when the ABI type is FFI_SYSV.
228
# case FFI_SYSV_TYPE_SMALL_STRUCT + 1. One byte struct.
234
# case FFI_SYSV_TYPE_SMALL_STRUCT + 2. Two byte struct.
240
# case FFI_SYSV_TYPE_SMALL_STRUCT + 3. Three byte struct.
246
# case FFI_SYSV_TYPE_SMALL_STRUCT + 4. Four byte struct.
252
# case FFI_SYSV_TYPE_SMALL_STRUCT + 5. Five byte struct.
258
# case FFI_SYSV_TYPE_SMALL_STRUCT + 6. Six byte struct.
264
# case FFI_SYSV_TYPE_SMALL_STRUCT + 7. Seven byte struct.
270
# case FFI_SYSV_TYPE_SMALL_STRUCT + 8. Eight byte struct.
292
END(ffi_closure_SYSV)
294
.section ".eh_frame",EH_FRAME_FLAGS,@progbits
296
.4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
298
.4byte 0x0 # CIE Identifier Tag
299
.byte 0x1 # CIE Version
300
#if defined _RELOCATABLE || defined __PIC__
301
.ascii "zR\0" # CIE Augmentation
303
.ascii "\0" # CIE Augmentation
305
.uleb128 0x1 # CIE Code Alignment Factor
306
.sleb128 -4 # CIE Data Alignment Factor
307
.byte 0x41 # CIE RA Column
308
#if defined _RELOCATABLE || defined __PIC__
309
.uleb128 0x1 # Augmentation size
310
.byte 0x1b # FDE Encoding (pcrel sdata4)
312
.byte 0xc # DW_CFA_def_cfa
318
.4byte .LEFDE1-.LASFDE1 # FDE Length
320
.4byte .LASFDE1-.Lframe1 # FDE CIE offset
321
#if defined _RELOCATABLE || defined __PIC__
322
.4byte .LFB1-. # FDE initial location
324
.4byte .LFB1 # FDE initial location
326
.4byte .LFE1-.LFB1 # FDE address range
327
#if defined _RELOCATABLE || defined __PIC__
328
.uleb128 0x0 # Augmentation size
330
.byte 0x4 # DW_CFA_advance_loc4
332
.byte 0xe # DW_CFA_def_cfa_offset
334
.byte 0x4 # DW_CFA_advance_loc4
336
.byte 0x11 # DW_CFA_offset_extended_sf
344
#if defined __ELF__ && defined __linux__
345
.section .note.GNU-stack,"",@progbits