source: trunk/gcc/libffi/src/powerpc/darwin_closure.S

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.9 KB
Line 
1/* -----------------------------------------------------------------------
2 darwin_closure.S - Copyright (c) 2002 2003 Free Software Foundation,
3 Inc. based on ppc_closure.S
4
5 PowerPC Assembly glue.
6
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:
14
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
17
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 ----------------------------------------------------------------------- */
26
27#define LIBFFI_ASM
28#define JUMPTARGET(name) name
29#define L(x) x
30.text
31.globl _ffi_closure_helper_DARWIN
32
33.text
34 .align 2
35.globl _ffi_closure_ASM
36
37.text
38 .align 2
39_ffi_closure_ASM:
40LFB1:
41 mflr r0 /* extract return address */
42 stw r0, 8(r1) /* save the return address */
43LCFI0:
44 /* 24 Bytes (Linkage Area)
45 32 Bytes (outgoing parameter area, always reserved)
46 104 Bytes (13*8 from FPR)
47 8 Bytes (result)
48 168 Bytes */
49
50 stwu r1,-176(r1) /* skip over caller save area
51 keep stack aligned to 16 */
52LCFI1:
53 /* we want to build up an area for the parameters passed
54 in registers (both floating point and integer) */
55
56 /* we store gpr 3 to gpr 10 (aligned to 4)
57 in the parents outgoing area */
58 stw r3, 200(r1)
59 stw r4, 204(r1)
60 stw r5, 208(r1)
61 stw r6, 212(r1)
62 stw r7, 216(r1)
63 stw r8, 220(r1)
64 stw r9, 224(r1)
65 stw r10, 228(r1)
66
67 /* we save fpr 1 to fpr 13 (aligned to 8) */
68 stfd f1, 56(r1)
69 stfd f2, 64(r1)
70 stfd f3, 72(r1)
71 stfd f4, 80(r1)
72 stfd f5, 88(r1)
73 stfd f6, 96(r1)
74 stfd f7, 104(r1)
75 stfd f8, 112(r1)
76 stfd f9, 120(r1)
77 stfd f10, 128(r1)
78 stfd f11, 136(r1)
79 stfd f12, 144(r1)
80 stfd f13, 152(r1)
81
82 /* set up registers for the routine that actually does the work */
83 /* get the context pointer from the trampoline */
84 mr r3,r11
85
86 /* now load up the pointer to the result storage */
87 addi r4,r1,160
88
89 /* now load up the pointer to the saved gpr registers */
90 addi r5,r1,200
91
92 /* now load up the pointer to the saved fpr registers */
93 addi r6,r1,56
94
95 /* now load up the pointer to the outgoing parameter
96 stack in the previous frame */
97 addi r7,r1,232
98
99 /* make the call */
100 bl L(_ffi_closure_helper_DARWIN)
101
102 /* now r3 contains the return type */
103 /* so use it to look up in a table */
104 /* so we know how to deal with each type */
105
106 /* look up the proper starting point in table */
107 /* by using return type as offset */
108 addi r5,r1,160 /* get pointer to results area */
109 addis r4,0,ha16(.L60) /* get address of jump table */
110 addi r4,r4,lo16(.L60)
111 slwi r3,r3,2 /* now multiply return type by 4 */
112 lwzx r3,r4,r3 /* get the contents of that table value */
113 add r3,r3,r4 /* add contents of table to table address */
114 mtctr r3
115 bctr /* jump to it */
116LFE1:
117 .align 2
118
119.L60:
120 .long .L44-.L60 /* FFI_TYPE_VOID */
121 .long .L50-.L60 /* FFI_TYPE_INT */
122 .long .L47-.L60 /* FFI_TYPE_FLOAT */
123 .long .L46-.L60 /* FFI_TYPE_DOUBLE */
124 .long .L46-.L60 /* FFI_TYPE_LONGDOUBLE */
125 .long .L56-.L60 /* FFI_TYPE_UINT8 */
126 .long .L55-.L60 /* FFI_TYPE_SINT8 */
127 .long .L58-.L60 /* FFI_TYPE_UINT16 */
128 .long .L57-.L60 /* FFI_TYPE_SINT16 */
129 .long .L50-.L60 /* FFI_TYPE_UINT32 */
130 .long .L50-.L60 /* FFI_TYPE_SINT32 */
131 .long .L48-.L60 /* FFI_TYPE_UINT64 */
132 .long .L48-.L60 /* FFI_TYPE_SINT64 */
133 .long .L44-.L60 /* FFI_TYPE_STRUCT */
134 .long .L50-.L60 /* FFI_TYPE_POINTER */
135
136
137/* case double */
138.L46:
139 lfd f1,0(r5)
140 b .L44
141
142/* case float */
143.L47:
144 lfs f1,0(r5)
145 b .L44
146
147/* case long long */
148.L48:
149 lwz r3,0(r5)
150 lwz r4,4(r5)
151 b .L44
152
153/* case default / int32 / pointer */
154.L50:
155 lwz r3,0(r5)
156 b .L44
157
158/* case signed int8 */
159.L55:
160 addi r5,r5,3
161 lbz r3,0(r5)
162 extsb r3,r3
163 b .L44
164
165/* case unsigned int8 */
166.L56:
167 addi r5,r5,3
168 lbz r3,0(r5)
169 b .L44
170
171/* case signed int16 */
172.L57:
173 addi r5,r5,2
174 lhz r3,0(r5)
175 extsh r3,r3
176 b .L44
177
178/* case unsigned int16 */
179.L58:
180 addi r5,r5,2
181 lhz r3,0(r5)
182
183/* case void / done */
184.L44:
185
186 addi r1,r1,176 /* restore stack pointer */
187 lwz r0,8(r1) /* get return address */
188 mtlr r0 /* reset link register */
189 blr
190
191/* END(ffi_closure_ASM) */
192
193.data
194.section __TEXT,__eh_frame
195Lframe1:
196 .set L$set$0,LECIE1-LSCIE1
197 .long L$set$0 ; Length of Common Information Entry
198LSCIE1:
199 .long 0x0 ; CIE Identifier Tag
200 .byte 0x1 ; CIE Version
201 .ascii "zR\0" ; CIE Augmentation
202 .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor
203 .byte 0x7c ; sleb128 -4; CIE Data Alignment Factor
204 .byte 0x41 ; CIE RA Column
205 .byte 0x1 ; uleb128 0x1; Augmentation size
206 .byte 0x10 ; FDE Encoding (pcrel)
207 .byte 0xc ; DW_CFA_def_cfa
208 .byte 0x1 ; uleb128 0x1
209 .byte 0x0 ; uleb128 0x0
210 .align 2
211LECIE1:
212LSFDE1:
213 .set L$set$1,LEFDE1-LASFDE1
214 .long L$set$1 ; FDE Length
215
216LASFDE1:
217 .set L$set$2,LASFDE1-Lframe1
218 .long L$set$2 ; FDE CIE offset
219 .long LFB1-. ; FDE initial location
220 .set L$set$3,LFE1-LFB1
221 .long L$set$3 ; FDE address range
222 .byte 0x0 ; uleb128 0x0; Augmentation size
223 .byte 0x4 ; DW_CFA_advance_loc4
224 .set L$set$3,LCFI1-LCFI0
225 .long L$set$3
226 .byte 0xe ; DW_CFA_def_cfa_offset
227 .byte 176,1 ; uleb128 176
228 .byte 0x4 ; DW_CFA_advance_loc4
229 .set L$set$4,LCFI0-LFB1
230 .long L$set$4
231 .byte 0x11 ; DW_CFA_offset_extended_sf
232 .byte 0x41 ; uleb128 0x41
233 .byte 0x7e ; sleb128 -2
234 .align 2
235LEFDE1:
236
Note: See TracBrowser for help on using the repository browser.