Print this page
saveargs: Implement as libsaveargs
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/common/saveargs/tests/testmatch/data.s
+++ new/usr/src/lib/libsaveargs/tests/testmatch/data.s
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright 2012, Richard Lowe.
14 14 */
15 15
16 16 #define FUNC(x) \
17 17 .text; \
18 18 .align 16; \
19 19 .globl x; \
20 20 .type x, @function; \
21 21 x:
22 22
23 23 #define SET_SIZE(x, x_size) \
24 24 .size x, [.-x]; \
25 25 .globl x_size; \
26 26 .type x_size, @object; \
27 27 x_size:
28 28
29 29 /*
30 30 * Extracted versions of the functional tests
31 31 *
32 32 * Named of the form <compiler>-<prologue style>-<nature of test>
33 33 * basic -- A regular function
34 34 * align -- odd number of arguments needing save-area
35 35 * alignment
36 36 * big-struct-ret -- returns a > 16byte structure by value
37 37 * big-struct-ret-and-spill -- returns a > 16byte structure by value and
38 38 * spills args to the stack
39 39 * small-struct-ret -- returns a < 16byte structure by value
40 40 * small-struct-ret-and-spill -- returns a < 16byte structure by value and
41 41 * spills args to the stack
42 42 * stack-spill -- spills arguments to the stack
43 43 */
44 44 FUNC(gcc_mov_align)
45 45 pushq %rbp
46 46 movq %rsp, %rbp
47 47 movq %rbx, -0x38(%rbp)
48 48 movq %r8, -0x28(%rbp)
49 49 movq %rcx, -0x20(%rbp)
50 50 movq %rdx, -0x18(%rbp)
51 51 movq %rsi, -0x10(%rbp)
52 52 movq %rdi, -0x8(%rbp)
53 53 subq $0x70, %rsp
54 54 SET_SIZE(gcc_mov_align, gcc_mov_align_end)
55 55
56 56 FUNC(gcc_mov_basic)
↓ open down ↓ |
56 lines elided |
↑ open up ↑ |
57 57 pushq %rbp
58 58 movq %rsp, %rbp
59 59 movq %rbx,-0x28(%rbp)
60 60 movq %rcx,-0x20(%rbp)
61 61 movq %rdx,-0x18(%rbp)
62 62 movq %rsi,-0x10(%rbp)
63 63 movq %rdi,-0x8(%rbp)
64 64 subq $0x50,%rsp
65 65 SET_SIZE(gcc_mov_basic, gcc_mov_basic_end)
66 66
67 +FUNC(gcc_mov_noorder)
68 +pushq %rbp
69 +movq %rsp, %rbp
70 +movq %rcx,-0x20(%rbp)
71 +movq %rbx,-0x28(%rbp)
72 +movq %rdi,-0x8(%rbp)
73 +movq %rdx,-0x18(%rbp)
74 +movq %rsi,-0x10(%rbp)
75 +subq $0x50,%rsp
76 +SET_SIZE(gcc_mov_noorder, gcc_mov_noorder_end)
77 +
67 78 FUNC(gcc_mov_big_struct_ret)
68 79 pushq %rbp
69 80 movq %rsp,%rbp
70 81 movq %rbx,-0x28(%rbp)
71 82 movq %r8,-0x20(%rbp)
72 83 movq %rcx,-0x18(%rbp)
73 84 movq %rdx,-0x10(%rbp)
74 85 movq %rsi,-0x8(%rbp)
75 86 subq $0x50,%rsp
76 87 SET_SIZE(gcc_mov_big_struct_ret, gcc_mov_big_struct_ret_end)
77 88
89 +FUNC(gcc_mov_struct_noorder)
90 +pushq %rbp
91 +movq %rsp,%rbp
92 +movq %rcx,-0x18(%rbp)
93 +movq %r8,-0x20(%rbp)
94 +movq %rsi,-0x8(%rbp)
95 +movq %rdx,-0x10(%rbp)
96 +movq %rbx,-0x28(%rbp)
97 +subq $0x50,%rsp
98 +SET_SIZE(gcc_mov_struct_noorder, gcc_mov_struct_noorder_end)
99 +
78 100 FUNC(gcc_mov_big_struct_ret_and_spill)
79 101 pushq %rbp
80 102 movq %rsp,%rbp
81 103 movq %rbx,-0x38(%rbp)
82 104 movq %r9,-0x28(%rbp)
83 105 movq %r8,-0x20(%rbp)
84 106 movq %rcx,-0x18(%rbp)
85 107 movq %rdx,-0x10(%rbp)
86 108 movq %rsi,-0x8(%rbp)
87 109 subq $0x90,%rsp
88 110 SET_SIZE(gcc_mov_big_struct_ret_and_spill, gcc_mov_big_struct_ret_and_spill_end)
89 111
90 112 FUNC(gcc_mov_small_struct_ret)
91 113 pushq %rbp
92 114 movq %rsp,%rbp
93 115 movq %rbx,-0x28(%rbp)
94 116 movq %rcx,-0x20(%rbp)
95 117 movq %rdx,-0x18(%rbp)
96 118 movq %rsi,-0x10(%rbp)
97 119 movq %rdi,-0x8(%rbp)
98 120 subq $0x50,%rsp
99 121 SET_SIZE(gcc_mov_small_struct_ret, gcc_mov_small_struct_ret_end)
100 122
101 123 FUNC(gcc_mov_small_struct_ret_and_spill)
102 124 pushq %rbp
103 125 movq %rsp,%rbp
104 126 movq %rbx,-0x38(%rbp)
105 127 movq %r9,-0x30(%rbp)
106 128 movq %r8,-0x28(%rbp)
107 129 movq %rcx,-0x20(%rbp)
108 130 movq %rdx,-0x18(%rbp)
109 131 movq %rsi,-0x10(%rbp)
110 132 movq %rdi,-0x8(%rbp)
111 133 subq $0x90,%rsp
112 134 SET_SIZE(gcc_mov_small_struct_ret_and_spill, gcc_mov_small_struct_ret_and_spill_end)
113 135
114 136 FUNC(gcc_mov_stack_spill)
115 137 pushq %rbp
116 138 movq %rsp,%rbp
117 139 movq %rbx,-0x38(%rbp)
118 140 movq %r9,-0x30(%rbp)
119 141 movq %r8,-0x28(%rbp)
120 142 movq %rcx,-0x20(%rbp)
121 143 movq %rdx,-0x18(%rbp)
122 144 movq %rsi,-0x10(%rbp)
123 145 movq %rdi,-0x8(%rbp)
124 146 subq $0x90,%rsp
125 147 SET_SIZE(gcc_mov_stack_spill, gcc_mov_stack_spill_end)
126 148
127 149 FUNC(gcc_push_align)
128 150 pushq %rbp
129 151 movq %rsp,%rbp
130 152 pushq %rdi
131 153 pushq %rsi
132 154 pushq %rdx
133 155 pushq %rcx
134 156 pushq %r8
135 157 subq $0x8,%rsp
136 158 subq $0x30,%rsp
137 159 SET_SIZE(gcc_push_align, gcc_push_align_end)
138 160
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
139 161 FUNC(gcc_push_basic)
140 162 pushq %rbp
141 163 movq %rsp,%rbp
142 164 pushq %rdi
143 165 pushq %rsi
144 166 pushq %rdx
145 167 pushq %rcx
146 168 subq $0x20,%rsp
147 169 SET_SIZE(gcc_push_basic, gcc_push_basic_end)
148 170
171 +FUNC(gcc_push_noorder)
172 +pushq %rbp
173 +movq %rsp,%rbp
174 +pushq %rsi
175 +pushq %rdi
176 +pushq %rcx
177 +pushq %rdx
178 +subq $0x20,%rsp
179 +SET_SIZE(gcc_push_noorder, gcc_push_noorder_end)
180 +
149 181 FUNC(gcc_push_big_struct_ret)
150 182 pushq %rbp
151 183 movq %rsp,%rbp
152 184 pushq %rsi
153 185 pushq %rdx
154 186 pushq %rcx
155 187 pushq %r8
156 188 subq $0x30,%rsp
157 189 SET_SIZE(gcc_push_big_struct_ret, gcc_push_big_struct_ret_end)
158 190
191 +FUNC(gcc_push_struct_noorder)
192 +pushq %rbp
193 +movq %rsp,%rbp
194 +pushq %rdx
195 +pushq %rsi
196 +pushq %r8
197 +pushq %rcx
198 +subq $0x30,%rsp
199 +SET_SIZE(gcc_push_struct_noorder, gcc_push_struct_noorder_end)
200 +
159 201 FUNC(gcc_push_big_struct_ret_and_spill)
160 202 pushq %rbp
161 203 movq %rsp,%rbp
162 204 pushq %rsi
163 205 pushq %rdx
164 206 pushq %rcx
165 207 pushq %r8
166 208 pushq %r9
167 209 subq $0x8,%rsp
168 210 subq $0x50,%rsp
169 211 SET_SIZE(gcc_push_big_struct_ret_and_spill, gcc_push_big_struct_ret_and_spill_end)
170 212
171 213 FUNC(gcc_push_small_struct_ret)
172 214 pushq %rbp
173 215 movq %rsp,%rbp
174 216 pushq %rdi
175 217 pushq %rsi
176 218 pushq %rdx
177 219 pushq %rcx
178 220 subq $0x20,%rsp
179 221 SET_SIZE(gcc_push_small_struct_ret, gcc_push_small_struct_ret_end)
180 222
181 223 FUNC(gcc_push_small_struct_ret_and_spill)
182 224 pushq %rbp
183 225 movq %rsp,%rbp
184 226 pushq %rdi
185 227 pushq %rsi
186 228 pushq %rdx
187 229 pushq %rcx
188 230 pushq %r8
189 231 pushq %r9
190 232 subq $0x50,%rsp
191 233 SET_SIZE(gcc_push_small_struct_ret_and_spill, gcc_push_small_struct_ret_and_spill_end)
192 234
193 235 FUNC(gcc_push_stack_spill)
194 236 pushq %rbp
195 237 movq %rsp,%rbp
196 238 pushq %rdi
197 239 pushq %rsi
198 240 pushq %rdx
199 241 pushq %rcx
200 242 pushq %r8
201 243 pushq %r9
202 244 subq $0x50,%rsp
203 245 SET_SIZE(gcc_push_stack_spill, gcc_push_stack_spill_end)
204 246
205 247 FUNC(ss_mov_align)
206 248 pushq %rbp
207 249 movq %rsp,%rbp
208 250 subq $0x30,%rsp
209 251 movq %rdi,-0x8(%rbp)
210 252 movq %rsi,-0x10(%rbp)
211 253 movq %rdx,-0x18(%rbp)
212 254 movq %rcx,-0x20(%rbp)
213 255 movq %r8,-0x28(%rbp)
214 256 SET_SIZE(ss_mov_align, ss_mov_align_end)
215 257
216 258 FUNC(ss_mov_basic)
217 259 pushq %rbp
218 260 movq %rsp,%rbp
219 261 subq $0x20,%rsp
220 262 movq %rdi,-0x8(%rbp)
221 263 movq %rsi,-0x10(%rbp)
222 264 movq %rdx,-0x18(%rbp)
223 265 movq %rcx,-0x20(%rbp)
224 266 SET_SIZE(ss_mov_basic, ss_mov_basic_end)
225 267
226 268 FUNC(ss_mov_big_struct_ret)
227 269 pushq %rbp
228 270 movq %rsp,%rbp
229 271 subq $0x30,%rsp
230 272 movq %rdi,-0x8(%rbp)
231 273 movq %rsi,-0x10(%rbp)
232 274 movq %rdx,-0x18(%rbp)
233 275 movq %rcx,-0x20(%rbp)
234 276 movq %r8,-0x28(%rbp)
235 277 SET_SIZE(ss_mov_big_struct_ret, ss_mov_big_struct_ret_end)
236 278
237 279 FUNC(ss_mov_big_struct_ret_and_spill)
238 280 pushq %rbp
239 281 movq %rsp,%rbp
240 282 subq $0x50,%rsp
241 283 movq %rdi,-0x8(%rbp)
242 284 movq %rsi,-0x10(%rbp)
243 285 movq %rdx,-0x18(%rbp)
244 286 movq %rcx,-0x20(%rbp)
245 287 movq %r8,-0x28(%rbp)
246 288 movq %r9,-0x30(%rbp)
247 289 SET_SIZE(ss_mov_big_struct_ret_and_spill, ss_mov_big_struct_ret_and_spill_end)
248 290
249 291 FUNC(ss_mov_small_struct_ret)
250 292 pushq %rbp
251 293 movq %rsp,%rbp
252 294 subq $0x20,%rsp
253 295 movq %rdi,-0x8(%rbp)
254 296 movq %rsi,-0x10(%rbp)
255 297 movq %rdx,-0x18(%rbp)
256 298 movq %rcx,-0x20(%rbp)
257 299 SET_SIZE(ss_mov_small_struct_ret, ss_mov_small_struct_ret_end)
258 300
259 301 FUNC(ss_mov_small_struct_ret_and_spill)
260 302 pushq %rbp
261 303 movq %rsp,%rbp
262 304 subq $0x50,%rsp
263 305 movq %rdi,-0x8(%rbp)
264 306 movq %rsi,-0x10(%rbp)
265 307 movq %rdx,-0x18(%rbp)
266 308 movq %rcx,-0x20(%rbp)
267 309 movq %r8,-0x28(%rbp)
268 310 movq %r9,-0x30(%rbp)
269 311 SET_SIZE(ss_mov_small_struct_ret_and_spill, ss_mov_small_struct_ret_and_spill_end)
270 312
271 313 FUNC(ss_mov_stack_spill)
272 314 pushq %rbp
273 315 movq %rsp,%rbp
274 316 subq $0x50,%rsp
275 317 movq %rdi,-0x8(%rbp)
276 318 movq %rsi,-0x10(%rbp)
277 319 movq %rdx,-0x18(%rbp)
278 320 movq %rcx,-0x20(%rbp)
279 321 movq %r8,-0x28(%rbp)
280 322 movq %r9,-0x30(%rbp)
281 323 SET_SIZE(ss_mov_stack_spill, ss_mov_stack_spill_end)
282 324
283 325 /* DTrace instrumentation */
284 326 FUNC(dtrace_instrumented)
285 327 int $0x3
286 328 movq %rsp, %rbp
287 329 movq %rbx,-0x28(%rbp)
288 330 movq %rcx,-0x20(%rbp)
289 331 movq %rdx,-0x18(%rbp)
290 332 movq %rsi,-0x10(%rbp)
291 333 movq %rdi,-0x8(%rbp)
292 334 subq $0x50,%rsp
293 335 SET_SIZE(dtrace_instrumented, dtrace_instrumented_end)
294 336
295 337 /*
296 338 * System functions with special characteristics, be they non-initial FP save,
297 339 * gaps between FP save and argument saving, or gaps between saved arguments.
298 340 */
299 341 FUNC(kmem_alloc)
300 342 leaq -0x1(%rdi),%rax
301 343 pushq %rbp
302 344 movq %rax,%rdx
303 345 movq %rsp,%rbp
304 346 subq $0x30,%rsp
305 347 shrq $0x3,%rdx
306 348 movq %r12,-0x28(%rbp)
307 349 movq %rbx,-0x30(%rbp)
308 350 cmpq $0x1ff,%rdx
309 351 movq %r13,-0x20(%rbp)
310 352 movq %r14,-0x18(%rbp)
311 353 movq %rsi,-0x10(%rbp)
312 354 movq %rdi,-0x8(%rbp)
313 355 movq %rdi,%r12
314 356 SET_SIZE(kmem_alloc, kmem_alloc_end)
315 357
316 358 FUNC(uts_kill)
317 359 pushq %rbp
318 360 movq %rsp,%rbp
319 361 subq $0x50,%rsp
320 362 movq %rbx,-0x28(%rbp)
321 363 leaq -0x50(%rbp),%rbx
322 364 movq %r12,-0x20(%rbp)
323 365 movq %r13,-0x18(%rbp)
324 366 movq %rsi,-0x10(%rbp)
325 367 movl %edi,%r12d
326 368 movq %rdi,-0x8(%rbp)
327 369 SET_SIZE(uts_kill, uts_kill_end)
328 370
329 371 FUNC(av1394_ic_bitreverse)
330 372 movq %rdi,%rdx
331 373 movq $0x5555555555555555,%rax
332 374 movq $0x3333333333333333,%rcx
333 375 shrq $0x1,%rdx
334 376 pushq %rbp
335 377 andq %rax,%rdx
336 378 andq %rdi,%rax
337 379 addq %rax,%rax
338 380 movq %rsp,%rbp
339 381 subq $0x10,%rsp
340 382 orq %rdx,%rax
341 383 movq %rdi,-0x8(%rbp)
342 384 SET_SIZE(av1394_ic_bitreverse, av1394_ic_bitreverse_end)
343 385
344 386 /* Problematic functions which should not match */
345 387
346 388 FUNC(no_fp) /* No frame pointer */
347 389 movq %rdi, %rsi
348 390 movq %rsi, %rdi
349 391 movq %rbx,-0x28(%rbp)
350 392 movq %rcx,-0x20(%rbp)
351 393 movq %rdx,-0x18(%rbp)
352 394 movq %rsi,-0x10(%rbp)
353 395 movq %rdi,-0x8(%rbp)
354 396 subq $0x50,%rsp
355 397 SET_SIZE(no_fp, no_fp_end)
356 398
357 399 /* Small structure return, but with an SSE type (thus forcing it to the stack) */
358 400 FUNC(small_struct_ret_w_float)
359 401 pushq %rbp
360 402 movq %rsp,%rbp
361 403 movq %rdi,-0x8(%rbp)
362 404 subq $0x30,%rsp
363 405 SET_SIZE(small_struct_ret_w_float, small_struct_ret_w_float_end)
364 406
365 407 /* Big structure return, but with an SSE type */
366 408 FUNC(big_struct_ret_w_float)
367 409 pushq %rbp
368 410 movq %rsp,%rbp
369 411 movq %rsi,-0x8(%rbp)
370 412 subq $0x50,%rsp
371 413 movq %rsi,-0x48(%rbp)
372 414 movq -0x48(%rbp),%rax
373 415 movq %rax,%rsi
374 416 movl $0x400f60,%edi
375 417 movl $0x0,%eax
376 418 movl $0x1770,%edi
377 419 movl $0x0,%eax
378 420 leave
379 421 ret
380 422 SET_SIZE(big_struct_ret_w_float, big_struct_ret_w_float_end)
381 423
382 424 FUNC(big_struct_arg_by_value)
383 425 pushq %rbp
384 426 movq %rsp,%rbp
385 427 movq %rdi,-0x8(%rbp)
386 428 subq $0x40,%rsp
↓ open down ↓ |
218 lines elided |
↑ open up ↑ |
387 429 SET_SIZE(big_struct_arg_by_value, big_struct_arg_by_value_end)
388 430
389 431 FUNC(small_struct_arg_by_value)
390 432 pushq %rbp
391 433 movq %rsp,%rbp
392 434 movq %rdx,-0x18(%rbp)
393 435 movq %rsi,-0x10(%rbp)
394 436 movq %rdi,-0x8(%rbp)
395 437 subq $0x50,%rsp
396 438 SET_SIZE(small_struct_arg_by_value, small_struct_arg_by_value_end)
439 +
440 +FUNC(interleaved_argument_saves)
441 +pushq %rbp
442 +movq %rdi,%rax
443 +shlq $0x21,%rax
444 +movq %rsp,%rbp
445 +shrq $0x29,%rax
446 +subq $0x30,%rsp
447 +movq %rdi,-0x8(%rbp)
448 +movq %rbx,-0x28(%rbp)
449 +movzbl %dil,%edi
450 +movq %rcx,-0x20(%rbp)
451 +movq %rdx,-0x18(%rbp)
452 +movq %rsi,-0x10(%rbp)
453 +movq 0x0(,%rax,8),%rax
454 +SET_SIZE(interleaved_argument_saves, interleaved_argument_saves_end)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX