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