1 /* -----------------------------------------------------------------------
2 darwin.S - Copyright (c) 2000 John Hornkvist
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 ``Software''), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24 ----------------------------------------------------------------------- */
28 #define JUMPTARGET(name) name
36 .globl _ffi_call_DARWIN
41 mr r12,r8 /* We only need r12 until the call,
42 so it doesn't have to be saved... */
44 /* Save the old stack pointer as AP. */
47 /* Allocate the stack space we need. */
50 /* Save registers we use. */
62 /* Save arguments over call... */
63 mr r31,r5 /* flags, */
64 mr r30,r6 /* rvalue, */
65 mr r29,r7 /* function address, */
66 mr r28,r8 /* our AP. */
68 /* Call ffi_prep_args. */
72 mtctr r12 // r12 holds address of _ffi_prep_args
76 /* Now do the call. */
77 /* Set up cr1 with bits 4-7 of the flags. */
79 /* Get the address to call into CTR. */
81 /* Load all those argument registers. */
82 // We have set up a nice stack frame, just load it into registers.
94 /* Load all the FP registers. */
96 lfd f1,-16-(13*8)(r28)
97 lfd f2,-16-(12*8)(r28)
98 lfd f3,-16-(11*8)(r28)
99 lfd f4,-16-(10*8)(r28)
101 lfd f5,-16-(9*8)(r28)
102 lfd f6,-16-(8*8)(r28)
103 lfd f7,-16-(7*8)(r28)
104 lfd f8,-16-(6*8)(r28)
106 lfd f9,-16-(5*8)(r28)
107 lfd f10,-16-(4*8)(r28)
108 lfd f11,-16-(3*8)(r28)
109 lfd f12,-16-(2*8)(r28)
111 lfd f13,-16-(1*8)(r28)
114 mr r12,r29 // Put the target address in r12 as specified.
121 /* Now, deal with the return value. */
124 bt 30,L(done_return_value)
125 bt 29,L(fp_return_value)
127 bf 28,L(done_return_value)
130 /* Fall through... */
132 L(done_return_value):
133 /* Restore the registers we used and return. */
144 bf 28,L(float_return_value)
146 b L(done_return_value)
147 L(float_return_value):
149 b L(done_return_value)
151 /* END(_ffi_call_DARWIN) */
153 /* Provide a null definition of _ffi_call_AIX. */
161 /* END(_ffi_call_AIX) */
164 .section __TEXT,__eh_frame
166 .set L$set$0,LECIE1-LSCIE1
167 .long L$set$0 ; Length of Common Information Entry
169 .long 0x0 ; CIE Identifier Tag
170 .byte 0x1 ; CIE Version
171 .ascii "zR\0" ; CIE Augmentation
172 .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor
173 .byte 0x7c ; sleb128 -4; CIE Data Alignment Factor
174 .byte 0x41 ; CIE RA Column
175 .byte 0x1 ; uleb128 0x1; Augmentation size
176 .byte 0x10 ; FDE Encoding (pcrel)
177 .byte 0xc ; DW_CFA_def_cfa
178 .byte 0x1 ; uleb128 0x1
179 .byte 0x0 ; uleb128 0x0
183 .set L$set$1,LEFDE1-LASFDE1
184 .long L$set$1 ; FDE Length
186 .set L$set$2,LASFDE1-Lframe1
187 .long L$set$2 ; FDE CIE offset
188 .long LFB0-. ; FDE initial location
189 .set L$set$3,LFE1-LFB0
190 .long L$set$3 ; FDE address range
191 .byte 0x0 ; uleb128 0x0; Augmentation size
192 .byte 0x4 ; DW_CFA_advance_loc4
193 .set L$set$4,LCFI0-LFB1
195 .byte 0xd ; DW_CFA_def_cfa_register
196 .byte 0x08 ; uleb128 0x08
197 .byte 0x4 ; DW_CFA_advance_loc4
198 .set L$set$5,LCFI1-LCFI0
200 .byte 0x11 ; DW_CFA_offset_extended_sf
201 .byte 0x41 ; uleb128 0x41
202 .byte 0x7e ; sleb128 -2
203 .byte 0x9f ; DW_CFA_offset, column 0x1f
204 .byte 0x1 ; uleb128 0x1
205 .byte 0x9e ; DW_CFA_offset, column 0x1e
206 .byte 0x2 ; uleb128 0x2
207 .byte 0x9d ; DW_CFA_offset, column 0x1d
208 .byte 0x3 ; uleb128 0x3
209 .byte 0x9c ; DW_CFA_offset, column 0x1c
210 .byte 0x4 ; uleb128 0x4
211 .byte 0x4 ; DW_CFA_advance_loc4
212 .set L$set$6,LCFI2-LCFI1
214 .byte 0xd ; DW_CFA_def_cfa_register
215 .byte 0x1c ; uleb128 0x1c