comparison dyncallback/dyncall_callback_sparc64.s @ 196:95cf20c0d1de

- sparc64 callbacks: * floating point support * fixes for many arg calls * this completes sparc64 callback support
author Tassilo Philipp
date Sun, 19 Mar 2017 19:34:34 +0100
parents 2f7a7f3472cb
children 91db39538e78
comparison
equal deleted inserted replaced
195:be9cb092625f 196:95cf20c0d1de
37 /* Called by thunk - thunk stores pointer to DCCallback */ 37 /* Called by thunk - thunk stores pointer to DCCallback */
38 /* in %g1, and pointer to called function in %g2 */ 38 /* in %g1, and pointer to called function in %g2 */
39 dcCallbackThunkEntry: 39 dcCallbackThunkEntry:
40 40
41 /* Prolog. */ 41 /* Prolog. */
42 /* Frame size of 208b comes from needing storage space for the following: */ 42 /* Frame size of 336b comes from needing storage space for the following: */
43 /* DCargs(sparc_req_reg_save_area:128 + spill:64 + argptr:8) + retval:8 */ 43 /* req_reg_save_area:128 + spill:48 + dcargs:144 + retval:8 + pad:8 */
44 /* Spill area could theoretically be only 32b, b/c cbHandler function has */ 44 /* Spill area could theoretically be only 32b, b/c cbHandler function has */
45 /* 4 arguments, and retval doesn't need stack, but let's be conservative. */ 45 /* 4 arguments, but let's be conservative. */
46 save %sp, -208, %sp 46 save %sp, -336, %sp
47 47
48 /* Spill register args. */ 48 /* Spill register args as dcargs is based on that (in prev frame, after */
49 add %fp, BIAS + 136, %l0 49 /* req_reg_save_area). */
50 stx %i0, [ %l0 + 0 ] /* reg arg 0 */ 50 add %fp, BIAS + 128, %l0
51 stx %i1, [ %l0 + 8 ] /* reg arg 1 */ 51 stx %i0, [ %l0 + 0 ] /* reg arg 0 */
52 stx %i2, [ %l0 + 16 ] /* reg arg 2 */ 52 stx %i1, [ %l0 + 8 ] /* reg arg 1 */
53 stx %i3, [ %l0 + 24 ] /* reg arg 3 */ 53 stx %i2, [ %l0 + 16 ] /* reg arg 2 */
54 stx %i4, [ %l0 + 32 ] /* reg arg 4 */ 54 stx %i3, [ %l0 + 24 ] /* reg arg 3 */
55 stx %i5, [ %l0 + 40 ] /* reg arg 5 */ 55 stx %i4, [ %l0 + 32 ] /* reg arg 4 */
56 stx %l0, [ %sp + BIAS + 192 ] /* init arg_ptr */ 56 stx %i5, [ %l0 + 40 ] /* reg arg 5 */
57 stx %l0, [ %sp + BIAS + 176 ] /* set DCArg's arg_ptr */
58 st %f0, [ %sp + BIAS + 184 ] /* store fp args in DCArgs's dreg_data */
59 st %f1, [ %sp + BIAS + 188 ] /* @@@ I think stx should work to store */
60 st %f2, [ %sp + BIAS + 192 ] /* all 64bits, but I get "Illegal */
61 st %f3, [ %sp + BIAS + 196 ] /* Operands", so using single prec. */
62 st %f4, [ %sp + BIAS + 200 ] /* store (st) */
63 st %f5, [ %sp + BIAS + 204 ]
64 st %f6, [ %sp + BIAS + 208 ]
65 st %f7, [ %sp + BIAS + 212 ]
66 st %f8, [ %sp + BIAS + 216 ]
67 st %f9, [ %sp + BIAS + 220 ]
68 st %f10, [ %sp + BIAS + 224 ]
69 st %f11, [ %sp + BIAS + 228 ]
70 st %f12, [ %sp + BIAS + 232 ]
71 st %f13, [ %sp + BIAS + 236 ]
72 st %f14, [ %sp + BIAS + 240 ]
73 st %f15, [ %sp + BIAS + 244 ]
74 st %f16, [ %sp + BIAS + 248 ]
75 st %f17, [ %sp + BIAS + 252 ]
76 st %f18, [ %sp + BIAS + 256 ]
77 st %f19, [ %sp + BIAS + 260 ]
78 st %f20, [ %sp + BIAS + 264 ]
79 st %f21, [ %sp + BIAS + 268 ]
80 st %f22, [ %sp + BIAS + 272 ]
81 st %f23, [ %sp + BIAS + 276 ]
82 st %f24, [ %sp + BIAS + 280 ]
83 st %f25, [ %sp + BIAS + 284 ]
84 st %f26, [ %sp + BIAS + 288 ]
85 st %f27, [ %sp + BIAS + 292 ]
86 st %f28, [ %sp + BIAS + 296 ]
87 st %f29, [ %sp + BIAS + 300 ]
88 st %f30, [ %sp + BIAS + 304 ]
89 st %f31, [ %sp + BIAS + 308 ]
90 stx %g0, [ %sp + BIAS + 312 ] /* init DCArg's i */
57 91
58 /* Zero retval store. */ 92 /* Zero retval store. */
59 stx %g0, [ %sp + BIAS + 200 ] 93 stx %g0, [ %sp + BIAS + 320 ]
60 94
61 /* Prepare callback handler call. */ 95 /* Prepare callback handler call. */
62 mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */ 96 mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */
63 add %sp, BIAS + 192, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr) */ 97 add %sp, BIAS + 176, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr) */
64 add %sp, BIAS + 200, %o2 /* Param 2 = results ptr to 8b of local stack data */ 98 add %sp, BIAS + 320, %o2 /* Param 2 = results ptr to 8b of local stack data */
65 ldx [ %g1 + 64 ], %o3 /* Param 3 = userdata ptr */ 99 ldx [ %g1 + 64 ], %o3 /* Param 3 = userdata ptr */
66 100
67 /* Fetch callback handler address (after thunk blob) and call. */ 101 /* Fetch callback handler address (after thunk blob) and call. */
68 ldx [ %g1 + 56 ], %l0 102 ldx [ %g1 + 56 ], %l0
69 call %l0 103 call %l0
70 nop 104 nop
71 105
72 /* Put retval in %i0 (to be in caller's %o0), and %f0. */ 106 /* Put retval in %i0 (to be in caller's %o0), and %f0. */
73 ldx [ %sp + BIAS + 200 ], %i0 107 ldx [ %sp + BIAS + 320 ], %i0
74 ldd [ %sp + BIAS + 200 ], %f0 108 ldd [ %sp + BIAS + 320 ], %f0
75 109
76 /* Epilog. */ 110 /* Epilog. */
77 restore /* unshift reg window */ 111 restore /* unshift reg window */
78 retl /* Return from proc. -- jmpl %i7 + 8, %g0 */ 112 retl /* Return from proc. -- jmpl %i7 + 8, %g0 */
79 nop 113 nop