summaryrefslogtreecommitdiff
path: root/usr/src/lib/libsaveargs/tests/testmatch/data.s
blob: 77a5b30394a2d4cb42b7f4fd2e6c23d416f9c76a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2012, Richard Lowe.
 */

#define	FUNC(x) \
	.text; \
	.align	16; \
	.globl	x; \
	.type	x, @function; \
x:

#define	SET_SIZE(x, x_size) \
	.size	x, [.-x]; \
        .globl x_size; \
        .type  x_size, @object; \
x_size:

/*
 * Extracted versions of the functional tests
 *
 * Named of the form <compiler>-<prologue style>-<nature of test>
 * basic			-- A regular function
 * align			-- odd number of arguments needing save-area
 * 				   alignment
 * big-struct-ret		-- returns a > 16byte structure by value
 * big-struct-ret-and-spill	-- returns a > 16byte structure by value and
 * 				   spills args to the stack
 * small-struct-ret		-- returns a < 16byte structure by value
 * small-struct-ret-and-spill	-- returns a < 16byte structure by value and
 * 				   spills args to the stack
 * stack-spill			-- spills arguments to the stack
 */
FUNC(gcc_mov_align)
pushq	%rbp
movq	%rsp, %rbp
movq	%rbx, -0x38(%rbp)
movq	%r8, -0x28(%rbp)
movq	%rcx, -0x20(%rbp)
movq	%rdx, -0x18(%rbp)
movq	%rsi, -0x10(%rbp)
movq	%rdi, -0x8(%rbp)
subq	$0x70, %rsp
SET_SIZE(gcc_mov_align, gcc_mov_align_end)

