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; \ 21 x: 22 23 #define SET_SIZE(x, x_size) \ 24 .size x, [.-x]; \ 25 .globl x_size; \ 26 .type x_size, @object; \ 27 x_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 */ 44 FUNC(gcc_mov_align) 45 pushq %rbp 46 movq %rsp, %rbp 47 movq %rbx, -0x38(%rbp) 48 movq %r8, -0x28(%rbp) 49 movq %rcx, -0x20(%rbp) 50 movq %rdx, -0x18(%rbp) 51 movq %rsi, -0x10(%rbp) 52 movq %rdi, -0x8(%rbp) 53 subq $0x70, %rsp 54 SET_SIZE(gcc_mov_align, gcc_mov_align_end) 55 56 FUNC(gcc_mov_basic) 57 pushq %rbp 58 movq %rsp, %rbp 59 movq %rbx,-0x28(%rbp) 60 movq %rcx,-0x20(%rbp) 61 movq %rdx,-0x18(%rbp) 62 movq %rsi,-0x10(%rbp) 63 movq %rdi,-0x8(%rbp) 64 subq $0x50,%rsp 65 SET_SIZE(gcc_mov_basic, gcc_mov_basic_end) 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 78 FUNC(gcc_mov_big_struct_ret) 79 pushq %rbp 80 movq %rsp,%rbp 81 movq %rbx,-0x28(%rbp) 82 movq %r8,-0x20(%rbp) 83 movq %rcx,-0x18(%rbp) 84 movq %rdx,-0x10(%rbp) 85 movq %rsi,-0x8(%rbp) 86 subq $0x50,%rsp 87 SET_SIZE(gcc_mov_big_struct_ret, gcc_mov_big_struct_ret_end) 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 100 FUNC(gcc_mov_big_struct_ret_and_spill) 101 pushq %rbp 102 movq %rsp,%rbp 103 movq %rbx,-0x38(%rbp) 104 movq %r9,-0x28(%rbp) 105 movq %r8,-0x20(%rbp) 106 movq %rcx,-0x18(%rbp) 107 movq %rdx,-0x10(%rbp) 108 movq %rsi,-0x8(%rbp) 109 subq $0x90,%rsp 110 SET_SIZE(gcc_mov_big_struct_ret_and_spill, gcc_mov_big_struct_ret_and_spill_end) 111 112 FUNC(gcc_mov_small_struct_ret) 113 pushq %rbp 114 movq %rsp,%rbp 115 movq %rbx,-0x28(%rbp) 116 movq %rcx,-0x20(%rbp) 117 movq %rdx,-0x18(%rbp) 118 movq %rsi,-0x10(%rbp) 119 movq %rdi,-0x8(%rbp) 120 subq $0x50,%rsp 121 SET_SIZE(gcc_mov_small_struct_ret, gcc_mov_small_struct_ret_end) 122 123 FUNC(gcc_mov_small_struct_ret_and_spill) 124 pushq %rbp 125 movq %rsp,%rbp 126 movq %rbx,-0x38(%rbp) 127 movq %r9,-0x30(%rbp) 128 movq %r8,-0x28(%rbp) 129 movq %rcx,-0x20(%rbp) 130 movq %rdx,-0x18(%rbp) 131 movq %rsi,-0x10(%rbp) 132 movq %rdi,-0x8(%rbp) 133 subq $0x90,%rsp 134 SET_SIZE(gcc_mov_small_struct_ret_and_spill, gcc_mov_small_struct_ret_and_spill_end) 135 136 FUNC(gcc_mov_stack_spill) 137 pushq %rbp 138 movq %rsp,%rbp 139 movq %rbx,-0x38(%rbp) 140 movq %r9,-0x30(%rbp) 141 movq %r8,-0x28(%rbp) 142 movq %rcx,-0x20(%rbp) 143 movq %rdx,-0x18(%rbp) 144 movq %rsi,-0x10(%rbp) 145 movq %rdi,-0x8(%rbp) 146 subq $0x90,%rsp 147 SET_SIZE(gcc_mov_stack_spill, gcc_mov_stack_spill_end) 148 149 FUNC(gcc_push_align) 150 pushq %rbp 151 movq %rsp,%rbp 152 pushq %rdi 153 pushq %rsi 154 pushq %rdx 155 pushq %rcx 156 pushq %r8 157 subq $0x8,%rsp 158 subq $0x30,%rsp 159 SET_SIZE(gcc_push_align, gcc_push_align_end) 160 161 FUNC(gcc_push_basic) 162 pushq %rbp 163 movq %rsp,%rbp 164 pushq %rdi 165 pushq %rsi 166 pushq %rdx 167 pushq %rcx 168 subq $0x20,%rsp 169 SET_SIZE(gcc_push_basic, gcc_push_basic_end) 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 181 FUNC(gcc_push_big_struct_ret) 182 pushq %rbp 183 movq %rsp,%rbp 184 pushq %rsi 185 pushq %rdx 186 pushq %rcx 187 pushq %r8 188 subq $0x30,%rsp 189 SET_SIZE(gcc_push_big_struct_ret, gcc_push_big_struct_ret_end) 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 201 FUNC(gcc_push_big_struct_ret_and_spill) 202 pushq %rbp 203 movq %rsp,%rbp 204 pushq %rsi 205 pushq %rdx 206 pushq %rcx 207 pushq %r8 208 pushq %r9 209 subq $0x8,%rsp 210 subq $0x50,%rsp 211 SET_SIZE(gcc_push_big_struct_ret_and_spill, gcc_push_big_struct_ret_and_spill_end) 212 213 FUNC(gcc_push_small_struct_ret) 214 pushq %rbp 215 movq %rsp,%rbp 216 pushq %rdi 217 pushq %rsi 218 pushq %rdx 219 pushq %rcx 220 subq $0x20,%rsp 221 SET_SIZE(gcc_push_small_struct_ret, gcc_push_small_struct_ret_end) 222 223 FUNC(gcc_push_small_struct_ret_and_spill) 224 pushq %rbp 225 movq %rsp,%rbp 226 pushq %rdi 227 pushq %rsi 228 pushq %rdx 229 pushq %rcx 230 pushq %r8 231 pushq %r9 232 subq $0x50,%rsp 233 SET_SIZE(gcc_push_small_struct_ret_and_spill, gcc_push_small_struct_ret_and_spill_end) 234 235 FUNC(gcc_push_stack_spill) 236 pushq %rbp 237 movq %rsp,%rbp 238 pushq %rdi 239 pushq %rsi 240 pushq %rdx 241 pushq %rcx 242 pushq %r8 243 pushq %r9 244 subq $0x50,%rsp 245 SET_SIZE(gcc_push_stack_spill, gcc_push_stack_spill_end) 246 247 FUNC(ss_mov_align) 248 pushq %rbp 249 movq %rsp,%rbp 250 subq $0x30,%rsp 251 movq %rdi,-0x8(%rbp) 252 movq %rsi,-0x10(%rbp) 253 movq %rdx,-0x18(%rbp) 254 movq %rcx,-0x20(%rbp) 255 movq %r8,-0x28(%rbp) 256 SET_SIZE(ss_mov_align, ss_mov_align_end) 257 258 FUNC(ss_mov_basic) 259 pushq %rbp 260 movq %rsp,%rbp 261 subq $0x20,%rsp 262 movq %rdi,-0x8(%rbp) 263 movq %rsi,-0x10(%rbp) 264 movq %rdx,-0x18(%rbp) 265 movq %rcx,-0x20(%rbp) 266 SET_SIZE(ss_mov_basic, ss_mov_basic_end) 267 268 FUNC(ss_mov_big_struct_ret) 269 pushq %rbp 270 movq %rsp,%rbp 271 subq $0x30,%rsp 272 movq %rdi,-0x8(%rbp) 273 movq %rsi,-0x10(%rbp) 274 movq %rdx,-0x18(%rbp) 275 movq %rcx,-0x20(%rbp) 276 movq %r8,-0x28(%rbp) 277 SET_SIZE(ss_mov_big_struct_ret, ss_mov_big_struct_ret_end) 278 279 FUNC(ss_mov_big_struct_ret_and_spill) 280 pushq %rbp 281 movq %rsp,%rbp 282 subq $0x50,%rsp 283 movq %rdi,-0x8(%rbp) 284 movq %rsi,-0x10(%rbp) 285 movq %rdx,-0x18(%rbp) 286 movq %rcx,-0x20(%rbp) 287 movq %r8,-0x28(%rbp) 288 movq %r9,-0x30(%rbp) 289 SET_SIZE(ss_mov_big_struct_ret_and_spill, ss_mov_big_struct_ret_and_spill_end) 290 291 FUNC(ss_mov_small_struct_ret) 292 pushq %rbp 293 movq %rsp,%rbp 294 subq $0x20,%rsp 295 movq %rdi,-0x8(%rbp) 296 movq %rsi,-0x10(%rbp) 297 movq %rdx,-0x18(%rbp) 298 movq %rcx,-0x20(%rbp) 299 SET_SIZE(ss_mov_small_struct_ret, ss_mov_small_struct_ret_end) 300 301 FUNC(ss_mov_small_struct_ret_and_spill) 302 pushq %rbp 303 movq %rsp,%rbp 304 subq $0x50,%rsp 305 movq %rdi,-0x8(%rbp) 306 movq %rsi,-0x10(%rbp) 307 movq %rdx,-0x18(%rbp) 308 movq %rcx,-0x20(%rbp) 309 movq %r8,-0x28(%rbp) 310 movq %r9,-0x30(%rbp) 311 SET_SIZE(ss_mov_small_struct_ret_and_spill, ss_mov_small_struct_ret_and_spill_end) 312 313 FUNC(ss_mov_stack_spill) 314 pushq %rbp 315 movq %rsp,%rbp 316 subq $0x50,%rsp 317 movq %rdi,-0x8(%rbp) 318 movq %rsi,-0x10(%rbp) 319 movq %rdx,-0x18(%rbp) 320 movq %rcx,-0x20(%rbp) 321 movq %r8,-0x28(%rbp) 322 movq %r9,-0x30(%rbp) 323 SET_SIZE(ss_mov_stack_spill, ss_mov_stack_spill_end) 324 325 /* DTrace instrumentation */ 326 FUNC(dtrace_instrumented) 327 int $0x3 328 movq %rsp, %rbp 329 movq %rbx,-0x28(%rbp) 330 movq %rcx,-0x20(%rbp) 331 movq %rdx,-0x18(%rbp) 332 movq %rsi,-0x10(%rbp) 333 movq %rdi,-0x8(%rbp) 334 subq $0x50,%rsp 335 SET_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 */ 341 FUNC(kmem_alloc) 342 leaq -0x1(%rdi),%rax 343 pushq %rbp 344 movq %rax,%rdx 345 movq %rsp,%rbp 346 subq $0x30,%rsp 347 shrq $0x3,%rdx 348 movq %r12,-0x28(%rbp) 349 movq %rbx,-0x30(%rbp) 350 cmpq $0x1ff,%rdx 351 movq %r13,-0x20(%rbp) 352 movq %r14,-0x18(%rbp) 353 movq %rsi,-0x10(%rbp) 354 movq %rdi,-0x8(%rbp) 355 movq %rdi,%r12 356 SET_SIZE(kmem_alloc, kmem_alloc_end) 357 358 FUNC(uts_kill) 359 pushq %rbp 360 movq %rsp,%rbp 361 subq $0x50,%rsp 362 movq %rbx,-0x28(%rbp) 363 leaq -0x50(%rbp),%rbx 364 movq %r12,-0x20(%rbp) 365 movq %r13,-0x18(%rbp) 366 movq %rsi,-0x10(%rbp) 367 movl %edi,%r12d 368 movq %rdi,-0x8(%rbp) 369 SET_SIZE(uts_kill, uts_kill_end) 370 371 FUNC(av1394_ic_bitreverse) 372 movq %rdi,%rdx 373 movq $0x5555555555555555,%rax 374 movq $0x3333333333333333,%rcx 375 shrq $0x1,%rdx 376 pushq %rbp 377 andq %rax,%rdx 378 andq %rdi,%rax 379 addq %rax,%rax 380 movq %rsp,%rbp 381 subq $0x10,%rsp 382 orq %rdx,%rax 383 movq %rdi,-0x8(%rbp) 384 SET_SIZE(av1394_ic_bitreverse, av1394_ic_bitreverse_end) 385 386 /* Problematic functions which should not match */ 387 388 FUNC(no_fp) /* No frame pointer */ 389 movq %rdi, %rsi 390 movq %rsi, %rdi 391 movq %rbx,-0x28(%rbp) 392 movq %rcx,-0x20(%rbp) 393 movq %rdx,-0x18(%rbp) 394 movq %rsi,-0x10(%rbp) 395 movq %rdi,-0x8(%rbp) 396 subq $0x50,%rsp 397 SET_SIZE(no_fp, no_fp_end) 398 399 /* Small structure return, but with an SSE type (thus forcing it to the stack) */ 400 FUNC(small_struct_ret_w_float) 401 pushq %rbp 402 movq %rsp,%rbp 403 movq %rdi,-0x8(%rbp) 404 subq $0x30,%rsp 405 SET_SIZE(small_struct_ret_w_float, small_struct_ret_w_float_end) 406 407 /* Big structure return, but with an SSE type */ 408 FUNC(big_struct_ret_w_float) 409 pushq %rbp 410 movq %rsp,%rbp 411 movq %rsi,-0x8(%rbp) 412 subq $0x50,%rsp 413 movq %rsi,-0x48(%rbp) 414 movq -0x48(%rbp),%rax 415 movq %rax,%rsi 416 movl $0x400f60,%edi 417 movl $0x0,%eax 418 movl $0x1770,%edi 419 movl $0x0,%eax 420 leave 421 ret 422 SET_SIZE(big_struct_ret_w_float, big_struct_ret_w_float_end) 423 424 FUNC(big_struct_arg_by_value) 425 pushq %rbp 426 movq %rsp,%rbp 427 movq %rdi,-0x8(%rbp) 428 subq $0x40,%rsp 429 SET_SIZE(big_struct_arg_by_value, big_struct_arg_by_value_end) 430 431 FUNC(small_struct_arg_by_value) 432 pushq %rbp 433 movq %rsp,%rbp 434 movq %rdx,-0x18(%rbp) 435 movq %rsi,-0x10(%rbp) 436 movq %rdi,-0x8(%rbp) 437 subq $0x50,%rsp 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)