1//===-- xray_trampoline_hexagon.s -------------------------------*- ASM -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of XRay, a dynamic runtime instrumentation system.
10//
11// This implements the hexagon-specific assembler for the trampolines.
12//
13//===----------------------------------------------------------------------===//
14
15#include "../builtins/assembly.h"
16#include "../sanitizer_common/sanitizer_asm.h"
17
18.macro SAVE_REGISTERS
19memw(sp+#0)=r0
20memw(sp+#4)=r1
21memw(sp+#8)=r2
22memw(sp+#12)=r3
23memw(sp+#16)=r4
24.endm
25.macro RESTORE_REGISTERS
26r0=memw(sp+#0)
27r1=memw(sp+#4)
28r2=memw(sp+#8)
29r3=memw(sp+#12)
30r4=memw(sp+#16)
31.endm
32
33.macro CALL_PATCHED_FUNC entry_type
34 // if (xray::XRayPatchedFunctionE != NULL)
35 // xray::XRayPatchedFunctionE(FuncType);
36
37 r8 = #ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
38
39 // The patched sled puts the function type
40 // into r6. Move it into r0 to pass it to
41 // the patched function.
42 { r0 = r6
43 r1 = \entry_type
44 p0 = !cmp.eq(r8, #0)
45 if (p0) callr r8 }
46.endm
47
48 .text
49 .globl ASM_SYMBOL(__xray_FunctionEntry)
50 ASM_HIDDEN(__xray_FunctionEntry)
51 ASM_TYPE_FUNCTION(__xray_FunctionEntry)
52# LLVM-MCA-BEGIN __xray_FunctionEntry
53ASM_SYMBOL(__xray_FunctionEntry):
54 CFI_STARTPROC
55 SAVE_REGISTERS
56
57 CALL_PATCHED_FUNC #0 // XRayEntryType::ENTRY
58.Ltmp0:
59 RESTORE_REGISTERS
60 // return
61# LLVM-MCA-END
62 ASM_SIZE(__xray_FunctionEntry)
63 CFI_ENDPROC
64
65
66 .globl ASM_SYMBOL(__xray_FunctionExit)
67 ASM_HIDDEN(__xray_FunctionExit)
68 ASM_TYPE_FUNCTION(__xray_FunctionExit)
69# LLVM-MCA-BEGIN __xray_FunctionExit
70ASM_SYMBOL(__xray_FunctionExit):
71 CFI_STARTPROC
72 SAVE_REGISTERS
73
74 CALL_PATCHED_FUNC #1 // XRayEntryType::EXIT
75.Ltmp1:
76 RESTORE_REGISTERS
77 // return
78 jumpr r31
79# LLVM-MCA-END
80 ASM_SIZE(__xray_FunctionExit)
81 CFI_ENDPROC
82
83
84 .globl ASM_SYMBOL(__xray_FunctionTailExit)
85 ASM_HIDDEN(__xray_FunctionTailExit)
86 ASM_TYPE_FUNCTION(__xray_FunctionTailExit)
87# LLVM-MCA-BEGIN __xray_FunctionTailExit
88ASM_SYMBOL(__xray_FunctionTailExit):
89 CFI_STARTPROC
90 SAVE_REGISTERS
91
92 CALL_PATCHED_FUNC #2 // XRayEntryType::TAIL
93.Ltmp2:
94 RESTORE_REGISTERS
95 // return
96 jumpr r31
97# LLVM-MCA-END
98 ASM_SIZE(__xray_FunctionTailExit)
99 CFI_ENDPROC
100

source code of compiler-rt/lib/xray/xray_trampoline_hexagon.S