Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_call_arm64.S @ 542:a73a5cd50c19
- fix passing aggregate-by-val on x64/sysv: subaggr classification for
aggr *arrays* was wrong (was problematic when there ware exactly 2 8bytes to
be classified, potentially be passed via registers)
author | Tassilo Philipp |
---|---|
date | Mon, 02 May 2022 15:32:41 +0200 |
parents | 451299d50c1a |
children | cab0031c6691 |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
5 File: dyncall/dyncall_call_arm64.S | |
6 Description: Call Kernel for ARM 64-bit Architecture (aka ARM64, AArch64) | |
7 License: | |
8 | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
9 Copyright (c) 2015-2020 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 */ | |
25 | |
26 | |
27 | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
28 #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
|
29 BEGIN_ASM |
0 | 30 |
31 /* ============================================================================ | |
32 DynCall Call Kernel for ARM 64-bit ARM Architecture | |
33 ---------------------------------------------------------------------------- | |
34 C Interface: | |
35 dcCall_arm64 (DCpointer target, DCpointer data, DCsize size, DCfloat* regdata); | |
36 | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
37 This Call Kernel was tested on Debian/qemu-debootstrap arm64 jessie and on win64. |
0 | 38 */ |
39 | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
40 TEXTAREA |
0 | 41 // |
42 // DynCall Back-End arm64 | |
43 // | |
44 // Supported ABIs: | |
45 // - 'ARM 64-bit AArch64 PCS' (@dadler: work in progress) | |
46 // | |
47 // Useful Links: | |
48 // - http://lxr.free-electrons.com/source/arch/arm64/kernel/stacktrace.c | |
49 | |
50 GLOBAL_C(dcCall_arm64) | |
51 ENTRY_C(dcCall_arm64) | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
52 ALIGN(2) |
0 | 53 |
54 // input: | |
55 // x0: target (address of target) | |
56 // x1: data (address of stack copy data) | |
57 // x2: size (number of 'pair' 16-byte units) | |
58 // x3: regdata (address of register data) | |
59 | |
60 // prolog: | |
61 | |
62 stp x29, x30, [sp, #-16]! // allocate frame | |
63 mov x29, sp | |
64 | |
65 // load 64-bit floating-point registers | |
66 | |
67 ldr d0, [x3,#0 ] | |
68 ldr d1, [x3,#8 ] | |
69 ldr d2, [x3,#16] | |
70 ldr d3, [x3,#24] | |
71 ldr d4, [x3,#32] | |
72 ldr d5, [x3,#40] | |
73 ldr d6, [x3,#48] | |
74 ldr d7, [x3,#56] | |
75 | |
76 // copy to stack | |
77 | |
78 sub sp, sp, x2 // create call-frame | |
79 | |
80 eor x4, x4, x4 // x4: cnt = 0 | |
81 | |
82 mov x5, x1 // x5: read pointer = data | |
83 mov x6, sp // x6: write pointer = sp | |
84 | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
85 LABELDEF(next) |
0 | 86 cmp x4, x2 |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
87 b.ge LABELUSE(done) |
0 | 88 |
89 ldp x7, x9, [x5], #16 // get pair from data | |
90 stp x7, x9, [x6], #16 // put to stack | |
91 add x4, x4, 16 // advance 16 bytes | |
92 | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
93 b LABELUSE(next) |
0 | 94 |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
95 LABELDEF(done) |
0 | 96 |
97 // rescue temp int registers | |
98 | |
99 mov x9 , x0 // x9: target | |
100 add x10, x3, 64 // x3: integer reg buffer | |
101 | |
102 // load 64-bit integer registers ( 8 x 64-bit ) | |
103 | |
104 // load register set | |
105 | |
106 ldr x0, [x10, #0] | |
107 ldr x1, [x10, #8] | |
108 ldr x2, [x10, #16] | |
109 ldr x3, [x10, #24] | |
110 ldr x4, [x10, #32] | |
111 ldr x5, [x10, #40] | |
112 ldr x6, [x10, #48] | |
113 ldr x7, [x10, #56] | |
114 | |
115 // call target: | |
116 | |
117 blr x9 | |
118 | |
119 // epilog: | |
120 | |
121 mov sp, x29 | |
122 ldp x29, x30, [sp], 16 | |
123 | |
124 ret | |
125 | |
126 | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
127 END_PROC |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
128 END_ASM |
0 | 129 |