]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - opcodes/i386-opc.h
GDB kills itself instead of interrupting inferior
[thirdparty/binutils-gdb.git] / opcodes / i386-opc.h
CommitLineData
0b1cf022 1/* Declarations for Intel 80386 opcode table
29c048b6 2 Copyright 2007, 2008, 2009, 2010, 2012
0b1cf022
L
3 Free Software Foundation, Inc.
4
9b201bb5 5 This file is part of the GNU opcodes library.
0b1cf022 6
9b201bb5 7 This library is free software; you can redistribute it and/or modify
0b1cf022 8 it under the terms of the GNU General Public License as published by
9b201bb5 9 the Free Software Foundation; either version 3, or (at your option)
0b1cf022
L
10 any later version.
11
9b201bb5
NC
12 It is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
0b1cf022
L
16
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
21
22#include "opcode/i386.h"
40fb9820
L
23#ifdef HAVE_LIMITS_H
24#include <limits.h>
25#endif
26
27#ifndef CHAR_BIT
28#define CHAR_BIT 8
29#endif
30
31/* Position of cpu flags bitfiled. */
32
52a6c1fe
L
33enum
34{
35 /* i186 or better required */
36 Cpu186 = 0,
37 /* i286 or better required */
38 Cpu286,
39 /* i386 or better required */
40 Cpu386,
41 /* i486 or better required */
42 Cpu486,
43 /* i585 or better required */
44 Cpu586,
45 /* i686 or better required */
46 Cpu686,
b49dfb4a 47 /* CLFLUSH Instruction support required */
52a6c1fe 48 CpuClflush,
22109423
L
49 /* NOP Instruction support required */
50 CpuNop,
b49dfb4a 51 /* SYSCALL Instructions support required */
52a6c1fe
L
52 CpuSYSCALL,
53 /* Floating point support required */
54 Cpu8087,
55 /* i287 support required */
56 Cpu287,
57 /* i387 support required */
58 Cpu387,
59 /* i686 and floating point support required */
60 Cpu687,
61 /* SSE3 and floating point support required */
62 CpuFISTTP,
63 /* MMX support required */
64 CpuMMX,
65 /* SSE support required */
66 CpuSSE,
67 /* SSE2 support required */
68 CpuSSE2,
69 /* 3dnow! support required */
70 Cpu3dnow,
71 /* 3dnow! Extensions support required */
72 Cpu3dnowA,
73 /* SSE3 support required */
74 CpuSSE3,
75 /* VIA PadLock required */
76 CpuPadLock,
77 /* AMD Secure Virtual Machine Ext-s required */
78 CpuSVME,
79 /* VMX Instructions required */
80 CpuVMX,
81 /* SMX Instructions required */
82 CpuSMX,
83 /* SSSE3 support required */
84 CpuSSSE3,
85 /* SSE4a support required */
86 CpuSSE4a,
87 /* ABM New Instructions required */
88 CpuABM,
89 /* SSE4.1 support required */
90 CpuSSE4_1,
91 /* SSE4.2 support required */
92 CpuSSE4_2,
93 /* AVX support required */
94 CpuAVX,
6c30d220
L
95 /* AVX2 support required */
96 CpuAVX2,
52a6c1fe
L
97 /* Intel L1OM support required */
98 CpuL1OM,
7a9068fe
L
99 /* Intel K1OM support required */
100 CpuK1OM,
b49dfb4a 101 /* Xsave/xrstor New Instructions support required */
52a6c1fe 102 CpuXsave,
b49dfb4a 103 /* Xsaveopt New Instructions support required */
c7b8aa3a 104 CpuXsaveopt,
52a6c1fe
L
105 /* AES support required */
106 CpuAES,
107 /* PCLMUL support required */
108 CpuPCLMUL,
109 /* FMA support required */
110 CpuFMA,
111 /* FMA4 support required */
112 CpuFMA4,
5dd85c99
SP
113 /* XOP support required */
114 CpuXOP,
f88c9eb0
SP
115 /* LWP support required */
116 CpuLWP,
f12dc422
L
117 /* BMI support required */
118 CpuBMI,
2a2a0f38
QN
119 /* TBM support required */
120 CpuTBM,
b49dfb4a 121 /* MOVBE Instruction support required */
52a6c1fe 122 CpuMovbe,
60aa667e
L
123 /* CMPXCHG16B instruction support required. */
124 CpuCX16,
52a6c1fe
L
125 /* EPT Instructions required */
126 CpuEPT,
b49dfb4a 127 /* RDTSCP Instruction support required */
52a6c1fe 128 CpuRdtscp,
77321f53 129 /* FSGSBASE Instructions required */
c7b8aa3a
L
130 CpuFSGSBase,
131 /* RDRND Instructions required */
132 CpuRdRnd,
133 /* F16C Instructions required */
134 CpuF16C,
6c30d220
L
135 /* Intel BMI2 support required */
136 CpuBMI2,
137 /* LZCNT support required */
138 CpuLZCNT,
42164a71
L
139 /* HLE support required */
140 CpuHLE,
141 /* RTM support required */
142 CpuRTM,
6c30d220
L
143 /* INVPCID Instructions required */
144 CpuINVPCID,
8729a6f6
L
145 /* VMFUNC Instruction required */
146 CpuVMFUNC,
7e8b059b
L
147 /* Intel MPX Instructions required */
148 CpuMPX,
52a6c1fe
L
149 /* 64bit support available, used by -march= in assembler. */
150 CpuLM,
e2e1fcde
L
151 /* RDRSEED instruction required. */
152 CpuRDSEED,
153 /* Multi-presisionn add-carry instructions are required. */
154 CpuADX,
7b458c12 155 /* Supports prefetchw and prefetch instructions. */
e2e1fcde 156 CpuPRFCHW,
5c111e37
L
157 /* SMAP instructions required. */
158 CpuSMAP,
a0046408
L
159 /* SHA instructions required. */
160 CpuSHA,
52a6c1fe
L
161 /* 64bit support required */
162 Cpu64,
163 /* Not supported in the 64bit mode */
164 CpuNo64,
165 /* The last bitfield in i386_cpu_flags. */
166 CpuMax = CpuNo64
167};
40fb9820
L
168
169#define CpuNumOfUints \
170 (CpuMax / sizeof (unsigned int) / CHAR_BIT + 1)
171#define CpuNumOfBits \
172 (CpuNumOfUints * sizeof (unsigned int) * CHAR_BIT)
173
174/* If you get a compiler error for zero width of the unused field,
175 comment it out. */
a0046408 176#define CpuUnused (CpuMax + 1)
40fb9820
L
177
178/* We can check if an instruction is available with array instead
179 of bitfield. */
180typedef union i386_cpu_flags
181{
182 struct
183 {
184 unsigned int cpui186:1;
185 unsigned int cpui286:1;
186 unsigned int cpui386:1;
187 unsigned int cpui486:1;
188 unsigned int cpui586:1;
189 unsigned int cpui686:1;
bd5295b2 190 unsigned int cpuclflush:1;
22109423 191 unsigned int cpunop:1;
bd5295b2 192 unsigned int cpusyscall:1;
309d3373
JB
193 unsigned int cpu8087:1;
194 unsigned int cpu287:1;
195 unsigned int cpu387:1;
196 unsigned int cpu687:1;
197 unsigned int cpufisttp:1;
40fb9820 198 unsigned int cpummx:1;
40fb9820
L
199 unsigned int cpusse:1;
200 unsigned int cpusse2:1;
201 unsigned int cpua3dnow:1;
202 unsigned int cpua3dnowa:1;
203 unsigned int cpusse3:1;
204 unsigned int cpupadlock:1;
205 unsigned int cpusvme:1;
206 unsigned int cpuvmx:1;
47dd174c 207 unsigned int cpusmx:1;
40fb9820
L
208 unsigned int cpussse3:1;
209 unsigned int cpusse4a:1;
210 unsigned int cpuabm:1;
211 unsigned int cpusse4_1:1;
212 unsigned int cpusse4_2:1;
c0f3af97 213 unsigned int cpuavx:1;
6c30d220 214 unsigned int cpuavx2:1;
8a9036a4 215 unsigned int cpul1om:1;
7a9068fe 216 unsigned int cpuk1om:1;
475a2301 217 unsigned int cpuxsave:1;
c7b8aa3a 218 unsigned int cpuxsaveopt:1;
c0f3af97 219 unsigned int cpuaes:1;
594ab6a3 220 unsigned int cpupclmul:1;
c0f3af97 221 unsigned int cpufma:1;
922d8de8 222 unsigned int cpufma4:1;
5dd85c99 223 unsigned int cpuxop:1;
f88c9eb0 224 unsigned int cpulwp:1;
f12dc422 225 unsigned int cpubmi:1;
2a2a0f38 226 unsigned int cputbm:1;
f1f8f695 227 unsigned int cpumovbe:1;
60aa667e 228 unsigned int cpucx16:1;
f1f8f695 229 unsigned int cpuept:1;
1b7f3fb0 230 unsigned int cpurdtscp:1;
c7b8aa3a
L
231 unsigned int cpufsgsbase:1;
232 unsigned int cpurdrnd:1;
233 unsigned int cpuf16c:1;
6c30d220
L
234 unsigned int cpubmi2:1;
235 unsigned int cpulzcnt:1;
42164a71
L
236 unsigned int cpuhle:1;
237 unsigned int cpurtm:1;
6c30d220 238 unsigned int cpuinvpcid:1;
8729a6f6 239 unsigned int cpuvmfunc:1;
7e8b059b 240 unsigned int cpumpx:1;
40fb9820 241 unsigned int cpulm:1;
e2e1fcde
L
242 unsigned int cpurdseed:1;
243 unsigned int cpuadx:1;
244 unsigned int cpuprfchw:1;
5c111e37 245 unsigned int cpusmap:1;
a0046408 246 unsigned int cpusha:1;
40fb9820
L
247 unsigned int cpu64:1;
248 unsigned int cpuno64:1;
249#ifdef CpuUnused
250 unsigned int unused:(CpuNumOfBits - CpuUnused);
251#endif
252 } bitfield;
253 unsigned int array[CpuNumOfUints];
254} i386_cpu_flags;
255
256/* Position of opcode_modifier bits. */
257
52a6c1fe
L
258enum
259{
260 /* has direction bit. */
261 D = 0,
262 /* set if operands can be words or dwords encoded the canonical way */
263 W,
264 /* Skip the current insn and use the next insn in i386-opc.tbl to swap
265 operand in encoding. */
266 S,
267 /* insn has a modrm byte. */
268 Modrm,
269 /* register is in low 3 bits of opcode */
270 ShortForm,
271 /* special case for jump insns. */
272 Jump,
273 /* call and jump */
274 JumpDword,
275 /* loop and jecxz */
276 JumpByte,
277 /* special case for intersegment leaps/calls */
278 JumpInterSegment,
279 /* FP insn memory format bit, sized by 0x4 */
280 FloatMF,
281 /* src/dest swap for floats. */
282 FloatR,
283 /* has float insn direction bit. */
284 FloatD,
285 /* needs size prefix if in 32-bit mode */
286 Size16,
287 /* needs size prefix if in 16-bit mode */
288 Size32,
289 /* needs size prefix if in 64-bit mode */
290 Size64,
56ffb741
L
291 /* check register size. */
292 CheckRegSize,
52a6c1fe
L
293 /* instruction ignores operand size prefix and in Intel mode ignores
294 mnemonic size suffix check. */
295 IgnoreSize,
296 /* default insn size depends on mode */
297 DefaultSize,
298 /* b suffix on instruction illegal */
299 No_bSuf,
300 /* w suffix on instruction illegal */
301 No_wSuf,
302 /* l suffix on instruction illegal */
303 No_lSuf,
304 /* s suffix on instruction illegal */
305 No_sSuf,
306 /* q suffix on instruction illegal */
307 No_qSuf,
308 /* long double suffix on instruction illegal */
309 No_ldSuf,
310 /* instruction needs FWAIT */
311 FWait,
312 /* quick test for string instructions */
313 IsString,
7e8b059b
L
314 /* quick test if branch instruction is MPX supported */
315 BNDPrefixOk,
c32fa91d
L
316 /* quick test for lockable instructions */
317 IsLockable,
52a6c1fe
L
318 /* fake an extra reg operand for clr, imul and special register
319 processing for some instructions. */
320 RegKludge,
321 /* The first operand must be xmm0 */
322 FirstXmm0,
323 /* An implicit xmm0 as the first operand */
324 Implicit1stXmm0,
42164a71
L
325 /* The HLE prefix is OK:
326 1. With a LOCK prefix.
327 2. With or without a LOCK prefix.
328 3. With a RELEASE (0xf3) prefix.
329 */
82c2def5
L
330#define HLEPrefixNone 0
331#define HLEPrefixLock 1
332#define HLEPrefixAny 2
333#define HLEPrefixRelease 3
42164a71 334 HLEPrefixOk,
29c048b6
RM
335 /* An instruction on which a "rep" prefix is acceptable. */
336 RepPrefixOk,
52a6c1fe
L
337 /* Convert to DWORD */
338 ToDword,
339 /* Convert to QWORD */
340 ToQword,
341 /* Address prefix changes operand 0 */
342 AddrPrefixOp0,
343 /* opcode is a prefix */
344 IsPrefix,
345 /* instruction has extension in 8 bit imm */
346 ImmExt,
347 /* instruction don't need Rex64 prefix. */
348 NoRex64,
349 /* instruction require Rex64 prefix. */
350 Rex64,
351 /* deprecated fp insn, gets a warning */
352 Ugh,
353 /* insn has VEX prefix:
2bf05e57
L
354 1: 128bit VEX prefix.
355 2: 256bit VEX prefix.
712366da 356 3: Scalar VEX prefix.
52a6c1fe 357 */
712366da
L
358#define VEX128 1
359#define VEX256 2
360#define VEXScalar 3
52a6c1fe 361 Vex,
2426c15f
L
362 /* How to encode VEX.vvvv:
363 0: VEX.vvvv must be 1111b.
a2a7d12c 364 1: VEX.NDS. Register-only source is encoded in VEX.vvvv where
2426c15f 365 the content of source registers will be preserved.
29c048b6 366 VEX.DDS. The second register operand is encoded in VEX.vvvv
2426c15f
L
367 where the content of first source register will be overwritten
368 by the result.
6c30d220
L
369 VEX.NDD2. The second destination register operand is encoded in
370 VEX.vvvv for instructions with 2 destination register operands.
371 For assembler, there are no difference between VEX.NDS, VEX.DDS
372 and VEX.NDD2.
373 2. VEX.NDD. Register destination is encoded in VEX.vvvv for
374 instructions with 1 destination register operand.
2426c15f
L
375 3. VEX.LWP. Register destination is encoded in VEX.vvvv and one
376 of the operands can access a memory location.
377 */
378#define VEXXDS 1
379#define VEXNDD 2
380#define VEXLWP 3
381 VexVVVV,
1ef99a7b
L
382 /* How the VEX.W bit is used:
383 0: Set by the REX.W bit.
384 1: VEX.W0. Should always be 0.
385 2: VEX.W1. Should always be 1.
386 */
387#define VEXW0 1
388#define VEXW1 2
389 VexW,
7f399153
L
390 /* VEX opcode prefix:
391 0: VEX 0x0F opcode prefix.
392 1: VEX 0x0F38 opcode prefix.
393 2: VEX 0x0F3A opcode prefix
394 3: XOP 0x08 opcode prefix.
395 4: XOP 0x09 opcode prefix
396 5: XOP 0x0A opcode prefix.
397 */
398#define VEX0F 0
399#define VEX0F38 1
400#define VEX0F3A 2
401#define XOP08 3
402#define XOP09 4
403#define XOP0A 5
404 VexOpcode,
8cd7925b 405 /* number of VEX source operands:
8c43a48b
L
406 0: <= 2 source operands.
407 1: 2 XOP source operands.
8cd7925b
L
408 2: 3 source operands.
409 */
8c43a48b 410#define XOP2SOURCES 1
8cd7925b
L
411#define VEX3SOURCES 2
412 VexSources,
52a6c1fe
L
413 /* instruction has VEX 8 bit imm */
414 VexImmExt,
6c30d220
L
415 /* Instruction with vector SIB byte:
416 1: 128bit vector register.
417 2: 256bit vector register.
418 */
419#define VecSIB128 1
420#define VecSIB256 2
421 VecSIB,
52a6c1fe
L
422 /* SSE to AVX support required */
423 SSE2AVX,
424 /* No AVX equivalent */
425 NoAVX,
426 /* Compatible with old (<= 2.8.1) versions of gcc */
427 OldGcc,
428 /* AT&T mnemonic. */
429 ATTMnemonic,
430 /* AT&T syntax. */
431 ATTSyntax,
432 /* Intel syntax. */
433 IntelSyntax,
434 /* The last bitfield in i386_opcode_modifier. */
435 Opcode_Modifier_Max
436};
40fb9820
L
437
438typedef struct i386_opcode_modifier
439{
440 unsigned int d:1;
441 unsigned int w:1;
b6169b20 442 unsigned int s:1;
40fb9820
L
443 unsigned int modrm:1;
444 unsigned int shortform:1;
445 unsigned int jump:1;
446 unsigned int jumpdword:1;
447 unsigned int jumpbyte:1;
448 unsigned int jumpintersegment:1;
449 unsigned int floatmf:1;
450 unsigned int floatr:1;
451 unsigned int floatd:1;
452 unsigned int size16:1;
453 unsigned int size32:1;
454 unsigned int size64:1;
56ffb741 455 unsigned int checkregsize:1;
40fb9820
L
456 unsigned int ignoresize:1;
457 unsigned int defaultsize:1;
458 unsigned int no_bsuf:1;
459 unsigned int no_wsuf:1;
460 unsigned int no_lsuf:1;
461 unsigned int no_ssuf:1;
462 unsigned int no_qsuf:1;
7ce189b3 463 unsigned int no_ldsuf:1;
40fb9820
L
464 unsigned int fwait:1;
465 unsigned int isstring:1;
7e8b059b 466 unsigned int bndprefixok:1;
c32fa91d 467 unsigned int islockable:1;
40fb9820 468 unsigned int regkludge:1;
e2ec9d29 469 unsigned int firstxmm0:1;
c0f3af97 470 unsigned int implicit1stxmm0:1;
42164a71 471 unsigned int hleprefixok:2;
29c048b6 472 unsigned int repprefixok:1;
ca61edf2
L
473 unsigned int todword:1;
474 unsigned int toqword:1;
475 unsigned int addrprefixop0:1;
40fb9820
L
476 unsigned int isprefix:1;
477 unsigned int immext:1;
478 unsigned int norex64:1;
479 unsigned int rex64:1;
480 unsigned int ugh:1;
2bf05e57 481 unsigned int vex:2;
2426c15f 482 unsigned int vexvvvv:2;
1ef99a7b 483 unsigned int vexw:2;
7f399153 484 unsigned int vexopcode:3;
8cd7925b 485 unsigned int vexsources:2;
c0f3af97 486 unsigned int veximmext:1;
6c30d220 487 unsigned int vecsib:2;
c0f3af97 488 unsigned int sse2avx:1;
81f8a913 489 unsigned int noavx:1;
1efbbeb4
L
490 unsigned int oldgcc:1;
491 unsigned int attmnemonic:1;
e1d4d893 492 unsigned int attsyntax:1;
5c07affc 493 unsigned int intelsyntax:1;
40fb9820
L
494} i386_opcode_modifier;
495
496/* Position of operand_type bits. */
497
52a6c1fe
L
498enum
499{
500 /* 8bit register */
501 Reg8 = 0,
502 /* 16bit register */
503 Reg16,
504 /* 32bit register */
505 Reg32,
506 /* 64bit register */
507 Reg64,
508 /* Floating pointer stack register */
509 FloatReg,
510 /* MMX register */
511 RegMMX,
512 /* SSE register */
513 RegXMM,
514 /* AVX registers */
515 RegYMM,
516 /* Control register */
517 Control,
518 /* Debug register */
519 Debug,
520 /* Test register */
521 Test,
522 /* 2 bit segment register */
523 SReg2,
524 /* 3 bit segment register */
525 SReg3,
526 /* 1 bit immediate */
527 Imm1,
528 /* 8 bit immediate */
529 Imm8,
530 /* 8 bit immediate sign extended */
531 Imm8S,
532 /* 16 bit immediate */
533 Imm16,
534 /* 32 bit immediate */
535 Imm32,
536 /* 32 bit immediate sign extended */
537 Imm32S,
538 /* 64 bit immediate */
539 Imm64,
540 /* 8bit/16bit/32bit displacements are used in different ways,
541 depending on the instruction. For jumps, they specify the
542 size of the PC relative displacement, for instructions with
543 memory operand, they specify the size of the offset relative
544 to the base register, and for instructions with memory offset
545 such as `mov 1234,%al' they specify the size of the offset
546 relative to the segment base. */
547 /* 8 bit displacement */
548 Disp8,
549 /* 16 bit displacement */
550 Disp16,
551 /* 32 bit displacement */
552 Disp32,
553 /* 32 bit signed displacement */
554 Disp32S,
555 /* 64 bit displacement */
556 Disp64,
557 /* Accumulator %al/%ax/%eax/%rax */
558 Acc,
559 /* Floating pointer top stack register %st(0) */
560 FloatAcc,
561 /* Register which can be used for base or index in memory operand. */
562 BaseIndex,
563 /* Register to hold in/out port addr = dx */
564 InOutPortReg,
565 /* Register to hold shift count = cl */
566 ShiftCount,
567 /* Absolute address for jump. */
568 JumpAbsolute,
569 /* String insn operand with fixed es segment */
570 EsSeg,
571 /* RegMem is for instructions with a modrm byte where the register
572 destination operand should be encoded in the mod and regmem fields.
573 Normally, it will be encoded in the reg field. We add a RegMem
574 flag to the destination register operand to indicate that it should
575 be encoded in the regmem field. */
576 RegMem,
577 /* Memory. */
578 Mem,
579 /* BYTE memory. */
580 Byte,
581 /* WORD memory. 2 byte */
582 Word,
583 /* DWORD memory. 4 byte */
584 Dword,
585 /* FWORD memory. 6 byte */
586 Fword,
587 /* QWORD memory. 8 byte */
588 Qword,
589 /* TBYTE memory. 10 byte */
590 Tbyte,
591 /* XMMWORD memory. */
592 Xmmword,
593 /* YMMWORD memory. */
594 Ymmword,
595 /* Unspecified memory size. */
596 Unspecified,
597 /* Any memory size. */
598 Anysize,
40fb9820 599
a683cc34
SP
600 /* Vector 4 bit immediate. */
601 Vec_Imm4,
602
7e8b059b
L
603 /* Bound register. */
604 RegBND,
605
52a6c1fe
L
606 /* The last bitfield in i386_operand_type. */
607 OTMax
608};
40fb9820
L
609
610#define OTNumOfUints \
611 (OTMax / sizeof (unsigned int) / CHAR_BIT + 1)
612#define OTNumOfBits \
613 (OTNumOfUints * sizeof (unsigned int) * CHAR_BIT)
614
615/* If you get a compiler error for zero width of the unused field,
616 comment it out. */
8c6c9809 617#define OTUnused (OTMax + 1)
40fb9820
L
618
619typedef union i386_operand_type
620{
621 struct
622 {
623 unsigned int reg8:1;
624 unsigned int reg16:1;
625 unsigned int reg32:1;
626 unsigned int reg64:1;
7d5e4556
L
627 unsigned int floatreg:1;
628 unsigned int regmmx:1;
629 unsigned int regxmm:1;
c0f3af97 630 unsigned int regymm:1;
7d5e4556
L
631 unsigned int control:1;
632 unsigned int debug:1;
633 unsigned int test:1;
634 unsigned int sreg2:1;
635 unsigned int sreg3:1;
636 unsigned int imm1:1;
40fb9820
L
637 unsigned int imm8:1;
638 unsigned int imm8s:1;
639 unsigned int imm16:1;
640 unsigned int imm32:1;
641 unsigned int imm32s:1;
642 unsigned int imm64:1;
40fb9820
L
643 unsigned int disp8:1;
644 unsigned int disp16:1;
645 unsigned int disp32:1;
646 unsigned int disp32s:1;
647 unsigned int disp64:1;
7d5e4556
L
648 unsigned int acc:1;
649 unsigned int floatacc:1;
650 unsigned int baseindex:1;
40fb9820
L
651 unsigned int inoutportreg:1;
652 unsigned int shiftcount:1;
40fb9820 653 unsigned int jumpabsolute:1;
40fb9820
L
654 unsigned int esseg:1;
655 unsigned int regmem:1;
5c07affc 656 unsigned int mem:1;
7d5e4556
L
657 unsigned int byte:1;
658 unsigned int word:1;
659 unsigned int dword:1;
660 unsigned int fword:1;
661 unsigned int qword:1;
662 unsigned int tbyte:1;
663 unsigned int xmmword:1;
c0f3af97 664 unsigned int ymmword:1;
7d5e4556
L
665 unsigned int unspecified:1;
666 unsigned int anysize:1;
a683cc34 667 unsigned int vec_imm4:1;
7e8b059b 668 unsigned int regbnd:1;
40fb9820
L
669#ifdef OTUnused
670 unsigned int unused:(OTNumOfBits - OTUnused);
671#endif
672 } bitfield;
673 unsigned int array[OTNumOfUints];
674} i386_operand_type;
0b1cf022 675
d3ce72d0 676typedef struct insn_template
0b1cf022
L
677{
678 /* instruction name sans width suffix ("mov" for movl insns) */
679 char *name;
680
681 /* how many operands */
682 unsigned int operands;
683
684 /* base_opcode is the fundamental opcode byte without optional
685 prefix(es). */
686 unsigned int base_opcode;
687#define Opcode_D 0x2 /* Direction bit:
688 set if Reg --> Regmem;
689 unset if Regmem --> Reg. */
690#define Opcode_FloatR 0x8 /* Bit to swap src/dest for float insns. */
691#define Opcode_FloatD 0x400 /* Direction bit for float insns. */
692
693 /* extension_opcode is the 3 bit extension for group <n> insns.
694 This field is also used to store the 8-bit opcode suffix for the
695 AMD 3DNow! instructions.
29c048b6 696 If this template has no extension opcode (the usual case) use None
c1e679ec 697 Instructions */
0b1cf022
L
698 unsigned int extension_opcode;
699#define None 0xffff /* If no extension_opcode is possible. */
700
4dffcebc
L
701 /* Opcode length. */
702 unsigned char opcode_length;
703
0b1cf022 704 /* cpu feature flags */
40fb9820 705 i386_cpu_flags cpu_flags;
0b1cf022
L
706
707 /* the bits in opcode_modifier are used to generate the final opcode from
708 the base_opcode. These bits also are used to detect alternate forms of
709 the same instruction */
40fb9820 710 i386_opcode_modifier opcode_modifier;
0b1cf022
L
711
712 /* operand_types[i] describes the type of operand i. This is made
713 by OR'ing together all of the possible type masks. (e.g.
714 'operand_types[i] = Reg|Imm' specifies that operand i can be
715 either a register or an immediate operand. */
40fb9820 716 i386_operand_type operand_types[MAX_OPERANDS];
0b1cf022 717}
d3ce72d0 718insn_template;
0b1cf022 719
d3ce72d0 720extern const insn_template i386_optab[];
0b1cf022
L
721
722/* these are for register name --> number & type hash lookup */
723typedef struct
724{
725 char *reg_name;
40fb9820 726 i386_operand_type reg_type;
a60de03c 727 unsigned char reg_flags;
0b1cf022
L
728#define RegRex 0x1 /* Extended register. */
729#define RegRex64 0x2 /* Extended 8 bit register. */
a60de03c
JB
730 unsigned char reg_num;
731#define RegRip ((unsigned char ) ~0)
9a04903e 732#define RegEip (RegRip - 1)
db51cc60 733/* EIZ and RIZ are fake index registers. */
9a04903e 734#define RegEiz (RegEip - 1)
db51cc60 735#define RegRiz (RegEiz - 1)
b7240065
JB
736/* FLAT is a fake segment register (Intel mode). */
737#define RegFlat ((unsigned char) ~0)
a60de03c
JB
738 signed char dw2_regnum[2];
739#define Dw2Inval (-1)
0b1cf022
L
740}
741reg_entry;
742
743/* Entries in i386_regtab. */
744#define REGNAM_AL 1
745#define REGNAM_AX 25
746#define REGNAM_EAX 41
747
748extern const reg_entry i386_regtab[];
c3fe08fa 749extern const unsigned int i386_regtab_size;
0b1cf022
L
750
751typedef struct
752{
753 char *seg_name;
754 unsigned int seg_prefix;
755}
756seg_entry;
757
758extern const seg_entry cs;
759extern const seg_entry ds;
760extern const seg_entry ss;
761extern const seg_entry es;
762extern const seg_entry fs;
763extern const seg_entry gs;