Mercurial > pub > dyncall > dyncall
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 |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
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 | 6 Description: Callback Thunk - Implementation for ARM64 / ARMv8 / AAPCS64 |
7 License: | |
8 | |
651 | 9 Copyright (c) 2015-2024 Daniel Adler <dadler@uni-goettingen.de>, |
281 | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
0 | 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 */ | |
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 | 29 /* struct DCCallback |
30 type off size | |
31 ---------|------|------ | |
32 DCThunk | 0 | 32 | |
33 handler | 32 | 8 | |
34 userdata | 40 | 8 | |
35 */ | |
0 | 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 | 38 |
39 GLOBAL_C(dcCallbackThunkEntry) | |
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 | 42 |
651 | 43 /* input: |
44 x9: DCCallback* pcb | |
45 x0..x7 ?? GP regs | |
46 d0..d7 ?? FP/SIMD regs | |
47 sp... ?? arguments on stack | |
654 | 48 |
651 | 49 locals: |
50 type off size | |
51 ---------|------|------ | |
52 Frame 0 16 | |
654 | 53 DCArgs 16 144 |
54 DCValue 160 16 | |
55 | |
56 size 176 | |
57 aligned 176 | |
58 | |
0 | 59 |
651 | 60 locals: |
61 x10: sp | |
62 x11: DCArgs* args | |
63 */ | |
0 | 64 |
65 mov x10, sp | |
654 | 66 stp x29, x30, [sp, #-176 ]! |
0 | 67 mov x29, sp |
68 | |
69 add x11, x29 , #16 | |
70 | |
654 | 71 /* save registers */ |
0 | 72 |
73 stp x0, x1, [x11, #0 ] | |
74 stp x2, x3, [x11, #16] | |
75 stp x4, x5, [x11, #32] | |
654 | 76 stp x6, x7, [x11, #48] |
0 | 77 |
78 stp d0, d1, [x11, #64] | |
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 | 82 |
83 eor x12, x12, x12 | |
651 | 84 stp x10,x12,[x11, #128] /* sp=sp, i=0, f=0 */ |
85 | |
654 | 86 |
87 /* call handler/callback */ | |
0 | 88 |
654 | 89 mov x0 , x9 /* DCCallback* pcb */ |
90 add x1 , x29 , #16 /* DCArgs* args */ | |
91 add x2 , x29 , #160 /* DCValue* result */ | |
92 ldr x3 , [x9 , #40] /* void* userdata */ | |
0 | 93 |
94 ldr x11, [x9 , #32] | |
654 | 95 blr x11 |
0 | 96 |
97 and w0, w0, #255 | |
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 | 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 | 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 | 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 | 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 | 109 ldp x29, x30, [sp], #176 |
0 | 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 |