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 FFI_HIDDEN (.ffi_closure_LINUX64)
36 .globl ffi_closure_LINUX64, .ffi_closure_LINUX64
40 .quad .ffi_closure_LINUX64,.TOC.@tocbase,0
41 .size ffi_closure_LINUX64,24
42 .type .ffi_closure_LINUX64,@function
46 # save general regs into parm save area
59 # mandatory 48 bytes special reg save area + 64 bytes parm save area
60 # + 16 bytes retval area + 13*8 bytes fpr save area + round to 16
64 # next save fpr 1 to fpr 13
65 stfd %f1, 128+(0*8)(%r1)
66 stfd %f2, 128+(1*8)(%r1)
67 stfd %f3, 128+(2*8)(%r1)
68 stfd %f4, 128+(3*8)(%r1)
69 stfd %f5, 128+(4*8)(%r1)
70 stfd %f6, 128+(5*8)(%r1)
71 stfd %f7, 128+(6*8)(%r1)
72 stfd %f8, 128+(7*8)(%r1)
73 stfd %f9, 128+(8*8)(%r1)
74 stfd %f10, 128+(9*8)(%r1)
75 stfd %f11, 128+(10*8)(%r1)
76 stfd %f12, 128+(11*8)(%r1)
77 stfd %f13, 128+(12*8)(%r1)
79 # set up registers for the routine that actually does the work
80 # get the context pointer from the trampoline
83 # now load up the pointer to the result storage
86 # now load up the pointer to the parameter save area
87 # in the previous frame
88 addi %r5, %r1, 240 + 48
90 # now load up the pointer to the saved fpr registers */
94 bl .ffi_closure_helper_LINUX64
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
103 mflr %r4 # move address of .Lret to r4
104 sldi %r3, %r3, 4 # now multiply return type by 16
105 addi %r4, %r4, .Lret_type0 - .Lret
107 add %r3, %r3, %r4 # add contents of table to table address
111 # Each of the ret_typeX code fragments has to be exactly 16 bytes long
112 # (4 instructions). For cache effectiveness we align to a 16 byte boundary
127 # case FFI_TYPE_FLOAT
132 # case FFI_TYPE_DOUBLE
137 # case FFI_TYPE_LONGDOUBLE
142 # case FFI_TYPE_UINT8
147 # case FFI_TYPE_SINT8
152 # case FFI_TYPE_UINT16
158 # case FFI_TYPE_SINT16
163 # case FFI_TYPE_UINT32
168 # case FFI_TYPE_SINT32
173 # case FFI_TYPE_UINT64
178 # case FFI_TYPE_SINT64
183 # case FFI_TYPE_STRUCT
188 # case FFI_TYPE_POINTER
196 .byte 0,12,0,1,128,0,0,0
197 .size .ffi_closure_LINUX64,.-.ffi_closure_LINUX64
199 .section .eh_frame,EH_FRAME_FLAGS,@progbits
201 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
203 .4byte 0x0 # CIE Identifier Tag
204 .byte 0x1 # CIE Version
205 .ascii "zR\0" # CIE Augmentation
206 .uleb128 0x1 # CIE Code Alignment Factor
207 .sleb128 -8 # CIE Data Alignment Factor
208 .byte 0x41 # CIE RA Column
209 .uleb128 0x1 # Augmentation size
210 .byte 0x14 # FDE Encoding (pcrel udata8)
211 .byte 0xc # DW_CFA_def_cfa
217 .4byte .LEFDE1-.LASFDE1 # FDE Length
219 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
220 .8byte .LFB1-. # FDE initial location
221 .8byte .LFE1-.LFB1 # FDE address range
222 .uleb128 0x0 # Augmentation size
223 .byte 0x2 # DW_CFA_advance_loc1
225 .byte 0xe # DW_CFA_def_cfa_offset
227 .byte 0x11 # DW_CFA_offset_extended_sf
234 #if defined __ELF__ && defined __linux__
235 .section .note.GNU-stack,"",@progbits