annotate dyncallback/dyncall_callback_arm64.S @ 663:127b569978cc default tip

- another tweak handling clang trying to be too smart (see last commit)
author Tassilo Philipp
date Sun, 24 Mar 2024 13:52:44 +0100
parents 0079a8fa894e
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
15
03c516772c65 - consistency in filenames that have cpp logic .s -> .S
cslag
parents: 0
diff changeset
5 File: dyncallback/dyncall_callback_arm64.S
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: Callback Thunk - Implementation for ARM64 / ARMv8 / AAPCS64
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
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
9 Copyright (c) 2015-2024 Daniel Adler <dadler@uni-goettingen.de>,
281
f5577f6bf97a - file header cleanups for release
Tassilo Philipp
parents: 15
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
0
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 */
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
25
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
26 #include "../portasm/portasm-arm64.S"
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
27 BEGIN_ASM
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
28
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
29 /* struct DCCallback
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
30 type off size
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
31 ---------|------|------
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
32 DCThunk | 0 | 32
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
33 handler | 32 | 8
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
34 userdata | 40 | 8
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
35 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
37 TEXTAREA
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39 GLOBAL_C(dcCallbackThunkEntry)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40 ENTRY_C(dcCallbackThunkEntry)
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
41 ALIGN(4)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
43 /* input:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
44 x9: DCCallback* pcb
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
45 x0..x7 ?? GP regs
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
46 d0..d7 ?? FP/SIMD regs
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
47 sp... ?? arguments on stack
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
48
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
49 locals:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
50 type off size
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
51 ---------|------|------
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
52 Frame 0 16
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
53 DCArgs 16 144
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
54 DCValue 160 16
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
55
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
56 size 176
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
57 aligned 176
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
58
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
60 locals:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
61 x10: sp
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
62 x11: DCArgs* args
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
63 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
64
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65 mov x10, sp
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
66 stp x29, x30, [sp, #-176 ]!
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67 mov x29, sp
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
68
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
69 add x11, x29 , #16
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
71 /* save registers */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 stp x0, x1, [x11, #0 ]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74 stp x2, x3, [x11, #16]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75 stp x4, x5, [x11, #32]
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
76 stp x6, x7, [x11, #48]
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 stp d0, d1, [x11, #64]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
79 stp d2, d3, [x11, #80]
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
80 stp d4, d5, [x11, #96]
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
81 stp d6, d7, [x11, #112]
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83 eor x12, x12, x12
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
84 stp x10,x12,[x11, #128] /* sp=sp, i=0, f=0 */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
85
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
86
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
87 /* call handler/callback */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
88
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
89 mov x0 , x9 /* DCCallback* pcb */
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
90 add x1 , x29 , #16 /* DCArgs* args */
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
91 add x2 , x29 , #160 /* DCValue* result */
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
92 ldr x3 , [x9 , #40] /* void* userdata */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
93
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
94 ldr x11, [x9 , #32]
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
95 blr x11
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
96
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97 and w0, w0, #255
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98 cmp w0, 'f'
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
99 b.eq LABELUSE(retf)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
100 cmp w0, 'd'
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
101 b.eq LABELUSE(retf)
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
102
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
103 LABELDEF(reti)
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
104 ldr x0, [x29, #160]
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
105 b LABELUSE(ret)
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
106 LABELDEF(retf)
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
107 ldr d0, [x29, #160]
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
108 LABELDEF(ret)
654
0079a8fa894e - arm64 tweaks/cleanups for callbacks:
Tassilo Philipp
parents: 651
diff changeset
109 ldp x29, x30, [sp], #176
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
110 ret
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
111
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
112
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
113 END_PROC
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
114 END_ASM
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
115