annotate dyncallback/dyncall_callback_sparc32.s @ 457:90b1d927912a

- suite_aggrs: make sure random memory used doesn't ever result in NaN fp values (for every possible address), as this messes with result comparison
author Tassilo Philipp
date Fri, 28 Jan 2022 14:11:21 +0100
parents 706fb60a1760
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 Package: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 Library: dyncallback
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 File: dyncallback/dyncall_callback_sparc32.s
187
de5ed248757f - comment cleanup/corrections
Tassilo Philipp
parents: 157
diff changeset
6 Description: Callback - Implementation for Sparc 32-bit
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 License:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
155
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
26 /* input:
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
27 $i0 -> thunk
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
28 $i0+24 -> cb handler
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
29 $i0+28 -> userdata
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
30 */
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
06ee88ce4962 - doc and comment fixes
Tassilo Philipp
parents: 187
diff changeset
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
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
69 nop
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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