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>
33 .hidden ffi_call_LINUX64
34 .globl ffi_call_LINUX64
39 addis %r2, %r12, .TOC.-ffi_call_LINUX64@ha
40 addi %r2, %r2, .TOC.-ffi_call_LINUX64@l
41 .localentry ffi_call_LINUX64, . - ffi_call_LINUX64
47 .quad .L.ffi_call_LINUX64,.TOC.@tocbase,0
48 .type ffi_call_LINUX64,@function
52 .hidden .ffi_call_LINUX64
53 .globl .ffi_call_LINUX64
54 .quad .ffi_call_LINUX64,.TOC.@tocbase,0
55 .size ffi_call_LINUX64,24
56 .type .ffi_call_LINUX64,@function
66 std %r7, 8(%r1) /* closure, saved in cr field. */
69 mr %r28, %r1 /* our AP. */
70 .cfi_def_cfa_register 28
78 mr %r31, %r6 /* flags, */
79 mr %r30, %r5 /* rvalue, */
80 mr %r29, %r4 /* function address. */
81 /* Save toc pointer, not for the ffi_prep_args64 call, but for the later
82 bctrl function call. */
89 /* Call ffi_prep_args64. */
91 # if defined _CALL_LINUX || _CALL_ELF == 2
103 /* Now do the call. */
104 /* Set up cr1 with bits 4-7 of the flags. */
107 /* Get the address to call into CTR. */
109 /* Load all those argument registers. */
110 ld %r3, -32-(8*8)(%r28)
111 ld %r4, -32-(7*8)(%r28)
112 ld %r5, -32-(6*8)(%r28)
113 ld %r6, -32-(5*8)(%r28)
115 ld %r7, -32-(4*8)(%r28)
116 ld %r8, -32-(3*8)(%r28)
117 ld %r9, -32-(2*8)(%r28)
118 ld %r10, -32-(1*8)(%r28)
121 /* Load all the FP registers. */
123 lfd %f1, -32-(21*8)(%r28)
124 lfd %f2, -32-(20*8)(%r28)
125 lfd %f3, -32-(19*8)(%r28)
126 lfd %f4, -32-(18*8)(%r28)
127 lfd %f5, -32-(17*8)(%r28)
128 lfd %f6, -32-(16*8)(%r28)
129 lfd %f7, -32-(15*8)(%r28)
130 lfd %f8, -32-(14*8)(%r28)
131 lfd %f9, -32-(13*8)(%r28)
132 lfd %f10, -32-(12*8)(%r28)
133 lfd %f11, -32-(11*8)(%r28)
134 lfd %f12, -32-(10*8)(%r28)
135 lfd %f13, -32-(9*8)(%r28)
142 /* This must follow the call immediately, the unwinder
143 uses this to find out if r2 has been saved or not. */
150 /* Now, deal with the return value. */
152 bt 31, .Lstruct_return_value
153 bt 30, .Ldone_return_value
154 bt 29, .Lfp_return_value
156 /* Fall through... */
159 /* Restore the registers we used and return. */
161 .cfi_def_cfa_register 1
171 .cfi_def_cfa_register 28
172 bf 28, .Lfloat_return_value
174 mtcrf 0x02, %r31 /* cr6 */
175 bf 27, .Ldone_return_value
177 b .Ldone_return_value
178 .Lfloat_return_value:
180 b .Ldone_return_value
182 .Lstruct_return_value:
183 bf 29, .Lsmall_struct
184 bf 28, .Lfloat_homog_return_value
193 b .Ldone_return_value
195 .Lfloat_homog_return_value:
204 b .Ldone_return_value
209 b .Ldone_return_value
213 .size ffi_call_LINUX64,.-ffi_call_LINUX64
216 .size ffi_call_LINUX64,.-.L.ffi_call_LINUX64
219 .byte 0,12,0,1,128,4,0,0
220 .size .ffi_call_LINUX64,.-.ffi_call_LINUX64
226 #if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
227 .section .note.GNU-stack,"",@progbits