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 ----------------------------------------------------------------------- */
29 #include <fficonfig.h>
35 .hidden ffi_call_LINUX64
36 .globl ffi_call_LINUX64
42 addis %r2, %r12, .TOC.-ffi_call_LINUX64@ha
43 addi %r2, %r2, .TOC.-ffi_call_LINUX64@l
45 .localentry ffi_call_LINUX64, . - ffi_call_LINUX64
51 .quad .L.ffi_call_LINUX64,.TOC.@tocbase,0
52 .type ffi_call_LINUX64,@function
56 .hidden .ffi_call_LINUX64
57 .globl .ffi_call_LINUX64
58 .quad .ffi_call_LINUX64,.TOC.@tocbase,0
59 .size ffi_call_LINUX64,24
60 .type .ffi_call_LINUX64,@function
70 std %r7, 8(%r1) /* closure, saved in cr field. */
73 mr %r28, %r1 /* our AP. */
74 .cfi_def_cfa_register 28
82 mr %r31, %r6 /* flags, */
83 mr %r30, %r5 /* rvalue, */
84 mr %r29, %r4 /* function address. */
85 /* Save toc pointer, not for the ffi_prep_args64 call, but for the later
86 bctrl function call. */
93 /* Call ffi_prep_args64. */
95 # if defined _CALL_LINUX || _CALL_ELF == 2
97 bl ffi_prep_args64@notoc
113 /* Now do the call. */
114 /* Set up cr1 with bits 3-7 of the flags. */
117 /* Get the address to call into CTR. */
119 /* Load all those argument registers. */
120 addi %r29, %r28, -32-(8*8)
132 /* Load all the FP registers. */
134 addi %r29, %r29, -(14*8)
135 lfd %f1, ( 1*8)(%r29)
136 lfd %f2, ( 2*8)(%r29)
137 lfd %f3, ( 3*8)(%r29)
138 lfd %f4, ( 4*8)(%r29)
139 lfd %f5, ( 5*8)(%r29)
140 lfd %f6, ( 6*8)(%r29)
141 lfd %f7, ( 7*8)(%r29)
142 lfd %f8, ( 8*8)(%r29)
143 lfd %f9, ( 9*8)(%r29)
144 lfd %f10, (10*8)(%r29)
145 lfd %f11, (11*8)(%r29)
146 lfd %f12, (12*8)(%r29)
147 lfd %f13, (13*8)(%r29)
150 /* Load all the vector registers. */
182 /* This must follow the call immediately, the unwinder
183 uses this to find out if r2 has been saved or not. */
190 /* Now, deal with the return value. */
192 bt 31, .Lstruct_return_value
193 bt 30, .Ldone_return_value
194 bt 29, .Lfp_return_value
195 bt 28, .Lvec_return_value
197 /* Fall through... */
200 /* Restore the registers we used and return. */
202 .cfi_def_cfa_register 1
213 b .Ldone_return_value
216 .cfi_def_cfa_register 28
217 mtcrf 0x02, %r31 /* cr6 */
218 bf 27, .Lfloat_return_value
220 bf 26, .Ldone_return_value
222 b .Ldone_return_value
223 .Lfloat_return_value:
225 b .Ldone_return_value
227 .Lstruct_return_value:
228 bf 29, .Lvec_homog_or_small_struct
229 mtcrf 0x02, %r31 /* cr6 */
230 bf 27, .Lfloat_homog_return_value
239 b .Ldone_return_value
241 .Lfloat_homog_return_value:
250 b .Ldone_return_value
252 .Lvec_homog_or_small_struct:
253 bf 28, .Lsmall_struct
269 b .Ldone_return_value
274 b .Ldone_return_value
278 .size ffi_call_LINUX64,.-ffi_call_LINUX64
281 .size ffi_call_LINUX64,.-.L.ffi_call_LINUX64
284 .byte 0,12,0,1,128,4,0,0
285 .size .ffi_call_LINUX64,.-.ffi_call_LINUX64
291 #if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
292 .section .note.GNU-stack,"",@progbits