1//===-- xray_trampoline_mips64.s --------------------------------*- ASM -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file is a part of XRay, a dynamic runtime instrumentation system. 11// 12// This implements the MIPS64-specific assembler for the trampolines. 13// 14//===----------------------------------------------------------------------===// 15 16 .text 17 .file "xray_trampoline_mips64.S" 18 .globl __xray_FunctionEntry 19 .p2align 2 20 .type __xray_FunctionEntry,@function 21__xray_FunctionEntry: 22 .cfi_startproc 23 // Save argument registers before doing any actual work. 24 .cfi_def_cfa_offset 144 25 daddiu $sp, $sp, -144 26 sd $ra, 136($sp) 27 .cfi_offset 31, -8 28 sd $gp, 128($sp) 29 sd $a7, 120($sp) 30 sd $a6, 112($sp) 31 sd $a5, 104($sp) 32 sd $a4, 96($sp) 33 sd $a3, 88($sp) 34 sd $a2, 80($sp) 35 sd $a1, 72($sp) 36 sd $a0, 64($sp) 37 sdc1 $f19, 56($sp) 38 sdc1 $f18, 48($sp) 39 sdc1 $f17, 40($sp) 40 sdc1 $f16, 32($sp) 41 sdc1 $f15, 24($sp) 42 sdc1 $f14, 16($sp) 43 sdc1 $f13, 8($sp) 44 sdc1 $f12, 0($sp) 45 46 lui $gp, %hi(%neg(%gp_rel(__xray_FunctionEntry))) 47 daddu $gp, $gp, $t9 48 daddiu $gp ,$gp, %lo(%neg(%gp_rel(__xray_FunctionEntry))) 49 50 dla $t9, _ZN6__xray19XRayPatchedFunctionE 51 ld $t9, 0($t9) 52 53 beqz $t9, FunctionEntry_restore 54 55 // a1=0 means that we are tracing an entry event 56 move $a1, $zero 57 // Function ID is in t0 (the first parameter). 58 move $a0, $t0 59 jalr $t9 60 61FunctionEntry_restore: 62 // Restore argument registers 63 ldc1 $f12, 0($sp) 64 ldc1 $f13, 8($sp) 65 ldc1 $f14, 16($sp) 66 ldc1 $f15, 24($sp) 67 ldc1 $f16, 32($sp) 68 ldc1 $f17, 40($sp) 69 ldc1 $f18, 48($sp) 70 ldc1 $f19, 56($sp) 71 ld $a0, 64($sp) 72 ld $a1, 72($sp) 73 ld $a2, 80($sp) 74 ld $a3, 88($sp) 75 ld $a4, 96($sp) 76 ld $a5, 104($sp) 77 ld $a6, 112($sp) 78 ld $a7, 120($sp) 79 ld $gp, 128($sp) 80 ld $ra, 136($sp) 81 daddiu $sp, $sp, 144 82 jr $ra 83FunctionEntry_end: 84 .size __xray_FunctionEntry, FunctionEntry_end-__xray_FunctionEntry 85 .cfi_endproc 86 87 .text 88 .globl __xray_FunctionExit 89 .p2align 2 90 .type __xray_FunctionExit,@function 91__xray_FunctionExit: 92 .cfi_startproc 93 // Save return registers before doing any actual work. 94 .cfi_def_cfa_offset 64 95 daddiu $sp, $sp, -64 96 sd $ra, 56($sp) 97 .cfi_offset 31, -8 98 sd $gp, 48($sp) 99 sd $a0, 40($sp) 100 sd $v1, 32($sp) 101 sd $v0, 24($sp) 102 sdc1 $f2, 16($sp) 103 sdc1 $f1, 8($sp) 104 sdc1 $f0, 0($sp) 105 106 lui $gp, %hi(%neg(%gp_rel(__xray_FunctionExit))) 107 daddu $gp, $gp, $t9 108 daddiu $gp ,$gp, %lo(%neg(%gp_rel(__xray_FunctionExit))) 109 110 dla $t9, _ZN6__xray19XRayPatchedFunctionE 111 ld $t9, 0($t9) 112 113 beqz $t9, FunctionExit_restore 114 115 // a1=1 means that we are tracing an exit event 116 li $a1, 1 117 // Function ID is in t0 (the first parameter). 118 move $a0, $t0 119 jalr $t9 120 121FunctionExit_restore: 122 // Restore return registers 123 ldc1 $f0, 0($sp) 124 ldc1 $f1, 8($sp) 125 ldc1 $f2, 16($sp) 126 ld $v0, 24($sp) 127 ld $v1, 32($sp) 128 ld $a0, 40($sp) 129 ld $gp, 48($sp) 130 ld $ra, 56($sp) 131 daddiu $sp, $sp, 64 132 jr $ra 133 134FunctionExit_end: 135 .size __xray_FunctionExit, FunctionExit_end-__xray_FunctionExit 136 .cfi_endproc 137