1//===-- xray_trampoline_s390x.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-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of XRay, a dynamic runtime instrumentation system.
10//
11// This implements the s390x-specific assembler for the trampolines.
12// 2 versions of the functions are provided: one which does not store the
13// vector registers, and one which does store them. The compiler decides
14// which to call based on the availability of the vector extension.
15//
16//===----------------------------------------------------------------------===//
17
18 .text
19
20// Minimal stack frame size
21#define STACKSZ 160
22
23// Minimal stack frame size (160) plus space for 8 vector registers a 16 bytes.
24#define STACKSZ_VEC 288
25
26//===----------------------------------------------------------------------===//
27
28 .globl __xray_FunctionEntry
29 .p2align 4
30 .type __xray_FunctionEntry,@function
31__xray_FunctionEntry:
32 # The registers r2-15 of the instrumented function are already saved in the
33 # stack frame. On entry, r2 contains the function id, and %r14 the address
34 # of the first instruction of the instrumented function.
35 # Register r14 will be stored in the slot reserved for compiler use.
36 stg %r14, 8(%r15)
37 std %f0, 128(%r15)
38 std %f2, 136(%r15)
39 std %f4, 144(%r15)
40 std %f6, 152(%r15)
41 aghi %r15, -STACKSZ
42
43 lgrl %r1, _ZN6__xray19XRayPatchedFunctionE@GOT
44 ltg %r1, 0(%r1)
45 je .Lrestore0
46
47 # Set r3 to XRayEntryType::ENTRY = 0.
48 # The FuncId is still stored in r2.
49 lghi %r3, 0
50 basr %r14, %r1
51
52.Lrestore0:
53 ld %f6, STACKSZ+152(%r15)
54 ld %f4, STACKSZ+144(%r15)
55 ld %f2, STACKSZ+136(%r15)
56 ld %f0, STACKSZ+128(%r15)
57 lmg %r1, %r15, STACKSZ+8(%r15)
58 br %r1
59.Lfunc_end0:
60 .size __xray_FunctionEntry, .Lfunc_end0-__xray_FunctionEntry
61
62//===----------------------------------------------------------------------===//
63
64 .globl __xray_FunctionEntryVec
65 .p2align 4
66 .type __xray_FunctionEntryVec,@function
67__xray_FunctionEntryVec:
68 # The registers r2-15 of the instrumented function are already saved in the
69 # stack frame. On entry, r2 contains the function id, and %r14 the address
70 # of the first instruction of the instrumented function.
71 # Register r14 will be stored in the slot reserved for compiler use.
72 stg %r14, 8(%r15)
73 std %f0, 128(%r15)
74 std %f2, 136(%r15)
75 std %f4, 144(%r15)
76 std %f6, 152(%r15)
77 aghi %r15, -STACKSZ_VEC
78 vstm %v24, %v31, 160(%r15)
79
80 lgrl %r1, _ZN6__xray19XRayPatchedFunctionE@GOT
81 ltg %r1, 0(%r1)
82 je .Lrestore1
83
84 # Set r3 to XRayEntryType::ENTRY = 0.
85 # The FuncId is still stored in r2.
86 lghi %r3, 0
87 basr %r14, %r1
88
89.Lrestore1:
90 vlm %v24, %v31, 160(%r15)
91 ld %f6, STACKSZ_VEC+152(%r15)
92 ld %f4, STACKSZ_VEC+144(%r15)
93 ld %f2, STACKSZ_VEC+136(%r15)
94 ld %f0, STACKSZ_VEC+128(%r15)
95 lmg %r1, %r15, STACKSZ_VEC+8(%r15)
96 br %r1
97.Lfunc_end1:
98 .size __xray_FunctionEntryVec, .Lfunc_end1-__xray_FunctionEntryVec
99
100//===----------------------------------------------------------------------===//
101
102 .globl __xray_FunctionExit
103 .p2align 4
104 .type __xray_FunctionExit,@function
105__xray_FunctionExit:
106 # The registers r2-15 of the instrumented function are already saved in the
107 # stack frame. On entry, the register r2 contains the function id.
108 # At the end, the function jumps to the address saved in the slot for r14,
109 # which contains the return address into the caller of the instrumented
110 # function.
111 std %f0, 128(%r15)
112 std %f2, 136(%r15)
113 std %f4, 144(%r15)
114 std %f6, 152(%r15)
115 aghi %r15, -STACKSZ
116
117 lgrl %r1, _ZN6__xray19XRayPatchedFunctionE@GOT
118 ltg %r1, 0(%r1)
119 je .Lrestore2
120
121 # Set r3 to XRayEntryType::EXIT = 1.
122 # The FuncId is still stored in r2.
123 lghi %r3, 1
124 basr %r14, %r1
125
126.Lrestore2:
127 ld %f6, STACKSZ+152(%r15)
128 ld %f4, STACKSZ+144(%r15)
129 ld %f2, STACKSZ+136(%r15)
130 ld %f0, STACKSZ+128(%r15)
131 lmg %r2, %r15, STACKSZ+16(%r15)
132 br %r14
133.Lfunc_end2:
134 .size __xray_FunctionExit, .Lfunc_end2-__xray_FunctionExit
135
136//===----------------------------------------------------------------------===//
137
138 .globl __xray_FunctionExitVec
139 .p2align 4
140 .type __xray_FunctionExitVec,@function
141__xray_FunctionExitVec:
142 # The registers r2-15 of the instrumented function are already saved in the
143 # stack frame. On entry, the register r2 contains the function id.
144 # At the end, the function jumps to the address saved in the slot for r14,
145 # which contains the return address into the caller of the instrumented
146 # function.
147 std %f0, 128(%r15)
148 std %f2, 136(%r15)
149 std %f4, 144(%r15)
150 std %f6, 152(%r15)
151 aghi %r15, -STACKSZ_VEC
152 vstm %v24, %v31, 160(%r15)
153
154 lgrl %r1, _ZN6__xray19XRayPatchedFunctionE@GOT
155 ltg %r1, 0(%r1)
156 je .Lrestore3
157
158 # Set r3 to XRayEntryType::EXIT = 1.
159 # The FuncId is still stored in r2.
160 lghi %r3, 1
161 basr %r14, %r1
162
163.Lrestore3:
164 vlm %v24, %v31, 160(%r15)
165 ld %f6, STACKSZ_VEC+152(%r15)
166 ld %f4, STACKSZ_VEC+144(%r15)
167 ld %f2, STACKSZ_VEC+136(%r15)
168 ld %f0, STACKSZ_VEC+128(%r15)
169 lmg %r2, %r15, STACKSZ_VEC+16(%r15)
170 br %r14
171.Lfunc_end3:
172 .size __xray_FunctionExit, .Lfunc_end3-__xray_FunctionExit
173
174//===----------------------------------------------------------------------===//
175
176 .section ".note.GNU-stack","",@progbits
177

source code of compiler-rt/lib/xray/xray_trampoline_s390x.S