Debian Codegraph @

tests/inputs/Assembly-sysv.S

raw
1 /*
2 Python-3.5.2/Modules/_ctypes/libffi/src/m68k/sysv.S
3 */
4 /* -----------------------------------------------------------------------
5
6
7 sysv.S - Copyright (c) 2012 Alan Hourihane
8 Copyright (c) 1998, 2012 Andreas Schwab
9 Copyright (c) 2008 Red Hat, Inc.
10 Copyright (c) 2012 Thorsten Glaser
11
12 m68k Foreign Function Interface
13
14 Permission is hereby granted, free of charge, to any person obtaining
15 a copy of this software and associated documentation files (the
16 ``Software''), to deal in the Software without restriction, including
17 without limitation the rights to use, copy, modify, merge, publish,
18 distribute, sublicense, and/or sell copies of the Software, and to
19 permit persons to whom the Software is furnished to do so, subject to
20 the following conditions:
21
22 The above copyright notice and this permission notice shall be included
23 in all copies or substantial portions of the Software.
24
25 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
26 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
29 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
30 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 DEALINGS IN THE SOFTWARE.
33 ----------------------------------------------------------------------- */
34
35 #define LIBFFI_ASM
36 #include <fficonfig.h>
37 #include <ffi.h>
38
39 #ifdef HAVE_AS_CFI_PSEUDO_OP
40 #define CFI_STARTPROC() .cfi_startproc
41 #define CFI_OFFSET(reg,off) .cfi_offset reg,off
42 #define CFI_DEF_CFA(reg,off) .cfi_def_cfa reg,off
43 #define CFI_ENDPROC() .cfi_endproc
44 #else
45 #define CFI_STARTPROC()
46 #define CFI_OFFSET(reg,off)
47 #define CFI_DEF_CFA(reg,off)
48 #define CFI_ENDPROC()
49 #endif
50
51 #ifdef __MINT__
52 #define CALLFUNC(funcname) _ ## funcname
53 #else
54 #define CALLFUNC(funcname) funcname
55 #endif
56
57 .text
58
59 .globl CALLFUNC(ffi_call_SYSV)
60 .type CALLFUNC(ffi_call_SYSV),@function
61 .align 4
62
63 CALLFUNC(ffi_call_SYSV):
64 CFI_STARTPROC()
65 link %fp,#0
66 CFI_OFFSET(14,-8)
67 CFI_DEF_CFA(14,8)
68 move.l %d2,-(%sp)
69 CFI_OFFSET(2,-12)
70
71 | Make room for all of the new args.
72 sub.l 12(%fp),%sp
73
74 | Call ffi_prep_args
75 move.l 8(%fp),-(%sp)
76 pea 4(%sp)
77 #if !defined __PIC__
78 jsr CALLFUNC(ffi_prep_args)
79 #else
80 bsr.l CALLFUNC(ffi_prep_args@PLTPC)
81 #endif
82 addq.l #8,%sp
83
84 | Pass pointer to struct value, if any
85 #ifdef __MINT__
86 move.l %d0,%a1
87 #else
88 move.l %a0,%a1
89 #endif
90
91 | Call the function
92 move.l 24(%fp),%a0
93 jsr (%a0)
94
95 | Remove the space we pushed for the args
96 add.l 12(%fp),%sp
97
98 | Load the pointer to storage for the return value
99 move.l 20(%fp),%a1
100
101 | Load the return type code
102 move.l 16(%fp),%d2
103
104 | If the return value pointer is NULL, assume no return value.
105 | NOTE: On the mc68000, tst on an address register is not supported.
106 #if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
107 cmp.w #0, %a1
108 #else
109 tst.l %a1
110 #endif
111 jbeq noretval
112
113 btst #0,%d2
114 jbeq retlongint
115 move.l %d0,(%a1)
116 jbra epilogue
117
118 retlongint:
119 btst #1,%d2
120 jbeq retfloat
121 move.l %d0,(%a1)
122 move.l %d1,4(%a1)
123 jbra epilogue
124
125 retfloat:
126 btst #2,%d2
127 jbeq retdouble
128 #if defined(__MC68881__) || defined(__HAVE_68881__)
129 fmove.s %fp0,(%a1)
130 #else
131 move.l %d0,(%a1)
132 #endif
133 jbra epilogue
134
135 retdouble:
136 btst #3,%d2
137 jbeq retlongdouble
138 #if defined(__MC68881__) || defined(__HAVE_68881__)
139 fmove.d %fp0,(%a1)
140 #else
141 move.l %d0,(%a1)+
142 move.l %d1,(%a1)
143 #endif
144 jbra epilogue
145
146 retlongdouble:
147 btst #4,%d2
148 jbeq retpointer
149 #if defined(__MC68881__) || defined(__HAVE_68881__)
150 fmove.x %fp0,(%a1)
151 #else
152 move.l %d0,(%a1)+
153 move.l %d1,(%a1)+
154 move.l %d2,(%a1)
155 #endif
156 jbra epilogue
157
158 retpointer:
159 btst #5,%d2
160 jbeq retstruct1
161 #ifdef __MINT__
162 move.l %d0,(%a1)
163 #else
164 move.l %a0,(%a1)
165 #endif
166 jbra epilogue
167
168 retstruct1:
169 btst #6,%d2
170 jbeq retstruct2
171 move.b %d0,(%a1)
172 jbra epilogue
173
174 retstruct2:
175 btst #7,%d2
176 jbeq retsint8
177 move.w %d0,(%a1)
178 jbra epilogue
179
180 retsint8:
181 btst #8,%d2
182 jbeq retsint16
183 | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
184 #if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
185 ext.w %d0
186 ext.l %d0
187 #else
188 extb.l %d0
189 #endif
190 move.l %d0,(%a1)
191 jbra epilogue
192
193 retsint16:
194 btst #9,%d2
195 jbeq noretval
196 ext.l %d0
197 move.l %d0,(%a1)
198
199 noretval:
200 epilogue:
201 move.l (%sp)+,%d2
202 unlk %fp
203 rts
204 CFI_ENDPROC()
205 .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV)
206
207 .globl CALLFUNC(ffi_closure_SYSV)
208 .type CALLFUNC(ffi_closure_SYSV), @function
209 .align 4
210
211 CALLFUNC(ffi_closure_SYSV):
212 CFI_STARTPROC()
213 link %fp,#-12
214 CFI_OFFSET(14,-8)
215 CFI_DEF_CFA(14,8)
216 move.l %sp,-12(%fp)
217 pea 8(%fp)
218 pea -12(%fp)
219 move.l %a0,-(%sp)
220 #if !defined __PIC__
221 jsr CALLFUNC(ffi_closure_SYSV_inner)
222 #else
223 bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
224 #endif
225
226 lsr.l #1,%d0
227 jne 1f
228 jcc .Lcls_epilogue
229 | CIF_FLAGS_INT
230 move.l -12(%fp),%d0
231 .Lcls_epilogue:
232 | no CIF_FLAGS_*
233 unlk %fp
234 rts
235 1:
236 lea -12(%fp),%a0
237 lsr.l #2,%d0
238 jne 1f
239 jcs .Lcls_ret_float
240 | CIF_FLAGS_DINT
241 move.l (%a0)+,%d0
242 move.l (%a0),%d1
243 jra .Lcls_epilogue
244 .Lcls_ret_float:
245 #if defined(__MC68881__) || defined(__HAVE_68881__)
246 fmove.s (%a0),%fp0
247 #else
248 move.l (%a0),%d0
249 #endif
250 jra .Lcls_epilogue
251 1:
252 lsr.l #2,%d0
253 jne 1f
254 jcs .Lcls_ret_ldouble
255 | CIF_FLAGS_DOUBLE
256 #if defined(__MC68881__) || defined(__HAVE_68881__)
257 fmove.d (%a0),%fp0
258 #else
259 move.l (%a0)+,%d0
260 move.l (%a0),%d1
261 #endif
262 jra .Lcls_epilogue
263 .Lcls_ret_ldouble:
264 #if defined(__MC68881__) || defined(__HAVE_68881__)
265 fmove.x (%a0),%fp0
266 #else
267 move.l (%a0)+,%d0
268 move.l (%a0)+,%d1
269 move.l (%a0),%d2
270 #endif
271 jra .Lcls_epilogue
272 1:
273 lsr.l #2,%d0
274 jne 1f
275 jcs .Lcls_ret_struct1
276 | CIF_FLAGS_POINTER
277 move.l (%a0),%a0
278 move.l %a0,%d0
279 jra .Lcls_epilogue
280 .Lcls_ret_struct1:
281 move.b (%a0),%d0
282 jra .Lcls_epilogue
283 1:
284 lsr.l #2,%d0
285 jne 1f
286 jcs .Lcls_ret_sint8
287 | CIF_FLAGS_STRUCT2
288 move.w (%a0),%d0
289 jra .Lcls_epilogue
290 .Lcls_ret_sint8:
291 move.l (%a0),%d0
292 | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
293 #if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
294 ext.w %d0
295 ext.l %d0
296 #else
297 extb.l %d0
298 #endif
299 jra .Lcls_epilogue
300 1:
301 | CIF_FLAGS_SINT16
302 move.l (%a0),%d0
303 ext.l %d0
304 jra .Lcls_epilogue
305 CFI_ENDPROC()
306
307 .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
308
309 .globl CALLFUNC(ffi_closure_struct_SYSV)
310 .type CALLFUNC(ffi_closure_struct_SYSV), @function
311 .align 4
312
313 CALLFUNC(ffi_closure_struct_SYSV):
314 CFI_STARTPROC()
315 link %fp,#0
316 CFI_OFFSET(14,-8)
317 CFI_DEF_CFA(14,8)
318 move.l %sp,-12(%fp)
319 pea 8(%fp)
320 move.l %a1,-(%sp)
321 move.l %a0,-(%sp)
322 #if !defined __PIC__
323 jsr CALLFUNC(ffi_closure_SYSV_inner)
324 #else
325 bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
326 #endif
327 unlk %fp
328 rts
329 CFI_ENDPROC()
330 .size CALLFUNC(ffi_closure_struct_SYSV),.-CALLFUNC(ffi_closure_struct_SYSV)
331
332 #if defined __ELF__ && defined __linux__
333 .section .note.GNU-stack,"",@progbits
334 #endif