Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_call_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 | cab0031c6691 |
children |
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 |
651 | 41 /* |
42 DynCall Back-End arm64 | |
43 | |
44 Supported ABIs: | |
45 - 'ARM 64-bit AArch64 PCS' (@dadler: work in progress) | |
46 */ | |
0 | 47 |
48 GLOBAL_C(dcCall_arm64) | |
49 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
|
50 ALIGN(2) |
0 | 51 |
651 | 52 /* input: |
53 x0: target (address of target) | |
54 x1: data (address of stack copy data) | |
55 x2: size (number of 'pair' 16-byte units) | |
56 x3: regdata (address of register data) | |
57 */ | |
0 | 58 |
651 | 59 /* prolog: */ |
60 | |
61 stp x29, x30, [sp, #-16]! /* allocate frame */ | |
0 | 62 mov x29, sp |
63 | |
651 | 64 /* load 64-bit floating-point registers */ |
0 | 65 |
66 ldr d0, [x3,#0 ] | |
67 ldr d1, [x3,#8 ] | |
68 ldr d2, [x3,#16] | |
69 ldr d3, [x3,#24] | |
70 ldr d4, [x3,#32] | |
71 ldr d5, [x3,#40] | |
72 ldr d6, [x3,#48] | |
73 ldr d7, [x3,#56] | |
74 | |
651 | 75 /* copy to stack */ |
76 | |
77 sub sp, sp, x2 /* create call-frame */ | |
0 | 78 |
651 | 79 eor x4, x4, x4 /* x4: cnt = 0 */ |
0 | 80 |
651 | 81 mov x5, x1 /* x5: read pointer = data */ |
82 mov x6, sp /* x6: write pointer = sp */ | |
0 | 83 |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
84 LABELDEF(next) |
0 | 85 cmp x4, x2 |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
86 b.ge LABELUSE(done) |
651 | 87 |
88 ldp x7, x9, [x5], #16 /* get pair from data */ | |
89 stp x7, x9, [x6], #16 /* put to stack */ | |
90 add x4, x4, 16 /* advance 16 bytes */ | |
0 | 91 |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
92 b LABELUSE(next) |
0 | 93 |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
94 LABELDEF(done) |
651 | 95 |
96 /* rescue temp int registers */ | |
0 | 97 |
651 | 98 mov x9 , x0 /* x9: target */ |
99 add x10, x3, 64 /* x3: integer reg buffer */ | |
0 | 100 |
651 | 101 /* load 64-bit integer registers ( 8 x 64-bit ) */ |
102 | |
103 /* load register set */ | |
0 | 104 |
105 ldr x0, [x10, #0] | |
106 ldr x1, [x10, #8] | |
107 ldr x2, [x10, #16] | |
108 ldr x3, [x10, #24] | |
109 ldr x4, [x10, #32] | |
110 ldr x5, [x10, #40] | |
111 ldr x6, [x10, #48] | |
112 ldr x7, [x10, #56] | |
651 | 113 |
114 /* call target: */ | |
115 | |
0 | 116 blr x9 |
117 | |
651 | 118 /* epilog: */ |
0 | 119 |
120 mov sp, x29 | |
121 ldp x29, x30, [sp], 16 | |
122 | |
123 ret | |
124 | |
125 | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
126 END_PROC |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
127 END_ASM |
0 | 128 |