1//===-- xray_trampoline_mips.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 MIPS-specific assembler for the trampolines. 13// 14//===----------------------------------------------------------------------===// 15 16 .text 17 .file "xray_trampoline_mips.S" 18 .globl __xray_FunctionEntry 19 .p2align 2 20 .type __xray_FunctionEntry,@function 21__xray_FunctionEntry: 22 .cfi_startproc 23 .set noreorder 24 .cpload $t9 25 .set reorder 26 // Save argument registers before doing any actual work 27 .cfi_def_cfa_offset 36 28 addiu $sp, $sp, -36 29 sw $ra, 32($sp) 30 .cfi_offset 31, -4 31 sw $a3, 28($sp) 32 sw $a2, 24($sp) 33 sw $a1, 20($sp) 34 sw $a0, 16($sp) 35 sdc1 $f14, 8($sp) 36 sdc1 $f12, 0($sp) 37 38 la $t9, _ZN6__xray19XRayPatchedFunctionE 39 lw $t9, 0($t9) 40 41 beqz $t9, FunctionEntry_restore 42 43 // a1=0 means that we are tracing an entry event 44 move $a1, $zero 45 // Function ID is in t0 (the first parameter). 46 move $a0, $t0 47 jalr $t9 48 49FunctionEntry_restore: 50 // Restore argument registers 51 ldc1 $f12, 0($sp) 52 ldc1 $f14, 8($sp) 53 lw $a0, 16($sp) 54 lw $a1, 20($sp) 55 lw $a2, 24($sp) 56 lw $a3, 28($sp) 57 lw $ra, 32($sp) 58 addiu $sp, $sp, 36 59 jr $ra 60FunctionEntry_end: 61 .size __xray_FunctionEntry, FunctionEntry_end-__xray_FunctionEntry 62 .cfi_endproc 63 64 .text 65 .globl __xray_FunctionExit 66 .p2align 2 67 .type __xray_FunctionExit,@function 68__xray_FunctionExit: 69 .cfi_startproc 70 .set noreorder 71 .cpload $t9 72 .set reorder 73 // Save return registers before doing any actual work. 74 .cfi_def_cfa_offset 36 75 addiu $sp, $sp, -36 76 sw $ra, 32($sp) 77 .cfi_offset 31, -4 78 sw $a1, 28($sp) 79 sw $a0, 24($sp) 80 sw $v1, 20($sp) 81 sw $v0, 16($sp) 82 sdc1 $f2, 8($sp) 83 sdc1 $f0, 0($sp) 84 85 la $t9, _ZN6__xray19XRayPatchedFunctionE 86 lw $t9, 0($t9) 87 88 beqz $t9, FunctionExit_restore 89 90 // a1=1 means that we are tracing an exit event 91 li $a1, 1 92 // Function ID is in t0 (the first parameter). 93 move $a0, $t0 94 jalr $t9 95 96FunctionExit_restore: 97 // Restore return registers 98 ldc1 $f0, 0($sp) 99 ldc1 $f2, 8($sp) 100 lw $v0, 16($sp) 101 lw $v1, 20($sp) 102 lw $a0, 24($sp) 103 lw $a1, 28($sp) 104 lw $ra, 32($sp) 105 addiu $sp, $sp, 36 106 jr $ra 107 108FunctionExit_end: 109 .size __xray_FunctionExit, FunctionExit_end-__xray_FunctionExit 110 .cfi_endproc 111