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 mr r12,r8 // We only need r12 until the call, so it doesn't have to be saved...
108 /* Save the old stack pointer as AP. */
111 /* Allocate the stack space we need. */
114 /* Save registers we use. */
125 /* Save arguments over call... */
126 mr r31,r5 /* flags, */
127 mr r30,r6 /* rvalue, */
128 mr r29,r7 /* function address, */
129 mr r28,r8 /* our AP. */
131 /* Call ffi_prep_args. */
137 mtctr r12 // r12 holds address of _ffi_prep_args
141 /* Now do the call. */
143 /* Set up cr1 with bits 4-7 of the flags. */
148 /* Load all those argument registers. */
149 // We have set up a nice stack frame, just load it into registers.
161 /* Load all the FP registers. */
163 lfd f1,-32-(13*8)(r28)
164 lfd f2,-32-(12*8)(r28)
165 lfd f3,-32-(11*8)(r28)
166 lfd f4,-32-(10*8)(r28)
168 lfd f5,-32-(9*8)(r28)
169 lfd f6,-32-(8*8)(r28)
170 lfd f7,-32-(7*8)(r28)
171 lfd f8,-32-(6*8)(r28)
173 lfd f9,-32-(5*8)(r28)
174 lfd f10,-32-(4*8)(r28)
175 lfd f11,-32-(3*8)(r28)
176 lfd f12,-32-(2*8)(r28)
178 lfd f13,-32-(1*8)(r28)
185 /* Now, deal with the return value. */
188 bt 30,L(done_return_value)
189 bt 29,L(fp_return_value)
191 bf 28,L(done_return_value)
194 /* Fall through... */
196 L(done_return_value):
197 /* Restore the registers we used and return. */
208 bf 28,L(float_return_value)
210 b L(done_return_value)
211 L(float_return_value):
213 b L(done_return_value)
215 #else /* ! __64BIT__ */
217 .long .ffi_call_AIX, TOC[tc0], 0
220 mr r12,r8 // We only need r12 until the call, so it doesn't have to be saved...
221 /* Save the old stack pointer as AP. */
224 /* Allocate the stack space we need. */
227 /* Save registers we use. */
238 /* Save arguments over call... */
239 mr r31,r5 /* flags, */
240 mr r30,r6 /* rvalue, */
241 mr r29,r7 /* function address, */
242 mr r28,r8 /* our AP. */
244 /* Call ffi_prep_args. */
250 mtctr r12 // r12 holds address of _ffi_prep_args
254 /* Now do the call. */
256 /* Set up cr1 with bits 4-7 of the flags. */
261 /* Load all those argument registers. */
262 // We have set up a nice stack frame, just load it into registers.
274 /* Load all the FP registers. */
276 lfd f1,-16-(13*8)(r28)
277 lfd f2,-16-(12*8)(r28)
278 lfd f3,-16-(11*8)(r28)
279 lfd f4,-16-(10*8)(r28)
281 lfd f5,-16-(9*8)(r28)
282 lfd f6,-16-(8*8)(r28)
283 lfd f7,-16-(7*8)(r28)
284 lfd f8,-16-(6*8)(r28)
286 lfd f9,-16-(5*8)(r28)
287 lfd f10,-16-(4*8)(r28)
288 lfd f11,-16-(3*8)(r28)
289 lfd f12,-16-(2*8)(r28)
291 lfd f13,-16-(1*8)(r28)
298 /* Now, deal with the return value. */
301 bt 30,L(done_return_value)
302 bt 29,L(fp_return_value)
304 bf 28,L(done_return_value)
307 /* Fall through... */
309 L(done_return_value):
310 /* Restore the registers we used and return. */
321 bf 28,L(float_return_value)
323 b L(done_return_value)
324 L(float_return_value):
326 b L(done_return_value)
329 .byte 0,0,0,1,128,4,0,0
334 .globl ffi_call_DARWIN
335 .globl .ffi_call_DARWIN
336 .csect ffi_call_DARWIN[DS]
339 .llong .ffi_call_DARWIN, TOC[tc0], 0
341 .long .ffi_call_DARWIN, TOC[tc0], 0
347 .byte 0,0,0,0,0,0,0,0
348 //END(ffi_call_DARWIN)