1 //===-- xray_trampoline_x86.s -----------------------------------*- ASM -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of XRay, a dynamic runtime instrumentation system.
12 // This implements the X86-specific assembler for the trampolines.
14 //===----------------------------------------------------------------------===//
16 #include "../builtins/assembly.h"
20 .cfi_def_cfa_offset 200
21 // At this point, the stack pointer should be aligned to an 8-byte boundary,
22 // because any call instructions that come after this will add another 8
23 // bytes and therefore align it to 16-bytes.
25 movupd %xmm0, 168(%rsp)
26 movupd %xmm1, 152(%rsp)
27 movupd %xmm2, 136(%rsp)
28 movupd %xmm3, 120(%rsp)
29 movupd %xmm4, 104(%rsp)
30 movupd %xmm5, 88(%rsp)
31 movupd %xmm6, 72(%rsp)
32 movupd %xmm7, 56(%rsp)
42 .macro RESTORE_REGISTERS
44 movupd 168(%rsp), %xmm0
45 movupd 152(%rsp), %xmm1
46 movupd 136(%rsp), %xmm2
47 movupd 120(%rsp), %xmm3
48 movupd 104(%rsp), %xmm4
49 movupd 88(%rsp), %xmm5
50 movupd 72(%rsp) , %xmm6
51 movupd 56(%rsp) , %xmm7
64 .file "xray_trampoline_x86.S"
66 //===----------------------------------------------------------------------===//
68 .globl __xray_FunctionEntry
70 .type __xray_FunctionEntry,@function
76 // This load has to be atomic, it's concurrent with __xray_patch().
77 // On x86/amd64, a simple (type-aligned) MOV instruction is enough.
78 movq _ZN6__xray19XRayPatchedFunctionE(%rip), %rax
82 // The patched function prolog puts its xray_instr_map index into %r10d.
90 .size __xray_FunctionEntry, .Ltmp1-__xray_FunctionEntry
93 //===----------------------------------------------------------------------===//
95 .globl __xray_FunctionExit
97 .type __xray_FunctionExit,@function
100 // Save the important registers first. Since we're assuming that this
101 // function is only jumped into, we only preserve the registers for
104 .cfi_def_cfa_offset 64
106 movupd %xmm0, 32(%rsp)
107 movupd %xmm1, 16(%rsp)
110 movq _ZN6__xray19XRayPatchedFunctionE(%rip), %rax
118 // Restore the important registers.
120 movupd 32(%rsp), %xmm0
121 movupd 16(%rsp), %xmm1
125 .cfi_def_cfa_offset 8
128 .size __xray_FunctionExit, .Ltmp3-__xray_FunctionExit
131 //===----------------------------------------------------------------------===//
133 .global __xray_FunctionTailExit
135 .type __xray_FunctionTailExit,@function
136 __xray_FunctionTailExit:
138 // Save the important registers as in the entry trampoline, but indicate that
139 // this is an exit. In the future, we will introduce a new entry type that
140 // differentiates between a normal exit and a tail exit, but we'd have to do
141 // this and increment the version number for the header.
144 movq _ZN6__xray19XRayPatchedFunctionE(%rip), %rax
156 .size __xray_FunctionTailExit, .Ltmp5-__xray_FunctionTailExit
159 //===----------------------------------------------------------------------===//
161 .globl __xray_ArgLoggerEntry
163 .type __xray_ArgLoggerEntry,@function
164 __xray_ArgLoggerEntry:
168 // Again, these function pointer loads must be atomic; MOV is fine.
169 movq _ZN6__xray13XRayArgLoggerE(%rip), %rax
173 // If [arg1 logging handler] not set, defer to no-arg logging.
174 movq _ZN6__xray19XRayPatchedFunctionE(%rip), %rax
179 movq %rdi, %rdx // first argument will become the third
180 xorq %rsi, %rsi // XRayEntryType::ENTRY into the second
181 movl %r10d, %edi // 32-bit function ID becomes the first
189 .size __xray_ArgLoggerEntry, .Larg1entryEnd-__xray_ArgLoggerEntry
192 NO_EXEC_STACK_DIRECTIVE