]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/xray/xray_trampoline_arm.S
MFV r316124: Fix build when WITHOUT_INET6.
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / xray / xray_trampoline_arm.S
1     .syntax unified
2     .arch armv6t2
3     .fpu vfpv2
4     .code 32
5     .global _ZN6__xray19XRayPatchedFunctionE
6     @ Word-aligned function entry point
7     .p2align 2
8     @ Let C/C++ see the symbol
9     .global __xray_FunctionEntry
10     @ It preserves all registers except r0, r12(ip), r14(lr) and r15(pc)
11     @ Assume that "q" part of the floating-point registers is not used
12     @   for passing parameters to C/C++ functions.
13     .type __xray_FunctionEntry, %function
14     @ In C++ it is void extern "C" __xray_FunctionEntry(uint32_t FuncId) with
15     @   FuncId passed in r0 register.
16 __xray_FunctionEntry:
17     PUSH {r1-r3,lr}
18     @ Save floating-point parameters of the instrumented function
19     VPUSH {d0-d7}
20     MOVW r1,#:lower16:_ZN6__xray19XRayPatchedFunctionE
21     MOVT r1,#:upper16:_ZN6__xray19XRayPatchedFunctionE
22     LDR r2, [r1]
23     @ Handler address is nullptr if handler is not set
24     CMP r2, #0
25     BEQ FunctionEntry_restore
26     @ Function ID is already in r0 (the first parameter).
27     @ r1=0 means that we are tracing an entry event
28     MOV r1, #0
29     @ Call the handler with 2 parameters in r0 and r1
30     BLX r2
31 FunctionEntry_restore:
32     @ Restore floating-point parameters of the instrumented function
33     VPOP {d0-d7}
34     POP {r1-r3,pc}
35
36     @ Word-aligned function entry point
37     .p2align 2
38     @ Let C/C++ see the symbol
39         .global __xray_FunctionExit
40         @ Assume that d1-d7 are not used for the return value.
41     @ Assume that "q" part of the floating-point registers is not used for the
42     @   return value in C/C++.
43         .type __xray_FunctionExit, %function
44         @ In C++ it is extern "C" void __xray_FunctionExit(uint32_t FuncId) with
45     @   FuncId passed in r0 register.
46 __xray_FunctionExit:
47     PUSH {r1-r3,lr}
48     @ Save the floating-point return value of the instrumented function
49     VPUSH {d0}
50     @ Load the handler address
51     MOVW r1,#:lower16:_ZN6__xray19XRayPatchedFunctionE
52     MOVT r1,#:upper16:_ZN6__xray19XRayPatchedFunctionE
53     LDR r2, [r1]
54     @ Handler address is nullptr if handler is not set
55     CMP r2, #0
56     BEQ FunctionExit_restore
57     @ Function ID is already in r0 (the first parameter).
58     @ 1 means that we are tracing an exit event
59     MOV r1, #1
60     @ Call the handler with 2 parameters in r0 and r1
61     BLX r2
62 FunctionExit_restore:
63     @ Restore the floating-point return value of the instrumented function
64     VPOP {d0}
65     POP {r1-r3,pc}