i386-opc.h revision 1.1.1.8 1 1.1 skrll /* Declarations for Intel 80386 opcode table
2 1.1.1.8 christos Copyright (C) 2007-2020 Free Software Foundation, Inc.
3 1.1 skrll
4 1.1 skrll This file is part of the GNU opcodes library.
5 1.1 skrll
6 1.1 skrll This library is free software; you can redistribute it and/or modify
7 1.1 skrll it under the terms of the GNU General Public License as published by
8 1.1 skrll the Free Software Foundation; either version 3, or (at your option)
9 1.1 skrll any later version.
10 1.1 skrll
11 1.1 skrll It is distributed in the hope that it will be useful, but WITHOUT
12 1.1 skrll ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 1.1 skrll or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 1.1 skrll License for more details.
15 1.1 skrll
16 1.1 skrll You should have received a copy of the GNU General Public License
17 1.1 skrll along with GAS; see the file COPYING. If not, write to the Free
18 1.1 skrll Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19 1.1 skrll 02110-1301, USA. */
20 1.1 skrll
21 1.1 skrll #include "opcode/i386.h"
22 1.1 skrll #ifdef HAVE_LIMITS_H
23 1.1 skrll #include <limits.h>
24 1.1 skrll #endif
25 1.1 skrll
26 1.1 skrll #ifndef CHAR_BIT
27 1.1 skrll #define CHAR_BIT 8
28 1.1 skrll #endif
29 1.1 skrll
30 1.1 skrll /* Position of cpu flags bitfiled. */
31 1.1 skrll
32 1.1.1.2 christos enum
33 1.1.1.2 christos {
34 1.1.1.2 christos /* i186 or better required */
35 1.1.1.2 christos Cpu186 = 0,
36 1.1.1.2 christos /* i286 or better required */
37 1.1.1.2 christos Cpu286,
38 1.1.1.2 christos /* i386 or better required */
39 1.1.1.2 christos Cpu386,
40 1.1.1.2 christos /* i486 or better required */
41 1.1.1.2 christos Cpu486,
42 1.1.1.2 christos /* i585 or better required */
43 1.1.1.2 christos Cpu586,
44 1.1.1.2 christos /* i686 or better required */
45 1.1.1.2 christos Cpu686,
46 1.1.1.8 christos /* CMOV Instruction support required */
47 1.1.1.8 christos CpuCMOV,
48 1.1.1.8 christos /* FXSR Instruction support required */
49 1.1.1.8 christos CpuFXSR,
50 1.1.1.2 christos /* CLFLUSH Instruction support required */
51 1.1.1.2 christos CpuClflush,
52 1.1.1.2 christos /* NOP Instruction support required */
53 1.1.1.2 christos CpuNop,
54 1.1.1.2 christos /* SYSCALL Instructions support required */
55 1.1.1.2 christos CpuSYSCALL,
56 1.1.1.2 christos /* Floating point support required */
57 1.1.1.2 christos Cpu8087,
58 1.1.1.2 christos /* i287 support required */
59 1.1.1.2 christos Cpu287,
60 1.1.1.2 christos /* i387 support required */
61 1.1.1.2 christos Cpu387,
62 1.1.1.2 christos /* i686 and floating point support required */
63 1.1.1.2 christos Cpu687,
64 1.1.1.2 christos /* SSE3 and floating point support required */
65 1.1.1.2 christos CpuFISTTP,
66 1.1.1.2 christos /* MMX support required */
67 1.1.1.2 christos CpuMMX,
68 1.1.1.2 christos /* SSE support required */
69 1.1.1.2 christos CpuSSE,
70 1.1.1.2 christos /* SSE2 support required */
71 1.1.1.2 christos CpuSSE2,
72 1.1.1.2 christos /* 3dnow! support required */
73 1.1.1.2 christos Cpu3dnow,
74 1.1.1.2 christos /* 3dnow! Extensions support required */
75 1.1.1.2 christos Cpu3dnowA,
76 1.1.1.2 christos /* SSE3 support required */
77 1.1.1.2 christos CpuSSE3,
78 1.1.1.2 christos /* VIA PadLock required */
79 1.1.1.2 christos CpuPadLock,
80 1.1.1.2 christos /* AMD Secure Virtual Machine Ext-s required */
81 1.1.1.2 christos CpuSVME,
82 1.1.1.2 christos /* VMX Instructions required */
83 1.1.1.2 christos CpuVMX,
84 1.1.1.2 christos /* SMX Instructions required */
85 1.1.1.2 christos CpuSMX,
86 1.1.1.2 christos /* SSSE3 support required */
87 1.1.1.2 christos CpuSSSE3,
88 1.1.1.2 christos /* SSE4a support required */
89 1.1.1.2 christos CpuSSE4a,
90 1.1.1.2 christos /* ABM New Instructions required */
91 1.1.1.2 christos CpuABM,
92 1.1.1.2 christos /* SSE4.1 support required */
93 1.1.1.2 christos CpuSSE4_1,
94 1.1.1.2 christos /* SSE4.2 support required */
95 1.1.1.2 christos CpuSSE4_2,
96 1.1.1.2 christos /* AVX support required */
97 1.1.1.2 christos CpuAVX,
98 1.1.1.3 christos /* AVX2 support required */
99 1.1.1.3 christos CpuAVX2,
100 1.1.1.4 christos /* Intel AVX-512 Foundation Instructions support required */
101 1.1.1.4 christos CpuAVX512F,
102 1.1.1.4 christos /* Intel AVX-512 Conflict Detection Instructions support required */
103 1.1.1.4 christos CpuAVX512CD,
104 1.1.1.4 christos /* Intel AVX-512 Exponential and Reciprocal Instructions support
105 1.1.1.4 christos required */
106 1.1.1.4 christos CpuAVX512ER,
107 1.1.1.4 christos /* Intel AVX-512 Prefetch Instructions support required */
108 1.1.1.4 christos CpuAVX512PF,
109 1.1.1.4 christos /* Intel AVX-512 VL Instructions support required. */
110 1.1.1.4 christos CpuAVX512VL,
111 1.1.1.4 christos /* Intel AVX-512 DQ Instructions support required. */
112 1.1.1.4 christos CpuAVX512DQ,
113 1.1.1.4 christos /* Intel AVX-512 BW Instructions support required. */
114 1.1.1.4 christos CpuAVX512BW,
115 1.1.1.2 christos /* Intel L1OM support required */
116 1.1.1.2 christos CpuL1OM,
117 1.1.1.3 christos /* Intel K1OM support required */
118 1.1.1.3 christos CpuK1OM,
119 1.1.1.4 christos /* Intel IAMCU support required */
120 1.1.1.4 christos CpuIAMCU,
121 1.1.1.2 christos /* Xsave/xrstor New Instructions support required */
122 1.1.1.2 christos CpuXsave,
123 1.1.1.2 christos /* Xsaveopt New Instructions support required */
124 1.1.1.2 christos CpuXsaveopt,
125 1.1.1.2 christos /* AES support required */
126 1.1.1.2 christos CpuAES,
127 1.1.1.2 christos /* PCLMUL support required */
128 1.1.1.2 christos CpuPCLMUL,
129 1.1.1.2 christos /* FMA support required */
130 1.1.1.2 christos CpuFMA,
131 1.1.1.2 christos /* FMA4 support required */
132 1.1.1.2 christos CpuFMA4,
133 1.1.1.2 christos /* XOP support required */
134 1.1.1.2 christos CpuXOP,
135 1.1.1.2 christos /* LWP support required */
136 1.1.1.2 christos CpuLWP,
137 1.1.1.3 christos /* BMI support required */
138 1.1.1.3 christos CpuBMI,
139 1.1.1.3 christos /* TBM support required */
140 1.1.1.3 christos CpuTBM,
141 1.1.1.2 christos /* MOVBE Instruction support required */
142 1.1.1.2 christos CpuMovbe,
143 1.1.1.4 christos /* CMPXCHG16B instruction support required. */
144 1.1.1.4 christos CpuCX16,
145 1.1.1.2 christos /* EPT Instructions required */
146 1.1.1.2 christos CpuEPT,
147 1.1.1.2 christos /* RDTSCP Instruction support required */
148 1.1.1.2 christos CpuRdtscp,
149 1.1.1.2 christos /* FSGSBASE Instructions required */
150 1.1.1.2 christos CpuFSGSBase,
151 1.1.1.2 christos /* RDRND Instructions required */
152 1.1.1.2 christos CpuRdRnd,
153 1.1.1.2 christos /* F16C Instructions required */
154 1.1.1.2 christos CpuF16C,
155 1.1.1.3 christos /* Intel BMI2 support required */
156 1.1.1.3 christos CpuBMI2,
157 1.1.1.3 christos /* LZCNT support required */
158 1.1.1.3 christos CpuLZCNT,
159 1.1.1.3 christos /* HLE support required */
160 1.1.1.3 christos CpuHLE,
161 1.1.1.3 christos /* RTM support required */
162 1.1.1.3 christos CpuRTM,
163 1.1.1.3 christos /* INVPCID Instructions required */
164 1.1.1.3 christos CpuINVPCID,
165 1.1.1.3 christos /* VMFUNC Instruction required */
166 1.1.1.3 christos CpuVMFUNC,
167 1.1.1.4 christos /* Intel MPX Instructions required */
168 1.1.1.4 christos CpuMPX,
169 1.1.1.2 christos /* 64bit support available, used by -march= in assembler. */
170 1.1.1.2 christos CpuLM,
171 1.1.1.3 christos /* RDRSEED instruction required. */
172 1.1.1.3 christos CpuRDSEED,
173 1.1.1.3 christos /* Multi-presisionn add-carry instructions are required. */
174 1.1.1.3 christos CpuADX,
175 1.1.1.3 christos /* Supports prefetchw and prefetch instructions. */
176 1.1.1.3 christos CpuPRFCHW,
177 1.1.1.4 christos /* SMAP instructions required. */
178 1.1.1.4 christos CpuSMAP,
179 1.1.1.4 christos /* SHA instructions required. */
180 1.1.1.4 christos CpuSHA,
181 1.1.1.4 christos /* CLFLUSHOPT instruction required */
182 1.1.1.4 christos CpuClflushOpt,
183 1.1.1.4 christos /* XSAVES/XRSTORS instruction required */
184 1.1.1.4 christos CpuXSAVES,
185 1.1.1.4 christos /* XSAVEC instruction required */
186 1.1.1.4 christos CpuXSAVEC,
187 1.1.1.4 christos /* PREFETCHWT1 instruction required */
188 1.1.1.4 christos CpuPREFETCHWT1,
189 1.1.1.4 christos /* SE1 instruction required */
190 1.1.1.4 christos CpuSE1,
191 1.1.1.4 christos /* CLWB instruction required */
192 1.1.1.4 christos CpuCLWB,
193 1.1.1.4 christos /* Intel AVX-512 IFMA Instructions support required. */
194 1.1.1.4 christos CpuAVX512IFMA,
195 1.1.1.4 christos /* Intel AVX-512 VBMI Instructions support required. */
196 1.1.1.4 christos CpuAVX512VBMI,
197 1.1.1.6 christos /* Intel AVX-512 4FMAPS Instructions support required. */
198 1.1.1.6 christos CpuAVX512_4FMAPS,
199 1.1.1.6 christos /* Intel AVX-512 4VNNIW Instructions support required. */
200 1.1.1.6 christos CpuAVX512_4VNNIW,
201 1.1.1.6 christos /* Intel AVX-512 VPOPCNTDQ Instructions support required. */
202 1.1.1.6 christos CpuAVX512_VPOPCNTDQ,
203 1.1.1.6 christos /* Intel AVX-512 VBMI2 Instructions support required. */
204 1.1.1.6 christos CpuAVX512_VBMI2,
205 1.1.1.6 christos /* Intel AVX-512 VNNI Instructions support required. */
206 1.1.1.6 christos CpuAVX512_VNNI,
207 1.1.1.6 christos /* Intel AVX-512 BITALG Instructions support required. */
208 1.1.1.6 christos CpuAVX512_BITALG,
209 1.1.1.8 christos /* Intel AVX-512 BF16 Instructions support required. */
210 1.1.1.8 christos CpuAVX512_BF16,
211 1.1.1.8 christos /* Intel AVX-512 VP2INTERSECT Instructions support required. */
212 1.1.1.8 christos CpuAVX512_VP2INTERSECT,
213 1.1.1.4 christos /* mwaitx instruction required */
214 1.1.1.4 christos CpuMWAITX,
215 1.1.1.4 christos /* Clzero instruction required */
216 1.1.1.4 christos CpuCLZERO,
217 1.1.1.4 christos /* OSPKE instruction required */
218 1.1.1.4 christos CpuOSPKE,
219 1.1.1.5 christos /* RDPID instruction required */
220 1.1.1.5 christos CpuRDPID,
221 1.1.1.6 christos /* PTWRITE instruction required */
222 1.1.1.6 christos CpuPTWRITE,
223 1.1.1.7 christos /* CET instructions support required */
224 1.1.1.7 christos CpuIBT,
225 1.1.1.7 christos CpuSHSTK,
226 1.1.1.6 christos /* GFNI instructions required */
227 1.1.1.6 christos CpuGFNI,
228 1.1.1.6 christos /* VAES instructions required */
229 1.1.1.6 christos CpuVAES,
230 1.1.1.6 christos /* VPCLMULQDQ instructions required */
231 1.1.1.6 christos CpuVPCLMULQDQ,
232 1.1.1.7 christos /* WBNOINVD instructions required */
233 1.1.1.7 christos CpuWBNOINVD,
234 1.1.1.7 christos /* PCONFIG instructions required */
235 1.1.1.7 christos CpuPCONFIG,
236 1.1.1.7 christos /* WAITPKG instructions required */
237 1.1.1.7 christos CpuWAITPKG,
238 1.1.1.7 christos /* CLDEMOTE instruction required */
239 1.1.1.7 christos CpuCLDEMOTE,
240 1.1.1.7 christos /* MOVDIRI instruction support required */
241 1.1.1.7 christos CpuMOVDIRI,
242 1.1.1.7 christos /* MOVDIRR64B instruction required */
243 1.1.1.7 christos CpuMOVDIR64B,
244 1.1.1.8 christos /* ENQCMD instruction required */
245 1.1.1.8 christos CpuENQCMD,
246 1.1.1.8 christos /* RDPRU instruction required */
247 1.1.1.8 christos CpuRDPRU,
248 1.1.1.8 christos /* MCOMMIT instruction required */
249 1.1.1.8 christos CpuMCOMMIT,
250 1.1.1.2 christos /* 64bit support required */
251 1.1.1.2 christos Cpu64,
252 1.1.1.2 christos /* Not supported in the 64bit mode */
253 1.1.1.2 christos CpuNo64,
254 1.1.1.2 christos /* The last bitfield in i386_cpu_flags. */
255 1.1.1.2 christos CpuMax = CpuNo64
256 1.1.1.2 christos };
257 1.1 skrll
258 1.1 skrll #define CpuNumOfUints \
259 1.1 skrll (CpuMax / sizeof (unsigned int) / CHAR_BIT + 1)
260 1.1 skrll #define CpuNumOfBits \
261 1.1 skrll (CpuNumOfUints * sizeof (unsigned int) * CHAR_BIT)
262 1.1 skrll
263 1.1 skrll /* If you get a compiler error for zero width of the unused field,
264 1.1 skrll comment it out. */
265 1.1 skrll #define CpuUnused (CpuMax + 1)
266 1.1 skrll
267 1.1 skrll /* We can check if an instruction is available with array instead
268 1.1 skrll of bitfield. */
269 1.1 skrll typedef union i386_cpu_flags
270 1.1 skrll {
271 1.1 skrll struct
272 1.1 skrll {
273 1.1 skrll unsigned int cpui186:1;
274 1.1 skrll unsigned int cpui286:1;
275 1.1 skrll unsigned int cpui386:1;
276 1.1 skrll unsigned int cpui486:1;
277 1.1 skrll unsigned int cpui586:1;
278 1.1 skrll unsigned int cpui686:1;
279 1.1.1.8 christos unsigned int cpucmov:1;
280 1.1.1.8 christos unsigned int cpufxsr:1;
281 1.1.1.2 christos unsigned int cpuclflush:1;
282 1.1.1.2 christos unsigned int cpunop:1;
283 1.1.1.2 christos unsigned int cpusyscall:1;
284 1.1.1.2 christos unsigned int cpu8087:1;
285 1.1.1.2 christos unsigned int cpu287:1;
286 1.1.1.2 christos unsigned int cpu387:1;
287 1.1.1.2 christos unsigned int cpu687:1;
288 1.1.1.2 christos unsigned int cpufisttp:1;
289 1.1 skrll unsigned int cpummx:1;
290 1.1 skrll unsigned int cpusse:1;
291 1.1 skrll unsigned int cpusse2:1;
292 1.1 skrll unsigned int cpua3dnow:1;
293 1.1 skrll unsigned int cpua3dnowa:1;
294 1.1 skrll unsigned int cpusse3:1;
295 1.1 skrll unsigned int cpupadlock:1;
296 1.1 skrll unsigned int cpusvme:1;
297 1.1 skrll unsigned int cpuvmx:1;
298 1.1 skrll unsigned int cpusmx:1;
299 1.1 skrll unsigned int cpussse3:1;
300 1.1 skrll unsigned int cpusse4a:1;
301 1.1 skrll unsigned int cpuabm:1;
302 1.1 skrll unsigned int cpusse4_1:1;
303 1.1 skrll unsigned int cpusse4_2:1;
304 1.1 skrll unsigned int cpuavx:1;
305 1.1.1.3 christos unsigned int cpuavx2:1;
306 1.1.1.4 christos unsigned int cpuavx512f:1;
307 1.1.1.4 christos unsigned int cpuavx512cd:1;
308 1.1.1.4 christos unsigned int cpuavx512er:1;
309 1.1.1.4 christos unsigned int cpuavx512pf:1;
310 1.1.1.4 christos unsigned int cpuavx512vl:1;
311 1.1.1.4 christos unsigned int cpuavx512dq:1;
312 1.1.1.4 christos unsigned int cpuavx512bw:1;
313 1.1.1.2 christos unsigned int cpul1om:1;
314 1.1.1.3 christos unsigned int cpuk1om:1;
315 1.1.1.4 christos unsigned int cpuiamcu:1;
316 1.1 skrll unsigned int cpuxsave:1;
317 1.1.1.2 christos unsigned int cpuxsaveopt:1;
318 1.1 skrll unsigned int cpuaes:1;
319 1.1 skrll unsigned int cpupclmul:1;
320 1.1 skrll unsigned int cpufma:1;
321 1.1.1.2 christos unsigned int cpufma4:1;
322 1.1.1.2 christos unsigned int cpuxop:1;
323 1.1.1.2 christos unsigned int cpulwp:1;
324 1.1.1.3 christos unsigned int cpubmi:1;
325 1.1.1.3 christos unsigned int cputbm:1;
326 1.1 skrll unsigned int cpumovbe:1;
327 1.1.1.4 christos unsigned int cpucx16:1;
328 1.1 skrll unsigned int cpuept:1;
329 1.1.1.2 christos unsigned int cpurdtscp:1;
330 1.1.1.2 christos unsigned int cpufsgsbase:1;
331 1.1.1.2 christos unsigned int cpurdrnd:1;
332 1.1.1.2 christos unsigned int cpuf16c:1;
333 1.1.1.3 christos unsigned int cpubmi2:1;
334 1.1.1.3 christos unsigned int cpulzcnt:1;
335 1.1.1.3 christos unsigned int cpuhle:1;
336 1.1.1.3 christos unsigned int cpurtm:1;
337 1.1.1.3 christos unsigned int cpuinvpcid:1;
338 1.1.1.3 christos unsigned int cpuvmfunc:1;
339 1.1.1.4 christos unsigned int cpumpx:1;
340 1.1 skrll unsigned int cpulm:1;
341 1.1.1.3 christos unsigned int cpurdseed:1;
342 1.1.1.3 christos unsigned int cpuadx:1;
343 1.1.1.3 christos unsigned int cpuprfchw:1;
344 1.1.1.4 christos unsigned int cpusmap:1;
345 1.1.1.4 christos unsigned int cpusha:1;
346 1.1.1.4 christos unsigned int cpuclflushopt:1;
347 1.1.1.4 christos unsigned int cpuxsaves:1;
348 1.1.1.4 christos unsigned int cpuxsavec:1;
349 1.1.1.4 christos unsigned int cpuprefetchwt1:1;
350 1.1.1.4 christos unsigned int cpuse1:1;
351 1.1.1.4 christos unsigned int cpuclwb:1;
352 1.1.1.4 christos unsigned int cpuavx512ifma:1;
353 1.1.1.4 christos unsigned int cpuavx512vbmi:1;
354 1.1.1.6 christos unsigned int cpuavx512_4fmaps:1;
355 1.1.1.6 christos unsigned int cpuavx512_4vnniw:1;
356 1.1.1.6 christos unsigned int cpuavx512_vpopcntdq:1;
357 1.1.1.6 christos unsigned int cpuavx512_vbmi2:1;
358 1.1.1.6 christos unsigned int cpuavx512_vnni:1;
359 1.1.1.6 christos unsigned int cpuavx512_bitalg:1;
360 1.1.1.8 christos unsigned int cpuavx512_bf16:1;
361 1.1.1.8 christos unsigned int cpuavx512_vp2intersect:1;
362 1.1.1.4 christos unsigned int cpumwaitx:1;
363 1.1.1.4 christos unsigned int cpuclzero:1;
364 1.1.1.4 christos unsigned int cpuospke:1;
365 1.1.1.5 christos unsigned int cpurdpid:1;
366 1.1.1.6 christos unsigned int cpuptwrite:1;
367 1.1.1.7 christos unsigned int cpuibt:1;
368 1.1.1.7 christos unsigned int cpushstk:1;
369 1.1.1.6 christos unsigned int cpugfni:1;
370 1.1.1.6 christos unsigned int cpuvaes:1;
371 1.1.1.6 christos unsigned int cpuvpclmulqdq:1;
372 1.1.1.7 christos unsigned int cpuwbnoinvd:1;
373 1.1.1.7 christos unsigned int cpupconfig:1;
374 1.1.1.7 christos unsigned int cpuwaitpkg:1;
375 1.1.1.7 christos unsigned int cpucldemote:1;
376 1.1.1.7 christos unsigned int cpumovdiri:1;
377 1.1.1.7 christos unsigned int cpumovdir64b:1;
378 1.1.1.8 christos unsigned int cpuenqcmd:1;
379 1.1.1.8 christos unsigned int cpurdpru:1;
380 1.1.1.8 christos unsigned int cpumcommit:1;
381 1.1 skrll unsigned int cpu64:1;
382 1.1 skrll unsigned int cpuno64:1;
383 1.1 skrll #ifdef CpuUnused
384 1.1 skrll unsigned int unused:(CpuNumOfBits - CpuUnused);
385 1.1 skrll #endif
386 1.1 skrll } bitfield;
387 1.1 skrll unsigned int array[CpuNumOfUints];
388 1.1 skrll } i386_cpu_flags;
389 1.1 skrll
390 1.1 skrll /* Position of opcode_modifier bits. */
391 1.1 skrll
392 1.1.1.2 christos enum
393 1.1.1.2 christos {
394 1.1.1.2 christos /* has direction bit. */
395 1.1.1.2 christos D = 0,
396 1.1.1.8 christos /* set if operands can be both bytes and words/dwords/qwords, encoded the
397 1.1.1.8 christos canonical way; the base_opcode field should hold the encoding for byte
398 1.1.1.8 christos operands */
399 1.1.1.2 christos W,
400 1.1.1.6 christos /* load form instruction. Must be placed before store form. */
401 1.1.1.6 christos Load,
402 1.1.1.2 christos /* insn has a modrm byte. */
403 1.1.1.2 christos Modrm,
404 1.1.1.2 christos /* register is in low 3 bits of opcode */
405 1.1.1.2 christos ShortForm,
406 1.1.1.8 christos /* special case for jump insns; value has to be 1 */
407 1.1.1.8 christos #define JUMP 1
408 1.1.1.2 christos /* call and jump */
409 1.1.1.8 christos #define JUMP_DWORD 2
410 1.1.1.2 christos /* loop and jecxz */
411 1.1.1.8 christos #define JUMP_BYTE 3
412 1.1.1.2 christos /* special case for intersegment leaps/calls */
413 1.1.1.8 christos #define JUMP_INTERSEGMENT 4
414 1.1.1.8 christos /* absolute address for jump */
415 1.1.1.8 christos #define JUMP_ABSOLUTE 5
416 1.1.1.8 christos Jump,
417 1.1.1.2 christos /* FP insn memory format bit, sized by 0x4 */
418 1.1.1.2 christos FloatMF,
419 1.1.1.2 christos /* src/dest swap for floats. */
420 1.1.1.2 christos FloatR,
421 1.1.1.2 christos /* needs size prefix if in 32-bit mode */
422 1.1.1.8 christos #define SIZE16 1
423 1.1.1.2 christos /* needs size prefix if in 16-bit mode */
424 1.1.1.8 christos #define SIZE32 2
425 1.1.1.2 christos /* needs size prefix if in 64-bit mode */
426 1.1.1.8 christos #define SIZE64 3
427 1.1.1.8 christos Size,
428 1.1.1.2 christos /* check register size. */
429 1.1.1.2 christos CheckRegSize,
430 1.1.1.2 christos /* instruction ignores operand size prefix and in Intel mode ignores
431 1.1.1.2 christos mnemonic size suffix check. */
432 1.1.1.2 christos IgnoreSize,
433 1.1.1.2 christos /* default insn size depends on mode */
434 1.1.1.2 christos DefaultSize,
435 1.1.1.8 christos /* any memory size */
436 1.1.1.8 christos Anysize,
437 1.1.1.2 christos /* b suffix on instruction illegal */
438 1.1.1.2 christos No_bSuf,
439 1.1.1.2 christos /* w suffix on instruction illegal */
440 1.1.1.2 christos No_wSuf,
441 1.1.1.2 christos /* l suffix on instruction illegal */
442 1.1.1.2 christos No_lSuf,
443 1.1.1.2 christos /* s suffix on instruction illegal */
444 1.1.1.2 christos No_sSuf,
445 1.1.1.2 christos /* q suffix on instruction illegal */
446 1.1.1.2 christos No_qSuf,
447 1.1.1.2 christos /* long double suffix on instruction illegal */
448 1.1.1.2 christos No_ldSuf,
449 1.1.1.2 christos /* instruction needs FWAIT */
450 1.1.1.2 christos FWait,
451 1.1.1.8 christos /* IsString provides for a quick test for string instructions, and
452 1.1.1.8 christos its actual value also indicates which of the operands (if any)
453 1.1.1.8 christos requires use of the %es segment. */
454 1.1.1.8 christos #define IS_STRING_ES_OP0 2
455 1.1.1.8 christos #define IS_STRING_ES_OP1 3
456 1.1.1.2 christos IsString,
457 1.1.1.8 christos /* RegMem is for instructions with a modrm byte where the register
458 1.1.1.8 christos destination operand should be encoded in the mod and regmem fields.
459 1.1.1.8 christos Normally, it will be encoded in the reg field. We add a RegMem
460 1.1.1.8 christos flag to indicate that it should be encoded in the regmem field. */
461 1.1.1.8 christos RegMem,
462 1.1.1.4 christos /* quick test if branch instruction is MPX supported */
463 1.1.1.4 christos BNDPrefixOk,
464 1.1.1.6 christos /* quick test if NOTRACK prefix is supported */
465 1.1.1.6 christos NoTrackPrefixOk,
466 1.1.1.2 christos /* quick test for lockable instructions */
467 1.1.1.2 christos IsLockable,
468 1.1.1.2 christos /* fake an extra reg operand for clr, imul and special register
469 1.1.1.2 christos processing for some instructions. */
470 1.1.1.2 christos RegKludge,
471 1.1.1.2 christos /* An implicit xmm0 as the first operand */
472 1.1.1.2 christos Implicit1stXmm0,
473 1.1.1.3 christos /* The HLE prefix is OK:
474 1.1.1.3 christos 1. With a LOCK prefix.
475 1.1.1.3 christos 2. With or without a LOCK prefix.
476 1.1.1.3 christos 3. With a RELEASE (0xf3) prefix.
477 1.1.1.3 christos */
478 1.1.1.3 christos #define HLEPrefixNone 0
479 1.1.1.3 christos #define HLEPrefixLock 1
480 1.1.1.3 christos #define HLEPrefixAny 2
481 1.1.1.3 christos #define HLEPrefixRelease 3
482 1.1.1.3 christos HLEPrefixOk,
483 1.1.1.3 christos /* An instruction on which a "rep" prefix is acceptable. */
484 1.1.1.3 christos RepPrefixOk,
485 1.1.1.2 christos /* Convert to DWORD */
486 1.1.1.2 christos ToDword,
487 1.1.1.2 christos /* Convert to QWORD */
488 1.1.1.2 christos ToQword,
489 1.1.1.7 christos /* Address prefix changes register operand */
490 1.1.1.7 christos AddrPrefixOpReg,
491 1.1.1.2 christos /* opcode is a prefix */
492 1.1.1.2 christos IsPrefix,
493 1.1.1.2 christos /* instruction has extension in 8 bit imm */
494 1.1.1.2 christos ImmExt,
495 1.1.1.2 christos /* instruction don't need Rex64 prefix. */
496 1.1.1.2 christos NoRex64,
497 1.1.1.2 christos /* instruction require Rex64 prefix. */
498 1.1.1.2 christos Rex64,
499 1.1.1.2 christos /* deprecated fp insn, gets a warning */
500 1.1.1.2 christos Ugh,
501 1.1.1.2 christos /* insn has VEX prefix:
502 1.1.1.6 christos 1: 128bit VEX prefix (or operand dependent).
503 1.1.1.2 christos 2: 256bit VEX prefix.
504 1.1.1.2 christos 3: Scalar VEX prefix.
505 1.1.1.2 christos */
506 1.1.1.2 christos #define VEX128 1
507 1.1.1.2 christos #define VEX256 2
508 1.1.1.2 christos #define VEXScalar 3
509 1.1.1.2 christos Vex,
510 1.1.1.2 christos /* How to encode VEX.vvvv:
511 1.1.1.2 christos 0: VEX.vvvv must be 1111b.
512 1.1.1.2 christos 1: VEX.NDS. Register-only source is encoded in VEX.vvvv where
513 1.1.1.2 christos the content of source registers will be preserved.
514 1.1.1.3 christos VEX.DDS. The second register operand is encoded in VEX.vvvv
515 1.1.1.2 christos where the content of first source register will be overwritten
516 1.1.1.2 christos by the result.
517 1.1.1.3 christos VEX.NDD2. The second destination register operand is encoded in
518 1.1.1.3 christos VEX.vvvv for instructions with 2 destination register operands.
519 1.1.1.3 christos For assembler, there are no difference between VEX.NDS, VEX.DDS
520 1.1.1.3 christos and VEX.NDD2.
521 1.1.1.3 christos 2. VEX.NDD. Register destination is encoded in VEX.vvvv for
522 1.1.1.3 christos instructions with 1 destination register operand.
523 1.1.1.2 christos 3. VEX.LWP. Register destination is encoded in VEX.vvvv and one
524 1.1.1.2 christos of the operands can access a memory location.
525 1.1.1.2 christos */
526 1.1.1.2 christos #define VEXXDS 1
527 1.1.1.2 christos #define VEXNDD 2
528 1.1.1.2 christos #define VEXLWP 3
529 1.1.1.2 christos VexVVVV,
530 1.1.1.2 christos /* How the VEX.W bit is used:
531 1.1.1.2 christos 0: Set by the REX.W bit.
532 1.1.1.2 christos 1: VEX.W0. Should always be 0.
533 1.1.1.2 christos 2: VEX.W1. Should always be 1.
534 1.1.1.8 christos 3: VEX.WIG. The VEX.W bit is ignored.
535 1.1.1.2 christos */
536 1.1.1.2 christos #define VEXW0 1
537 1.1.1.2 christos #define VEXW1 2
538 1.1.1.8 christos #define VEXWIG 3
539 1.1.1.2 christos VexW,
540 1.1.1.2 christos /* VEX opcode prefix:
541 1.1.1.2 christos 0: VEX 0x0F opcode prefix.
542 1.1.1.2 christos 1: VEX 0x0F38 opcode prefix.
543 1.1.1.2 christos 2: VEX 0x0F3A opcode prefix
544 1.1.1.2 christos 3: XOP 0x08 opcode prefix.
545 1.1.1.2 christos 4: XOP 0x09 opcode prefix
546 1.1.1.2 christos 5: XOP 0x0A opcode prefix.
547 1.1.1.2 christos */
548 1.1.1.2 christos #define VEX0F 0
549 1.1.1.2 christos #define VEX0F38 1
550 1.1.1.2 christos #define VEX0F3A 2
551 1.1.1.2 christos #define XOP08 3
552 1.1.1.2 christos #define XOP09 4
553 1.1.1.2 christos #define XOP0A 5
554 1.1.1.2 christos VexOpcode,
555 1.1.1.2 christos /* number of VEX source operands:
556 1.1.1.2 christos 0: <= 2 source operands.
557 1.1.1.2 christos 1: 2 XOP source operands.
558 1.1.1.2 christos 2: 3 source operands.
559 1.1.1.2 christos */
560 1.1.1.2 christos #define XOP2SOURCES 1
561 1.1.1.2 christos #define VEX3SOURCES 2
562 1.1.1.2 christos VexSources,
563 1.1.1.3 christos /* Instruction with vector SIB byte:
564 1.1.1.3 christos 1: 128bit vector register.
565 1.1.1.3 christos 2: 256bit vector register.
566 1.1.1.4 christos 3: 512bit vector register.
567 1.1.1.3 christos */
568 1.1.1.3 christos #define VecSIB128 1
569 1.1.1.3 christos #define VecSIB256 2
570 1.1.1.4 christos #define VecSIB512 3
571 1.1.1.3 christos VecSIB,
572 1.1.1.2 christos /* SSE to AVX support required */
573 1.1.1.2 christos SSE2AVX,
574 1.1.1.2 christos /* No AVX equivalent */
575 1.1.1.2 christos NoAVX,
576 1.1.1.4 christos
577 1.1.1.4 christos /* insn has EVEX prefix:
578 1.1.1.4 christos 1: 512bit EVEX prefix.
579 1.1.1.4 christos 2: 128bit EVEX prefix.
580 1.1.1.4 christos 3: 256bit EVEX prefix.
581 1.1.1.4 christos 4: Length-ignored (LIG) EVEX prefix.
582 1.1.1.7 christos 5: Length determined from actual operands.
583 1.1.1.4 christos */
584 1.1.1.4 christos #define EVEX512 1
585 1.1.1.4 christos #define EVEX128 2
586 1.1.1.4 christos #define EVEX256 3
587 1.1.1.4 christos #define EVEXLIG 4
588 1.1.1.7 christos #define EVEXDYN 5
589 1.1.1.4 christos EVex,
590 1.1.1.4 christos
591 1.1.1.4 christos /* AVX512 masking support:
592 1.1.1.8 christos 1: Zeroing or merging masking depending on operands.
593 1.1.1.4 christos 2: Merging-masking.
594 1.1.1.4 christos 3: Both zeroing and merging masking.
595 1.1.1.4 christos */
596 1.1.1.8 christos #define DYNAMIC_MASKING 1
597 1.1.1.4 christos #define MERGING_MASKING 2
598 1.1.1.4 christos #define BOTH_MASKING 3
599 1.1.1.4 christos Masking,
600 1.1.1.4 christos
601 1.1.1.8 christos /* AVX512 broadcast support. The number of bytes to broadcast is
602 1.1.1.8 christos 1 << (Broadcast - 1):
603 1.1.1.8 christos 1: Byte broadcast.
604 1.1.1.8 christos 2: Word broadcast.
605 1.1.1.8 christos 3: Dword broadcast.
606 1.1.1.8 christos 4: Qword broadcast.
607 1.1.1.8 christos */
608 1.1.1.8 christos #define BYTE_BROADCAST 1
609 1.1.1.8 christos #define WORD_BROADCAST 2
610 1.1.1.8 christos #define DWORD_BROADCAST 3
611 1.1.1.8 christos #define QWORD_BROADCAST 4
612 1.1.1.4 christos Broadcast,
613 1.1.1.4 christos
614 1.1.1.4 christos /* Static rounding control is supported. */
615 1.1.1.4 christos StaticRounding,
616 1.1.1.4 christos
617 1.1.1.4 christos /* Supress All Exceptions is supported. */
618 1.1.1.4 christos SAE,
619 1.1.1.4 christos
620 1.1.1.8 christos /* Compressed Disp8*N attribute. */
621 1.1.1.8 christos #define DISP8_SHIFT_VL 7
622 1.1.1.4 christos Disp8MemShift,
623 1.1.1.4 christos
624 1.1.1.4 christos /* Default mask isn't allowed. */
625 1.1.1.4 christos NoDefMask,
626 1.1.1.4 christos
627 1.1.1.6 christos /* The second operand must be a vector register, {x,y,z}mmN, where N is a multiple of 4.
628 1.1.1.6 christos It implicitly denotes the register group of {x,y,z}mmN - {x,y,z}mm(N + 3).
629 1.1.1.6 christos */
630 1.1.1.6 christos ImplicitQuadGroup,
631 1.1.1.6 christos
632 1.1.1.7 christos /* Support encoding optimization. */
633 1.1.1.7 christos Optimize,
634 1.1.1.7 christos
635 1.1.1.2 christos /* AT&T mnemonic. */
636 1.1.1.2 christos ATTMnemonic,
637 1.1.1.2 christos /* AT&T syntax. */
638 1.1.1.2 christos ATTSyntax,
639 1.1.1.2 christos /* Intel syntax. */
640 1.1.1.2 christos IntelSyntax,
641 1.1.1.5 christos /* AMD64. */
642 1.1.1.5 christos AMD64,
643 1.1.1.5 christos /* Intel64. */
644 1.1.1.5 christos Intel64,
645 1.1.1.2 christos /* The last bitfield in i386_opcode_modifier. */
646 1.1.1.8 christos Opcode_Modifier_Num
647 1.1.1.2 christos };
648 1.1 skrll
649 1.1 skrll typedef struct i386_opcode_modifier
650 1.1 skrll {
651 1.1 skrll unsigned int d:1;
652 1.1 skrll unsigned int w:1;
653 1.1.1.6 christos unsigned int load:1;
654 1.1 skrll unsigned int modrm:1;
655 1.1 skrll unsigned int shortform:1;
656 1.1.1.8 christos unsigned int jump:3;
657 1.1 skrll unsigned int floatmf:1;
658 1.1 skrll unsigned int floatr:1;
659 1.1.1.8 christos unsigned int size:2;
660 1.1.1.2 christos unsigned int checkregsize:1;
661 1.1 skrll unsigned int ignoresize:1;
662 1.1 skrll unsigned int defaultsize:1;
663 1.1.1.8 christos unsigned int anysize:1;
664 1.1 skrll unsigned int no_bsuf:1;
665 1.1 skrll unsigned int no_wsuf:1;
666 1.1 skrll unsigned int no_lsuf:1;
667 1.1 skrll unsigned int no_ssuf:1;
668 1.1 skrll unsigned int no_qsuf:1;
669 1.1 skrll unsigned int no_ldsuf:1;
670 1.1 skrll unsigned int fwait:1;
671 1.1.1.8 christos unsigned int isstring:2;
672 1.1.1.8 christos unsigned int regmem:1;
673 1.1.1.4 christos unsigned int bndprefixok:1;
674 1.1.1.6 christos unsigned int notrackprefixok:1;
675 1.1.1.2 christos unsigned int islockable:1;
676 1.1 skrll unsigned int regkludge:1;
677 1.1 skrll unsigned int implicit1stxmm0:1;
678 1.1.1.3 christos unsigned int hleprefixok:2;
679 1.1.1.3 christos unsigned int repprefixok:1;
680 1.1 skrll unsigned int todword:1;
681 1.1 skrll unsigned int toqword:1;
682 1.1.1.7 christos unsigned int addrprefixopreg:1;
683 1.1 skrll unsigned int isprefix:1;
684 1.1 skrll unsigned int immext:1;
685 1.1 skrll unsigned int norex64:1;
686 1.1 skrll unsigned int rex64:1;
687 1.1 skrll unsigned int ugh:1;
688 1.1.1.2 christos unsigned int vex:2;
689 1.1.1.2 christos unsigned int vexvvvv:2;
690 1.1.1.2 christos unsigned int vexw:2;
691 1.1.1.2 christos unsigned int vexopcode:3;
692 1.1.1.2 christos unsigned int vexsources:2;
693 1.1.1.3 christos unsigned int vecsib:2;
694 1.1 skrll unsigned int sse2avx:1;
695 1.1 skrll unsigned int noavx:1;
696 1.1.1.4 christos unsigned int evex:3;
697 1.1.1.4 christos unsigned int masking:2;
698 1.1.1.8 christos unsigned int broadcast:3;
699 1.1.1.4 christos unsigned int staticrounding:1;
700 1.1.1.4 christos unsigned int sae:1;
701 1.1.1.4 christos unsigned int disp8memshift:3;
702 1.1.1.4 christos unsigned int nodefmask:1;
703 1.1.1.6 christos unsigned int implicitquadgroup:1;
704 1.1.1.7 christos unsigned int optimize:1;
705 1.1 skrll unsigned int attmnemonic:1;
706 1.1 skrll unsigned int attsyntax:1;
707 1.1 skrll unsigned int intelsyntax:1;
708 1.1.1.5 christos unsigned int amd64:1;
709 1.1.1.5 christos unsigned int intel64:1;
710 1.1 skrll } i386_opcode_modifier;
711 1.1 skrll
712 1.1.1.8 christos /* Operand classes. */
713 1.1.1.8 christos
714 1.1.1.8 christos #define CLASS_WIDTH 4
715 1.1.1.8 christos enum operand_class
716 1.1.1.8 christos {
717 1.1.1.8 christos ClassNone,
718 1.1.1.8 christos Reg, /* GPRs and FP regs, distinguished by operand size */
719 1.1.1.8 christos SReg, /* Segment register */
720 1.1.1.8 christos RegCR, /* Control register */
721 1.1.1.8 christos RegDR, /* Debug register */
722 1.1.1.8 christos RegTR, /* Test register */
723 1.1.1.8 christos RegMMX, /* MMX register */
724 1.1.1.8 christos RegSIMD, /* XMM/YMM/ZMM registers, distinguished by operand size */
725 1.1.1.8 christos RegMask, /* Vector Mask register */
726 1.1.1.8 christos RegBND, /* Bound register */
727 1.1.1.8 christos };
728 1.1.1.8 christos
729 1.1.1.8 christos /* Special operand instances. */
730 1.1.1.8 christos
731 1.1.1.8 christos #define INSTANCE_WIDTH 3
732 1.1.1.8 christos enum operand_instance
733 1.1.1.8 christos {
734 1.1.1.8 christos InstanceNone,
735 1.1.1.8 christos Accum, /* Accumulator %al/%ax/%eax/%rax/%st(0)/%xmm0 */
736 1.1.1.8 christos RegC, /* %cl / %cx / %ecx / %rcx, e.g. register to hold shift count */
737 1.1.1.8 christos RegD, /* %dl / %dx / %edx / %rdx, e.g. register to hold I/O port addr */
738 1.1.1.8 christos RegB, /* %bl / %bx / %ebx / %rbx */
739 1.1.1.8 christos };
740 1.1.1.8 christos
741 1.1 skrll /* Position of operand_type bits. */
742 1.1 skrll
743 1.1.1.2 christos enum
744 1.1.1.2 christos {
745 1.1.1.8 christos /* Class and Instance */
746 1.1.1.8 christos ClassInstance = CLASS_WIDTH + INSTANCE_WIDTH - 1,
747 1.1.1.2 christos /* 1 bit immediate */
748 1.1.1.2 christos Imm1,
749 1.1.1.2 christos /* 8 bit immediate */
750 1.1.1.2 christos Imm8,
751 1.1.1.2 christos /* 8 bit immediate sign extended */
752 1.1.1.2 christos Imm8S,
753 1.1.1.2 christos /* 16 bit immediate */
754 1.1.1.2 christos Imm16,
755 1.1.1.2 christos /* 32 bit immediate */
756 1.1.1.2 christos Imm32,
757 1.1.1.2 christos /* 32 bit immediate sign extended */
758 1.1.1.2 christos Imm32S,
759 1.1.1.2 christos /* 64 bit immediate */
760 1.1.1.2 christos Imm64,
761 1.1.1.2 christos /* 8bit/16bit/32bit displacements are used in different ways,
762 1.1.1.2 christos depending on the instruction. For jumps, they specify the
763 1.1.1.2 christos size of the PC relative displacement, for instructions with
764 1.1.1.2 christos memory operand, they specify the size of the offset relative
765 1.1.1.2 christos to the base register, and for instructions with memory offset
766 1.1.1.2 christos such as `mov 1234,%al' they specify the size of the offset
767 1.1.1.2 christos relative to the segment base. */
768 1.1.1.2 christos /* 8 bit displacement */
769 1.1.1.2 christos Disp8,
770 1.1.1.2 christos /* 16 bit displacement */
771 1.1.1.2 christos Disp16,
772 1.1.1.2 christos /* 32 bit displacement */
773 1.1.1.2 christos Disp32,
774 1.1.1.2 christos /* 32 bit signed displacement */
775 1.1.1.2 christos Disp32S,
776 1.1.1.2 christos /* 64 bit displacement */
777 1.1.1.2 christos Disp64,
778 1.1.1.2 christos /* Register which can be used for base or index in memory operand. */
779 1.1.1.2 christos BaseIndex,
780 1.1.1.8 christos /* BYTE size. */
781 1.1.1.2 christos Byte,
782 1.1.1.8 christos /* WORD size. 2 byte */
783 1.1.1.2 christos Word,
784 1.1.1.8 christos /* DWORD size. 4 byte */
785 1.1.1.2 christos Dword,
786 1.1.1.8 christos /* FWORD size. 6 byte */
787 1.1.1.2 christos Fword,
788 1.1.1.8 christos /* QWORD size. 8 byte */
789 1.1.1.2 christos Qword,
790 1.1.1.8 christos /* TBYTE size. 10 byte */
791 1.1.1.2 christos Tbyte,
792 1.1.1.8 christos /* XMMWORD size. */
793 1.1.1.2 christos Xmmword,
794 1.1.1.8 christos /* YMMWORD size. */
795 1.1.1.2 christos Ymmword,
796 1.1.1.8 christos /* ZMMWORD size. */
797 1.1.1.4 christos Zmmword,
798 1.1.1.2 christos /* Unspecified memory size. */
799 1.1.1.2 christos Unspecified,
800 1.1.1.2 christos
801 1.1.1.8 christos /* The number of bits in i386_operand_type. */
802 1.1.1.8 christos OTNum
803 1.1.1.2 christos };
804 1.1 skrll
805 1.1 skrll #define OTNumOfUints \
806 1.1.1.8 christos ((OTNum - 1) / sizeof (unsigned int) / CHAR_BIT + 1)
807 1.1 skrll #define OTNumOfBits \
808 1.1 skrll (OTNumOfUints * sizeof (unsigned int) * CHAR_BIT)
809 1.1 skrll
810 1.1 skrll /* If you get a compiler error for zero width of the unused field,
811 1.1 skrll comment it out. */
812 1.1.1.8 christos #define OTUnused OTNum
813 1.1 skrll
814 1.1 skrll typedef union i386_operand_type
815 1.1 skrll {
816 1.1 skrll struct
817 1.1 skrll {
818 1.1.1.8 christos unsigned int class:CLASS_WIDTH;
819 1.1.1.8 christos unsigned int instance:INSTANCE_WIDTH;
820 1.1 skrll unsigned int imm1:1;
821 1.1 skrll unsigned int imm8:1;
822 1.1 skrll unsigned int imm8s:1;
823 1.1 skrll unsigned int imm16:1;
824 1.1 skrll unsigned int imm32:1;
825 1.1 skrll unsigned int imm32s:1;
826 1.1 skrll unsigned int imm64:1;
827 1.1 skrll unsigned int disp8:1;
828 1.1 skrll unsigned int disp16:1;
829 1.1 skrll unsigned int disp32:1;
830 1.1 skrll unsigned int disp32s:1;
831 1.1 skrll unsigned int disp64:1;
832 1.1 skrll unsigned int baseindex:1;
833 1.1 skrll unsigned int byte:1;
834 1.1 skrll unsigned int word:1;
835 1.1 skrll unsigned int dword:1;
836 1.1 skrll unsigned int fword:1;
837 1.1 skrll unsigned int qword:1;
838 1.1 skrll unsigned int tbyte:1;
839 1.1 skrll unsigned int xmmword:1;
840 1.1 skrll unsigned int ymmword:1;
841 1.1.1.4 christos unsigned int zmmword:1;
842 1.1 skrll unsigned int unspecified:1;
843 1.1 skrll #ifdef OTUnused
844 1.1 skrll unsigned int unused:(OTNumOfBits - OTUnused);
845 1.1 skrll #endif
846 1.1 skrll } bitfield;
847 1.1 skrll unsigned int array[OTNumOfUints];
848 1.1 skrll } i386_operand_type;
849 1.1 skrll
850 1.1.1.2 christos typedef struct insn_template
851 1.1 skrll {
852 1.1 skrll /* instruction name sans width suffix ("mov" for movl insns) */
853 1.1 skrll char *name;
854 1.1 skrll
855 1.1 skrll /* base_opcode is the fundamental opcode byte without optional
856 1.1 skrll prefix(es). */
857 1.1 skrll unsigned int base_opcode;
858 1.1 skrll #define Opcode_D 0x2 /* Direction bit:
859 1.1 skrll set if Reg --> Regmem;
860 1.1 skrll unset if Regmem --> Reg. */
861 1.1 skrll #define Opcode_FloatR 0x8 /* Bit to swap src/dest for float insns. */
862 1.1 skrll #define Opcode_FloatD 0x400 /* Direction bit for float insns. */
863 1.1.1.8 christos #define Opcode_SIMD_FloatD 0x1 /* Direction bit for SIMD fp insns. */
864 1.1.1.8 christos #define Opcode_SIMD_IntD 0x10 /* Direction bit for SIMD int insns. */
865 1.1 skrll
866 1.1 skrll /* extension_opcode is the 3 bit extension for group <n> insns.
867 1.1 skrll This field is also used to store the 8-bit opcode suffix for the
868 1.1 skrll AMD 3DNow! instructions.
869 1.1.1.3 christos If this template has no extension opcode (the usual case) use None
870 1.1.1.2 christos Instructions */
871 1.1.1.8 christos unsigned short extension_opcode;
872 1.1 skrll #define None 0xffff /* If no extension_opcode is possible. */
873 1.1 skrll
874 1.1 skrll /* Opcode length. */
875 1.1 skrll unsigned char opcode_length;
876 1.1 skrll
877 1.1.1.8 christos /* how many operands */
878 1.1.1.8 christos unsigned char operands;
879 1.1.1.8 christos
880 1.1 skrll /* cpu feature flags */
881 1.1 skrll i386_cpu_flags cpu_flags;
882 1.1 skrll
883 1.1 skrll /* the bits in opcode_modifier are used to generate the final opcode from
884 1.1 skrll the base_opcode. These bits also are used to detect alternate forms of
885 1.1 skrll the same instruction */
886 1.1 skrll i386_opcode_modifier opcode_modifier;
887 1.1 skrll
888 1.1 skrll /* operand_types[i] describes the type of operand i. This is made
889 1.1 skrll by OR'ing together all of the possible type masks. (e.g.
890 1.1 skrll 'operand_types[i] = Reg|Imm' specifies that operand i can be
891 1.1 skrll either a register or an immediate operand. */
892 1.1 skrll i386_operand_type operand_types[MAX_OPERANDS];
893 1.1 skrll }
894 1.1.1.2 christos insn_template;
895 1.1 skrll
896 1.1.1.2 christos extern const insn_template i386_optab[];
897 1.1 skrll
898 1.1 skrll /* these are for register name --> number & type hash lookup */
899 1.1 skrll typedef struct
900 1.1 skrll {
901 1.1 skrll char *reg_name;
902 1.1 skrll i386_operand_type reg_type;
903 1.1 skrll unsigned char reg_flags;
904 1.1 skrll #define RegRex 0x1 /* Extended register. */
905 1.1 skrll #define RegRex64 0x2 /* Extended 8 bit register. */
906 1.1.1.4 christos #define RegVRex 0x4 /* Extended vector register. */
907 1.1 skrll unsigned char reg_num;
908 1.1.1.8 christos #define RegIP ((unsigned char ) ~0)
909 1.1 skrll /* EIZ and RIZ are fake index registers. */
910 1.1.1.8 christos #define RegIZ (RegIP - 1)
911 1.1 skrll /* FLAT is a fake segment register (Intel mode). */
912 1.1 skrll #define RegFlat ((unsigned char) ~0)
913 1.1 skrll signed char dw2_regnum[2];
914 1.1 skrll #define Dw2Inval (-1)
915 1.1 skrll }
916 1.1 skrll reg_entry;
917 1.1 skrll
918 1.1 skrll /* Entries in i386_regtab. */
919 1.1 skrll #define REGNAM_AL 1
920 1.1 skrll #define REGNAM_AX 25
921 1.1 skrll #define REGNAM_EAX 41
922 1.1 skrll
923 1.1 skrll extern const reg_entry i386_regtab[];
924 1.1 skrll extern const unsigned int i386_regtab_size;
925 1.1 skrll
926 1.1 skrll typedef struct
927 1.1 skrll {
928 1.1 skrll char *seg_name;
929 1.1 skrll unsigned int seg_prefix;
930 1.1 skrll }
931 1.1 skrll seg_entry;
932 1.1 skrll
933 1.1 skrll extern const seg_entry cs;
934 1.1 skrll extern const seg_entry ds;
935 1.1 skrll extern const seg_entry ss;
936 1.1 skrll extern const seg_entry es;
937 1.1 skrll extern const seg_entry fs;
938 1.1 skrll extern const seg_entry gs;
939