annotate dyncallback/dyncall_callback_mips_n64.S @ 357:d982a00c2177

- PPC64 asm syntax fix, specifying explicitly comparison mode for cmpi (newer toolchains complain, older ones took optional field of instruction which happened to be same value)
author Tassilo Philipp
date Tue, 25 Feb 2020 18:16:13 +0100
parents b104c5beec8b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
1 /*
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
2
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
3 Package: dyncall
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
4 Library: dyncallback
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 138
diff changeset
5 File: dyncallback/dyncall_callback_mips_n64.S
101
1ce60358fbad - mips related cleanup, mostly comments, cpp macro lib
cslag
parents: 94
diff changeset
6 Description: Callback Thunk - Implementation for mips64 n64
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
7 License:
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
8
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
9 Copyright (c) 2016-2018 Tassilo Philipp <tphilipp@potion-studios.com>
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
10
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
11 Permission to use, copy, modify, and distribute this software for any
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
12 purpose with or without fee is hereby granted, provided that the above
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
13 copyright notice and this permission notice appear in all copies.
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
14
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
22
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
23 */
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
24
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
25 /* input:
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
26 $t8 -> thunk
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
27 $t8+56 -> cb handler
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
28 $t8+64 -> userdata
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
29 */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
30
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
31 /* Frame size is 160b for hard- and 128b for soft-float, as follows: */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
32 /* DCargs(fregs:64? + iregs:64 + regcnts:8 + sp:8) + rval:8 + ra:8 */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
33 #if defined(DC__ABI_HARDFLOAT)
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
34 SP_SP = 160
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
35 #else
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
36 SP_SP = 96
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
37 #endif
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
38 SP_LR = SP_SP-8
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
39 SP_RVAL = SP_SP-16
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
40 SP_ARG_SP = SP_SP-24
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
41 SP_ARG_RC = SP_SP-32
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
42
116
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
43 .section .mdebug.abi64
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
44 .previous
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
45 .abicalls
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
46 .text
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
47 .align 2
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
48 .globl dcCallbackThunkEntry
116
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
49 .ent dcCallbackThunkEntry
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
50 dcCallbackThunkEntry:
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
51 .set noreorder
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
52
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
53 /* Prolog. */
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
54 daddiu $sp, $sp, -SP_SP /* open frame */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
55 sd $ra, SP_LR($sp) /* save link register */
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
56
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
57 .frame $fp,SP_SP,$31 /* specify our frame: fp,size,lr; creates virt $fp */
138
1b0c02e827c4 mips n64 fixes for platforms using hiword of addresses
cslag
parents: 124
diff changeset
58 /* code below doesn't use $fp though, as n/a with -O1 */
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
59 /* Init return value */
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
60 sd $zero, SP_RVAL($sp)
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
61
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
62 /* Store reg args where our DCargs member arrays are, in local stack area */
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
63 sd $4, 0($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
64 sd $5, 8($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
65 sd $6, 16($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
66 sd $7, 24($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
67 sd $8, 32($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
68 sd $9, 40($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
69 sd $10, 48($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
70 sd $11, 56($sp)
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
71 #if defined(DC__ABI_HARDFLOAT)
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
72 s.d $f12, 64($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
73 s.d $f13, 72($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
74 s.d $f14, 80($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
75 s.d $f15, 88($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
76 s.d $f16, 96($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
77 s.d $f17, 104($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
78 s.d $f18, 112($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
79 s.d $f19, 120($sp)
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
80 #endif
116
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
81
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
82 /* Init DCarg's reg_counts and stackptr. */
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
83 sd $zero, SP_ARG_RC($sp) /* reg_count */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
84 daddiu $4, $sp, SP_SP
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
85 sd $4, SP_ARG_SP($sp) /* stackptr */
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
86
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
87 /* Prepare callback handler call. */
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
88 move $4, $24 /* Param 0 = DCCallback*, $24/$t8 holds DCThunk* */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
89 move $5, $sp /* Param 1 = ptr to where DCArgs* is stored */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
90 daddiu $6, $sp, SP_RVAL /* Param 2 = results ptr to 8b of local stack data */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
91 ld $7, 64($24) /* Param 3 = userdata pointer */
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
92
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
93 ld $25, 56($24) /* store handler entry in $25/$t9, required for PIC */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
94 jalr $25 /* jump */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
95 nop /* branch delay nop */
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
96
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
97 /* Copy result in corresponding registers $2-$3 ($v0-$v1) and $f0 */
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
98 ld $2, SP_RVAL($sp) /* note: ignoring 2nd possible retval in $3, here */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
99 #if defined(DC__ABI_HARDFLOAT)
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
100 l.d $f0, SP_RVAL($sp)
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
101 #endif
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
102
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
103 /* Epilog. Tear down frame and return. */
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
104 ld $ra, SP_LR($sp) /* restore return address */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
105 daddiu $sp, $sp, SP_SP /* close frame */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
106 j $ra /* return */
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 302
diff changeset
107 nop /* branch delay nop */
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
108
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
109 .set reorder
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
110 .end dcCallbackThunkEntry
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
111 .ident "handwritten"
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
112