| 1 |
/* Assembly proxy functions for ms_abi tests. |
| 2 |
Copyright (C) 2016-2025 Free Software Foundation, Inc. |
| 3 |
Contributed by Daniel Santos <[email protected]> |
| 4 |
|
| 5 |
This file is part of GCC. |
| 6 |
|
| 7 |
GCC is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3, or (at your option) |
| 10 |
any later version. |
| 11 |
|
| 12 |
GCC is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
Under Section 7 of GPL version 3, you are granted additional |
| 18 |
permissions described in the GCC Runtime Library Exception, version |
| 19 |
3.1, as published by the Free Software Foundation. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public License and |
| 22 |
a copy of the GCC Runtime Library Exception along with this program; |
| 23 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 24 |
<http://www.gnu.org/licenses/>. */ |
| 25 |
|
| 26 |
#if defined(__x86_64__) && defined(__SSE2__) |
| 27 |
|
| 28 |
/* These macros currently support GNU/Linux, Solaris and Darwin. */ |
| 29 |
|
| 30 |
#ifdef __ELF__ |
| 31 |
# define FN_TYPE(fn) .type fn,@function |
| 32 |
# define FN_SIZE(fn) .size fn,.-fn |
| 33 |
# ifdef __linux__ |
| 34 |
.section .note.GNU-stack,"",@progbits |
| 35 |
# endif |
| 36 |
#else |
| 37 |
# define FN_TYPE(fn) |
| 38 |
# define FN_SIZE(fn) |
| 39 |
#endif |
| 40 |
|
| 41 |
#ifdef __USER_LABEL_PREFIX__ |
| 42 |
# define ASMNAME2(prefix, name) prefix ## name |
| 43 |
# define ASMNAME1(prefix, name) ASMNAME2(prefix, name) |
| 44 |
# define ASMNAME(name) ASMNAME1(__USER_LABEL_PREFIX__, name) |
| 45 |
#else |
| 46 |
# define ASMNAME(name) name |
| 47 |
#endif |
| 48 |
|
| 49 |
#define FUNC_BEGIN(fn) \ |
| 50 |
.globl ASMNAME(fn); \ |
| 51 |
FN_TYPE (ASMNAME(fn)); \ |
| 52 |
ASMNAME(fn): |
| 53 |
|
| 54 |
#define FUNC_END(fn) FN_SIZE(ASMNAME(fn)) |
| 55 |
|
| 56 |
#ifdef __AVX__ |
| 57 |
# define MOVAPS vmovaps |
| 58 |
#else |
| 59 |
# define MOVAPS movaps |
| 60 |
#endif |
| 61 |
|
| 62 |
.text |
| 63 |
|
| 64 |
FUNC_BEGIN(regs_to_mem) |
| 65 |
MOVAPS %xmm6, (%r10) |
| 66 |
MOVAPS %xmm7, 0x10(%r10) |
| 67 |
MOVAPS %xmm8, 0x20(%r10) |
| 68 |
MOVAPS %xmm9, 0x30(%r10) |
| 69 |
MOVAPS %xmm10, 0x40(%r10) |
| 70 |
MOVAPS %xmm11, 0x50(%r10) |
| 71 |
MOVAPS %xmm12, 0x60(%r10) |
| 72 |
MOVAPS %xmm13, 0x70(%r10) |
| 73 |
MOVAPS %xmm14, 0x80(%r10) |
| 74 |
MOVAPS %xmm15, 0x90(%r10) |
| 75 |
mov %rsi, 0xa0(%r10) |
| 76 |
mov %rdi, 0xa8(%r10) |
| 77 |
mov %rbx, 0xb0(%r10) |
| 78 |
mov %rbp, 0xb8(%r10) |
| 79 |
mov %r12, 0xc0(%r10) |
| 80 |
mov %r13, 0xc8(%r10) |
| 81 |
mov %r14, 0xd0(%r10) |
| 82 |
mov %r15, 0xd8(%r10) |
| 83 |
retq |
| 84 |
FUNC_END(regs_to_mem) |
| 85 |
|
| 86 |
FUNC_BEGIN(mem_to_regs) |
| 87 |
MOVAPS (%r10), %xmm6 |
| 88 |
MOVAPS 0x10(%r10),%xmm7 |
| 89 |
MOVAPS 0x20(%r10),%xmm8 |
| 90 |
MOVAPS 0x30(%r10),%xmm9 |
| 91 |
MOVAPS 0x40(%r10),%xmm10 |
| 92 |
MOVAPS 0x50(%r10),%xmm11 |
| 93 |
MOVAPS 0x60(%r10),%xmm12 |
| 94 |
MOVAPS 0x70(%r10),%xmm13 |
| 95 |
MOVAPS 0x80(%r10),%xmm14 |
| 96 |
MOVAPS 0x90(%r10),%xmm15 |
| 97 |
mov 0xa0(%r10),%rsi |
| 98 |
mov 0xa8(%r10),%rdi |
| 99 |
mov 0xb0(%r10),%rbx |
| 100 |
mov 0xb8(%r10),%rbp |
| 101 |
mov 0xc0(%r10),%r12 |
| 102 |
mov 0xc8(%r10),%r13 |
| 103 |
mov 0xd0(%r10),%r14 |
| 104 |
mov 0xd8(%r10),%r15 |
| 105 |
retq |
| 106 |
FUNC_END(mem_to_regs) |
| 107 |
|
| 108 |
# NOTE: Not MT safe |
| 109 |
FUNC_BEGIN(do_test_unaligned) |
| 110 |
# The below alignment checks are to verify correctness of the test |
| 111 |
# its self. |
| 112 |
|
| 113 |
# Verify that incoming stack is aligned + 8 |
| 114 |
test $0xf, %rsp |
| 115 |
je ASMNAME(do_test_body) |
| 116 |
int $3 # Stack not unaligned |
| 117 |
FUNC_END(do_test_unaligned) |
| 118 |
|
| 119 |
FUNC_BEGIN(do_test_aligned) |
| 120 |
# Verify that incoming stack is aligned |
| 121 |
test $0x8, %rsp |
| 122 |
jne ASMNAME(do_test_body) |
| 123 |
int $3 # Stack not aligned |
| 124 |
FUNC_END(do_test_aligned) |
| 125 |
|
| 126 |
#endif /* __x86_64__ */ |