1 /* -----------------------------------------------------------------------
2 aix_closure.S - Copyright (c) 2002 2003 Free Software Foundation, Inc.
3 based on darwin_closure.S
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, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 OTHER DEALINGS IN THE SOFTWARE.
25 ----------------------------------------------------------------------- */
83 #define JUMPTARGET(name) name
94 .globl ffi_closure_ASM
95 .globl .ffi_closure_ASM
96 .csect ffi_closure_ASM[DS]
99 .long .ffi_closure_ASM, TOC[tc0], 0
103 mflr r0 /* extract return address */
104 stw r0, 8(r1) /* save the return address */
106 /* 24 Bytes (Linkage Area) */
107 /* 32 Bytes (params) */
108 /* 104 Bytes (13*8 from FPR) */
109 /* 8 Bytes (result) */
112 stwu r1,-176(r1) /* skip over caller save area
113 keep stack aligned to 16 */
115 /* we want to build up an area for the parameters passed */
116 /* in registers (both floating point and integer) */
118 /* we store gpr 3 to gpr 10 (aligned to 4)
119 in the parents outgoing area */
129 /* next save fpr 1 to fpr 13 (aligned to 8) */
144 /* set up registers for the routine that actually does the work */
145 /* get the context pointer from the trampoline */
148 /* now load up the pointer to the result storage */
151 /* now load up the pointer to the saved gpr registers */
154 /* now load up the pointer to the saved fpr registers */
158 bl .ffi_closure_helper_DARWIN
161 /* now r3 contains the return type */
162 /* so use it to look up in a table */
163 /* so we know how to deal with each type */
165 /* look up the proper starting point in table */
166 /* by using return type as offset */
167 addi r5,r1,160 /* get pointer to results area */
168 lwz r4,LC..60(2) /* get address of jump table */
169 slwi r3,r3,2 /* now multiply return type by 4 */
170 lwzx r3,r4,r3 /* get the contents of that table value */
171 add r3,r3,r4 /* add contents of table to table address */
173 bctr /* jump to it */
176 .long L..44-L..60 /* FFI_TYPE_VOID */
177 .long L..50-L..60 /* FFI_TYPE_INT */
178 .long L..47-L..60 /* FFI_TYPE_FLOAT */
179 .long L..46-L..60 /* FFI_TYPE_DOUBLE */
180 .long L..46-L..60 /* FFI_TYPE_LONGDOUBLE */
181 .long L..56-L..60 /* FFI_TYPE_UINT8 */
182 .long L..55-L..60 /* FFI_TYPE_SINT8 */
183 .long L..58-L..60 /* FFI_TYPE_UINT16 */
184 .long L..57-L..60 /* FFI_TYPE_SINT16 */
185 .long L..50-L..60 /* FFI_TYPE_UINT32 */
186 .long L..50-L..60 /* FFI_TYPE_SINT32 */
187 .long L..48-L..60 /* FFI_TYPE_UINT64 */
188 .long L..48-L..60 /* FFI_TYPE_SINT64 */
189 .long L..44-L..60 /* FFI_TYPE_STRUCT */
190 .long L..50-L..60 /* FFI_TYPE_POINTER */
209 /* case default / int32 / pointer */
214 /* case signed int8 */
222 /* case unsigned int8 */
228 /* case signed int16 */
235 /* case unsigned int16 */
240 /* case void / done */
242 addi r1,r1,176 /* restore stack pointer */
243 lwz r0,8(r1) /* get return address */
244 mtlr r0 /* reset link register */
247 /* END(ffi_closure_ASM) */