Added compressed disp8 calculation for MVEX instructions without swizzle/broadcast/convert functionality

This commit is contained in:
flobernd 2017-06-23 01:15:42 +02:00
parent 6c370d29c9
commit d8f3843f57
3 changed files with 55 additions and 22 deletions

View File

@ -6509,8 +6509,8 @@ const ZydisInstructionDefinitionEVEX instructionDefinitionsEVEX[] =
const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
{
/*0000*/ { ZYDIS_MNEMONIC_CLEVICT0, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*0001*/ { ZYDIS_MNEMONIC_CLEVICT1, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*0000*/ { ZYDIS_MNEMONIC_CLEVICT0, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*0001*/ { ZYDIS_MNEMONIC_CLEVICT1, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*0002*/ { ZYDIS_MNEMONIC_VADDNPD, 4, 0x0880, 0x00, ZYDIS_MVEX_FUNC_SF_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0003*/ { ZYDIS_MNEMONIC_VADDNPD, 4, 0x0884, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0004*/ { ZYDIS_MNEMONIC_VADDNPD, 4, 0x0884, 0x00, ZYDIS_MVEX_FUNC_RC, ZYDIS_MASK_POLICY_ALLOWED },
@ -6526,7 +6526,7 @@ const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
/*000E*/ { ZYDIS_MNEMONIC_VADDSETSPS, 4, 0x088C, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_32, ZYDIS_MASK_POLICY_ALLOWED },
/*000F*/ { ZYDIS_MNEMONIC_VADDSETSPS, 4, 0x088C, 0x00, ZYDIS_MVEX_FUNC_RC, ZYDIS_MASK_POLICY_ALLOWED },
/*0010*/ { ZYDIS_MNEMONIC_VADDSETSPS, 4, 0x0890, 0x00, ZYDIS_MVEX_FUNC_SF_32, ZYDIS_MASK_POLICY_ALLOWED },
/*0011*/ { ZYDIS_MNEMONIC_VALIGND, 5, 0x0396, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0011*/ { ZYDIS_MNEMONIC_VALIGND, 5, 0x0396, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0012*/ { ZYDIS_MNEMONIC_VALIGND, 5, 0x039B, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0013*/ { ZYDIS_MNEMONIC_VBLENDMPD, 4, 0x0880, 0x00, ZYDIS_MVEX_FUNC_SF_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0014*/ { ZYDIS_MNEMONIC_VBLENDMPD, 4, 0x0884, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_64, ZYDIS_MASK_POLICY_ALLOWED },
@ -6576,7 +6576,7 @@ const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
/*0040*/ { ZYDIS_MNEMONIC_VCVTUDQ2PD, 3, 0x08B8, 0x00, ZYDIS_MVEX_FUNC_SI_32_BCST, ZYDIS_MASK_POLICY_ALLOWED },
/*0041*/ { ZYDIS_MNEMONIC_VCVTUDQ2PD, 3, 0x08BC, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_32, ZYDIS_MASK_POLICY_ALLOWED },
/*0042*/ { ZYDIS_MNEMONIC_VCVTUDQ2PD, 3, 0x08BC, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0043*/ { ZYDIS_MNEMONIC_VEXP223PS, 3, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0043*/ { ZYDIS_MNEMONIC_VEXP223PS, 3, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_F_32, ZYDIS_MASK_POLICY_ALLOWED },
/*0044*/ { ZYDIS_MNEMONIC_VEXP223PS, 3, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_SAE, ZYDIS_MASK_POLICY_ALLOWED },
/*0045*/ { ZYDIS_MNEMONIC_VEXP223PS, 3, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0046*/ { ZYDIS_MNEMONIC_VFIXUPNANPD, 4, 0x0880, 0x00, ZYDIS_MVEX_FUNC_SI_64, ZYDIS_MASK_POLICY_ALLOWED },
@ -6701,7 +6701,7 @@ const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
/*00BD*/ { ZYDIS_MNEMONIC_VLOADUNPACKLPD, 3, 0x08B8, 0x00, ZYDIS_MVEX_FUNC_UF_64, ZYDIS_MASK_POLICY_ALLOWED },
/*00BE*/ { ZYDIS_MNEMONIC_VLOADUNPACKLPS, 3, 0x0894, 0x00, ZYDIS_MVEX_FUNC_UF_32, ZYDIS_MASK_POLICY_ALLOWED },
/*00BF*/ { ZYDIS_MNEMONIC_VLOADUNPACKLQ, 3, 0x11B4, 0x00, ZYDIS_MVEX_FUNC_UI_64, ZYDIS_MASK_POLICY_ALLOWED },
/*00C0*/ { ZYDIS_MNEMONIC_VLOG2PS, 3, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*00C0*/ { ZYDIS_MNEMONIC_VLOG2PS, 3, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_F_32, ZYDIS_MASK_POLICY_ALLOWED },
/*00C1*/ { ZYDIS_MNEMONIC_VLOG2PS, 3, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_SAE, ZYDIS_MASK_POLICY_ALLOWED },
/*00C2*/ { ZYDIS_MNEMONIC_VLOG2PS, 3, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*00C3*/ { ZYDIS_MNEMONIC_VMOVAPD, 3, 0x08B8, 0x00, ZYDIS_MVEX_FUNC_UF_64, ZYDIS_MASK_POLICY_ALLOWED },
@ -6785,9 +6785,9 @@ const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
/*0111*/ { ZYDIS_MNEMONIC_VPCMPUD, 5, 0x03BE, 0x00, ZYDIS_MVEX_FUNC_SI_32, ZYDIS_MASK_POLICY_ALLOWED },
/*0112*/ { ZYDIS_MNEMONIC_VPCMPUD, 5, 0x03C3, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0113*/ { ZYDIS_MNEMONIC_VPCMPUD, 5, 0x03C3, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0114*/ { ZYDIS_MNEMONIC_VPERMD, 4, 0x0396, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0114*/ { ZYDIS_MNEMONIC_VPERMD, 4, 0x0396, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0115*/ { ZYDIS_MNEMONIC_VPERMD, 4, 0x039B, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0116*/ { ZYDIS_MNEMONIC_VPERMF32X4, 4, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0116*/ { ZYDIS_MNEMONIC_VPERMF32X4, 4, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0117*/ { ZYDIS_MNEMONIC_VPERMF32X4, 4, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0118*/ { ZYDIS_MNEMONIC_VPERMF32X4, 4, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0119*/ { ZYDIS_MNEMONIC_VPGATHERDD, 3, 0x11DE, 0x00, ZYDIS_MVEX_FUNC_UI_32, ZYDIS_MASK_POLICY_ALLOWED },
@ -6825,14 +6825,14 @@ const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
/*0139*/ { ZYDIS_MNEMONIC_VPORQ, 4, 0x0880, 0x00, ZYDIS_MVEX_FUNC_SI_64, ZYDIS_MASK_POLICY_ALLOWED },
/*013A*/ { ZYDIS_MNEMONIC_VPORQ, 4, 0x0884, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_64, ZYDIS_MASK_POLICY_ALLOWED },
/*013B*/ { ZYDIS_MNEMONIC_VPORQ, 4, 0x0884, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*013C*/ { ZYDIS_MNEMONIC_VPREFETCH0, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*013D*/ { ZYDIS_MNEMONIC_VPREFETCH1, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*013E*/ { ZYDIS_MNEMONIC_VPREFETCH2, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*013F*/ { ZYDIS_MNEMONIC_VPREFETCHE0, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*0140*/ { ZYDIS_MNEMONIC_VPREFETCHE1, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*0141*/ { ZYDIS_MNEMONIC_VPREFETCHE2, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*0142*/ { ZYDIS_MNEMONIC_VPREFETCHENTA, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*0143*/ { ZYDIS_MNEMONIC_VPREFETCHNTA, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_INVALID },
/*013C*/ { ZYDIS_MNEMONIC_VPREFETCH0, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*013D*/ { ZYDIS_MNEMONIC_VPREFETCH1, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*013E*/ { ZYDIS_MNEMONIC_VPREFETCH2, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*013F*/ { ZYDIS_MNEMONIC_VPREFETCHE0, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*0140*/ { ZYDIS_MNEMONIC_VPREFETCHE1, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*0141*/ { ZYDIS_MNEMONIC_VPREFETCHE2, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*0142*/ { ZYDIS_MNEMONIC_VPREFETCHENTA, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*0143*/ { ZYDIS_MNEMONIC_VPREFETCHNTA, 1, 0x16CA, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_INVALID },
/*0144*/ { ZYDIS_MNEMONIC_VPSBBD, 4, 0x08C4, 0x00, ZYDIS_MVEX_FUNC_SI_32, ZYDIS_MASK_POLICY_ALLOWED },
/*0145*/ { ZYDIS_MNEMONIC_VPSBBD, 4, 0x08C8, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_32, ZYDIS_MASK_POLICY_ALLOWED },
/*0146*/ { ZYDIS_MNEMONIC_VPSBBD, 4, 0x08C8, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
@ -6841,7 +6841,7 @@ const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
/*0149*/ { ZYDIS_MNEMONIC_VPSBBRD, 4, 0x08C8, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*014A*/ { ZYDIS_MNEMONIC_VPSCATTERDD, 3, 0x11E4, 0x00, ZYDIS_MVEX_FUNC_DI_32, ZYDIS_MASK_POLICY_ALLOWED },
/*014B*/ { ZYDIS_MNEMONIC_VPSCATTERDQ, 3, 0x11E7, 0x00, ZYDIS_MVEX_FUNC_DI_64, ZYDIS_MASK_POLICY_ALLOWED },
/*014C*/ { ZYDIS_MNEMONIC_VPSHUFD, 4, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*014C*/ { ZYDIS_MNEMONIC_VPSHUFD, 4, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_F_64, ZYDIS_MASK_POLICY_ALLOWED },
/*014D*/ { ZYDIS_MNEMONIC_VPSHUFD, 4, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*014E*/ { ZYDIS_MNEMONIC_VPSHUFD, 4, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*014F*/ { ZYDIS_MNEMONIC_VPSLLD, 4, 0x08D4, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_32, ZYDIS_MASK_POLICY_ALLOWED },
@ -6883,7 +6883,7 @@ const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
/*0173*/ { ZYDIS_MNEMONIC_VPXORQ, 4, 0x0880, 0x00, ZYDIS_MVEX_FUNC_SI_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0174*/ { ZYDIS_MNEMONIC_VPXORQ, 4, 0x0884, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_64, ZYDIS_MASK_POLICY_ALLOWED },
/*0175*/ { ZYDIS_MNEMONIC_VPXORQ, 4, 0x0884, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0176*/ { ZYDIS_MNEMONIC_VRCP23PS, 3, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0176*/ { ZYDIS_MNEMONIC_VRCP23PS, 3, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_F_32, ZYDIS_MASK_POLICY_ALLOWED },
/*0177*/ { ZYDIS_MNEMONIC_VRCP23PS, 3, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_SAE, ZYDIS_MASK_POLICY_ALLOWED },
/*0178*/ { ZYDIS_MNEMONIC_VRCP23PS, 3, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0179*/ { ZYDIS_MNEMONIC_VRNDFXPNTPD, 4, 0x08B8, 0x00, ZYDIS_MVEX_FUNC_SF_64, ZYDIS_MASK_POLICY_ALLOWED },
@ -6892,7 +6892,7 @@ const ZydisInstructionDefinitionMVEX instructionDefinitionsMVEX[] =
/*017C*/ { ZYDIS_MNEMONIC_VRNDFXPNTPS, 4, 0x0894, 0x00, ZYDIS_MVEX_FUNC_SF_32, ZYDIS_MASK_POLICY_ALLOWED },
/*017D*/ { ZYDIS_MNEMONIC_VRNDFXPNTPS, 4, 0x08C0, 0x00, ZYDIS_MVEX_FUNC_SAE, ZYDIS_MASK_POLICY_ALLOWED },
/*017E*/ { ZYDIS_MNEMONIC_VRNDFXPNTPS, 4, 0x08C0, 0x00, ZYDIS_MVEX_FUNC_SWIZZLE_32, ZYDIS_MASK_POLICY_ALLOWED },
/*017F*/ { ZYDIS_MNEMONIC_VRSQRT23PS, 3, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*017F*/ { ZYDIS_MNEMONIC_VRSQRT23PS, 3, 0x08CC, 0x00, ZYDIS_MVEX_FUNC_F_32, ZYDIS_MASK_POLICY_ALLOWED },
/*0180*/ { ZYDIS_MNEMONIC_VRSQRT23PS, 3, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_SAE, ZYDIS_MASK_POLICY_ALLOWED },
/*0181*/ { ZYDIS_MNEMONIC_VRSQRT23PS, 3, 0x08D0, 0x00, ZYDIS_MVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED },
/*0182*/ { ZYDIS_MNEMONIC_VSCALEPS, 4, 0x0888, 0x00, ZYDIS_MVEX_FUNC_SI_32, ZYDIS_MASK_POLICY_ALLOWED },

View File

@ -449,6 +449,22 @@ enum ZydisMVEXFunctionalities
* @brief @c MVEX.SSS controls sae functionality.
*/
ZYDIS_MVEX_FUNC_SAE,
/**
* @brief No special operation (32bit float elements).
*/
ZYDIS_MVEX_FUNC_F_32,
/**
* @brief No special operation (32bit uint elements).
*/
ZYDIS_MVEX_FUNC_I_32,
/**
* @brief No special operation (64bit float elements).
*/
ZYDIS_MVEX_FUNC_F_64,
/**
* @brief No special operation (64bit uint elements).
*/
ZYDIS_MVEX_FUNC_I_64,
/**
* @brief Sf32(reg) or Si32(reg).
*/

View File

@ -1094,8 +1094,7 @@ static void ZydisSetOperandSizeAndElementInfo(ZydisDecoderContext* context,
break;
default:
ZYDIS_UNREACHABLE;
}
}
break;
case ZYDIS_CONVERSION_MODE_FLOAT16:
operand->size = 256;
@ -2625,6 +2624,12 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
case ZYDIS_MVEX_FUNC_SWIZZLE_64:
// Nothing to do here
break;
case ZYDIS_MVEX_FUNC_F_32:
case ZYDIS_MVEX_FUNC_I_32:
case ZYDIS_MVEX_FUNC_F_64:
case ZYDIS_MVEX_FUNC_I_64:
info->avx.compressedDisp8Scale = 64;
break;
case ZYDIS_MVEX_FUNC_SF_32:
case ZYDIS_MVEX_FUNC_UF_32:
{
@ -2684,6 +2689,10 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
switch (def->functionality)
{
case ZYDIS_MVEX_FUNC_INVALID:
case ZYDIS_MVEX_FUNC_F_32:
case ZYDIS_MVEX_FUNC_I_32:
case ZYDIS_MVEX_FUNC_F_64:
case ZYDIS_MVEX_FUNC_I_64:
// Nothing to do here
break;
case ZYDIS_MVEX_FUNC_RC:
@ -3527,14 +3536,22 @@ static ZydisStatus ZydisDecodeInstruction(ZydisDecoderContext* context, ZydisIns
maskPolicy = def->maskPolicy;
// Check for invalid MVEX.SSS values
static const uint8_t lookup[21][8] =
static const uint8_t lookup[25][8] =
{
// ZYDIS_MVEX_FUNC_INVALID
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 0, 0, 0, 0 },
// ZYDIS_MVEX_FUNC_RC
{ 1, 1, 1, 1, 1, 1, 1, 1 },
// ZYDIS_MVEX_FUNC_SAE
{ 1, 1, 1, 1, 1, 1, 1, 1 },
// ZYDIS_MVEX_FUNC_F_32
{ 1, 0, 0, 0, 0, 0, 0, 0 },
// ZYDIS_MVEX_FUNC_I_32
{ 1, 0, 0, 0, 0, 0, 0, 0 },
// ZYDIS_MVEX_FUNC_F_64
{ 1, 0, 0, 0, 0, 0, 0, 0 },
// ZYDIS_MVEX_FUNC_I_64
{ 1, 0, 0, 0, 0, 0, 0, 0 },
// ZYDIS_MVEX_FUNC_SWIZZLE_32
{ 1, 1, 1, 1, 1, 1, 1, 1 },
// ZYDIS_MVEX_FUNC_SWIZZLE_64