annotate dyncall/dyncall_call_arm32_arm_armhf.S @ 407:7364f285cac8

- use UAL syntax for some arm instructions for armhf targets, as clang's integrated as disallows pre-UAL syntax
author Tassilo Philipp
date Sun, 03 Oct 2021 10:41:46 +0200
parents 351bb41d3bb1
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_arm32_arm_armhf.S
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: Call Kernel for ARM 32-bit ARM Architecture - Hard Float
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
281
f5577f6bf97a - file header cleanups for release
Tassilo Philipp
parents: 148
diff changeset
9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 #include "../portasm/portasm-arm.S"
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 /* ============================================================================
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 DynCall Call Kernel for ARM 32-bit ARM Architecture Hard-Float
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 ----------------------------------------------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 C Interface:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 dcCall_arm32_armhf (DCpointer target, DCpointer argv, DCsize size, DCfloat* regdata);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36 This Call Kernel was tested on Raspberry Pi/Raspbian (Debian)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39 .text
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40 .code 32 /* ARM mode */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41 .arch armv6
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42 .fpu vfp
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43
36
93f315f02a32 - armhf dyncall optimization/cleanup
cslag
parents: 0
diff changeset
44 /*
93f315f02a32 - armhf dyncall optimization/cleanup
cslag
parents: 0
diff changeset
45 1st arg / r0 = funptr
93f315f02a32 - armhf dyncall optimization/cleanup
cslag
parents: 0
diff changeset
46 2st arg / r1 = ptr to int args
93f315f02a32 - armhf dyncall optimization/cleanup
cslag
parents: 0
diff changeset
47 3st arg / r2 = size
93f315f02a32 - armhf dyncall optimization/cleanup
cslag
parents: 0
diff changeset
48 4st arg / r3 = ptr to float args
93f315f02a32 - armhf dyncall optimization/cleanup
cslag
parents: 0
diff changeset
49 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50 GLOBAL_C(dcCall_arm32_armhf)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51 ENTRY_C(dcCall_arm32_armhf)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53 /* Prolog. This function never needs to spill inside its prolog, so just store the permanent registers. */
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
54 mov r12 , r13 /* Stack ptr (r13) -> temporary (r12). */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
55 stmdb r13!, {r4-r5, r11, r12, r14} /* Permanent registers and stack pointer (now in r12), etc... -> save area on stack (except counter). */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
57 mov r11, r12 /* Set frame ptr. */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
58 mov r4, r0 /* r4 = fptr */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
59 add r5, r1, #16 /* r5 = stack args (after intreg ones) */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
60
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
61 /* Load 16 single-precision registers (= 8 double-precision registers). */
407
7364f285cac8 - use UAL syntax for some arm instructions for armhf targets, as clang's integrated as disallows pre-UAL syntax
Tassilo Philipp
parents: 406
diff changeset
62 vldmia r3, {d0-d7}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
64 /* prep stack parameter area (includes room for spill area, callee spills if needed) */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
65 sub r13, r13, r2
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
66 and r13, r13, #-8 /* align 8-byte. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
68 sub r2, r2, #16 /* loop counters for stack params to copy */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
69 mov r3, #0
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70 armhf_pushArgs:
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
71 cmp r2, r3
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
72 ble armhf_call
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
73 ldr r0, [r5, +r3] /* load word into r0 ... */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
74 str r0, [r13, +r3] /* ... then push onto stack */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
75 add r3, r3, #4
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
76 b armhf_pushArgs
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 armhf_call:
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
79 ldmia r1, {r0-r3} /* Load first 4 arguments for new call into r0-r3. */
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
80 /* 'blx r4' workaround for ARMv4t: */
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
81 mov r14, r15 /* Branch return address(r15) -> link register (r14) -- r15 always points to address of current + 2 instructions (= Epilog code). */
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
82 bx r4 /* Call (ARM/THUMB), available for ARMv4t. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
84 /* Epilog. */
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 146
diff changeset
85 ldmdb r11, {r4-r5, r11, r13, r15} /* Restore permanent registers (ignore temporary (r12), restore stack ptr and program counter).@@@db not needed since we rewrite r13? */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
86