annotate libffi/src/pa/linux.S @ 155:da32f4b04d38

fix __code name conflict
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 17:51:46 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* -----------------------------------------------------------------------
kono
parents:
diff changeset
2 linux.S - (c) 2003-2004 Randolph Chung <tausq@debian.org>
kono
parents:
diff changeset
3 (c) 2008 Red Hat, Inc.
kono
parents:
diff changeset
4 (c) 2016 John David Anglin
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 HPPA Foreign Function Interface
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 Permission is hereby granted, free of charge, to any person obtaining
kono
parents:
diff changeset
9 a copy of this software and associated documentation files (the
kono
parents:
diff changeset
10 ``Software''), to deal in the Software without restriction, including
kono
parents:
diff changeset
11 without limitation the rights to use, copy, modify, merge, publish,
kono
parents:
diff changeset
12 distribute, sublicense, and/or sell copies of the Software, and to
kono
parents:
diff changeset
13 permit persons to whom the Software is furnished to do so, subject to
kono
parents:
diff changeset
14 the following conditions:
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 The above copyright notice and this permission notice shall be included
kono
parents:
diff changeset
17 in all copies or substantial portions of the Software.
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
kono
parents:
diff changeset
20 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
kono
parents:
diff changeset
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
kono
parents:
diff changeset
22 IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
kono
parents:
diff changeset
23 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
kono
parents:
diff changeset
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
kono
parents:
diff changeset
25 OTHER DEALINGS IN THE SOFTWARE.
kono
parents:
diff changeset
26 ----------------------------------------------------------------------- */
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 #define LIBFFI_ASM
kono
parents:
diff changeset
29 #include <fficonfig.h>
kono
parents:
diff changeset
30 #include <ffi.h>
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 .text
kono
parents:
diff changeset
33 .level 1.1
kono
parents:
diff changeset
34 .align 4
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 /* void ffi_call_pa32(void (*)(char *, extended_cif *),
kono
parents:
diff changeset
37 extended_cif *ecif,
kono
parents:
diff changeset
38 unsigned bytes,
kono
parents:
diff changeset
39 unsigned flags,
kono
parents:
diff changeset
40 unsigned *rvalue,
kono
parents:
diff changeset
41 void (*fn)(void),
kono
parents:
diff changeset
42 ffi_go_closure *closure);
kono
parents:
diff changeset
43 */
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 .export ffi_call_pa32,code
kono
parents:
diff changeset
46 .import ffi_prep_args_pa32,code
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 .type ffi_call_pa32, @function
kono
parents:
diff changeset
49 .cfi_startproc
kono
parents:
diff changeset
50 ffi_call_pa32:
kono
parents:
diff changeset
51 .proc
kono
parents:
diff changeset
52 .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4
kono
parents:
diff changeset
53 .entry
kono
parents:
diff changeset
54 stw %rp, -20(%sp)
kono
parents:
diff changeset
55 copy %r3, %r1
kono
parents:
diff changeset
56 .cfi_offset 2, -20
kono
parents:
diff changeset
57 .cfi_register 3, 1
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 copy %sp, %r3
kono
parents:
diff changeset
60 .cfi_def_cfa_register 3
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 /* Setup the stack for calling prep_args...
kono
parents:
diff changeset
63 We want the stack to look like this:
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 [ Previous stack ] <- %r3
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 [ 64-bytes register save area ] <- %r4
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 [ Stack space for actual call, passed as ] <- %arg0
kono
parents:
diff changeset
70 [ arg0 to ffi_prep_args_pa32 ]
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 [ Stack for calling prep_args ] <- %sp
kono
parents:
diff changeset
73 */
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 stwm %r1, 64(%sp)
kono
parents:
diff changeset
76 .cfi_offset 3, 0
kono
parents:
diff changeset
77 stw %r4, 12(%r3)
kono
parents:
diff changeset
78 copy %sp, %r4
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 addl %arg2, %r4, %arg0 /* arg stack */
kono
parents:
diff changeset
81 stw %arg3, -48(%r3) /* save flags; we need it later */
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 /* Call prep_args:
kono
parents:
diff changeset
84 %arg0(stack) -- set up above
kono
parents:
diff changeset
85 %arg1(ecif) -- same as incoming param
kono
parents:
diff changeset
86 %arg2(bytes) -- same as incoming param */
kono
parents:
diff changeset
87 bl ffi_prep_args_pa32,%r2
kono
parents:
diff changeset
88 ldo 64(%arg0), %sp
kono
parents:
diff changeset
89 ldo -64(%sp), %sp
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 /* now %sp should point where %arg0 was pointing. */
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /* Load the arguments that should be passed in registers
kono
parents:
diff changeset
94 The fp args were loaded by the prep_args function. */
kono
parents:
diff changeset
95 ldw -36(%sp), %arg0
kono
parents:
diff changeset
96 ldw -40(%sp), %arg1
kono
parents:
diff changeset
97 ldw -44(%sp), %arg2
kono
parents:
diff changeset
98 ldw -48(%sp), %arg3
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 /* in case the function is going to return a structure
kono
parents:
diff changeset
101 we need to give it a place to put the result. */
kono
parents:
diff changeset
102 ldw -52(%r3), %ret0 /* %ret0 <- rvalue */
kono
parents:
diff changeset
103 ldw -56(%r3), %r22 /* %r22 <- function to call */
kono
parents:
diff changeset
104 ldw -60(%r3), %ret1 /* %ret1 <- closure */
kono
parents:
diff changeset
105 bl $$dyncall, %r31 /* Call the user function */
kono
parents:
diff changeset
106 copy %r31, %rp
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 /* Prepare to store the result; we need to recover flags and rvalue. */
kono
parents:
diff changeset
109 ldw -48(%r3), %r21 /* r21 <- flags */
kono
parents:
diff changeset
110 ldw -52(%r3), %r20 /* r20 <- rvalue */
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 /* Store the result according to the return type. */
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 .Lcheckint:
kono
parents:
diff changeset
115 comib,<>,n FFI_TYPE_INT, %r21, .Lcheckint8
kono
parents:
diff changeset
116 b .Ldone
kono
parents:
diff changeset
117 stw %ret0, 0(%r20)
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 .Lcheckint8:
kono
parents:
diff changeset
120 comib,<>,n FFI_TYPE_UINT8, %r21, .Lcheckint16
kono
parents:
diff changeset
121 b .Ldone
kono
parents:
diff changeset
122 stb %ret0, 0(%r20)
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 .Lcheckint16:
kono
parents:
diff changeset
125 comib,<>,n FFI_TYPE_UINT16, %r21, .Lcheckdbl
kono
parents:
diff changeset
126 b .Ldone
kono
parents:
diff changeset
127 sth %ret0, 0(%r20)
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 .Lcheckdbl:
kono
parents:
diff changeset
130 comib,<>,n FFI_TYPE_DOUBLE, %r21, .Lcheckfloat
kono
parents:
diff changeset
131 b .Ldone
kono
parents:
diff changeset
132 fstd %fr4,0(%r20)
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 .Lcheckfloat:
kono
parents:
diff changeset
135 comib,<>,n FFI_TYPE_FLOAT, %r21, .Lcheckll
kono
parents:
diff changeset
136 b .Ldone
kono
parents:
diff changeset
137 fstw %fr4L,0(%r20)
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 .Lcheckll:
kono
parents:
diff changeset
140 comib,<>,n FFI_TYPE_UINT64, %r21, .Lchecksmst2
kono
parents:
diff changeset
141 stw %ret0, 0(%r20)
kono
parents:
diff changeset
142 b .Ldone
kono
parents:
diff changeset
143 stw %ret1, 4(%r20)
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 .Lchecksmst2:
kono
parents:
diff changeset
146 comib,<>,n FFI_TYPE_SMALL_STRUCT2, %r21, .Lchecksmst3
kono
parents:
diff changeset
147 /* 2-byte structs are returned in ret0 as ????xxyy. */
kono
parents:
diff changeset
148 extru %ret0, 23, 8, %r22
kono
parents:
diff changeset
149 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
150 b .Ldone
kono
parents:
diff changeset
151 stb %ret0, 0(%r20)
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 .Lchecksmst3:
kono
parents:
diff changeset
154 comib,<>,n FFI_TYPE_SMALL_STRUCT3, %r21, .Lchecksmst4
kono
parents:
diff changeset
155 /* 3-byte structs are returned in ret0 as ??xxyyzz. */
kono
parents:
diff changeset
156 extru %ret0, 15, 8, %r22
kono
parents:
diff changeset
157 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
158 extru %ret0, 23, 8, %r22
kono
parents:
diff changeset
159 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
160 b .Ldone
kono
parents:
diff changeset
161 stb %ret0, 0(%r20)
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 .Lchecksmst4:
kono
parents:
diff changeset
164 comib,<>,n FFI_TYPE_SMALL_STRUCT4, %r21, .Lchecksmst5
kono
parents:
diff changeset
165 /* 4-byte structs are returned in ret0 as wwxxyyzz. */
kono
parents:
diff changeset
166 extru %ret0, 7, 8, %r22
kono
parents:
diff changeset
167 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
168 extru %ret0, 15, 8, %r22
kono
parents:
diff changeset
169 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
170 extru %ret0, 23, 8, %r22
kono
parents:
diff changeset
171 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
172 b .Ldone
kono
parents:
diff changeset
173 stb %ret0, 0(%r20)
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 .Lchecksmst5:
kono
parents:
diff changeset
176 comib,<>,n FFI_TYPE_SMALL_STRUCT5, %r21, .Lchecksmst6
kono
parents:
diff changeset
177 /* 5 byte values are returned right justified:
kono
parents:
diff changeset
178 ret0 ret1
kono
parents:
diff changeset
179 5: ??????aa bbccddee */
kono
parents:
diff changeset
180 stbs,ma %ret0, 1(%r20)
kono
parents:
diff changeset
181 extru %ret1, 7, 8, %r22
kono
parents:
diff changeset
182 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
183 extru %ret1, 15, 8, %r22
kono
parents:
diff changeset
184 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
185 extru %ret1, 23, 8, %r22
kono
parents:
diff changeset
186 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
187 b .Ldone
kono
parents:
diff changeset
188 stb %ret1, 0(%r20)
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 .Lchecksmst6:
kono
parents:
diff changeset
191 comib,<>,n FFI_TYPE_SMALL_STRUCT6, %r21, .Lchecksmst7
kono
parents:
diff changeset
192 /* 6 byte values are returned right justified:
kono
parents:
diff changeset
193 ret0 ret1
kono
parents:
diff changeset
194 6: ????aabb ccddeeff */
kono
parents:
diff changeset
195 extru %ret0, 23, 8, %r22
kono
parents:
diff changeset
196 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
197 stbs,ma %ret0, 1(%r20)
kono
parents:
diff changeset
198 extru %ret1, 7, 8, %r22
kono
parents:
diff changeset
199 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
200 extru %ret1, 15, 8, %r22
kono
parents:
diff changeset
201 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
202 extru %ret1, 23, 8, %r22
kono
parents:
diff changeset
203 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
204 b .Ldone
kono
parents:
diff changeset
205 stb %ret1, 0(%r20)
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 .Lchecksmst7:
kono
parents:
diff changeset
208 comib,<>,n FFI_TYPE_SMALL_STRUCT7, %r21, .Lchecksmst8
kono
parents:
diff changeset
209 /* 7 byte values are returned right justified:
kono
parents:
diff changeset
210 ret0 ret1
kono
parents:
diff changeset
211 7: ??aabbcc ddeeffgg */
kono
parents:
diff changeset
212 extru %ret0, 15, 8, %r22
kono
parents:
diff changeset
213 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
214 extru %ret0, 23, 8, %r22
kono
parents:
diff changeset
215 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
216 stbs,ma %ret0, 1(%r20)
kono
parents:
diff changeset
217 extru %ret1, 7, 8, %r22
kono
parents:
diff changeset
218 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
219 extru %ret1, 15, 8, %r22
kono
parents:
diff changeset
220 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
221 extru %ret1, 23, 8, %r22
kono
parents:
diff changeset
222 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
223 b .Ldone
kono
parents:
diff changeset
224 stb %ret1, 0(%r20)
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 .Lchecksmst8:
kono
parents:
diff changeset
227 comib,<>,n FFI_TYPE_SMALL_STRUCT8, %r21, .Ldone
kono
parents:
diff changeset
228 /* 8 byte values are returned right justified:
kono
parents:
diff changeset
229 ret0 ret1
kono
parents:
diff changeset
230 8: aabbccdd eeffgghh */
kono
parents:
diff changeset
231 extru %ret0, 7, 8, %r22
kono
parents:
diff changeset
232 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
233 extru %ret0, 15, 8, %r22
kono
parents:
diff changeset
234 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
235 extru %ret0, 23, 8, %r22
kono
parents:
diff changeset
236 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
237 stbs,ma %ret0, 1(%r20)
kono
parents:
diff changeset
238 extru %ret1, 7, 8, %r22
kono
parents:
diff changeset
239 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
240 extru %ret1, 15, 8, %r22
kono
parents:
diff changeset
241 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
242 extru %ret1, 23, 8, %r22
kono
parents:
diff changeset
243 stbs,ma %r22, 1(%r20)
kono
parents:
diff changeset
244 stb %ret1, 0(%r20)
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 .Ldone:
kono
parents:
diff changeset
247 /* all done, return */
kono
parents:
diff changeset
248 copy %r4, %sp /* pop arg stack */
kono
parents:
diff changeset
249 ldw 12(%r3), %r4
kono
parents:
diff changeset
250 ldwm -64(%sp), %r3 /* .. and pop stack */
kono
parents:
diff changeset
251 ldw -20(%sp), %rp
kono
parents:
diff changeset
252 bv %r0(%rp)
kono
parents:
diff changeset
253 nop
kono
parents:
diff changeset
254 .exit
kono
parents:
diff changeset
255 .procend
kono
parents:
diff changeset
256 .cfi_endproc
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 /* void ffi_closure_pa32(void);
kono
parents:
diff changeset
259 Called with ffi_closure argument in %r21. */
kono
parents:
diff changeset
260 .export ffi_closure_pa32,code
kono
parents:
diff changeset
261 .import ffi_closure_inner_pa32,code
kono
parents:
diff changeset
262 .type ffi_closure_pa32, @function
kono
parents:
diff changeset
263 .cfi_startproc
kono
parents:
diff changeset
264 ffi_closure_pa32:
kono
parents:
diff changeset
265 .proc
kono
parents:
diff changeset
266 .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3
kono
parents:
diff changeset
267 .entry
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 stw %rp, -20(%sp)
kono
parents:
diff changeset
270 copy %r3, %r1
kono
parents:
diff changeset
271 .cfi_offset 2, -20
kono
parents:
diff changeset
272 .cfi_register 3, 1
kono
parents:
diff changeset
273 copy %sp, %r3
kono
parents:
diff changeset
274 .cfi_def_cfa_register 3
kono
parents:
diff changeset
275 stwm %r1, 64(%sp)
kono
parents:
diff changeset
276 .cfi_offset 3, 0
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 /* Put arguments onto the stack and call ffi_closure_inner. */
kono
parents:
diff changeset
279 stw %arg0, -36(%r3)
kono
parents:
diff changeset
280 stw %arg1, -40(%r3)
kono
parents:
diff changeset
281 stw %arg2, -44(%r3)
kono
parents:
diff changeset
282 stw %arg3, -48(%r3)
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 /* Closure type 0. */
kono
parents:
diff changeset
285 copy %r21, %arg0
kono
parents:
diff changeset
286 copy %r0, %arg2
kono
parents:
diff changeset
287 bl ffi_closure_inner_pa32, %r2
kono
parents:
diff changeset
288 copy %r3, %arg1
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 ldwm -64(%sp), %r3
kono
parents:
diff changeset
291 ldw -20(%sp), %rp
kono
parents:
diff changeset
292 ldw -36(%sp), %ret0
kono
parents:
diff changeset
293 bv %r0(%r2)
kono
parents:
diff changeset
294 ldw -40(%sp), %ret1
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 .exit
kono
parents:
diff changeset
297 .procend
kono
parents:
diff changeset
298 .cfi_endproc
kono
parents:
diff changeset
299
kono
parents:
diff changeset
300 /* void ffi_go_closure_pa32(void);
kono
parents:
diff changeset
301 Called with ffi_go_closure argument in %ret1. */
kono
parents:
diff changeset
302 .export ffi_go_closure_pa32,code
kono
parents:
diff changeset
303 .import ffi_closure_inner_pa32,code
kono
parents:
diff changeset
304 .type ffi_go_closure_pa32, @function
kono
parents:
diff changeset
305 .cfi_startproc
kono
parents:
diff changeset
306 ffi_go_closure_pa32:
kono
parents:
diff changeset
307 .proc
kono
parents:
diff changeset
308 .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3
kono
parents:
diff changeset
309 .entry
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 stw %rp, -20(%sp)
kono
parents:
diff changeset
312 copy %r3, %r1
kono
parents:
diff changeset
313 .cfi_offset 2, -20
kono
parents:
diff changeset
314 .cfi_register 3, 1
kono
parents:
diff changeset
315 copy %sp, %r3
kono
parents:
diff changeset
316 .cfi_def_cfa_register 3
kono
parents:
diff changeset
317 stwm %r1, 64(%sp)
kono
parents:
diff changeset
318 .cfi_offset 3, 0
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 /* Put arguments onto the stack and call ffi_closure_inner. */
kono
parents:
diff changeset
321 stw %arg0, -36(%r3)
kono
parents:
diff changeset
322 stw %arg1, -40(%r3)
kono
parents:
diff changeset
323 stw %arg2, -44(%r3)
kono
parents:
diff changeset
324 stw %arg3, -48(%r3)
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 /* Closure type 1. */
kono
parents:
diff changeset
327 copy %ret1, %arg0
kono
parents:
diff changeset
328 ldi 1, %arg2
kono
parents:
diff changeset
329 bl ffi_closure_inner_pa32, %r2
kono
parents:
diff changeset
330 copy %r3, %arg1
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332 ldwm -64(%sp), %r3
kono
parents:
diff changeset
333 ldw -20(%sp), %rp
kono
parents:
diff changeset
334 ldw -36(%sp), %ret0
kono
parents:
diff changeset
335 bv %r0(%r2)
kono
parents:
diff changeset
336 ldw -40(%sp), %ret1
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 .exit
kono
parents:
diff changeset
339 .procend
kono
parents:
diff changeset
340 .cfi_endproc