]>
Commit | Line | Data |
---|---|---|
d6d4d770 DS |
1 | /* Defines common perprocessor and assembly macros for use by various stubs. |
2 | Copyright (C) 2016-2017 Free Software Foundation, Inc. | |
3 | Contributed by Daniel Santos <daniel.santos@pobox.com> | |
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 | #ifndef I386_ASM_H | |
27 | #define I386_ASM_H | |
28 | ||
89762a83 | 29 | #include "auto-target.h" |
9cbc07cc DS |
30 | #include "auto-host.h" |
31 | ||
3cb626e4 DS |
32 | #define PASTE2(a, b) PASTE2a(a, b) |
33 | #define PASTE2a(a, b) a ## b | |
34 | ||
9cbc07cc DS |
35 | /* These macros currently support GNU/Linux, Solaris and Darwin. */ |
36 | ||
d6d4d770 | 37 | #ifdef __ELF__ |
9cbc07cc DS |
38 | # define FN_TYPE(fn) .type fn,@function |
39 | # define FN_SIZE(fn) .size fn,.-fn | |
40 | # ifdef HAVE_GAS_HIDDEN | |
41 | # define FN_HIDDEN(fn) .hidden fn | |
42 | # endif | |
43 | #else | |
44 | # define FN_TYPE(fn) | |
45 | # define FN_SIZE(fn) | |
46 | #endif | |
47 | ||
48 | #ifndef FN_HIDDEN | |
49 | # define FN_HIDDEN(fn) | |
50 | #endif | |
51 | ||
52 | #ifdef __USER_LABEL_PREFIX__ | |
3cb626e4 | 53 | # define ASMNAME(name) PASTE2(__USER_LABEL_PREFIX__, name) |
d6d4d770 | 54 | #else |
9cbc07cc | 55 | # define ASMNAME(name) name |
d6d4d770 DS |
56 | #endif |
57 | ||
9cbc07cc DS |
58 | #define FUNC_BEGIN(fn) \ |
59 | .globl ASMNAME(fn); \ | |
60 | FN_TYPE (ASMNAME(fn)); \ | |
61 | ASMNAME(fn): | |
d6d4d770 | 62 | |
9cbc07cc DS |
63 | #define HIDDEN_FUNC(fn) \ |
64 | .globl ASMNAME(fn); \ | |
65 | FN_TYPE(ASMNAME(fn)); \ | |
66 | FN_HIDDEN(ASMNAME(fn)); \ | |
67 | ASMNAME(fn): | |
d6d4d770 | 68 | |
9cbc07cc | 69 | #define FUNC_END(fn) FN_SIZE(ASMNAME(fn)) |
d6d4d770 | 70 | |
3cb626e4 DS |
71 | #ifdef MS2SYSV_STUB_AVX |
72 | # define MS2SYSV_STUB_PREFIX __avx_ | |
89762a83 DS |
73 | # ifdef HAVE_AS_AVX |
74 | # define MOVAPS vmovaps | |
75 | # endif | |
3cb626e4 DS |
76 | #elif defined(MS2SYSV_STUB_SSE) |
77 | # define MS2SYSV_STUB_PREFIX __sse_ | |
78 | # define MOVAPS movaps | |
79 | #endif | |
80 | ||
89762a83 | 81 | #ifdef MS2SYSV_STUB_PREFIX |
3cb626e4 DS |
82 | |
83 | # define MS2SYSV_STUB_BEGIN(base_name) \ | |
84 | HIDDEN_FUNC(PASTE2(MS2SYSV_STUB_PREFIX, base_name)) | |
85 | ||
86 | # define MS2SYSV_STUB_END(base_name) \ | |
87 | FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name)) | |
d6d4d770 | 88 | |
89762a83 DS |
89 | /* If expanding for sse or avx and we have assembler support. */ |
90 | # ifdef MOVAPS | |
91 | /* Save SSE registers 6-15 using rax as the base address. */ | |
92 | # define SSE_SAVE \ | |
9cbc07cc DS |
93 | MOVAPS %xmm15,-0x30(%rax); \ |
94 | MOVAPS %xmm14,-0x20(%rax); \ | |
95 | MOVAPS %xmm13,-0x10(%rax); \ | |
96 | MOVAPS %xmm12, (%rax); \ | |
97 | MOVAPS %xmm11, 0x10(%rax); \ | |
98 | MOVAPS %xmm10, 0x20(%rax); \ | |
99 | MOVAPS %xmm9, 0x30(%rax); \ | |
100 | MOVAPS %xmm8, 0x40(%rax); \ | |
101 | MOVAPS %xmm7, 0x50(%rax); \ | |
102 | MOVAPS %xmm6, 0x60(%rax) | |
d6d4d770 | 103 | |
89762a83 DS |
104 | /* Restore SSE registers 6-15 using rsi as the base address. */ |
105 | # define SSE_RESTORE \ | |
9cbc07cc DS |
106 | MOVAPS -0x30(%rsi), %xmm15; \ |
107 | MOVAPS -0x20(%rsi), %xmm14; \ | |
108 | MOVAPS -0x10(%rsi), %xmm13; \ | |
109 | MOVAPS (%rsi), %xmm12; \ | |
110 | MOVAPS 0x10(%rsi), %xmm11; \ | |
111 | MOVAPS 0x20(%rsi), %xmm10; \ | |
112 | MOVAPS 0x30(%rsi), %xmm9 ; \ | |
113 | MOVAPS 0x40(%rsi), %xmm8 ; \ | |
114 | MOVAPS 0x50(%rsi), %xmm7 ; \ | |
115 | MOVAPS 0x60(%rsi), %xmm6 | |
89762a83 DS |
116 | # else /* MOVAPS */ |
117 | /* If the assembler doesn't support AVX then directly emit machine code | |
118 | for the instructions above. */ | |
119 | # define SSE_SAVE \ | |
120 | .byte 0xc5, 0x78, 0x29, 0x78, 0xd0; /* vmovaps %xmm15,-0x30(%rax) */ \ | |
121 | .byte 0xc5, 0x78, 0x29, 0x70, 0xe0; /* vmovaps %xmm14,-0x20(%rax) */ \ | |
122 | .byte 0xc5, 0x78, 0x29, 0x68, 0xf0; /* vmovaps %xmm13,-0x10(%rax) */ \ | |
123 | .byte 0xc5, 0x78, 0x29, 0x20; /* vmovaps %xmm12, (%rax) */ \ | |
124 | .byte 0xc5, 0x78, 0x29, 0x58, 0x10; /* vmovaps %xmm11, 0x10(%rax) */ \ | |
125 | .byte 0xc5, 0x78, 0x29, 0x50, 0x20; /* vmovaps %xmm10, 0x20(%rax) */ \ | |
126 | .byte 0xc5, 0x78, 0x29, 0x48, 0x30; /* vmovaps %xmm9, 0x30(%rax) */ \ | |
127 | .byte 0xc5, 0x78, 0x29, 0x40, 0x40; /* vmovaps %xmm8, 0x40(%rax) */ \ | |
128 | .byte 0xc5, 0xf8, 0x29, 0x78, 0x50; /* vmovaps %xmm7, 0x50(%rax) */ \ | |
129 | .byte 0xc5, 0xf8, 0x29, 0x70, 0x60; /* vmovaps %xmm6, 0x60(%rax) */ | |
130 | # define SSE_RESTORE \ | |
131 | .byte 0xc5, 0x78, 0x28, 0x7e, 0xd0; /* vmovaps -0x30(%rsi),%xmm15 */ \ | |
132 | .byte 0xc5, 0x78, 0x28, 0x76, 0xe0; /* vmovaps -0x20(%rsi),%xmm14 */ \ | |
133 | .byte 0xc5, 0x78, 0x28, 0x6e, 0xf0; /* vmovaps -0x10(%rsi),%xmm13 */ \ | |
134 | .byte 0xc5, 0x78, 0x28, 0x26; /* vmovaps (%rsi),%xmm12 */ \ | |
135 | .byte 0xc5, 0x78, 0x28, 0x5e, 0x10; /* vmovaps 0x10(%rsi),%xmm11 */ \ | |
136 | .byte 0xc5, 0x78, 0x28, 0x56, 0x20; /* vmovaps 0x20(%rsi),%xmm10 */ \ | |
137 | .byte 0xc5, 0x78, 0x28, 0x4e, 0x30; /* vmovaps 0x30(%rsi),%xmm9 */ \ | |
138 | .byte 0xc5, 0x78, 0x28, 0x46, 0x40; /* vmovaps 0x40(%rsi),%xmm8 */ \ | |
139 | .byte 0xc5, 0xf8, 0x28, 0x7e, 0x50; /* vmovaps 0x50(%rsi),%xmm7 */ \ | |
140 | .byte 0xc5, 0xf8, 0x28, 0x76, 0x60; /* vmovaps 0x60(%rsi),%xmm6 */ | |
141 | # endif /* MOVAPS */ | |
142 | #endif /* MS2SYSV_STUB_PREFIX */ | |
d6d4d770 | 143 | #endif /* I386_ASM_H */ |