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
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: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 File: dyncall/dyncall_call_arm64.S
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: Call Kernel for ARM 64-bit Architecture (aka ARM64, AArch64)
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
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
f5577f6bf97a - file header cleanups for release
Tassilo Philipp
parents: 14
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 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 /* ============================================================================
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 DynCall Call Kernel for ARM 64-bit ARM Architecture
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 ----------------------------------------------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 C Interface:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35 dcCall_arm64 (DCpointer target, DCpointer data, DCsize size, DCfloat* regdata);
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 This Call Kernel was tested on Debian/qemu-debootstrap arm64 jessie and on win64.
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
371
451299d50c1a - windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents: 281
diff changeset
40 TEXTAREA
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
41 /*
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
42 DynCall Back-End arm64
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
43
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
44 Supported ABIs:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
45 - 'ARM 64-bit AArch64 PCS' (@dadler: work in progress)
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
46 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
47
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
48 GLOBAL_C(dcCall_arm64)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
52 /* input:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
53 x0: target (address of target)
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
54 x1: data (address of stack copy data)
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
55 x2: size (number of 'pair' 16-byte units)
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
56 x3: regdata (address of register data)
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
57 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
59 /* prolog: */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
60
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
61 stp x29, x30, [sp, #-16]! /* allocate frame */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
62 mov x29, sp
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
64 /* load 64-bit floating-point registers */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
66 ldr d0, [x3,#0 ]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67 ldr d1, [x3,#8 ]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
68 ldr d2, [x3,#16]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
69 ldr d3, [x3,#24]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70 ldr d4, [x3,#32]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
71 ldr d5, [x3,#40]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72 ldr d6, [x3,#48]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 ldr d7, [x3,#56]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
75 /* copy to stack */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
76
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
77 sub sp, sp, x2 /* create call-frame */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
79 eor x4, x4, x4 /* x4: cnt = 0 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
80
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
81 mov x5, x1 /* x5: read pointer = data */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
82 mov x6, sp /* x6: write pointer = sp */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
87
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
88 ldp x7, x9, [x5], #16 /* get pair from data */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
89 stp x7, x9, [x6], #16 /* put to stack */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
90 add x4, x4, 16 /* advance 16 bytes */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
95
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
96 /* rescue temp int registers */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
98 mov x9 , x0 /* x9: target */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
99 add x10, x3, 64 /* x3: integer reg buffer */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
100
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
101 /* load 64-bit integer registers ( 8 x 64-bit ) */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
102
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
103 /* load register set */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
104
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
105 ldr x0, [x10, #0]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
106 ldr x1, [x10, #8]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
107 ldr x2, [x10, #16]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
108 ldr x3, [x10, #24]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
109 ldr x4, [x10, #32]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
110 ldr x5, [x10, #40]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
111 ldr x6, [x10, #48]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
112 ldr x7, [x10, #56]
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
113
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
114 /* call target: */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
115
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
116 blr x9
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
117
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
118 /* epilog: */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
119
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
120 mov sp, x29
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
121 ldp x29, x30, [sp], 16
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
122
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
123 ret
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
124
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
128