11541Srgrimes//===-- xray_trampoline_mips64.s --------------------------------*- ASM -*-===// 21541Srgrimes// 31541Srgrimes// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 41541Srgrimes// See https://llvm.org/LICENSE.txt for license information. 51541Srgrimes// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 61541Srgrimes// 71541Srgrimes//===----------------------------------------------------------------------===// 812623Sphk// 912623Sphk// This file is a part of XRay, a dynamic runtime instrumentation system. 1012623Sphk// 111541Srgrimes// This implements the MIPS64-specific assembler for the trampolines. 121541Srgrimes// 131541Srgrimes//===----------------------------------------------------------------------===// 141541Srgrimes 151541Srgrimes .text 161541Srgrimes .file "xray_trampoline_mips64.S" 171541Srgrimes .globl __xray_FunctionEntry 181541Srgrimes .p2align 2 191541Srgrimes .type __xray_FunctionEntry,@function 201541Srgrimes__xray_FunctionEntry: 211541Srgrimes .cfi_startproc 221541Srgrimes // Save argument registers before doing any actual work. 231541Srgrimes .cfi_def_cfa_offset 144 241541Srgrimes daddiu $sp, $sp, -144 251541Srgrimes sd $ra, 136($sp) 261541Srgrimes .cfi_offset 31, -8 271541Srgrimes sd $gp, 128($sp) 281541Srgrimes sd $a7, 120($sp) 291541Srgrimes sd $a6, 112($sp) 301541Srgrimes sd $a5, 104($sp) 311541Srgrimes sd $a4, 96($sp) 321541Srgrimes sd $a3, 88($sp) 331541Srgrimes sd $a2, 80($sp) 341541Srgrimes sd $a1, 72($sp) 351541Srgrimes sd $a0, 64($sp) 361541Srgrimes sdc1 $f19, 56($sp) 371541Srgrimes sdc1 $f18, 48($sp) 38116182Sobrien sdc1 $f17, 40($sp) 39116182Sobrien sdc1 $f16, 32($sp) 40116182Sobrien sdc1 $f15, 24($sp) 41224159Srwatson sdc1 $f14, 16($sp) 4231778Seivind sdc1 $f13, 8($sp) 43189707Sjhb sdc1 $f12, 0($sp) 4431778Seivind 451541Srgrimes lui $gp, %hi(%neg(%gp_rel(__xray_FunctionEntry))) 46216060Smdf daddu $gp, $gp, $t9 4748274Speter daddiu $gp ,$gp, %lo(%neg(%gp_rel(__xray_FunctionEntry))) 48224159Srwatson 4948274Speter dla $t9, _ZN6__xray19XRayPatchedFunctionE 501541Srgrimes ld $t9, 0($t9) 5112623Sphk 52164033Srwatson beqz $t9, FunctionEntry_restore 5312662Sdg 54194368Sbz // a1=0 means that we are tracing an entry event 5582746Sdillon move $a1, $zero 5682746Sdillon // Function ID is in t0 (the first parameter). 57212750Smdf move $a0, $t0 5893616Salfred jalr $t9 5915103Sphk 60185983SkibFunctionEntry_restore: 61189707Sjhb // Restore argument registers 62189707Sjhb ldc1 $f12, 0($sp) 63189707Sjhb ldc1 $f13, 8($sp) 64163606Srwatson ldc1 $f14, 16($sp) 65195699Srwatson ldc1 $f15, 24($sp) 66195699Srwatson ldc1 $f16, 32($sp) 67163606Srwatson ldc1 $f17, 40($sp) 68163606Srwatson ldc1 $f18, 48($sp) 6912645Sbde ldc1 $f19, 56($sp) 7012662Sdg ld $a0, 64($sp) 7112645Sbde ld $a1, 72($sp) 7230354Sphk ld $a2, 80($sp) 7363212Sabial ld $a3, 88($sp) 74100833Struckman ld $a4, 96($sp) 7530309Sphk ld $a5, 104($sp) 7612429Sphk ld $a6, 112($sp) 77188232Sjhb ld $a7, 120($sp) 78188232Sjhb ld $gp, 128($sp) 79188232Sjhb ld $ra, 136($sp) 80188232Sjhb daddiu $sp, $sp, 144 81188232Sjhb jr $ra 82188232SjhbFunctionEntry_end: 83188232Sjhb .size __xray_FunctionEntry, FunctionEntry_end-__xray_FunctionEntry 84188232Sjhb .cfi_endproc 85192125Sjhb 86192125Sjhb .text 87192125Sjhb .globl __xray_FunctionExit 8812429Sphk .p2align 2 8993625Srwatson .type __xray_FunctionExit,@function 90192125Sjhb__xray_FunctionExit: 9112429Sphk .cfi_startproc 92188232Sjhb // Save return registers before doing any actual work. 93188232Sjhb .cfi_def_cfa_offset 64 94188232Sjhb daddiu $sp, $sp, -64 95112107Sjhb sd $ra, 56($sp) 96216060Smdf .cfi_offset 31, -8 97216060Smdf sd $gp, 48($sp) 9893616Salfred sd $a0, 40($sp) 9962573Sphk sd $v1, 32($sp) 10012429Sphk sd $v0, 24($sp) 10144078Sdfr sdc1 $f2, 16($sp) 10212152Sphk sdc1 $f1, 8($sp) 103188232Sjhb sdc1 $f0, 0($sp) 104188232Sjhb 105188232Sjhb lui $gp, %hi(%neg(%gp_rel(__xray_FunctionExit))) 10663212Sabial daddu $gp, $gp, $t9 10763212Sabial daddiu $gp ,$gp, %lo(%neg(%gp_rel(__xray_FunctionExit))) 10863212Sabial 10963212Sabial dla $t9, _ZN6__xray19XRayPatchedFunctionE 11063212Sabial ld $t9, 0($t9) 111216060Smdf 11263212Sabial beqz $t9, FunctionExit_restore 11363212Sabial 11463212Sabial // a1=1 means that we are tracing an exit event 11563212Sabial li $a1, 1 11663212Sabial // Function ID is in t0 (the first parameter). 11763212Sabial move $a0, $t0 11863212Sabial jalr $t9 11963212Sabial 12012623SphkFunctionExit_restore: 12112623Sphk // Restore return registers 12212623Sphk ldc1 $f0, 0($sp) 12344078Sdfr ldc1 $f1, 8($sp) 12412623Sphk ldc1 $f2, 16($sp) 125188232Sjhb ld $v0, 24($sp) 126188232Sjhb ld $v1, 32($sp) 127188232Sjhb ld $a0, 40($sp) 12812429Sphk ld $gp, 48($sp) 129188232Sjhb ld $ra, 56($sp) 130188232Sjhb daddiu $sp, $sp, 64 131188232Sjhb jr $ra 13280338Sroam 133188232SjhbFunctionExit_end: 134188232Sjhb .size __xray_FunctionExit, FunctionExit_end-__xray_FunctionExit 135188232Sjhb .cfi_endproc 136188232Sjhb