1 /* -----------------------------------------------------------------------
2 sysv.h - Copyright (c) 2003 Jakub Jelinek <jakub@redhat.com>
3 Copyright (c) 2008 Red Hat, Inc.
5 PowerPC64 Assembly glue.
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>
31 .file "linux64_closure.S"
34 FFI_HIDDEN (ffi_closure_LINUX64)
35 .globl ffi_closure_LINUX64
40 .quad .L.ffi_closure_LINUX64,.TOC.@tocbase,0
41 .type ffi_closure_LINUX64,@function
43 .L.ffi_closure_LINUX64:
45 FFI_HIDDEN (.ffi_closure_LINUX64)
46 .globl .ffi_closure_LINUX64
47 .quad .ffi_closure_LINUX64,.TOC.@tocbase,0
48 .size ffi_closure_LINUX64,24
49 .type .ffi_closure_LINUX64,@function
54 # save general regs into parm save area
67 # mandatory 48 bytes special reg save area + 64 bytes parm save area
68 # + 16 bytes retval area + 13*8 bytes fpr save area + round to 16
72 # next save fpr 1 to fpr 13
73 stfd %f1, 128+(0*8)(%r1)
74 stfd %f2, 128+(1*8)(%r1)
75 stfd %f3, 128+(2*8)(%r1)
76 stfd %f4, 128+(3*8)(%r1)
77 stfd %f5, 128+(4*8)(%r1)
78 stfd %f6, 128+(5*8)(%r1)
79 stfd %f7, 128+(6*8)(%r1)
80 stfd %f8, 128+(7*8)(%r1)
81 stfd %f9, 128+(8*8)(%r1)
82 stfd %f10, 128+(9*8)(%r1)
83 stfd %f11, 128+(10*8)(%r1)
84 stfd %f12, 128+(11*8)(%r1)
85 stfd %f13, 128+(12*8)(%r1)
87 # set up registers for the routine that actually does the work
88 # get the context pointer from the trampoline
91 # now load up the pointer to the result storage
94 # now load up the pointer to the parameter save area
95 # in the previous frame
96 addi %r5, %r1, 240 + 48
98 # now load up the pointer to the saved fpr registers */
103 bl ffi_closure_helper_LINUX64
105 bl .ffi_closure_helper_LINUX64
109 # now r3 contains the return type
110 # so use it to look up in a table
111 # so we know how to deal with each type
113 # look up the proper starting point in table
114 # by using return type as offset
115 mflr %r4 # move address of .Lret to r4
116 sldi %r3, %r3, 4 # now multiply return type by 16
117 addi %r4, %r4, .Lret_type0 - .Lret
119 add %r3, %r3, %r4 # add contents of table to table address
123 # Each of the ret_typeX code fragments has to be exactly 16 bytes long
124 # (4 instructions). For cache effectiveness we align to a 16 byte boundary
139 # case FFI_TYPE_FLOAT
144 # case FFI_TYPE_DOUBLE
149 # case FFI_TYPE_LONGDOUBLE
154 # case FFI_TYPE_UINT8
159 # case FFI_TYPE_SINT8
164 # case FFI_TYPE_UINT16
170 # case FFI_TYPE_SINT16
175 # case FFI_TYPE_UINT32
180 # case FFI_TYPE_SINT32
185 # case FFI_TYPE_UINT64
190 # case FFI_TYPE_SINT64
195 # case FFI_TYPE_STRUCT
200 # case FFI_TYPE_POINTER
208 .byte 0,12,0,1,128,0,0,0
210 .size ffi_closure_LINUX64,.-.L.ffi_closure_LINUX64
212 .size .ffi_closure_LINUX64,.-.ffi_closure_LINUX64
215 .section .eh_frame,EH_FRAME_FLAGS,@progbits
217 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
219 .4byte 0x0 # CIE Identifier Tag
220 .byte 0x1 # CIE Version
221 .ascii "zR\0" # CIE Augmentation
222 .uleb128 0x1 # CIE Code Alignment Factor
223 .sleb128 -8 # CIE Data Alignment Factor
224 .byte 0x41 # CIE RA Column
225 .uleb128 0x1 # Augmentation size
226 .byte 0x14 # FDE Encoding (pcrel udata8)
227 .byte 0xc # DW_CFA_def_cfa
233 .4byte .LEFDE1-.LASFDE1 # FDE Length
235 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
236 .8byte .LFB1-. # FDE initial location
237 .8byte .LFE1-.LFB1 # FDE address range
238 .uleb128 0x0 # Augmentation size
239 .byte 0x2 # DW_CFA_advance_loc1
241 .byte 0xe # DW_CFA_def_cfa_offset
243 .byte 0x11 # DW_CFA_offset_extended_sf
250 #if defined __ELF__ && defined __linux__
251 .section .note.GNU-stack,"",@progbits