1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*===- X86DisassemblerDecoderCommon.h - Disassembler decoder -------*- C -*-==*
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *                     The LLVM Compiler Infrastructure
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * This file is distributed under the University of Illinois Open Source
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * License. See LICENSE.TXT for details.
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *===----------------------------------------------------------------------===*
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * This file is part of the X86 Disassembler.
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * It contains common definitions used by both the disassembler and the table
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *  generator.
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Documentation for the disassembler can be found in X86Disassembler.h.
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *===----------------------------------------------------------------------===*/
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * This header file provides those definitions that need to be shared between
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * the decoder and the table generator in a C-friendly manner.
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef X86DISASSEMBLERDECODERCOMMON_H
23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define X86DISASSEMBLERDECODERCOMMON_H
24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
2519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Support/DataTypes.h"
26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define INSTRUCTIONS_SYM  x86DisassemblerInstrSpecifiers
28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define CONTEXTS_SYM      x86DisassemblerContexts
29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ONEBYTE_SYM       x86DisassemblerOneByteOpcodes
30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define TWOBYTE_SYM       x86DisassemblerTwoByteOpcodes
31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define THREEBYTE38_SYM   x86DisassemblerThreeByte38Opcodes
32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define THREEBYTE3A_SYM   x86DisassemblerThreeByte3AOpcodes
3319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#define THREEBYTEA6_SYM   x86DisassemblerThreeByteA6Opcodes
3419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#define THREEBYTEA7_SYM   x86DisassemblerThreeByteA7Opcodes
35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define INSTRUCTIONS_STR  "x86DisassemblerInstrSpecifiers"
37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define CONTEXTS_STR      "x86DisassemblerContexts"
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ONEBYTE_STR       "x86DisassemblerOneByteOpcodes"
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define TWOBYTE_STR       "x86DisassemblerTwoByteOpcodes"
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define THREEBYTE38_STR   "x86DisassemblerThreeByte38Opcodes"
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define THREEBYTE3A_STR   "x86DisassemblerThreeByte3AOpcodes"
4219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#define THREEBYTEA6_STR   "x86DisassemblerThreeByteA6Opcodes"
4319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#define THREEBYTEA7_STR   "x86DisassemblerThreeByteA7Opcodes"
44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Attributes of an instruction that must be known before the opcode can be
47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * processed correctly.  Most of these indicate the presence of particular
48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * prefixes, but ATTR_64BIT is simply an attribute of the decoding context.
49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ATTRIBUTE_BITS          \
51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ATTR_NONE,   0x00) \
52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ATTR_64BIT,  0x01) \
53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ATTR_XS,     0x02) \
54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ATTR_XD,     0x04) \
55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ATTR_REXW,   0x08) \
5619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(ATTR_OPSIZE, 0x10) \
5719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(ATTR_VEX,    0x20) \
5819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(ATTR_VEXL,   0x40)
59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ENUM_ENTRY(n, v) n = v,
61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanenum attributeBits {
62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ATTRIBUTE_BITS
63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ATTR_max
64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#undef ENUM_ENTRY
66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Combinations of the above attributes that are relevant to instruction
69894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * decode.  Although other combinations are possible, they can be reduced to
70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * these without affecting the ultimately decoded instruction.
71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*           Class name           Rank  Rationale for rank assignment         */
74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define INSTRUCTION_CONTEXTS                                                   \
75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC,                    0,  "says nothing about the instruction")  \
76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_64BIT,              1,  "says the instruction applies in "     \
77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "64-bit mode but no more")             \
78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_OPSIZE,             3,  "requires an OPSIZE prefix, so "       \
79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "operands change width")               \
80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_XD,                 2,  "may say something about the opcode "  \
81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "but not the operands")                \
82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_XS,                 2,  "may say something about the opcode "  \
83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "but not the operands")                \
8419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_XD_OPSIZE,          3,  "requires an OPSIZE prefix, so "       \
8519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                        "operands change width")               \
8619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_XS_OPSIZE,          3,  "requires an OPSIZE prefix, so "       \
8719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                        "operands change width")               \
88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_64BIT_REXW,         4,  "requires a REX.W prefix, so operands "\
89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "change width; overrides IC_OPSIZE")   \
90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_64BIT_OPSIZE,       3,  "Just as meaningful as IC_OPSIZE")     \
91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_64BIT_XD,           5,  "XD instructions are SSE; REX.W is "   \
92894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "secondary")                           \
93894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_64BIT_XS,           5,  "Just as meaningful as IC_64BIT_XD")   \
9419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_64BIT_XD_OPSIZE,    3,  "Just as meaningful as IC_XD_OPSIZE")  \
9519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_64BIT_XS_OPSIZE,    3,  "Just as meaningful as IC_XS_OPSIZE")  \
96894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_64BIT_REXW_XS,      6,  "OPSIZE could mean a different "       \
97894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "opcode")                              \
98894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_64BIT_REXW_XD,      6,  "Just as meaningful as "               \
99894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "IC_64BIT_REXW_XS")                    \
100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(IC_64BIT_REXW_OPSIZE,  7,  "The Dynamic Duo!  Prefer over all "   \
101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                        "else because this changes most "      \
10219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                        "operands' meaning")                   \
10319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX,                1,  "requires a VEX prefix")               \
10419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_XS,             2,  "requires VEX and the XS prefix")      \
10519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_XD,             2,  "requires VEX and the XD prefix")      \
10619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_OPSIZE,         2,  "requires VEX and the OpSize prefix")  \
10719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_W,              3,  "requires VEX and the W prefix")       \
10819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_W_XS,           4,  "requires VEX, W, and XS prefix")      \
10919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_W_XD,           4,  "requires VEX, W, and XD prefix")      \
11019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_W_OPSIZE,       4,  "requires VEX, W, and OpSize")         \
11119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_L,              3,  "requires VEX and the L prefix")       \
11219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_L_XS,           4,  "requires VEX and the L and XS prefix")\
11319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_L_XD,           4,  "requires VEX and the L and XD prefix")\
11419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(IC_VEX_L_OPSIZE,       4,  "requires VEX, L, and OpSize")
11519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
117894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ENUM_ENTRY(n, r, d) n,
118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef enum {
119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  INSTRUCTION_CONTEXTS
120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  IC_max
121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} InstructionContext;
122894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#undef ENUM_ENTRY
123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Opcode types, which determine which decode table to use, both in the Intel
126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * manual and also for the decoder.
127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef enum {
129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ONEBYTE       = 0,
130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  TWOBYTE       = 1,
131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  THREEBYTE_38  = 2,
13219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  THREEBYTE_3A  = 3,
13319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  THREEBYTE_A6  = 4,
13419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  THREEBYTE_A7  = 5
135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} OpcodeType;
136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * The following structs are used for the hierarchical decode table.  After
139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * determining the instruction's class (i.e., which IC_* constant applies to
140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * it), the decoder reads the opcode.  Some instructions require specific
141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * values of the ModR/M byte, so the ModR/M byte indexes into the final table.
142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * If a ModR/M byte is not required, "required" is left unset, and the values
144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * for each instructionID are identical.
145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef uint16_t InstrUID;
148894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
149894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * ModRMDecisionType - describes the type of ModR/M decision, allowing the
151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * consumer to determine the number of entries in it.
152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * MODRM_ONEENTRY - No matter what the value of the ModR/M byte is, the decoded
154894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *                  instruction is the same.
155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * MODRM_SPLITRM  - If the ModR/M byte is between 0x00 and 0xbf, the opcode
156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *                  corresponds to one instruction; otherwise, it corresponds to
157894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *                  a different instruction.
158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * MODRM_FULL     - Potentially, each value of the ModR/M byte could correspond
159894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *                  to a different instruction.
160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
161894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define MODRMTYPES            \
163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(MODRM_ONEENTRY)  \
164894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(MODRM_SPLITRM)   \
165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(MODRM_FULL)
166894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ENUM_ENTRY(n) n,
168894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef enum {
169894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  MODRMTYPES
170894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  MODRM_max
171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} ModRMDecisionType;
172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#undef ENUM_ENTRY
173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * ModRMDecision - Specifies whether a ModR/M byte is needed and (if so) which
176894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *  instruction each possible value of the ModR/M byte corresponds to.  Once
177894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *  this information is known, we have narrowed down to a single instruction.
178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct ModRMDecision {
180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  uint8_t     modrm_type;
181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /* The macro below must be defined wherever this file is included. */
183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  INSTRUCTION_IDS
184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * OpcodeDecision - Specifies which set of ModR/M->instruction tables to look at
188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *   given a particular opcode.
189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct OpcodeDecision {
191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  struct ModRMDecision modRMDecisions[256];
192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
194894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * ContextDecision - Specifies which opcode->instruction tables to look at given
196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *   a particular context (set of attributes).  Since there are many possible
197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *   contexts, the decoder first uses CONTEXTS_SYM to determine which context
198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *   applies given a specific set of attributes.  Hence there are only IC_max
199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *   entries in this table, rather than 2^(ATTR_max).
200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct ContextDecision {
202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  struct OpcodeDecision opcodeDecisions[IC_max];
203894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Physical encodings of instruction operands.
207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ENCODINGS                                                              \
210894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_NONE,   "")                                              \
211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_REG,    "Register operand in ModR/M byte.")              \
212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_RM,     "R/M operand in ModR/M byte.")                   \
21319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(ENCODING_VVVV,   "Register operand in VEX.vvvv byte.")            \
214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_CB,     "1-byte code offset (possible new CS value)")    \
215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_CW,     "2-byte")                                        \
216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_CD,     "4-byte")                                        \
217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_CP,     "6-byte")                                        \
218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_CO,     "8-byte")                                        \
219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_CT,     "10-byte")                                       \
220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_IB,     "1-byte immediate")                              \
221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_IW,     "2-byte")                                        \
222894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_ID,     "4-byte")                                        \
223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_IO,     "8-byte")                                        \
224894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_RB,     "(AL..DIL, R8L..R15L) Register code added to "   \
225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                              "the opcode byte")                               \
226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_RW,     "(AX..DI, R8W..R15W)")                           \
227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_RD,     "(EAX..EDI, R8D..R15D)")                         \
228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_RO,     "(RAX..RDI, R8..R15)")                           \
229894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_I,      "Position on floating-point stack added to the " \
230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                              "opcode byte")                                   \
231894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                                                               \
232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_Iv,     "Immediate of operand size")                     \
233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_Ia,     "Immediate of address size")                     \
234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_Rv,     "Register code of operand size added to the "    \
235894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                              "opcode byte")                                   \
236894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(ENCODING_DUP,    "Duplicate of another operand; ID is encoded "   \
237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                              "in type")
238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
239894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ENUM_ENTRY(n, d) n,
240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  typedef enum {
241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    ENCODINGS
242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    ENCODING_max
243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  } OperandEncoding;
244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#undef ENUM_ENTRY
245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Semantic interpretations of instruction operands.
248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define TYPES                                                                  \
251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_NONE,       "")                                              \
252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_REL8,       "1-byte immediate address")                      \
253894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_REL16,      "2-byte")                                        \
254894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_REL32,      "4-byte")                                        \
255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_REL64,      "8-byte")                                        \
256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_PTR1616,    "2+2-byte segment+offset address")               \
257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_PTR1632,    "2+4-byte")                                      \
258894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_PTR1664,    "2+8-byte")                                      \
259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_R8,         "1-byte register operand")                       \
260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_R16,        "2-byte")                                        \
261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_R32,        "4-byte")                                        \
262894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_R64,        "8-byte")                                        \
263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_IMM8,       "1-byte immediate operand")                      \
264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_IMM16,      "2-byte")                                        \
265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_IMM32,      "4-byte")                                        \
266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_IMM64,      "8-byte")                                        \
267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_IMM3,       "1-byte immediate operand between 0 and 7")      \
268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_RM8,        "1-byte register or memory operand")             \
269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_RM16,       "2-byte")                                        \
270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_RM32,       "4-byte")                                        \
271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_RM64,       "8-byte")                                        \
272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M,          "Memory operand")                                \
273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M8,         "1-byte")                                        \
274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M16,        "2-byte")                                        \
275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M32,        "4-byte")                                        \
276894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M64,        "8-byte")                                        \
277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_LEA,        "Effective address")                             \
278894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M128,       "16-byte (SSE/SSE2)")                            \
27919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(TYPE_M256,       "256-byte (AVX)")                                \
280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M1616,      "2+2-byte segment+offset address")               \
281894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M1632,      "2+4-byte")                                      \
282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M1664,      "2+8-byte")                                      \
283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M16_32,     "2+4-byte two-part memory operand (LIDT, LGDT)") \
284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M16_16,     "2+2-byte (BOUND)")                              \
285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M32_32,     "4+4-byte (BOUND)")                              \
286894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M16_64,     "2+8-byte (LIDT, LGDT)")                         \
287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_MOFFS8,     "1-byte memory offset (relative to segment "     \
288894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                              "base)")                                         \
289894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_MOFFS16,    "2-byte")                                        \
290894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_MOFFS32,    "4-byte")                                        \
291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_MOFFS64,    "8-byte")                                        \
292894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_SREG,       "Byte with single bit set: 0 = ES, 1 = CS, "     \
293894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                              "2 = SS, 3 = DS, 4 = FS, 5 = GS")                \
294894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M32FP,      "32-bit IEE754 memory floating-point operand")   \
295894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M64FP,      "64-bit")                                        \
296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M80FP,      "80-bit extended")                               \
297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M16INT,     "2-byte memory integer operand for use in "      \
298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                              "floating-point instructions")                   \
299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M32INT,     "4-byte")                                        \
300894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M64INT,     "8-byte")                                        \
301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_ST,         "Position on the floating-point stack")          \
302894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_MM,         "MMX register operand")                          \
303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_MM32,       "4-byte MMX register or memory operand")         \
304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_MM64,       "8-byte")                                        \
305894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_XMM,        "XMM register operand")                          \
306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_XMM32,      "4-byte XMM register or memory operand")         \
307894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_XMM64,      "8-byte")                                        \
308894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_XMM128,     "16-byte")                                       \
30919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  ENUM_ENTRY(TYPE_XMM256,     "32-byte")                                       \
310894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_XMM0,       "Implicit use of XMM0")                          \
311894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_SEGMENTREG, "Segment register operand")                      \
312894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_DEBUGREG,   "Debug register operand")                        \
313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_CONTROLREG, "Control register operand")                      \
314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                                                               \
315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_Mv,         "Memory operand of operand size")                \
316894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_Rv,         "Register operand of operand size")              \
317894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_IMMv,       "Immediate operand of operand size")             \
318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_RELv,       "Immediate address of operand size")             \
319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_DUP0,       "Duplicate of operand 0")                        \
320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_DUP1,       "operand 1")                                     \
321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_DUP2,       "operand 2")                                     \
322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_DUP3,       "operand 3")                                     \
323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_DUP4,       "operand 4")                                     \
324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(TYPE_M512,       "512-bit FPU/MMX/XMM/MXCSR state")
325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ENUM_ENTRY(n, d) n,
327894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef enum {
328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  TYPES
329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  TYPE_max
330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} OperandType;
331894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#undef ENUM_ENTRY
332894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * OperandSpecifier - The specification for how to extract and interpret one
335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *   operand.
336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
337894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct OperandSpecifier {
338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  OperandEncoding  encoding;
339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  OperandType      type;
340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Indicates where the opcode modifier (if any) is to be found.  Extended
344894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * opcodes with AddRegFrm have the opcode modifier in the ModR/M byte.
345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
346894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define MODIFIER_TYPES        \
348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(MODIFIER_NONE)   \
349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(MODIFIER_OPCODE) \
350894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ENUM_ENTRY(MODIFIER_MODRM)
351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ENUM_ENTRY(n) n,
353894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef enum {
354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  MODIFIER_TYPES
355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  MODIFIER_max
356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} ModifierType;
357894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#undef ENUM_ENTRY
358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define X86_MAX_OPERANDS 5
360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * The specification for how to extract and interpret a full instruction and
363894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * its operands.
364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct InstructionSpecifier {
366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ModifierType modifierType;
367894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  uint8_t modifierBase;
368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  struct OperandSpecifier operands[X86_MAX_OPERANDS];
369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
370894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /* The macro below must be defined wherever this file is included. */
371894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  INSTRUCTION_SPECIFIER_FIELDS
372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Decoding mode for the Intel disassembler.  16-bit, 32-bit, and 64-bit mode
376894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * are supported, and represent real mode, IA-32e, and IA-32e in 64-bit mode,
377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * respectively.
378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
379894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef enum {
380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  MODE_16BIT,
381894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  MODE_32BIT,
382894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  MODE_64BIT
383894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} DisassemblerMode;
384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
386