smbXsrv_client: handle NAME_NOT_FOUND from smb2srv_client_connection_{pass,drop}()
[Samba.git] / third_party / aesni-intel / inst-intel.h
blob95978be17e280af8257d8a6694c694a121ae2383
1 /*
2 * Generate .byte code for some instructions not supported by old
3 * binutils.
4 */
5 #ifndef X86_ASM_INST_H
6 #define X86_ASM_INST_H
8 #define REG_NUM_INVALID 100
10 #define REG_TYPE_R32 0
11 #define REG_TYPE_R64 1
12 #define REG_TYPE_XMM 2
13 #define REG_TYPE_INVALID 100
15 .macro R32_NUM opd r32
16 \opd = REG_NUM_INVALID
17 .ifc \r32,%eax
18 \opd = 0
19 .endif
20 .ifc \r32,%ecx
21 \opd = 1
22 .endif
23 .ifc \r32,%edx
24 \opd = 2
25 .endif
26 .ifc \r32,%ebx
27 \opd = 3
28 .endif
29 .ifc \r32,%esp
30 \opd = 4
31 .endif
32 .ifc \r32,%ebp
33 \opd = 5
34 .endif
35 .ifc \r32,%esi
36 \opd = 6
37 .endif
38 .ifc \r32,%edi
39 \opd = 7
40 .endif
41 #ifdef CONFIG_X86_64
42 .ifc \r32,%r8d
43 \opd = 8
44 .endif
45 .ifc \r32,%r9d
46 \opd = 9
47 .endif
48 .ifc \r32,%r10d
49 \opd = 10
50 .endif
51 .ifc \r32,%r11d
52 \opd = 11
53 .endif
54 .ifc \r32,%r12d
55 \opd = 12
56 .endif
57 .ifc \r32,%r13d
58 \opd = 13
59 .endif
60 .ifc \r32,%r14d
61 \opd = 14
62 .endif
63 .ifc \r32,%r15d
64 \opd = 15
65 .endif
66 #endif
67 .endm
69 .macro R64_NUM opd r64
70 \opd = REG_NUM_INVALID
71 #ifdef CONFIG_X86_64
72 .ifc \r64,%rax
73 \opd = 0
74 .endif
75 .ifc \r64,%rcx
76 \opd = 1
77 .endif
78 .ifc \r64,%rdx
79 \opd = 2
80 .endif
81 .ifc \r64,%rbx
82 \opd = 3
83 .endif
84 .ifc \r64,%rsp
85 \opd = 4
86 .endif
87 .ifc \r64,%rbp
88 \opd = 5
89 .endif
90 .ifc \r64,%rsi
91 \opd = 6
92 .endif
93 .ifc \r64,%rdi
94 \opd = 7
95 .endif
96 .ifc \r64,%r8
97 \opd = 8
98 .endif
99 .ifc \r64,%r9
100 \opd = 9
101 .endif
102 .ifc \r64,%r10
103 \opd = 10
104 .endif
105 .ifc \r64,%r11
106 \opd = 11
107 .endif
108 .ifc \r64,%r12
109 \opd = 12
110 .endif
111 .ifc \r64,%r13
112 \opd = 13
113 .endif
114 .ifc \r64,%r14
115 \opd = 14
116 .endif
117 .ifc \r64,%r15
118 \opd = 15
119 .endif
120 #endif
121 .endm
123 .macro XMM_NUM opd xmm
124 \opd = REG_NUM_INVALID
125 .ifc \xmm,%xmm0
126 \opd = 0
127 .endif
128 .ifc \xmm,%xmm1
129 \opd = 1
130 .endif
131 .ifc \xmm,%xmm2
132 \opd = 2
133 .endif
134 .ifc \xmm,%xmm3
135 \opd = 3
136 .endif
137 .ifc \xmm,%xmm4
138 \opd = 4
139 .endif
140 .ifc \xmm,%xmm5
141 \opd = 5
142 .endif
143 .ifc \xmm,%xmm6
144 \opd = 6
145 .endif
146 .ifc \xmm,%xmm7
147 \opd = 7
148 .endif
149 .ifc \xmm,%xmm8
150 \opd = 8
151 .endif
152 .ifc \xmm,%xmm9
153 \opd = 9
154 .endif
155 .ifc \xmm,%xmm10
156 \opd = 10
157 .endif
158 .ifc \xmm,%xmm11
159 \opd = 11
160 .endif
161 .ifc \xmm,%xmm12
162 \opd = 12
163 .endif
164 .ifc \xmm,%xmm13
165 \opd = 13
166 .endif
167 .ifc \xmm,%xmm14
168 \opd = 14
169 .endif
170 .ifc \xmm,%xmm15
171 \opd = 15
172 .endif
173 .endm
175 .macro REG_TYPE type reg
176 R32_NUM reg_type_r32 \reg
177 R64_NUM reg_type_r64 \reg
178 XMM_NUM reg_type_xmm \reg
179 .if reg_type_r64 <> REG_NUM_INVALID
180 \type = REG_TYPE_R64
181 .elseif reg_type_r32 <> REG_NUM_INVALID
182 \type = REG_TYPE_R32
183 .elseif reg_type_xmm <> REG_NUM_INVALID
184 \type = REG_TYPE_XMM
185 .else
186 \type = REG_TYPE_INVALID
187 .endif
188 .endm
190 .macro PFX_OPD_SIZE
191 .byte 0x66
192 .endm
194 .macro PFX_REX opd1 opd2 W=0
195 .if ((\opd1 | \opd2) & 8) || \W
196 .byte 0x40 | ((\opd1 & 8) >> 3) | ((\opd2 & 8) >> 1) | (\W << 3)
197 .endif
198 .endm
200 .macro MODRM mod opd1 opd2
201 .byte \mod | (\opd1 & 7) | ((\opd2 & 7) << 3)
202 .endm
204 .macro PSHUFB_XMM xmm1 xmm2
205 XMM_NUM pshufb_opd1 \xmm1
206 XMM_NUM pshufb_opd2 \xmm2
207 PFX_OPD_SIZE
208 PFX_REX pshufb_opd1 pshufb_opd2
209 .byte 0x0f, 0x38, 0x00
210 MODRM 0xc0 pshufb_opd1 pshufb_opd2
211 .endm
213 .macro PCLMULQDQ imm8 xmm1 xmm2
214 XMM_NUM clmul_opd1 \xmm1
215 XMM_NUM clmul_opd2 \xmm2
216 PFX_OPD_SIZE
217 PFX_REX clmul_opd1 clmul_opd2
218 .byte 0x0f, 0x3a, 0x44
219 MODRM 0xc0 clmul_opd1 clmul_opd2
220 .byte \imm8
221 .endm
223 .macro PEXTRD imm8 xmm gpr
224 R32_NUM extrd_opd1 \gpr
225 XMM_NUM extrd_opd2 \xmm
226 PFX_OPD_SIZE
227 PFX_REX extrd_opd1 extrd_opd2
228 .byte 0x0f, 0x3a, 0x16
229 MODRM 0xc0 extrd_opd1 extrd_opd2
230 .byte \imm8
231 .endm
233 .macro AESKEYGENASSIST rcon xmm1 xmm2
234 XMM_NUM aeskeygen_opd1 \xmm1
235 XMM_NUM aeskeygen_opd2 \xmm2
236 PFX_OPD_SIZE
237 PFX_REX aeskeygen_opd1 aeskeygen_opd2
238 .byte 0x0f, 0x3a, 0xdf
239 MODRM 0xc0 aeskeygen_opd1 aeskeygen_opd2
240 .byte \rcon
241 .endm
243 .macro AESIMC xmm1 xmm2
244 XMM_NUM aesimc_opd1 \xmm1
245 XMM_NUM aesimc_opd2 \xmm2
246 PFX_OPD_SIZE
247 PFX_REX aesimc_opd1 aesimc_opd2
248 .byte 0x0f, 0x38, 0xdb
249 MODRM 0xc0 aesimc_opd1 aesimc_opd2
250 .endm
252 .macro AESENC xmm1 xmm2
253 XMM_NUM aesenc_opd1 \xmm1
254 XMM_NUM aesenc_opd2 \xmm2
255 PFX_OPD_SIZE
256 PFX_REX aesenc_opd1 aesenc_opd2
257 .byte 0x0f, 0x38, 0xdc
258 MODRM 0xc0 aesenc_opd1 aesenc_opd2
259 .endm
261 .macro AESENCLAST xmm1 xmm2
262 XMM_NUM aesenclast_opd1 \xmm1
263 XMM_NUM aesenclast_opd2 \xmm2
264 PFX_OPD_SIZE
265 PFX_REX aesenclast_opd1 aesenclast_opd2
266 .byte 0x0f, 0x38, 0xdd
267 MODRM 0xc0 aesenclast_opd1 aesenclast_opd2
268 .endm
270 .macro AESDEC xmm1 xmm2
271 XMM_NUM aesdec_opd1 \xmm1
272 XMM_NUM aesdec_opd2 \xmm2
273 PFX_OPD_SIZE
274 PFX_REX aesdec_opd1 aesdec_opd2
275 .byte 0x0f, 0x38, 0xde
276 MODRM 0xc0 aesdec_opd1 aesdec_opd2
277 .endm
279 .macro AESDECLAST xmm1 xmm2
280 XMM_NUM aesdeclast_opd1 \xmm1
281 XMM_NUM aesdeclast_opd2 \xmm2
282 PFX_OPD_SIZE
283 PFX_REX aesdeclast_opd1 aesdeclast_opd2
284 .byte 0x0f, 0x38, 0xdf
285 MODRM 0xc0 aesdeclast_opd1 aesdeclast_opd2
286 .endm
288 .macro MOVQ_R64_XMM opd1 opd2
289 REG_TYPE movq_r64_xmm_opd1_type \opd1
290 .if movq_r64_xmm_opd1_type == REG_TYPE_XMM
291 XMM_NUM movq_r64_xmm_opd1 \opd1
292 R64_NUM movq_r64_xmm_opd2 \opd2
293 .else
294 R64_NUM movq_r64_xmm_opd1 \opd1
295 XMM_NUM movq_r64_xmm_opd2 \opd2
296 .endif
297 PFX_OPD_SIZE
298 PFX_REX movq_r64_xmm_opd1 movq_r64_xmm_opd2 1
299 .if movq_r64_xmm_opd1_type == REG_TYPE_XMM
300 .byte 0x0f, 0x7e
301 .else
302 .byte 0x0f, 0x6e
303 .endif
304 MODRM 0xc0 movq_r64_xmm_opd1 movq_r64_xmm_opd2
305 .endm
306 #endif