diff options
Diffstat (limited to 'contrib/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h')
| -rw-r--r-- | contrib/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h | 366 | 
1 files changed, 163 insertions, 203 deletions
diff --git a/contrib/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h b/contrib/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h index dd1719c64d76..13a7b557b440 100644 --- a/contrib/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h +++ b/contrib/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h @@ -1,37 +1,33 @@ -/*===-- X86DisassemblerDecoderCommon.h - Disassembler decoder -----*- C -*-===* - * - *                     The LLVM Compiler Infrastructure - * - * This file is distributed under the University of Illinois Open Source - * License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===* - * - * This file is part of the X86 Disassembler. - * It contains common definitions used by both the disassembler and the table - *  generator. - * Documentation for the disassembler can be found in X86Disassembler.h. - * - *===----------------------------------------------------------------------===*/ - -/* - * This header file provides those definitions that need to be shared between - * the decoder and the table generator in a C-friendly manner. - */ +//===-- X86DisassemblerDecoderCommon.h - Disassembler decoder ---*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is part of the X86 Disassembler. +// It contains common definitions used by both the disassembler and the table +//  generator. +// Documentation for the disassembler can be found in X86Disassembler.h. +// +//===----------------------------------------------------------------------===//  #ifndef X86DISASSEMBLERDECODERCOMMON_H  #define X86DISASSEMBLERDECODERCOMMON_H  #include "llvm/Support/DataTypes.h" +namespace llvm { +namespace X86Disassembler { +  #define INSTRUCTIONS_SYM  x86DisassemblerInstrSpecifiers  #define CONTEXTS_SYM      x86DisassemblerContexts  #define ONEBYTE_SYM       x86DisassemblerOneByteOpcodes  #define TWOBYTE_SYM       x86DisassemblerTwoByteOpcodes  #define THREEBYTE38_SYM   x86DisassemblerThreeByte38Opcodes  #define THREEBYTE3A_SYM   x86DisassemblerThreeByte3AOpcodes -#define THREEBYTEA6_SYM   x86DisassemblerThreeByteA6Opcodes -#define THREEBYTEA7_SYM   x86DisassemblerThreeByteA7Opcodes  #define XOP8_MAP_SYM      x86DisassemblerXOP8Opcodes  #define XOP9_MAP_SYM      x86DisassemblerXOP9Opcodes  #define XOPA_MAP_SYM      x86DisassemblerXOPAOpcodes @@ -42,27 +38,29 @@  #define TWOBYTE_STR       "x86DisassemblerTwoByteOpcodes"  #define THREEBYTE38_STR   "x86DisassemblerThreeByte38Opcodes"  #define THREEBYTE3A_STR   "x86DisassemblerThreeByte3AOpcodes" -#define THREEBYTEA6_STR   "x86DisassemblerThreeByteA6Opcodes" -#define THREEBYTEA7_STR   "x86DisassemblerThreeByteA7Opcodes"  #define XOP8_MAP_STR      "x86DisassemblerXOP8Opcodes"  #define XOP9_MAP_STR      "x86DisassemblerXOP9Opcodes"  #define XOPA_MAP_STR      "x86DisassemblerXOPAOpcodes" -/* - * Attributes of an instruction that must be known before the opcode can be - * processed correctly.  Most of these indicate the presence of particular - * prefixes, but ATTR_64BIT is simply an attribute of the decoding context. - */ -#define ATTRIBUTE_BITS          \ -  ENUM_ENTRY(ATTR_NONE,   0x00) \ -  ENUM_ENTRY(ATTR_64BIT,  0x01) \ -  ENUM_ENTRY(ATTR_XS,     0x02) \ -  ENUM_ENTRY(ATTR_XD,     0x04) \ -  ENUM_ENTRY(ATTR_REXW,   0x08) \ -  ENUM_ENTRY(ATTR_OPSIZE, 0x10) \ -  ENUM_ENTRY(ATTR_ADSIZE, 0x20) \ -  ENUM_ENTRY(ATTR_VEX,    0x40) \ -  ENUM_ENTRY(ATTR_VEXL,   0x80) +// Attributes of an instruction that must be known before the opcode can be +// processed correctly.  Most of these indicate the presence of particular +// prefixes, but ATTR_64BIT is simply an attribute of the decoding context. +#define ATTRIBUTE_BITS                  \ +  ENUM_ENTRY(ATTR_NONE,   0x00)         \ +  ENUM_ENTRY(ATTR_64BIT,  (0x1 << 0))   \ +  ENUM_ENTRY(ATTR_XS,     (0x1 << 1))   \ +  ENUM_ENTRY(ATTR_XD,     (0x1 << 2))   \ +  ENUM_ENTRY(ATTR_REXW,   (0x1 << 3))   \ +  ENUM_ENTRY(ATTR_OPSIZE, (0x1 << 4))   \ +  ENUM_ENTRY(ATTR_ADSIZE, (0x1 << 5))   \ +  ENUM_ENTRY(ATTR_VEX,    (0x1 << 6))   \ +  ENUM_ENTRY(ATTR_VEXL,   (0x1 << 7))   \ +  ENUM_ENTRY(ATTR_EVEX,   (0x1 << 8))   \ +  ENUM_ENTRY(ATTR_EVEXL,  (0x1 << 9))   \ +  ENUM_ENTRY(ATTR_EVEXL2, (0x1 << 10))  \ +  ENUM_ENTRY(ATTR_EVEXK,  (0x1 << 11))  \ +  ENUM_ENTRY(ATTR_EVEXKZ, (0x1 << 12))  \ +  ENUM_ENTRY(ATTR_EVEXB,  (0x1 << 13))  #define ENUM_ENTRY(n, v) n = v,  enum attributeBits { @@ -71,13 +69,11 @@ enum attributeBits {  };  #undef ENUM_ENTRY -/* - * Combinations of the above attributes that are relevant to instruction - * decode.  Although other combinations are possible, they can be reduced to - * these without affecting the ultimately decoded instruction. - */ +// Combinations of the above attributes that are relevant to instruction +// decode. Although other combinations are possible, they can be reduced to +// these without affecting the ultimately decoded instruction. -/*           Class name           Rank  Rationale for rank assignment         */ +//           Class name           Rank  Rationale for rank assignment  #define INSTRUCTION_CONTEXTS                                                   \    ENUM_ENTRY(IC,                    0,  "says nothing about the instruction")  \    ENUM_ENTRY(IC_64BIT,              1,  "says the instruction applies in "     \ @@ -198,38 +194,38 @@ enum attributeBits {    ENUM_ENTRY(IC_EVEX_L2_W_XS_B,     4,  "requires EVEX_B, L2, W and XS prefix")    \    ENUM_ENTRY(IC_EVEX_L2_W_XD_B,     4,  "requires EVEX_B, L2, W and XD prefix")    \    ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_B, 4,  "requires EVEX_B, L2, W and OpSize")       \ -  ENUM_ENTRY(IC_EVEX_K_B,             1,  "requires EVEX_B and EVEX_K prefix")             \ -  ENUM_ENTRY(IC_EVEX_XS_K_B,          2,  "requires EVEX_B, EVEX_K and the XS prefix")     \ -  ENUM_ENTRY(IC_EVEX_XD_K_B,          2,  "requires EVEX_B, EVEX_K and the XD prefix")     \ -  ENUM_ENTRY(IC_EVEX_OPSIZE_K_B,      2,  "requires EVEX_B, EVEX_K and the OpSize prefix") \ -  ENUM_ENTRY(IC_EVEX_W_K_B,           3,  "requires EVEX_B, EVEX_K and the W prefix")      \ -  ENUM_ENTRY(IC_EVEX_W_XS_K_B,        4,  "requires EVEX_B, EVEX_K, W, and XS prefix")     \ -  ENUM_ENTRY(IC_EVEX_W_XD_K_B,        4,  "requires EVEX_B, EVEX_K, W, and XD prefix")     \ -  ENUM_ENTRY(IC_EVEX_W_OPSIZE_K_B,    4,  "requires EVEX_B, EVEX_K, W, and OpSize")        \ -  ENUM_ENTRY(IC_EVEX_L_K_B,           3,  "requires EVEX_B, EVEX_K and the L prefix")       \ -  ENUM_ENTRY(IC_EVEX_L_XS_K_B,        4,  "requires EVEX_B, EVEX_K and the L and XS prefix")\ -  ENUM_ENTRY(IC_EVEX_L_XD_K_B,        4,  "requires EVEX_B, EVEX_K and the L and XD prefix")\ -  ENUM_ENTRY(IC_EVEX_L_OPSIZE_K_B,    4,  "requires EVEX_B, EVEX_K, L, and OpSize")         \ -  ENUM_ENTRY(IC_EVEX_L_W_K_B,         3,  "requires EVEX_B, EVEX_K, L and W")               \ -  ENUM_ENTRY(IC_EVEX_L_W_XS_K_B,      4,  "requires EVEX_B, EVEX_K, L, W and XS prefix")    \ -  ENUM_ENTRY(IC_EVEX_L_W_XD_K_B,      4,  "requires EVEX_B, EVEX_K, L, W and XD prefix")    \ -  ENUM_ENTRY(IC_EVEX_L_W_OPSIZE_K_B,  4,  "requires EVEX_B, EVEX_K, L, W and OpSize")       \ -  ENUM_ENTRY(IC_EVEX_L2_K_B,          3,  "requires EVEX_B, EVEX_K and the L2 prefix")       \ -  ENUM_ENTRY(IC_EVEX_L2_XS_K_B,       4,  "requires EVEX_B, EVEX_K and the L2 and XS prefix")\ -  ENUM_ENTRY(IC_EVEX_L2_XD_K_B,       4,  "requires EVEX_B, EVEX_K and the L2 and XD prefix")\ -  ENUM_ENTRY(IC_EVEX_L2_OPSIZE_K_B,   4,  "requires EVEX_B, EVEX_K, L2, and OpSize")         \ -  ENUM_ENTRY(IC_EVEX_L2_W_K_B,        3,  "requires EVEX_B, EVEX_K, L2 and W")               \ -  ENUM_ENTRY(IC_EVEX_L2_W_XS_K_B,     4,  "requires EVEX_B, EVEX_K, L2, W and XS prefix")    \ -  ENUM_ENTRY(IC_EVEX_L2_W_XD_K_B,     4,  "requires EVEX_B, EVEX_K, L2, W and XD prefix")    \ -  ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_K_B, 4,  "requires EVEX_B, EVEX_K, L2, W and OpSize")       \ -  ENUM_ENTRY(IC_EVEX_KZ_B,             1,  "requires EVEX_B and EVEX_KZ prefix")             \ -  ENUM_ENTRY(IC_EVEX_XS_KZ_B,          2,  "requires EVEX_B, EVEX_KZ and the XS prefix")     \ -  ENUM_ENTRY(IC_EVEX_XD_KZ_B,          2,  "requires EVEX_B, EVEX_KZ and the XD prefix")     \ -  ENUM_ENTRY(IC_EVEX_OPSIZE_KZ_B,      2,  "requires EVEX_B, EVEX_KZ and the OpSize prefix") \ -  ENUM_ENTRY(IC_EVEX_W_KZ_B,           3,  "requires EVEX_B, EVEX_KZ and the W prefix")      \ -  ENUM_ENTRY(IC_EVEX_W_XS_KZ_B,        4,  "requires EVEX_B, EVEX_KZ, W, and XS prefix")     \ -  ENUM_ENTRY(IC_EVEX_W_XD_KZ_B,        4,  "requires EVEX_B, EVEX_KZ, W, and XD prefix")     \ -  ENUM_ENTRY(IC_EVEX_W_OPSIZE_KZ_B,    4,  "requires EVEX_B, EVEX_KZ, W, and OpSize")        \ +  ENUM_ENTRY(IC_EVEX_K_B,           1,  "requires EVEX_B and EVEX_K prefix")             \ +  ENUM_ENTRY(IC_EVEX_XS_K_B,        2,  "requires EVEX_B, EVEX_K and the XS prefix")     \ +  ENUM_ENTRY(IC_EVEX_XD_K_B,        2,  "requires EVEX_B, EVEX_K and the XD prefix")     \ +  ENUM_ENTRY(IC_EVEX_OPSIZE_K_B,    2,  "requires EVEX_B, EVEX_K and the OpSize prefix") \ +  ENUM_ENTRY(IC_EVEX_W_K_B,         3,  "requires EVEX_B, EVEX_K and the W prefix")      \ +  ENUM_ENTRY(IC_EVEX_W_XS_K_B,      4,  "requires EVEX_B, EVEX_K, W, and XS prefix")     \ +  ENUM_ENTRY(IC_EVEX_W_XD_K_B,      4,  "requires EVEX_B, EVEX_K, W, and XD prefix")     \ +  ENUM_ENTRY(IC_EVEX_W_OPSIZE_K_B,  4,  "requires EVEX_B, EVEX_K, W, and OpSize")        \ +  ENUM_ENTRY(IC_EVEX_L_K_B,         3,  "requires EVEX_B, EVEX_K and the L prefix")       \ +  ENUM_ENTRY(IC_EVEX_L_XS_K_B,      4,  "requires EVEX_B, EVEX_K and the L and XS prefix")\ +  ENUM_ENTRY(IC_EVEX_L_XD_K_B,      4,  "requires EVEX_B, EVEX_K and the L and XD prefix")\ +  ENUM_ENTRY(IC_EVEX_L_OPSIZE_K_B,  4,  "requires EVEX_B, EVEX_K, L, and OpSize")         \ +  ENUM_ENTRY(IC_EVEX_L_W_K_B,       3,  "requires EVEX_B, EVEX_K, L and W")               \ +  ENUM_ENTRY(IC_EVEX_L_W_XS_K_B,    4,  "requires EVEX_B, EVEX_K, L, W and XS prefix")    \ +  ENUM_ENTRY(IC_EVEX_L_W_XD_K_B,    4,  "requires EVEX_B, EVEX_K, L, W and XD prefix")    \ +  ENUM_ENTRY(IC_EVEX_L_W_OPSIZE_K_B,4,  "requires EVEX_B, EVEX_K, L, W and OpSize")       \ +  ENUM_ENTRY(IC_EVEX_L2_K_B,        3,  "requires EVEX_B, EVEX_K and the L2 prefix")       \ +  ENUM_ENTRY(IC_EVEX_L2_XS_K_B,     4,  "requires EVEX_B, EVEX_K and the L2 and XS prefix")\ +  ENUM_ENTRY(IC_EVEX_L2_XD_K_B,     4,  "requires EVEX_B, EVEX_K and the L2 and XD prefix")\ +  ENUM_ENTRY(IC_EVEX_L2_OPSIZE_K_B, 4,  "requires EVEX_B, EVEX_K, L2, and OpSize")         \ +  ENUM_ENTRY(IC_EVEX_L2_W_K_B,      3,  "requires EVEX_B, EVEX_K, L2 and W")               \ +  ENUM_ENTRY(IC_EVEX_L2_W_XS_K_B,   4,  "requires EVEX_B, EVEX_K, L2, W and XS prefix")    \ +  ENUM_ENTRY(IC_EVEX_L2_W_XD_K_B,   4,  "requires EVEX_B, EVEX_K, L2, W and XD prefix")    \ +  ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_K_B,4,  "requires EVEX_B, EVEX_K, L2, W and OpSize")       \ +  ENUM_ENTRY(IC_EVEX_KZ_B,           1,  "requires EVEX_B and EVEX_KZ prefix")             \ +  ENUM_ENTRY(IC_EVEX_XS_KZ_B,        2,  "requires EVEX_B, EVEX_KZ and the XS prefix")     \ +  ENUM_ENTRY(IC_EVEX_XD_KZ_B,        2,  "requires EVEX_B, EVEX_KZ and the XD prefix")     \ +  ENUM_ENTRY(IC_EVEX_OPSIZE_KZ_B,    2,  "requires EVEX_B, EVEX_KZ and the OpSize prefix") \ +  ENUM_ENTRY(IC_EVEX_W_KZ_B,         3,  "requires EVEX_B, EVEX_KZ and the W prefix")      \ +  ENUM_ENTRY(IC_EVEX_W_XS_KZ_B,      4,  "requires EVEX_B, EVEX_KZ, W, and XS prefix")     \ +  ENUM_ENTRY(IC_EVEX_W_XD_KZ_B,      4,  "requires EVEX_B, EVEX_KZ, W, and XD prefix")     \ +  ENUM_ENTRY(IC_EVEX_W_OPSIZE_KZ_B,  4,  "requires EVEX_B, EVEX_KZ, W, and OpSize")        \    ENUM_ENTRY(IC_EVEX_L_KZ_B,           3,  "requires EVEX_B, EVEX_KZ and the L prefix")       \    ENUM_ENTRY(IC_EVEX_L_XS_KZ_B,        4,  "requires EVEX_B, EVEX_KZ and the L and XS prefix")\    ENUM_ENTRY(IC_EVEX_L_XD_KZ_B,        4,  "requires EVEX_B, EVEX_KZ and the L and XD prefix")\ @@ -269,62 +265,52 @@ enum attributeBits {    ENUM_ENTRY(IC_EVEX_L2_W_KZ,        3,  "requires EVEX_KZ, L2 and W")               \    ENUM_ENTRY(IC_EVEX_L2_W_XS_KZ,     4,  "requires EVEX_KZ, L2, W and XS prefix")    \    ENUM_ENTRY(IC_EVEX_L2_W_XD_KZ,     4,  "requires EVEX_KZ, L2, W and XD prefix")    \ -  ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_KZ, 4,  "requires EVEX_KZ, L2, W and OpSize")      +  ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_KZ, 4,  "requires EVEX_KZ, L2, W and OpSize")  #define ENUM_ENTRY(n, r, d) n, -typedef enum { +enum InstructionContext {    INSTRUCTION_CONTEXTS    IC_max -} InstructionContext; +};  #undef ENUM_ENTRY -/* - * Opcode types, which determine which decode table to use, both in the Intel - * manual and also for the decoder. - */ -typedef enum { +// Opcode types, which determine which decode table to use, both in the Intel +// manual and also for the decoder. +enum OpcodeType {    ONEBYTE       = 0,    TWOBYTE       = 1,    THREEBYTE_38  = 2,    THREEBYTE_3A  = 3, -  THREEBYTE_A6  = 4, -  THREEBYTE_A7  = 5, -  XOP8_MAP      = 6, -  XOP9_MAP      = 7, -  XOPA_MAP      = 8 -} OpcodeType; - -/* - * The following structs are used for the hierarchical decode table.  After - * determining the instruction's class (i.e., which IC_* constant applies to - * it), the decoder reads the opcode.  Some instructions require specific - * values of the ModR/M byte, so the ModR/M byte indexes into the final table. - * - * If a ModR/M byte is not required, "required" is left unset, and the values - * for each instructionID are identical. - */ +  XOP8_MAP      = 4, +  XOP9_MAP      = 5, +  XOPA_MAP      = 6 +}; +// The following structs are used for the hierarchical decode table.  After +// determining the instruction's class (i.e., which IC_* constant applies to +// it), the decoder reads the opcode.  Some instructions require specific +// values of the ModR/M byte, so the ModR/M byte indexes into the final table. +// +// If a ModR/M byte is not required, "required" is left unset, and the values +// for each instructionID are identical.  typedef uint16_t InstrUID; -/* - * ModRMDecisionType - describes the type of ModR/M decision, allowing the - * consumer to determine the number of entries in it. - * - * MODRM_ONEENTRY - No matter what the value of the ModR/M byte is, the decoded - *                  instruction is the same. - * MODRM_SPLITRM  - If the ModR/M byte is between 0x00 and 0xbf, the opcode - *                  corresponds to one instruction; otherwise, it corresponds to - *                  a different instruction. - * MODRM_SPLITMISC- If the ModR/M byte is between 0x00 and 0xbf, ModR/M byte - *                  divided by 8 is used to select instruction; otherwise, each - *                  value of the ModR/M byte could correspond to a different - *                  instruction. - * MODRM_SPLITREG - ModR/M byte divided by 8 is used to select instruction. This -                    corresponds to instructions that use reg field as opcode - * MODRM_FULL     - Potentially, each value of the ModR/M byte could correspond - *                  to a different instruction. - */ - +// ModRMDecisionType - describes the type of ModR/M decision, allowing the +// consumer to determine the number of entries in it. +// +// MODRM_ONEENTRY - No matter what the value of the ModR/M byte is, the decoded +//                  instruction is the same. +// MODRM_SPLITRM  - If the ModR/M byte is between 0x00 and 0xbf, the opcode +//                  corresponds to one instruction; otherwise, it corresponds to +//                  a different instruction. +// MODRM_SPLITMISC- If the ModR/M byte is between 0x00 and 0xbf, ModR/M byte +//                  divided by 8 is used to select instruction; otherwise, each +//                  value of the ModR/M byte could correspond to a different +//                  instruction. +// MODRM_SPLITREG - ModR/M byte divided by 8 is used to select instruction. This +//                  corresponds to instructions that use reg field as opcode +// MODRM_FULL     - Potentially, each value of the ModR/M byte could correspond +//                  to a different instruction.  #define MODRMTYPES            \    ENUM_ENTRY(MODRM_ONEENTRY)  \    ENUM_ENTRY(MODRM_SPLITRM)   \ @@ -333,51 +319,32 @@ typedef uint16_t InstrUID;    ENUM_ENTRY(MODRM_FULL)  #define ENUM_ENTRY(n) n, -typedef enum { +enum ModRMDecisionType {    MODRMTYPES    MODRM_max -} ModRMDecisionType; -#undef ENUM_ENTRY - -/* - * ModRMDecision - Specifies whether a ModR/M byte is needed and (if so) which - *  instruction each possible value of the ModR/M byte corresponds to.  Once - *  this information is known, we have narrowed down to a single instruction. - */ -struct ModRMDecision { -  uint8_t     modrm_type; - -  /* The macro below must be defined wherever this file is included. */ -  INSTRUCTION_IDS -}; - -/* - * OpcodeDecision - Specifies which set of ModR/M->instruction tables to look at - *   given a particular opcode. - */ -struct OpcodeDecision { -  struct ModRMDecision modRMDecisions[256]; -}; - -/* - * ContextDecision - Specifies which opcode->instruction tables to look at given - *   a particular context (set of attributes).  Since there are many possible - *   contexts, the decoder first uses CONTEXTS_SYM to determine which context - *   applies given a specific set of attributes.  Hence there are only IC_max - *   entries in this table, rather than 2^(ATTR_max). - */ -struct ContextDecision { -  struct OpcodeDecision opcodeDecisions[IC_max];  }; +#undef ENUM_ENTRY -/* - * Physical encodings of instruction operands. - */ +#define CASE_ENCODING_RM     \ +    case ENCODING_RM:        \ +    case ENCODING_RM_CD2:    \ +    case ENCODING_RM_CD4:    \ +    case ENCODING_RM_CD8:    \ +    case ENCODING_RM_CD16:   \ +    case ENCODING_RM_CD32:   \ +    case ENCODING_RM_CD64 +// Physical encodings of instruction operands.  #define ENCODINGS                                                              \    ENUM_ENTRY(ENCODING_NONE,   "")                                              \    ENUM_ENTRY(ENCODING_REG,    "Register operand in ModR/M byte.")              \    ENUM_ENTRY(ENCODING_RM,     "R/M operand in ModR/M byte.")                   \ +  ENUM_ENTRY(ENCODING_RM_CD2, "R/M operand with CDisp scaling of 2")           \ +  ENUM_ENTRY(ENCODING_RM_CD4, "R/M operand with CDisp scaling of 4")           \ +  ENUM_ENTRY(ENCODING_RM_CD8, "R/M operand with CDisp scaling of 8")           \ +  ENUM_ENTRY(ENCODING_RM_CD16,"R/M operand with CDisp scaling of 16")          \ +  ENUM_ENTRY(ENCODING_RM_CD32,"R/M operand with CDisp scaling of 32")          \ +  ENUM_ENTRY(ENCODING_RM_CD64,"R/M operand with CDisp scaling of 64")          \    ENUM_ENTRY(ENCODING_VVVV,   "Register operand in VEX.vvvv byte.")            \    ENUM_ENTRY(ENCODING_WRITEMASK, "Register operand in EVEX.aaa byte.")         \    ENUM_ENTRY(ENCODING_CB,     "1-byte code offset (possible new CS value)")    \ @@ -395,27 +362,26 @@ struct ContextDecision {    ENUM_ENTRY(ENCODING_RW,     "(AX..DI, R8W..R15W)")                           \    ENUM_ENTRY(ENCODING_RD,     "(EAX..EDI, R8D..R15D)")                         \    ENUM_ENTRY(ENCODING_RO,     "(RAX..RDI, R8..R15)")                           \ -  ENUM_ENTRY(ENCODING_I,      "Position on floating-point stack added to the " \ -                              "opcode byte")                                   \ +  ENUM_ENTRY(ENCODING_FP,     "Position on floating-point stack in ModR/M "    \ +                              "byte.")                                         \                                                                                 \    ENUM_ENTRY(ENCODING_Iv,     "Immediate of operand size")                     \    ENUM_ENTRY(ENCODING_Ia,     "Immediate of address size")                     \    ENUM_ENTRY(ENCODING_Rv,     "Register code of operand size added to the "    \                                "opcode byte")                                   \    ENUM_ENTRY(ENCODING_DUP,    "Duplicate of another operand; ID is encoded "   \ -                              "in type") +                              "in type")                                       \ +  ENUM_ENTRY(ENCODING_SI,     "Source index; encoded in OpSize/Adsize prefix") \ +  ENUM_ENTRY(ENCODING_DI,     "Destination index; encoded in prefixes")  #define ENUM_ENTRY(n, d) n, -  typedef enum { -    ENCODINGS -    ENCODING_max -  } OperandEncoding; +enum OperandEncoding { +  ENCODINGS +  ENCODING_max +};  #undef ENUM_ENTRY -/* - * Semantic interpretations of instruction operands. - */ - +// Semantic interpretations of instruction operands.  #define TYPES                                                                  \    ENUM_ENTRY(TYPE_NONE,       "")                                              \    ENUM_ENTRY(TYPE_REL8,       "1-byte immediate address")                      \ @@ -454,6 +420,14 @@ struct ContextDecision {    ENUM_ENTRY(TYPE_M16_16,     "2+2-byte (BOUND)")                              \    ENUM_ENTRY(TYPE_M32_32,     "4+4-byte (BOUND)")                              \    ENUM_ENTRY(TYPE_M16_64,     "2+8-byte (LIDT, LGDT)")                         \ +  ENUM_ENTRY(TYPE_SRCIDX8,    "1-byte memory at source index")                 \ +  ENUM_ENTRY(TYPE_SRCIDX16,   "2-byte memory at source index")                 \ +  ENUM_ENTRY(TYPE_SRCIDX32,   "4-byte memory at source index")                 \ +  ENUM_ENTRY(TYPE_SRCIDX64,   "8-byte memory at source index")                 \ +  ENUM_ENTRY(TYPE_DSTIDX8,    "1-byte memory at destination index")            \ +  ENUM_ENTRY(TYPE_DSTIDX16,   "2-byte memory at destination index")            \ +  ENUM_ENTRY(TYPE_DSTIDX32,   "4-byte memory at destination index")            \ +  ENUM_ENTRY(TYPE_DSTIDX64,   "8-byte memory at destination index")            \    ENUM_ENTRY(TYPE_MOFFS8,     "1-byte memory offset (relative to segment "     \                                "base)")                                         \    ENUM_ENTRY(TYPE_MOFFS16,    "2-byte")                                        \ @@ -478,8 +452,13 @@ struct ContextDecision {    ENUM_ENTRY(TYPE_XMM128,     "16-byte")                                       \    ENUM_ENTRY(TYPE_XMM256,     "32-byte")                                       \    ENUM_ENTRY(TYPE_XMM512,     "64-byte")                                       \ +  ENUM_ENTRY(TYPE_VK1,        "1-bit")                                         \ +  ENUM_ENTRY(TYPE_VK2,        "2-bit")                                         \ +  ENUM_ENTRY(TYPE_VK4,        "4-bit")                                         \    ENUM_ENTRY(TYPE_VK8,        "8-bit")                                         \    ENUM_ENTRY(TYPE_VK16,       "16-bit")                                        \ +  ENUM_ENTRY(TYPE_VK32,       "32-bit")                                        \ +  ENUM_ENTRY(TYPE_VK64,       "64-bit")                                        \    ENUM_ENTRY(TYPE_XMM0,       "Implicit use of XMM0")                          \    ENUM_ENTRY(TYPE_SEGMENTREG, "Segment register operand")                      \    ENUM_ENTRY(TYPE_DEBUGREG,   "Debug register operand")                        \ @@ -497,61 +476,42 @@ struct ContextDecision {    ENUM_ENTRY(TYPE_M512,       "512-bit FPU/MMX/XMM/MXCSR state")  #define ENUM_ENTRY(n, d) n, -typedef enum { +enum OperandType {    TYPES    TYPE_max -} OperandType; +};  #undef ENUM_ENTRY -/* - * OperandSpecifier - The specification for how to extract and interpret one - *   operand. - */ +/// \brief The specification for how to extract and interpret one operand.  struct OperandSpecifier {    uint8_t encoding;    uint8_t type;  }; -/* - * Indicates where the opcode modifier (if any) is to be found.  Extended - * opcodes with AddRegFrm have the opcode modifier in the ModR/M byte. - */ - +// Indicates where the opcode modifier (if any) is to be found.  Extended +// opcodes with AddRegFrm have the opcode modifier in the ModR/M byte.  #define MODIFIER_TYPES        \ -  ENUM_ENTRY(MODIFIER_NONE)   \ -  ENUM_ENTRY(MODIFIER_OPCODE) \ -  ENUM_ENTRY(MODIFIER_MODRM) +  ENUM_ENTRY(MODIFIER_NONE)  #define ENUM_ENTRY(n) n, -typedef enum { +enum ModifierType {    MODIFIER_TYPES    MODIFIER_max -} ModifierType; +};  #undef ENUM_ENTRY -#define X86_MAX_OPERANDS 5 - -/* - * The specification for how to extract and interpret a full instruction and - * its operands. - */ -struct InstructionSpecifier { -  uint8_t modifierType; -  uint8_t modifierBase; - -  /* The macro below must be defined wherever this file is included. */ -  INSTRUCTION_SPECIFIER_FIELDS -}; +static const unsigned X86_MAX_OPERANDS = 5; -/* - * Decoding mode for the Intel disassembler.  16-bit, 32-bit, and 64-bit mode - * are supported, and represent real mode, IA-32e, and IA-32e in 64-bit mode, - * respectively. - */ -typedef enum { +/// Decoding mode for the Intel disassembler.  16-bit, 32-bit, and 64-bit mode +/// are supported, and represent real mode, IA-32e, and IA-32e in 64-bit mode, +/// respectively. +enum DisassemblerMode {    MODE_16BIT,    MODE_32BIT,    MODE_64BIT -} DisassemblerMode; +}; + +} // namespace X86Disassembler +} // namespace llvm  #endif  | 
