1*4ba319b5SDimitry Andric //===-- X86DisassemblerDecoderCommon.h - Disassembler decoder ---*- C++ -*-===// 2*4ba319b5SDimitry Andric // 3*4ba319b5SDimitry Andric // The LLVM Compiler Infrastructure 4*4ba319b5SDimitry Andric // 5*4ba319b5SDimitry Andric // This file is distributed under the University of Illinois Open Source 6*4ba319b5SDimitry Andric // License. See LICENSE.TXT for details. 7*4ba319b5SDimitry Andric // 8*4ba319b5SDimitry Andric //===----------------------------------------------------------------------===// 9*4ba319b5SDimitry Andric // 10*4ba319b5SDimitry Andric // This file is part of the X86 Disassembler. 11*4ba319b5SDimitry Andric // It contains common definitions used by both the disassembler and the table 12*4ba319b5SDimitry Andric // generator. 13*4ba319b5SDimitry Andric // Documentation for the disassembler can be found in X86Disassembler.h. 14*4ba319b5SDimitry Andric // 15*4ba319b5SDimitry Andric //===----------------------------------------------------------------------===// 16*4ba319b5SDimitry Andric 17*4ba319b5SDimitry Andric #ifndef LLVM_LIB_TARGET_X86_DISASSEMBLER_X86DISASSEMBLERDECODERCOMMON_H 18*4ba319b5SDimitry Andric #define LLVM_LIB_TARGET_X86_DISASSEMBLER_X86DISASSEMBLERDECODERCOMMON_H 19*4ba319b5SDimitry Andric 20*4ba319b5SDimitry Andric #include "llvm/Support/DataTypes.h" 21*4ba319b5SDimitry Andric 22*4ba319b5SDimitry Andric namespace llvm { 23*4ba319b5SDimitry Andric namespace X86Disassembler { 24*4ba319b5SDimitry Andric 25*4ba319b5SDimitry Andric #define INSTRUCTIONS_SYM x86DisassemblerInstrSpecifiers 26*4ba319b5SDimitry Andric #define CONTEXTS_SYM x86DisassemblerContexts 27*4ba319b5SDimitry Andric #define ONEBYTE_SYM x86DisassemblerOneByteOpcodes 28*4ba319b5SDimitry Andric #define TWOBYTE_SYM x86DisassemblerTwoByteOpcodes 29*4ba319b5SDimitry Andric #define THREEBYTE38_SYM x86DisassemblerThreeByte38Opcodes 30*4ba319b5SDimitry Andric #define THREEBYTE3A_SYM x86DisassemblerThreeByte3AOpcodes 31*4ba319b5SDimitry Andric #define XOP8_MAP_SYM x86DisassemblerXOP8Opcodes 32*4ba319b5SDimitry Andric #define XOP9_MAP_SYM x86DisassemblerXOP9Opcodes 33*4ba319b5SDimitry Andric #define XOPA_MAP_SYM x86DisassemblerXOPAOpcodes 34*4ba319b5SDimitry Andric #define THREEDNOW_MAP_SYM x86Disassembler3DNowOpcodes 35*4ba319b5SDimitry Andric 36*4ba319b5SDimitry Andric #define INSTRUCTIONS_STR "x86DisassemblerInstrSpecifiers" 37*4ba319b5SDimitry Andric #define CONTEXTS_STR "x86DisassemblerContexts" 38*4ba319b5SDimitry Andric #define ONEBYTE_STR "x86DisassemblerOneByteOpcodes" 39*4ba319b5SDimitry Andric #define TWOBYTE_STR "x86DisassemblerTwoByteOpcodes" 40*4ba319b5SDimitry Andric #define THREEBYTE38_STR "x86DisassemblerThreeByte38Opcodes" 41*4ba319b5SDimitry Andric #define THREEBYTE3A_STR "x86DisassemblerThreeByte3AOpcodes" 42*4ba319b5SDimitry Andric #define XOP8_MAP_STR "x86DisassemblerXOP8Opcodes" 43*4ba319b5SDimitry Andric #define XOP9_MAP_STR "x86DisassemblerXOP9Opcodes" 44*4ba319b5SDimitry Andric #define XOPA_MAP_STR "x86DisassemblerXOPAOpcodes" 45*4ba319b5SDimitry Andric #define THREEDNOW_MAP_STR "x86Disassembler3DNowOpcodes" 46*4ba319b5SDimitry Andric 47*4ba319b5SDimitry Andric // Attributes of an instruction that must be known before the opcode can be 48*4ba319b5SDimitry Andric // processed correctly. Most of these indicate the presence of particular 49*4ba319b5SDimitry Andric // prefixes, but ATTR_64BIT is simply an attribute of the decoding context. 50*4ba319b5SDimitry Andric #define ATTRIBUTE_BITS \ 51*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_NONE, 0x00) \ 52*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_64BIT, (0x1 << 0)) \ 53*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_XS, (0x1 << 1)) \ 54*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_XD, (0x1 << 2)) \ 55*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_REXW, (0x1 << 3)) \ 56*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_OPSIZE, (0x1 << 4)) \ 57*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_ADSIZE, (0x1 << 5)) \ 58*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_VEX, (0x1 << 6)) \ 59*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_VEXL, (0x1 << 7)) \ 60*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_EVEX, (0x1 << 8)) \ 61*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_EVEXL, (0x1 << 9)) \ 62*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_EVEXL2, (0x1 << 10)) \ 63*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_EVEXK, (0x1 << 11)) \ 64*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_EVEXKZ, (0x1 << 12)) \ 65*4ba319b5SDimitry Andric ENUM_ENTRY(ATTR_EVEXB, (0x1 << 13)) 66*4ba319b5SDimitry Andric 67*4ba319b5SDimitry Andric #define ENUM_ENTRY(n, v) n = v, 68*4ba319b5SDimitry Andric enum attributeBits { 69*4ba319b5SDimitry Andric ATTRIBUTE_BITS 70*4ba319b5SDimitry Andric ATTR_max 71*4ba319b5SDimitry Andric }; 72*4ba319b5SDimitry Andric #undef ENUM_ENTRY 73*4ba319b5SDimitry Andric 74*4ba319b5SDimitry Andric // Combinations of the above attributes that are relevant to instruction 75*4ba319b5SDimitry Andric // decode. Although other combinations are possible, they can be reduced to 76*4ba319b5SDimitry Andric // these without affecting the ultimately decoded instruction. 77*4ba319b5SDimitry Andric 78*4ba319b5SDimitry Andric // Class name Rank Rationale for rank assignment 79*4ba319b5SDimitry Andric #define INSTRUCTION_CONTEXTS \ 80*4ba319b5SDimitry Andric ENUM_ENTRY(IC, 0, "says nothing about the instruction") \ 81*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT, 1, "says the instruction applies in " \ 82*4ba319b5SDimitry Andric "64-bit mode but no more") \ 83*4ba319b5SDimitry Andric ENUM_ENTRY(IC_OPSIZE, 3, "requires an OPSIZE prefix, so " \ 84*4ba319b5SDimitry Andric "operands change width") \ 85*4ba319b5SDimitry Andric ENUM_ENTRY(IC_ADSIZE, 3, "requires an ADSIZE prefix, so " \ 86*4ba319b5SDimitry Andric "operands change width") \ 87*4ba319b5SDimitry Andric ENUM_ENTRY(IC_OPSIZE_ADSIZE, 4, "requires ADSIZE and OPSIZE prefixes") \ 88*4ba319b5SDimitry Andric ENUM_ENTRY(IC_XD, 2, "may say something about the opcode " \ 89*4ba319b5SDimitry Andric "but not the operands") \ 90*4ba319b5SDimitry Andric ENUM_ENTRY(IC_XS, 2, "may say something about the opcode " \ 91*4ba319b5SDimitry Andric "but not the operands") \ 92*4ba319b5SDimitry Andric ENUM_ENTRY(IC_XD_OPSIZE, 3, "requires an OPSIZE prefix, so " \ 93*4ba319b5SDimitry Andric "operands change width") \ 94*4ba319b5SDimitry Andric ENUM_ENTRY(IC_XS_OPSIZE, 3, "requires an OPSIZE prefix, so " \ 95*4ba319b5SDimitry Andric "operands change width") \ 96*4ba319b5SDimitry Andric ENUM_ENTRY(IC_XD_ADSIZE, 3, "requires an ADSIZE prefix, so " \ 97*4ba319b5SDimitry Andric "operands change width") \ 98*4ba319b5SDimitry Andric ENUM_ENTRY(IC_XS_ADSIZE, 3, "requires an ADSIZE prefix, so " \ 99*4ba319b5SDimitry Andric "operands change width") \ 100*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_REXW, 5, "requires a REX.W prefix, so operands "\ 101*4ba319b5SDimitry Andric "change width; overrides IC_OPSIZE") \ 102*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_REXW_ADSIZE, 6, "requires a REX.W prefix and 0x67 " \ 103*4ba319b5SDimitry Andric "prefix") \ 104*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_OPSIZE, 3, "Just as meaningful as IC_OPSIZE") \ 105*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_ADSIZE, 3, "Just as meaningful as IC_ADSIZE") \ 106*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_OPSIZE_ADSIZE, 4, "Just as meaningful as IC_OPSIZE/" \ 107*4ba319b5SDimitry Andric "IC_ADSIZE") \ 108*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_XD, 6, "XD instructions are SSE; REX.W is " \ 109*4ba319b5SDimitry Andric "secondary") \ 110*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_XS, 6, "Just as meaningful as IC_64BIT_XD") \ 111*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_XD_OPSIZE, 3, "Just as meaningful as IC_XD_OPSIZE") \ 112*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_XS_OPSIZE, 3, "Just as meaningful as IC_XS_OPSIZE") \ 113*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_XD_ADSIZE, 3, "Just as meaningful as IC_XD_ADSIZE") \ 114*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_XS_ADSIZE, 3, "Just as meaningful as IC_XS_ADSIZE") \ 115*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_REXW_XS, 7, "OPSIZE could mean a different " \ 116*4ba319b5SDimitry Andric "opcode") \ 117*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_REXW_XD, 7, "Just as meaningful as " \ 118*4ba319b5SDimitry Andric "IC_64BIT_REXW_XS") \ 119*4ba319b5SDimitry Andric ENUM_ENTRY(IC_64BIT_REXW_OPSIZE, 8, "The Dynamic Duo! Prefer over all " \ 120*4ba319b5SDimitry Andric "else because this changes most " \ 121*4ba319b5SDimitry Andric "operands' meaning") \ 122*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX, 1, "requires a VEX prefix") \ 123*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_XS, 2, "requires VEX and the XS prefix") \ 124*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_XD, 2, "requires VEX and the XD prefix") \ 125*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_OPSIZE, 2, "requires VEX and the OpSize prefix") \ 126*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_W, 3, "requires VEX and the W prefix") \ 127*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_W_XS, 4, "requires VEX, W, and XS prefix") \ 128*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_W_XD, 4, "requires VEX, W, and XD prefix") \ 129*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_W_OPSIZE, 4, "requires VEX, W, and OpSize") \ 130*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_L, 3, "requires VEX and the L prefix") \ 131*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_L_XS, 4, "requires VEX and the L and XS prefix")\ 132*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_L_XD, 4, "requires VEX and the L and XD prefix")\ 133*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_L_OPSIZE, 4, "requires VEX, L, and OpSize") \ 134*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_L_W, 4, "requires VEX, L and W") \ 135*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_L_W_XS, 5, "requires VEX, L, W and XS prefix") \ 136*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_L_W_XD, 5, "requires VEX, L, W and XD prefix") \ 137*4ba319b5SDimitry Andric ENUM_ENTRY(IC_VEX_L_W_OPSIZE, 5, "requires VEX, L, W and OpSize") \ 138*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX, 1, "requires an EVEX prefix") \ 139*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XS, 2, "requires EVEX and the XS prefix") \ 140*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XD, 2, "requires EVEX and the XD prefix") \ 141*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_OPSIZE, 2, "requires EVEX and the OpSize prefix") \ 142*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W, 3, "requires EVEX and the W prefix") \ 143*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XS, 4, "requires EVEX, W, and XS prefix") \ 144*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XD, 4, "requires EVEX, W, and XD prefix") \ 145*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_OPSIZE, 4, "requires EVEX, W, and OpSize") \ 146*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L, 3, "requires EVEX and the L prefix") \ 147*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XS, 4, "requires EVEX and the L and XS prefix")\ 148*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XD, 4, "requires EVEX and the L and XD prefix")\ 149*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_OPSIZE, 4, "requires EVEX, L, and OpSize") \ 150*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W, 3, "requires EVEX, L and W") \ 151*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XS, 4, "requires EVEX, L, W and XS prefix") \ 152*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XD, 4, "requires EVEX, L, W and XD prefix") \ 153*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_OPSIZE, 4, "requires EVEX, L, W and OpSize") \ 154*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2, 3, "requires EVEX and the L2 prefix") \ 155*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XS, 4, "requires EVEX and the L2 and XS prefix")\ 156*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XD, 4, "requires EVEX and the L2 and XD prefix")\ 157*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_OPSIZE, 4, "requires EVEX, L2, and OpSize") \ 158*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W, 3, "requires EVEX, L2 and W") \ 159*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XS, 4, "requires EVEX, L2, W and XS prefix") \ 160*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XD, 4, "requires EVEX, L2, W and XD prefix") \ 161*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE, 4, "requires EVEX, L2, W and OpSize") \ 162*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_K, 1, "requires an EVEX_K prefix") \ 163*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XS_K, 2, "requires EVEX_K and the XS prefix") \ 164*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XD_K, 2, "requires EVEX_K and the XD prefix") \ 165*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_OPSIZE_K, 2, "requires EVEX_K and the OpSize prefix") \ 166*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_K, 3, "requires EVEX_K and the W prefix") \ 167*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XS_K, 4, "requires EVEX_K, W, and XS prefix") \ 168*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XD_K, 4, "requires EVEX_K, W, and XD prefix") \ 169*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_OPSIZE_K, 4, "requires EVEX_K, W, and OpSize") \ 170*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_K, 3, "requires EVEX_K and the L prefix") \ 171*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XS_K, 4, "requires EVEX_K and the L and XS prefix")\ 172*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XD_K, 4, "requires EVEX_K and the L and XD prefix")\ 173*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_OPSIZE_K, 4, "requires EVEX_K, L, and OpSize") \ 174*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_K, 3, "requires EVEX_K, L and W") \ 175*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XS_K, 4, "requires EVEX_K, L, W and XS prefix") \ 176*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XD_K, 4, "requires EVEX_K, L, W and XD prefix") \ 177*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_OPSIZE_K, 4, "requires EVEX_K, L, W and OpSize") \ 178*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_K, 3, "requires EVEX_K and the L2 prefix") \ 179*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XS_K, 4, "requires EVEX_K and the L2 and XS prefix")\ 180*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XD_K, 4, "requires EVEX_K and the L2 and XD prefix")\ 181*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_OPSIZE_K, 4, "requires EVEX_K, L2, and OpSize") \ 182*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_K, 3, "requires EVEX_K, L2 and W") \ 183*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XS_K, 4, "requires EVEX_K, L2, W and XS prefix") \ 184*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XD_K, 4, "requires EVEX_K, L2, W and XD prefix") \ 185*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_K, 4, "requires EVEX_K, L2, W and OpSize") \ 186*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_B, 1, "requires an EVEX_B prefix") \ 187*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XS_B, 2, "requires EVEX_B and the XS prefix") \ 188*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XD_B, 2, "requires EVEX_B and the XD prefix") \ 189*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_OPSIZE_B, 2, "requires EVEX_B and the OpSize prefix") \ 190*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_B, 3, "requires EVEX_B and the W prefix") \ 191*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XS_B, 4, "requires EVEX_B, W, and XS prefix") \ 192*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XD_B, 4, "requires EVEX_B, W, and XD prefix") \ 193*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_OPSIZE_B, 4, "requires EVEX_B, W, and OpSize") \ 194*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_B, 3, "requires EVEX_B and the L prefix") \ 195*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XS_B, 4, "requires EVEX_B and the L and XS prefix")\ 196*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XD_B, 4, "requires EVEX_B and the L and XD prefix")\ 197*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_OPSIZE_B, 4, "requires EVEX_B, L, and OpSize") \ 198*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_B, 3, "requires EVEX_B, L and W") \ 199*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XS_B, 4, "requires EVEX_B, L, W and XS prefix") \ 200*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XD_B, 4, "requires EVEX_B, L, W and XD prefix") \ 201*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_OPSIZE_B, 4, "requires EVEX_B, L, W and OpSize") \ 202*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_B, 3, "requires EVEX_B and the L2 prefix") \ 203*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XS_B, 4, "requires EVEX_B and the L2 and XS prefix")\ 204*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XD_B, 4, "requires EVEX_B and the L2 and XD prefix")\ 205*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_OPSIZE_B, 4, "requires EVEX_B, L2, and OpSize") \ 206*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_B, 3, "requires EVEX_B, L2 and W") \ 207*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XS_B, 4, "requires EVEX_B, L2, W and XS prefix") \ 208*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XD_B, 4, "requires EVEX_B, L2, W and XD prefix") \ 209*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_B, 4, "requires EVEX_B, L2, W and OpSize") \ 210*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_K_B, 1, "requires EVEX_B and EVEX_K prefix") \ 211*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XS_K_B, 2, "requires EVEX_B, EVEX_K and the XS prefix") \ 212*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XD_K_B, 2, "requires EVEX_B, EVEX_K and the XD prefix") \ 213*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_OPSIZE_K_B, 2, "requires EVEX_B, EVEX_K and the OpSize prefix") \ 214*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_K_B, 3, "requires EVEX_B, EVEX_K and the W prefix") \ 215*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XS_K_B, 4, "requires EVEX_B, EVEX_K, W, and XS prefix") \ 216*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XD_K_B, 4, "requires EVEX_B, EVEX_K, W, and XD prefix") \ 217*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_OPSIZE_K_B, 4, "requires EVEX_B, EVEX_K, W, and OpSize") \ 218*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_K_B, 3, "requires EVEX_B, EVEX_K and the L prefix") \ 219*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XS_K_B, 4, "requires EVEX_B, EVEX_K and the L and XS prefix")\ 220*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XD_K_B, 4, "requires EVEX_B, EVEX_K and the L and XD prefix")\ 221*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_OPSIZE_K_B, 4, "requires EVEX_B, EVEX_K, L, and OpSize") \ 222*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_K_B, 3, "requires EVEX_B, EVEX_K, L and W") \ 223*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XS_K_B, 4, "requires EVEX_B, EVEX_K, L, W and XS prefix") \ 224*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XD_K_B, 4, "requires EVEX_B, EVEX_K, L, W and XD prefix") \ 225*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_OPSIZE_K_B,4, "requires EVEX_B, EVEX_K, L, W and OpSize") \ 226*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_K_B, 3, "requires EVEX_B, EVEX_K and the L2 prefix") \ 227*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XS_K_B, 4, "requires EVEX_B, EVEX_K and the L2 and XS prefix")\ 228*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XD_K_B, 4, "requires EVEX_B, EVEX_K and the L2 and XD prefix")\ 229*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_OPSIZE_K_B, 4, "requires EVEX_B, EVEX_K, L2, and OpSize") \ 230*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_K_B, 3, "requires EVEX_B, EVEX_K, L2 and W") \ 231*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XS_K_B, 4, "requires EVEX_B, EVEX_K, L2, W and XS prefix") \ 232*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XD_K_B, 4, "requires EVEX_B, EVEX_K, L2, W and XD prefix") \ 233*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_K_B,4, "requires EVEX_B, EVEX_K, L2, W and OpSize") \ 234*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_KZ_B, 1, "requires EVEX_B and EVEX_KZ prefix") \ 235*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XS_KZ_B, 2, "requires EVEX_B, EVEX_KZ and the XS prefix") \ 236*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XD_KZ_B, 2, "requires EVEX_B, EVEX_KZ and the XD prefix") \ 237*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_OPSIZE_KZ_B, 2, "requires EVEX_B, EVEX_KZ and the OpSize prefix") \ 238*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_KZ_B, 3, "requires EVEX_B, EVEX_KZ and the W prefix") \ 239*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XS_KZ_B, 4, "requires EVEX_B, EVEX_KZ, W, and XS prefix") \ 240*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XD_KZ_B, 4, "requires EVEX_B, EVEX_KZ, W, and XD prefix") \ 241*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_OPSIZE_KZ_B, 4, "requires EVEX_B, EVEX_KZ, W, and OpSize") \ 242*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_KZ_B, 3, "requires EVEX_B, EVEX_KZ and the L prefix") \ 243*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XS_KZ_B, 4, "requires EVEX_B, EVEX_KZ and the L and XS prefix")\ 244*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XD_KZ_B, 4, "requires EVEX_B, EVEX_KZ and the L and XD prefix")\ 245*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_OPSIZE_KZ_B, 4, "requires EVEX_B, EVEX_KZ, L, and OpSize") \ 246*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_KZ_B, 3, "requires EVEX_B, EVEX_KZ, L and W") \ 247*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XS_KZ_B, 4, "requires EVEX_B, EVEX_KZ, L, W and XS prefix") \ 248*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XD_KZ_B, 4, "requires EVEX_B, EVEX_KZ, L, W and XD prefix") \ 249*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_OPSIZE_KZ_B, 4, "requires EVEX_B, EVEX_KZ, L, W and OpSize") \ 250*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_KZ_B, 3, "requires EVEX_B, EVEX_KZ and the L2 prefix") \ 251*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XS_KZ_B, 4, "requires EVEX_B, EVEX_KZ and the L2 and XS prefix")\ 252*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XD_KZ_B, 4, "requires EVEX_B, EVEX_KZ and the L2 and XD prefix")\ 253*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_OPSIZE_KZ_B, 4, "requires EVEX_B, EVEX_KZ, L2, and OpSize") \ 254*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_KZ_B, 3, "requires EVEX_B, EVEX_KZ, L2 and W") \ 255*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XS_KZ_B, 4, "requires EVEX_B, EVEX_KZ, L2, W and XS prefix") \ 256*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XD_KZ_B, 4, "requires EVEX_B, EVEX_KZ, L2, W and XD prefix") \ 257*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_KZ_B, 4, "requires EVEX_B, EVEX_KZ, L2, W and OpSize") \ 258*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_KZ, 1, "requires an EVEX_KZ prefix") \ 259*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XS_KZ, 2, "requires EVEX_KZ and the XS prefix") \ 260*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_XD_KZ, 2, "requires EVEX_KZ and the XD prefix") \ 261*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_OPSIZE_KZ, 2, "requires EVEX_KZ and the OpSize prefix") \ 262*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_KZ, 3, "requires EVEX_KZ and the W prefix") \ 263*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XS_KZ, 4, "requires EVEX_KZ, W, and XS prefix") \ 264*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_XD_KZ, 4, "requires EVEX_KZ, W, and XD prefix") \ 265*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_W_OPSIZE_KZ, 4, "requires EVEX_KZ, W, and OpSize") \ 266*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_KZ, 3, "requires EVEX_KZ and the L prefix") \ 267*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XS_KZ, 4, "requires EVEX_KZ and the L and XS prefix")\ 268*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_XD_KZ, 4, "requires EVEX_KZ and the L and XD prefix")\ 269*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_OPSIZE_KZ, 4, "requires EVEX_KZ, L, and OpSize") \ 270*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_KZ, 3, "requires EVEX_KZ, L and W") \ 271*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XS_KZ, 4, "requires EVEX_KZ, L, W and XS prefix") \ 272*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_XD_KZ, 4, "requires EVEX_KZ, L, W and XD prefix") \ 273*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L_W_OPSIZE_KZ, 4, "requires EVEX_KZ, L, W and OpSize") \ 274*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_KZ, 3, "requires EVEX_KZ and the L2 prefix") \ 275*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XS_KZ, 4, "requires EVEX_KZ and the L2 and XS prefix")\ 276*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_XD_KZ, 4, "requires EVEX_KZ and the L2 and XD prefix")\ 277*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_OPSIZE_KZ, 4, "requires EVEX_KZ, L2, and OpSize") \ 278*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_KZ, 3, "requires EVEX_KZ, L2 and W") \ 279*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XS_KZ, 4, "requires EVEX_KZ, L2, W and XS prefix") \ 280*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_XD_KZ, 4, "requires EVEX_KZ, L2, W and XD prefix") \ 281*4ba319b5SDimitry Andric ENUM_ENTRY(IC_EVEX_L2_W_OPSIZE_KZ, 4, "requires EVEX_KZ, L2, W and OpSize") 282*4ba319b5SDimitry Andric 283*4ba319b5SDimitry Andric #define ENUM_ENTRY(n, r, d) n, 284*4ba319b5SDimitry Andric enum InstructionContext { 285*4ba319b5SDimitry Andric INSTRUCTION_CONTEXTS 286*4ba319b5SDimitry Andric IC_max 287*4ba319b5SDimitry Andric }; 288*4ba319b5SDimitry Andric #undef ENUM_ENTRY 289*4ba319b5SDimitry Andric 290*4ba319b5SDimitry Andric // Opcode types, which determine which decode table to use, both in the Intel 291*4ba319b5SDimitry Andric // manual and also for the decoder. 292*4ba319b5SDimitry Andric enum OpcodeType { 293*4ba319b5SDimitry Andric ONEBYTE = 0, 294*4ba319b5SDimitry Andric TWOBYTE = 1, 295*4ba319b5SDimitry Andric THREEBYTE_38 = 2, 296*4ba319b5SDimitry Andric THREEBYTE_3A = 3, 297*4ba319b5SDimitry Andric XOP8_MAP = 4, 298*4ba319b5SDimitry Andric XOP9_MAP = 5, 299*4ba319b5SDimitry Andric XOPA_MAP = 6, 300*4ba319b5SDimitry Andric THREEDNOW_MAP = 7 301*4ba319b5SDimitry Andric }; 302*4ba319b5SDimitry Andric 303*4ba319b5SDimitry Andric // The following structs are used for the hierarchical decode table. After 304*4ba319b5SDimitry Andric // determining the instruction's class (i.e., which IC_* constant applies to 305*4ba319b5SDimitry Andric // it), the decoder reads the opcode. Some instructions require specific 306*4ba319b5SDimitry Andric // values of the ModR/M byte, so the ModR/M byte indexes into the final table. 307*4ba319b5SDimitry Andric // 308*4ba319b5SDimitry Andric // If a ModR/M byte is not required, "required" is left unset, and the values 309*4ba319b5SDimitry Andric // for each instructionID are identical. 310*4ba319b5SDimitry Andric typedef uint16_t InstrUID; 311*4ba319b5SDimitry Andric 312*4ba319b5SDimitry Andric // ModRMDecisionType - describes the type of ModR/M decision, allowing the 313*4ba319b5SDimitry Andric // consumer to determine the number of entries in it. 314*4ba319b5SDimitry Andric // 315*4ba319b5SDimitry Andric // MODRM_ONEENTRY - No matter what the value of the ModR/M byte is, the decoded 316*4ba319b5SDimitry Andric // instruction is the same. 317*4ba319b5SDimitry Andric // MODRM_SPLITRM - If the ModR/M byte is between 0x00 and 0xbf, the opcode 318*4ba319b5SDimitry Andric // corresponds to one instruction; otherwise, it corresponds to 319*4ba319b5SDimitry Andric // a different instruction. 320*4ba319b5SDimitry Andric // MODRM_SPLITMISC- If the ModR/M byte is between 0x00 and 0xbf, ModR/M byte 321*4ba319b5SDimitry Andric // divided by 8 is used to select instruction; otherwise, each 322*4ba319b5SDimitry Andric // value of the ModR/M byte could correspond to a different 323*4ba319b5SDimitry Andric // instruction. 324*4ba319b5SDimitry Andric // MODRM_SPLITREG - ModR/M byte divided by 8 is used to select instruction. This 325*4ba319b5SDimitry Andric // corresponds to instructions that use reg field as opcode 326*4ba319b5SDimitry Andric // MODRM_FULL - Potentially, each value of the ModR/M byte could correspond 327*4ba319b5SDimitry Andric // to a different instruction. 328*4ba319b5SDimitry Andric #define MODRMTYPES \ 329*4ba319b5SDimitry Andric ENUM_ENTRY(MODRM_ONEENTRY) \ 330*4ba319b5SDimitry Andric ENUM_ENTRY(MODRM_SPLITRM) \ 331*4ba319b5SDimitry Andric ENUM_ENTRY(MODRM_SPLITMISC) \ 332*4ba319b5SDimitry Andric ENUM_ENTRY(MODRM_SPLITREG) \ 333*4ba319b5SDimitry Andric ENUM_ENTRY(MODRM_FULL) 334*4ba319b5SDimitry Andric 335*4ba319b5SDimitry Andric #define ENUM_ENTRY(n) n, 336*4ba319b5SDimitry Andric enum ModRMDecisionType { 337*4ba319b5SDimitry Andric MODRMTYPES 338*4ba319b5SDimitry Andric MODRM_max 339*4ba319b5SDimitry Andric }; 340*4ba319b5SDimitry Andric #undef ENUM_ENTRY 341*4ba319b5SDimitry Andric 342*4ba319b5SDimitry Andric #define CASE_ENCODING_RM \ 343*4ba319b5SDimitry Andric case ENCODING_RM: \ 344*4ba319b5SDimitry Andric case ENCODING_RM_CD2: \ 345*4ba319b5SDimitry Andric case ENCODING_RM_CD4: \ 346*4ba319b5SDimitry Andric case ENCODING_RM_CD8: \ 347*4ba319b5SDimitry Andric case ENCODING_RM_CD16: \ 348*4ba319b5SDimitry Andric case ENCODING_RM_CD32: \ 349*4ba319b5SDimitry Andric case ENCODING_RM_CD64 350*4ba319b5SDimitry Andric 351*4ba319b5SDimitry Andric #define CASE_ENCODING_VSIB \ 352*4ba319b5SDimitry Andric case ENCODING_VSIB: \ 353*4ba319b5SDimitry Andric case ENCODING_VSIB_CD2: \ 354*4ba319b5SDimitry Andric case ENCODING_VSIB_CD4: \ 355*4ba319b5SDimitry Andric case ENCODING_VSIB_CD8: \ 356*4ba319b5SDimitry Andric case ENCODING_VSIB_CD16: \ 357*4ba319b5SDimitry Andric case ENCODING_VSIB_CD32: \ 358*4ba319b5SDimitry Andric case ENCODING_VSIB_CD64 359*4ba319b5SDimitry Andric 360*4ba319b5SDimitry Andric // Physical encodings of instruction operands. 361*4ba319b5SDimitry Andric #define ENCODINGS \ 362*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_NONE, "") \ 363*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_REG, "Register operand in ModR/M byte.") \ 364*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RM, "R/M operand in ModR/M byte.") \ 365*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RM_CD2, "R/M operand with CDisp scaling of 2") \ 366*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RM_CD4, "R/M operand with CDisp scaling of 4") \ 367*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RM_CD8, "R/M operand with CDisp scaling of 8") \ 368*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RM_CD16,"R/M operand with CDisp scaling of 16") \ 369*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RM_CD32,"R/M operand with CDisp scaling of 32") \ 370*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RM_CD64,"R/M operand with CDisp scaling of 64") \ 371*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_VSIB, "VSIB operand in ModR/M byte.") \ 372*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_VSIB_CD2, "VSIB operand with CDisp scaling of 2") \ 373*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_VSIB_CD4, "VSIB operand with CDisp scaling of 4") \ 374*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_VSIB_CD8, "VSIB operand with CDisp scaling of 8") \ 375*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_VSIB_CD16,"VSIB operand with CDisp scaling of 16") \ 376*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_VSIB_CD32,"VSIB operand with CDisp scaling of 32") \ 377*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_VSIB_CD64,"VSIB operand with CDisp scaling of 64") \ 378*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_VVVV, "Register operand in VEX.vvvv byte.") \ 379*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_WRITEMASK, "Register operand in EVEX.aaa byte.") \ 380*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_IB, "1-byte immediate") \ 381*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_IW, "2-byte") \ 382*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_ID, "4-byte") \ 383*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_IO, "8-byte") \ 384*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RB, "(AL..DIL, R8L..R15L) Register code added to " \ 385*4ba319b5SDimitry Andric "the opcode byte") \ 386*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RW, "(AX..DI, R8W..R15W)") \ 387*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RD, "(EAX..EDI, R8D..R15D)") \ 388*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_RO, "(RAX..RDI, R8..R15)") \ 389*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_FP, "Position on floating-point stack in ModR/M " \ 390*4ba319b5SDimitry Andric "byte.") \ 391*4ba319b5SDimitry Andric \ 392*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_Iv, "Immediate of operand size") \ 393*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_Ia, "Immediate of address size") \ 394*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_IRC, "Immediate for static rounding control") \ 395*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_Rv, "Register code of operand size added to the " \ 396*4ba319b5SDimitry Andric "opcode byte") \ 397*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_DUP, "Duplicate of another operand; ID is encoded " \ 398*4ba319b5SDimitry Andric "in type") \ 399*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_SI, "Source index; encoded in OpSize/Adsize prefix") \ 400*4ba319b5SDimitry Andric ENUM_ENTRY(ENCODING_DI, "Destination index; encoded in prefixes") 401*4ba319b5SDimitry Andric 402*4ba319b5SDimitry Andric #define ENUM_ENTRY(n, d) n, 403*4ba319b5SDimitry Andric enum OperandEncoding { 404*4ba319b5SDimitry Andric ENCODINGS 405*4ba319b5SDimitry Andric ENCODING_max 406*4ba319b5SDimitry Andric }; 407*4ba319b5SDimitry Andric #undef ENUM_ENTRY 408*4ba319b5SDimitry Andric 409*4ba319b5SDimitry Andric // Semantic interpretations of instruction operands. 410*4ba319b5SDimitry Andric #define TYPES \ 411*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_NONE, "") \ 412*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_REL, "immediate address") \ 413*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_R8, "1-byte register operand") \ 414*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_R16, "2-byte") \ 415*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_R32, "4-byte") \ 416*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_R64, "8-byte") \ 417*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_IMM, "immediate operand") \ 418*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_IMM3, "1-byte immediate operand between 0 and 7") \ 419*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_IMM5, "1-byte immediate operand between 0 and 31") \ 420*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_AVX512ICC, "1-byte immediate operand for AVX512 icmp") \ 421*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_UIMM8, "1-byte unsigned immediate operand") \ 422*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_M, "Memory operand") \ 423*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_MVSIBX, "Memory operand using XMM index") \ 424*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_MVSIBY, "Memory operand using YMM index") \ 425*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_MVSIBZ, "Memory operand using ZMM index") \ 426*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_SRCIDX, "memory at source index") \ 427*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_DSTIDX, "memory at destination index") \ 428*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_MOFFS, "memory offset (relative to segment base)") \ 429*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_ST, "Position on the floating-point stack") \ 430*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_MM64, "8-byte MMX register") \ 431*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_XMM, "16-byte") \ 432*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_YMM, "32-byte") \ 433*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_ZMM, "64-byte") \ 434*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_VK, "mask register") \ 435*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_SEGMENTREG, "Segment register operand") \ 436*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_DEBUGREG, "Debug register operand") \ 437*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_CONTROLREG, "Control register operand") \ 438*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_BNDR, "MPX bounds register") \ 439*4ba319b5SDimitry Andric \ 440*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_Rv, "Register operand of operand size") \ 441*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_RELv, "Immediate address of operand size") \ 442*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_DUP0, "Duplicate of operand 0") \ 443*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_DUP1, "operand 1") \ 444*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_DUP2, "operand 2") \ 445*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_DUP3, "operand 3") \ 446*4ba319b5SDimitry Andric ENUM_ENTRY(TYPE_DUP4, "operand 4") \ 447*4ba319b5SDimitry Andric 448*4ba319b5SDimitry Andric #define ENUM_ENTRY(n, d) n, 449*4ba319b5SDimitry Andric enum OperandType { 450*4ba319b5SDimitry Andric TYPES 451*4ba319b5SDimitry Andric TYPE_max 452*4ba319b5SDimitry Andric }; 453*4ba319b5SDimitry Andric #undef ENUM_ENTRY 454*4ba319b5SDimitry Andric 455*4ba319b5SDimitry Andric /// The specification for how to extract and interpret one operand. 456*4ba319b5SDimitry Andric struct OperandSpecifier { 457*4ba319b5SDimitry Andric uint8_t encoding; 458*4ba319b5SDimitry Andric uint8_t type; 459*4ba319b5SDimitry Andric }; 460*4ba319b5SDimitry Andric 461*4ba319b5SDimitry Andric static const unsigned X86_MAX_OPERANDS = 6; 462*4ba319b5SDimitry Andric 463*4ba319b5SDimitry Andric /// Decoding mode for the Intel disassembler. 16-bit, 32-bit, and 64-bit mode 464*4ba319b5SDimitry Andric /// are supported, and represent real mode, IA-32e, and IA-32e in 64-bit mode, 465*4ba319b5SDimitry Andric /// respectively. 466*4ba319b5SDimitry Andric enum DisassemblerMode { 467*4ba319b5SDimitry Andric MODE_16BIT, 468*4ba319b5SDimitry Andric MODE_32BIT, 469*4ba319b5SDimitry Andric MODE_64BIT 470*4ba319b5SDimitry Andric }; 471*4ba319b5SDimitry Andric 472*4ba319b5SDimitry Andric } // namespace X86Disassembler 473*4ba319b5SDimitry Andric } // namespace llvm 474*4ba319b5SDimitry Andric 475*4ba319b5SDimitry Andric #endif 476