Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_callback_sparc32.s @ 334:1cf6a4a94aca
- better output for plain test's struct size testing (maybe in prep for full struct support)
author | Tassilo Philipp |
---|---|
date | Wed, 27 Nov 2019 20:43:51 +0100 |
parents | 706fb60a1760 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_callback_sparc32.s | |
187 | 6 Description: Callback - Implementation for Sparc 32-bit |
0 | 7 License: |
8 | |
198
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
9 Copyright (c) 2007-2017 Daniel Adler <dadler@uni-goettingen.de>, |
0 | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
155 | 26 /* input: |
27 $i0 -> thunk | |
28 $i0+24 -> cb handler | |
29 $i0+28 -> userdata | |
30 */ | |
31 | |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
32 .text |
15
03c516772c65
- consistency in filenames that have cpp logic .s -> .S
cslag
parents:
0
diff
changeset
|
33 .globl dcCallbackThunkEntry |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
34 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
35 /* Called by thunk - thunk stores pointer to DCCallback */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
36 /* in %g1, and pointer to called function in %g2 */ |
0 | 37 dcCallbackThunkEntry: |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
38 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
39 /* Prolog. */ |
198
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
40 /* Frame size of 104b comes from needing storage space for the following: */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
41 /* req_reg_save_area:64 + spill:24 + dcargs:4 + retval:8 + pad:4 */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
42 /* Spill area could theoretically be only 16b, b/c cbHandler function has */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
43 /* 4 arguments, but let's be conservative. */ /* cbHandler function might decide to spill (6x4b) @@@ testcode, or rely on 8byte return space in parent stack */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
44 save %sp, -104, %sp |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
45 |
198
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
46 /* Spill register args as dcargs is based on that (in prev frame, after */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
47 /* req_reg_save_area and struct_ret_ptr). */ |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
48 add %fp, 68, %l0 |
198
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
49 st %i0, [ %l0 + 0 ] /* reg arg 0 */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
50 st %i1, [ %l0 + 4 ] /* reg arg 1 */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
51 st %i2, [ %l0 + 8 ] /* reg arg 2 */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
52 st %i3, [ %l0 + 12 ] /* reg arg 3 */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
53 st %i4, [ %l0 + 16 ] /* reg arg 4 */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
54 st %i5, [ %l0 + 20 ] /* reg arg 5 */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
55 st %l0, [ %sp + 88 ] /* init arg_ptr */ |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
56 |
190 | 57 /* Zero retval store. */ |
198
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
58 st %g0, [ %sp + 96 ] |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
59 st %g0, [ %sp + 100 ] |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
60 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
61 /* Prepare callback handler call. */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
62 mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */ |
198
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
63 add %sp, 88, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr) */ |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
64 add %sp, 96, %o2 /* Param 2 = results ptr to 8b of local stack data */ |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
65 ld [ %g1 + 28 ], %o3 /* Param 3 = userdata ptr */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
66 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
67 ld [ %g1 + 24 ], %l0 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
68 call %l0 |
155 | 69 nop |
0 | 70 |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
71 /* Put retval in %i0/%i1 (to be in caller's %o0/%o1), and %f0/%f1. */ |
198
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
72 ld [ %sp + 96 ], %i0 |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
73 ld [ %sp + 100 ], %i1 |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
74 ld [ %sp + 96 ], %f0 |
706fb60a1760
- safety fix for sparc32, protecting from callback handler problems when handler itself needs to spill
Tassilo Philipp
parents:
190
diff
changeset
|
75 ld [ %sp + 100 ], %f1 |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
76 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
77 /* Epilog. */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
78 restore /* unshift reg window */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
79 retl /* Return from proc. -- jmpl %i7 + 8, %g0 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
80 nop |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
81 |