FUNC(gcc_mov_basic)
pushq	%rbp
movq	%rsp, %rbp
movq	%rbx,-0x28(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdi,-0x8(%rbp)
subq    $0x50,%rsp
SET_SIZE(gcc_mov_basic, gcc_mov_basic_end)

FUNC(gcc_mov_noorder)
pushq	%rbp
movq	%rsp, %rbp
movq    %rcx,-0x20(%rbp)
movq	%rbx,-0x28(%rbp)
movq    %rdi,-0x8(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
subq    $0x50,%rsp
SET_SIZE(gcc_mov_noorder, gcc_mov_noorder_end)
        
FUNC(gcc_mov_big_struct_ret)
pushq   %rbp
movq    %rsp,%rbp
movq    %rbx,-0x28(%rbp)
movq    %r8,-0x20(%rbp)
movq    %rcx,-0x18(%rbp)
movq    %rdx,-0x10(%rbp)
movq    %rsi,-0x8(%rbp)
subq    $0x50,%rsp
SET_SIZE(gcc_mov_big_struct_ret, gcc_mov_big_struct_ret_end)

FUNC(gcc_mov_struct_noorder)
pushq   %rbp
movq    %rsp,%rbp
movq    %rcx,-0x18(%rbp)
movq    %r8,-0x20(%rbp)
movq    %rsi,-0x8(%rbp)
movq    %rdx,-0x10(%rbp)
movq    %rbx,-0x28(%rbp)
subq    $0x50,%rsp
SET_SIZE(gcc_mov_struct_noorder, gcc_mov_struct_noorder_end)

FUNC(gcc_mov_big_struct_ret_and_spill)
pushq   %rbp
movq    %rsp,%rbp
movq    %rbx,-0x38(%rbp)
movq    %r9,-0x28(%rbp)
movq    %r8,-0x20(%rbp)
movq    %rcx,-0x18(%rbp)
movq    %rdx,-0x10(%rbp)
movq    %rsi,-0x8(%rbp)
subq    $0x90,%rsp
SET_SIZE(gcc_mov_big_struct_ret_and_spill, gcc_mov_big_struct_ret_and_spill_end)

FUNC(gcc_mov_small_struct_ret)
pushq   %rbp
movq    %rsp,%rbp
movq    %rbx,-0x28(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdi,-0x8(%rbp)
subq    $0x50,%rsp
SET_SIZE(gcc_mov_small_struct_ret, gcc_mov_small_struct_ret_end)

FUNC(gcc_mov_small_struct_ret_and_spill)
pushq   %rbp
movq    %rsp,%rbp
movq    %rbx,-0x38(%rbp)
movq    %r9,-0x30(%rbp)
movq    %r8,-0x28(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdi,-0x8(%rbp)
subq    $0x90,%rsp
SET_SIZE(gcc_mov_small_struct_ret_and_spill, gcc_mov_small_struct_ret_and_spill_end)

FUNC(gcc_mov_stack_spill)
pushq   %rbp
movq    %rsp,%rbp
movq    %rbx,-0x38(%rbp)
movq    %r9,-0x30(%rbp)
movq    %r8,-0x28(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdi,-0x8(%rbp)
subq    $0x90,%rsp
SET_SIZE(gcc_mov_stack_spill, gcc_mov_stack_spill_end)

FUNC(gcc_push_align)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rdi
pushq   %rsi
pushq   %rdx
pushq   %rcx
pushq   %r8
subq    $0x8,%rsp
subq    $0x30,%rsp
SET_SIZE(gcc_push_align, gcc_push_align_end)

FUNC(gcc_push_basic)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rdi
pushq   %rsi
pushq   %rdx
pushq   %rcx
subq    $0x20,%rsp
SET_SIZE(gcc_push_basic, gcc_push_basic_end)

FUNC(gcc_push_noorder)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rsi
pushq   %rdi
pushq   %rcx
pushq   %rdx
subq    $0x20,%rsp
SET_SIZE(gcc_push_noorder, gcc_push_noorder_end)

FUNC(gcc_push_big_struct_ret)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rsi
pushq   %rdx
pushq   %rcx
pushq   %r8
subq    $0x30,%rsp
SET_SIZE(gcc_push_big_struct_ret, gcc_push_big_struct_ret_end)

FUNC(gcc_push_struct_noorder)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rdx
pushq   %rsi
pushq   %r8
pushq   %rcx
subq    $0x30,%rsp
SET_SIZE(gcc_push_struct_noorder, gcc_push_struct_noorder_end)
        
FUNC(gcc_push_big_struct_ret_and_spill)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rsi
pushq   %rdx
pushq   %rcx
pushq   %r8
pushq   %r9
subq    $0x8,%rsp
subq    $0x50,%rsp
SET_SIZE(gcc_push_big_struct_ret_and_spill, gcc_push_big_struct_ret_and_spill_end)

FUNC(gcc_push_small_struct_ret)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rdi
pushq   %rsi
pushq   %rdx
pushq   %rcx
subq    $0x20,%rsp
SET_SIZE(gcc_push_small_struct_ret, gcc_push_small_struct_ret_end)

FUNC(gcc_push_small_struct_ret_and_spill)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rdi
pushq   %rsi
pushq   %rdx
pushq   %rcx
pushq   %r8
pushq   %r9
subq    $0x50,%rsp
SET_SIZE(gcc_push_small_struct_ret_and_spill, gcc_push_small_struct_ret_and_spill_end)

FUNC(gcc_push_stack_spill)
pushq   %rbp
movq    %rsp,%rbp
pushq   %rdi
pushq   %rsi
pushq   %rdx
pushq   %rcx
pushq   %r8
pushq   %r9
subq    $0x50,%rsp
SET_SIZE(gcc_push_stack_spill, gcc_push_stack_spill_end)

FUNC(ss_mov_align)
pushq   %rbp
movq    %rsp,%rbp
subq    $0x30,%rsp
movq    %rdi,-0x8(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %r8,-0x28(%rbp)
SET_SIZE(ss_mov_align, ss_mov_align_end)

FUNC(ss_mov_basic)
pushq   %rbp
movq    %rsp,%rbp
subq    $0x20,%rsp
movq    %rdi,-0x8(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rcx,-0x20(%rbp)
SET_SIZE(ss_mov_basic, ss_mov_basic_end)

FUNC(ss_mov_big_struct_ret)
pushq   %rbp
movq    %rsp,%rbp
subq    $0x30,%rsp
movq    %rdi,-0x8(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %r8,-0x28(%rbp)
SET_SIZE(ss_mov_big_struct_ret, ss_mov_big_struct_ret_end)

FUNC(ss_mov_big_struct_ret_and_spill)
pushq   %rbp
movq    %rsp,%rbp
subq    $0x50,%rsp
movq    %rdi,-0x8(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %r8,-0x28(%rbp)
movq    %r9,-0x30(%rbp)
SET_SIZE(ss_mov_big_struct_ret_and_spill, ss_mov_big_struct_ret_and_spill_end)

FUNC(ss_mov_small_struct_ret)
pushq   %rbp
movq    %rsp,%rbp
subq    $0x20,%rsp
movq    %rdi,-0x8(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rcx,-0x20(%rbp)
SET_SIZE(ss_mov_small_struct_ret, ss_mov_small_struct_ret_end)

FUNC(ss_mov_small_struct_ret_and_spill)
pushq   %rbp
movq    %rsp,%rbp
subq    $0x50,%rsp
movq    %rdi,-0x8(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %r8,-0x28(%rbp)
movq    %r9,-0x30(%rbp)
SET_SIZE(ss_mov_small_struct_ret_and_spill, ss_mov_small_struct_ret_and_spill_end)

FUNC(ss_mov_stack_spill)
pushq   %rbp
movq    %rsp,%rbp
subq    $0x50,%rsp
movq    %rdi,-0x8(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %r8,-0x28(%rbp)
movq    %r9,-0x30(%rbp)
SET_SIZE(ss_mov_stack_spill, ss_mov_stack_spill_end)

/* DTrace instrumentation */
FUNC(dtrace_instrumented)
int	$0x3
movq	%rsp, %rbp
movq	%rbx,-0x28(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdi,-0x8(%rbp)
subq    $0x50,%rsp
SET_SIZE(dtrace_instrumented, dtrace_instrumented_end)

/*
 * System functions with special characteristics, be they non-initial FP save,
 * gaps between FP save and argument saving, or gaps between saved arguments.
 */
FUNC(kmem_alloc)
leaq    -0x1(%rdi),%rax
pushq   %rbp
movq    %rax,%rdx
movq    %rsp,%rbp
subq    $0x30,%rsp
shrq    $0x3,%rdx
movq    %r12,-0x28(%rbp)
movq    %rbx,-0x30(%rbp)
cmpq    $0x1ff,%rdx
movq    %r13,-0x20(%rbp)
movq    %r14,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdi,-0x8(%rbp)
movq    %rdi,%r12
SET_SIZE(kmem_alloc, kmem_alloc_end)

FUNC(uts_kill)
pushq   %rbp
movq    %rsp,%rbp
subq    $0x50,%rsp
movq    %rbx,-0x28(%rbp)
leaq    -0x50(%rbp),%rbx
movq    %r12,-0x20(%rbp)
movq    %r13,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movl    %edi,%r12d
movq    %rdi,-0x8(%rbp)
SET_SIZE(uts_kill, uts_kill_end)

FUNC(av1394_ic_bitreverse)
movq    %rdi,%rdx
movq    $0x5555555555555555,%rax
movq    $0x3333333333333333,%rcx
shrq    $0x1,%rdx
pushq   %rbp
andq    %rax,%rdx
andq    %rdi,%rax
addq    %rax,%rax
movq    %rsp,%rbp
subq    $0x10,%rsp
orq     %rdx,%rax
movq    %rdi,-0x8(%rbp)
SET_SIZE(av1394_ic_bitreverse, av1394_ic_bitreverse_end)

/* Problematic functions which should not match */

FUNC(no_fp) /* No frame pointer */
movq	%rdi, %rsi
movq	%rsi, %rdi
movq	%rbx,-0x28(%rbp)
movq    %rcx,-0x20(%rbp)
movq    %rdx,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdi,-0x8(%rbp)
subq    $0x50,%rsp
SET_SIZE(no_fp, no_fp_end)

/* Small structure return, but with an SSE type (thus forcing it to the stack) */
FUNC(small_struct_ret_w_float)
pushq   %rbp
movq    %rsp,%rbp
movq    %rdi,-0x8(%rbp)
subq    $0x30,%rsp
SET_SIZE(small_struct_ret_w_float, small_struct_ret_w_float_end)

/* Big structure return, but with an SSE type */
FUNC(big_struct_ret_w_float)
pushq  %rbp
movq   %rsp,%rbp
movq   %rsi,-0x8(%rbp)
subq   $0x50,%rsp
movq   %rsi,-0x48(%rbp)
movq   -0x48(%rbp),%rax
movq   %rax,%rsi
movl   $0x400f60,%edi
movl   $0x0,%eax
movl   $0x1770,%edi
movl   $0x0,%eax
leave
ret
SET_SIZE(big_struct_ret_w_float, big_struct_ret_w_float_end)

FUNC(big_struct_arg_by_value)
pushq   %rbp
movq    %rsp,%rbp
movq    %rdi,-0x8(%rbp)
subq    $0x40,%rsp
SET_SIZE(big_struct_arg_by_value, big_struct_arg_by_value_end)

FUNC(small_struct_arg_by_value)
pushq   %rbp
movq    %rsp,%rbp
movq    %rdx,-0x18(%rbp)
movq    %rsi,-0x10(%rbp)
movq    %rdi,-0x8(%rbp)
subq    $0x50,%rsp
SET_SIZE(small_struct_arg_by_value, small_struct_arg_by_value_end)

FUNC(interleaved_argument_saves)
pushq	%rbp
movq	%rdi,%rax
shlq	$0x21,%rax
movq	%rsp,%rbp
shrq	$0x29,%rax
subq	$0x30,%rsp
movq	%rdi,-0x8(%rbp)
movq	%rbx,-0x28(%rbp)
movzbl	%dil,%edi
movq	%rcx,-0x20(%rbp)
movq	%rdx,-0x18(%rbp)
movq	%rsi,-0x10(%rbp)
movq	0x0(,%rax,8),%rax
SET_SIZE(interleaved_argument_saves, interleaved_argument_saves_end)

FUNC(jmp_table)
pushq	%rbp
movq	%rsp,%rbp
.word	0x9afe
.word	0xffff
.word	0xffff
.word	0xa8ff
.word	0xffff
.word	0xffff
.word	0x7cff
.word	0xffff
.word	0xffff
SET_SIZE(jmp_table, jmp_table_end)