100 lines · plain
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-exception6//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_REGISTERS19memw(sp+#0)=r020memw(sp+#4)=r121memw(sp+#8)=r222memw(sp+#12)=r323memw(sp+#16)=r424.endm25.macro RESTORE_REGISTERS26r0=memw(sp+#0)27r1=memw(sp+#4)28r2=memw(sp+#8)29r3=memw(sp+#12)30r4=memw(sp+#16)31.endm32 33.macro CALL_PATCHED_FUNC entry_type34 // if (xray::XRayPatchedFunctionE != NULL)35 // xray::XRayPatchedFunctionE(FuncType);36 37 r8 = #ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)38 39 // The patched sled puts the function type40 // into r6. Move it into r0 to pass it to41 // the patched function.42 { r0 = r643 r1 = \entry_type44 p0 = !cmp.eq(r8, #0)45 if (p0) callr r8 }46.endm47 48 .text49 .globl ASM_SYMBOL(__xray_FunctionEntry)50 ASM_HIDDEN(__xray_FunctionEntry)51 ASM_TYPE_FUNCTION(__xray_FunctionEntry)52# LLVM-MCA-BEGIN __xray_FunctionEntry53ASM_SYMBOL(__xray_FunctionEntry):54 CFI_STARTPROC55 SAVE_REGISTERS56 57 CALL_PATCHED_FUNC #0 // XRayEntryType::ENTRY58.Ltmp0:59 RESTORE_REGISTERS60 // return61# LLVM-MCA-END62 ASM_SIZE(__xray_FunctionEntry)63 CFI_ENDPROC64 65 66 .globl ASM_SYMBOL(__xray_FunctionExit)67 ASM_HIDDEN(__xray_FunctionExit)68 ASM_TYPE_FUNCTION(__xray_FunctionExit)69# LLVM-MCA-BEGIN __xray_FunctionExit70ASM_SYMBOL(__xray_FunctionExit):71 CFI_STARTPROC72 SAVE_REGISTERS73 74 CALL_PATCHED_FUNC #1 // XRayEntryType::EXIT75.Ltmp1:76 RESTORE_REGISTERS77 // return78 jumpr r3179# LLVM-MCA-END80 ASM_SIZE(__xray_FunctionExit)81 CFI_ENDPROC82 83 84 .globl ASM_SYMBOL(__xray_FunctionTailExit)85 ASM_HIDDEN(__xray_FunctionTailExit)86 ASM_TYPE_FUNCTION(__xray_FunctionTailExit)87# LLVM-MCA-BEGIN __xray_FunctionTailExit88ASM_SYMBOL(__xray_FunctionTailExit):89 CFI_STARTPROC90 SAVE_REGISTERS91 92 CALL_PATCHED_FUNC #2 // XRayEntryType::TAIL93.Ltmp2:94 RESTORE_REGISTERS95 // return96 jumpr r3197# LLVM-MCA-END98 ASM_SIZE(__xray_FunctionTailExit)99 CFI_ENDPROC100