1 //===-- xray_trampoline_loongarch64.s ---------------------------*- ASM -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of XRay, a dynamic runtime instrumentation system.
11 // This implements the loongarch-specific assembler for the trampolines.
13 //===----------------------------------------------------------------------===//
15 #include "../sanitizer_common/sanitizer_asm.h"
17 #define FROM_0_TO_7 0,1,2,3,4,5,6,7
18 #define FROM_7_TO_0 7,6,5,4,3,2,1,0
20 .macro SAVE_ARG_REGISTERS
22 st.d $a\i, $sp, (8 * 8 + 8 * \i)
25 fst.d $f\i, $sp, (8 * \i)
29 .macro RESTORE_ARG_REGISTERS
31 fld.d $f\i, $sp, (8 * \i)
34 ld.d $a\i, $sp, (8 * 8 + 8 * \i)
38 .macro SAVE_RET_REGISTERS
45 .macro RESTORE_RET_REGISTERS
53 .file "xray_trampoline_loongarch64.S"
54 .globl ASM_SYMBOL(__xray_FunctionEntry)
55 ASM_HIDDEN(__xray_FunctionEntry)
57 ASM_TYPE_FUNCTION(__xray_FunctionEntry)
58 ASM_SYMBOL(__xray_FunctionEntry):
60 // Save argument registers before doing any actual work.
61 .cfi_def_cfa_offset 136
67 la.got $t2, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
70 beqz $t2, FunctionEntry_restore
72 // a1=0 means that we are tracing an entry event.
74 // Function ID is in t1 (the first parameter).
78 FunctionEntry_restore:
79 // Restore argument registers.
85 ASM_SIZE(__xray_FunctionEntry)
89 .globl ASM_SYMBOL(__xray_FunctionExit)
90 ASM_HIDDEN(__xray_FunctionExit)
92 ASM_TYPE_FUNCTION(__xray_FunctionExit)
93 ASM_SYMBOL(__xray_FunctionExit):
95 // Save return registers before doing any actual work.
96 .cfi_def_cfa_offset 48
103 la.got $t2, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
106 beqz $t2, FunctionExit_restore
108 // a1=1 means that we are tracing an exit event.
110 // Function ID is in t1 (the first parameter).
114 FunctionExit_restore:
115 // Restore return registers.
116 RESTORE_RET_REGISTERS
123 ASM_SIZE(__xray_FunctionExit)