1 /* -----------------------------------------------------------------------
2 darwin.S - Copyright (c) 2000 John Hornkvist
3 Copyright (c) 2004 Free Software Foundation, Inc.
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 ----------------------------------------------------------------------- */
27 #if defined(__ppc64__)
28 #define MODE_CHOICE(x, y) y
30 #define MODE_CHOICE(x, y) x
33 #define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */
35 #define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */
38 #include <fficonfig.h>
40 #define JUMPTARGET(name) name
48 .globl _ffi_call_DARWIN
53 mr r12,r8 /* We only need r12 until the call,
54 so it doesn't have to be saved. */
56 /* Save the old stack pointer as AP. */
59 /* Allocate the stack space we need. */
62 /* Save registers we use. */
74 /* Save arguments over call. */
75 mr r31,r5 /* flags, */
76 mr r30,r6 /* rvalue, */
77 mr r29,r7 /* function address, */
78 mr r28,r8 /* our AP. */
80 /* Call ffi_prep_args. */
84 mtctr r12 /* r12 holds address of _ffi_prep_args. */
89 Set up cr1 with bits 4-7 of the flags. */
91 /* Get the address to call into CTR. */
93 /* Load all those argument registers.
94 We have set up a nice stack frame, just load it into registers. */
106 /* Load all the FP registers. */
107 bf 6,L2 /* No floats to load. */
108 lfd f1,-16-(13*8)(r28)
109 lfd f2,-16-(12*8)(r28)
110 lfd f3,-16-(11*8)(r28)
111 lfd f4,-16-(10*8)(r28)
113 lfd f5,-16-(9*8)(r28)
114 lfd f6,-16-(8*8)(r28)
115 lfd f7,-16-(7*8)(r28)
116 lfd f8,-16-(6*8)(r28)
118 lfd f9,-16-(5*8)(r28)
119 lfd f10,-16-(4*8)(r28)
120 lfd f11,-16-(3*8)(r28)
121 lfd f12,-16-(2*8)(r28)
123 lfd f13,-16-(1*8)(r28)
126 mr r12,r29 /* Put the target address in r12 as specified. */
133 /* Now, deal with the return value. */
136 bt 30,L(done_return_value)
137 bt 29,L(fp_return_value)
139 bf 28,L(done_return_value)
144 L(done_return_value):
145 /* Restore the registers we used and return. */
156 /* Do we have long double to store? */
157 bf 31,L(fd_return_value)
160 b L(done_return_value)
163 /* Do we have double to store? */
164 bf 28,L(float_return_value)
166 b L(done_return_value)
168 L(float_return_value):
169 /* We only have a float to store. */
171 b L(done_return_value)
174 /* END(_ffi_call_DARWIN) */
176 /* Provide a null definition of _ffi_call_AIX. */
184 /* END(_ffi_call_AIX) */
187 .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms
189 .set L$set$0,LECIE1-LSCIE1
190 .long L$set$0 ; Length of Common Information Entry
192 .long 0x0 ; CIE Identifier Tag
193 .byte 0x1 ; CIE Version
194 .ascii "zR\0" ; CIE Augmentation
195 .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor
196 .byte 0x7c ; sleb128 -4; CIE Data Alignment Factor
197 .byte 0x41 ; CIE RA Column
198 .byte 0x1 ; uleb128 0x1; Augmentation size
199 .byte 0x90 ; FDE Encoding (indirect pcrel)
200 .byte 0xc ; DW_CFA_def_cfa
201 .byte 0x1 ; uleb128 0x1
202 .byte 0x0 ; uleb128 0x0
203 .align LOG2_GPR_BYTES
205 .globl _ffi_call_DARWIN.eh
208 .set L$set$1,LEFDE1-LASFDE1
209 .long L$set$1 ; FDE Length
211 .long LASFDE1-EH_frame1 ; FDE CIE offset
212 .g_long LLFB0$non_lazy_ptr-. ; FDE initial location
213 .set L$set$3,LFE1-LFB0
214 .g_long L$set$3 ; FDE address range
215 .byte 0x0 ; uleb128 0x0; Augmentation size
216 .byte 0x4 ; DW_CFA_advance_loc4
217 .set L$set$4,LCFI0-LFB1
219 .byte 0xd ; DW_CFA_def_cfa_register
220 .byte 0x08 ; uleb128 0x08
221 .byte 0x4 ; DW_CFA_advance_loc4
222 .set L$set$5,LCFI1-LCFI0
224 .byte 0x11 ; DW_CFA_offset_extended_sf
225 .byte 0x41 ; uleb128 0x41
226 .byte 0x7e ; sleb128 -2
227 .byte 0x9f ; DW_CFA_offset, column 0x1f
228 .byte 0x1 ; uleb128 0x1
229 .byte 0x9e ; DW_CFA_offset, column 0x1e
230 .byte 0x2 ; uleb128 0x2
231 .byte 0x9d ; DW_CFA_offset, column 0x1d
232 .byte 0x3 ; uleb128 0x3
233 .byte 0x9c ; DW_CFA_offset, column 0x1c
234 .byte 0x4 ; uleb128 0x4
235 .byte 0x4 ; DW_CFA_advance_loc4
236 .set L$set$6,LCFI2-LCFI1
238 .byte 0xd ; DW_CFA_def_cfa_register
239 .byte 0x1c ; uleb128 0x1c
240 .align LOG2_GPR_BYTES
243 .align LOG2_GPR_BYTES