1 /* -----------------------------------------------------------------------
2 aix.S - Copyright (c) 2002,2009 Free Software Foundation, Inc.
3 based on darwin.S by John Hornkvist
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 #include <fficonfig.h>
85 #define JUMPTARGET(name) name
90 /* void ffi_call_AIX(extended_cif *ecif, unsigned long bytes,
91 * unsigned int flags, unsigned int *rvalue,
93 * void (*prep_args)(extended_cif*, unsigned *const));
94 * r3=ecif, r4=bytes, r5=flags, r6=rvalue, r7=fn, r8=prep_args
101 .csect ffi_call_AIX[DS]
104 .llong .ffi_call_AIX, TOC[tc0], 0
107 /* Save registers we use. */
116 mr r28, r1 /* our AP. */
119 /* Save arguments over call... */
120 mr r31, r5 /* flags, */
121 mr r30, r6 /* rvalue, */
122 mr r29, r7 /* function address. */
125 /* Call ffi_prep_args. */
129 /* Now do the call. */
133 /* Set up cr1 with bits 4-7 of the flags. */
136 /* Load all those argument registers. */
137 // We have set up a nice stack frame, just load it into registers.
149 /* Load all the FP registers. */
151 lfd f1,-32-(13*8)(r28)
152 lfd f2,-32-(12*8)(r28)
153 lfd f3,-32-(11*8)(r28)
154 lfd f4,-32-(10*8)(r28)
156 lfd f5,-32-(9*8)(r28)
157 lfd f6,-32-(8*8)(r28)
158 lfd f7,-32-(7*8)(r28)
159 lfd f8,-32-(6*8)(r28)
161 lfd f9,-32-(5*8)(r28)
162 lfd f10,-32-(4*8)(r28)
163 lfd f11,-32-(3*8)(r28)
164 lfd f12,-32-(2*8)(r28)
166 lfd f13,-32-(1*8)(r28)
173 /* Now, deal with the return value. */
176 bt 30, L(done_return_value)
177 bt 29, L(fp_return_value)
180 /* Fall through... */
182 L(done_return_value):
183 /* Restore the registers we used and return. */
194 bf 28, L(float_return_value)
196 bf 31, L(done_return_value)
198 b L(done_return_value)
199 L(float_return_value):
201 b L(done_return_value)
203 #else /* ! __64BIT__ */
205 .long .ffi_call_AIX, TOC[tc0], 0
208 /* Save registers we use. */
217 mr r28, r1 /* out AP. */
220 /* Save arguments over call... */
221 mr r31, r5 /* flags, */
222 mr r30, r6 /* rvalue, */
223 mr r29, r7 /* function address, */
226 /* Call ffi_prep_args. */
230 /* Now do the call. */
234 /* Set up cr1 with bits 4-7 of the flags. */
237 /* Load all those argument registers. */
238 // We have set up a nice stack frame, just load it into registers.
250 /* Load all the FP registers. */
252 lfd f1,-16-(13*8)(r28)
253 lfd f2,-16-(12*8)(r28)
254 lfd f3,-16-(11*8)(r28)
255 lfd f4,-16-(10*8)(r28)
257 lfd f5,-16-(9*8)(r28)
258 lfd f6,-16-(8*8)(r28)
259 lfd f7,-16-(7*8)(r28)
260 lfd f8,-16-(6*8)(r28)
262 lfd f9,-16-(5*8)(r28)
263 lfd f10,-16-(4*8)(r28)
264 lfd f11,-16-(3*8)(r28)
265 lfd f12,-16-(2*8)(r28)
267 lfd f13,-16-(1*8)(r28)
274 /* Now, deal with the return value. */
277 bt 30, L(done_return_value)
278 bt 29, L(fp_return_value)
280 bf 28, L(done_return_value)
283 /* Fall through... */
285 L(done_return_value):
286 /* Restore the registers we used and return. */
297 bf 28, L(float_return_value)
299 b L(done_return_value)
300 L(float_return_value):
302 b L(done_return_value)
305 .byte 0,0,0,1,128,4,0,0
310 .globl ffi_call_DARWIN
311 .globl .ffi_call_DARWIN
312 .csect ffi_call_DARWIN[DS]
315 .llong .ffi_call_DARWIN, TOC[tc0], 0
317 .long .ffi_call_DARWIN, TOC[tc0], 0
323 .byte 0,0,0,0,0,0,0,0
324 //END(ffi_call_DARWIN)