Skip to content

Commit

Permalink
Add AMX ISA extension
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed Sep 12, 2023
1 parent 099fcb8 commit 1ff1048
Show file tree
Hide file tree
Showing 22 changed files with 21,377 additions and 14,752 deletions.
24 changes: 23 additions & 1 deletion include/Zydis/DecoderTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,33 @@ typedef enum ZydisExceptionClass_
ZYDIS_EXCEPTION_CLASS_AMXE4,
ZYDIS_EXCEPTION_CLASS_AMXE5,
ZYDIS_EXCEPTION_CLASS_AMXE6,
ZYDIS_EXCEPTION_CLASS_AMXE1_EVEX,
ZYDIS_EXCEPTION_CLASS_AMXE2_EVEX,
ZYDIS_EXCEPTION_CLASS_AMXE3_EVEX,
ZYDIS_EXCEPTION_CLASS_AMXE4_EVEX,
ZYDIS_EXCEPTION_CLASS_AMXE5_EVEX,
ZYDIS_EXCEPTION_CLASS_AMXE6_EVEX,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_INT,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_KEYLOCKER,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_BMI,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_CCMP,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_CFCMOV,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_CMPCCXADD,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_ENQCMD,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_INVEPT,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_INVPCID,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_INVVPID,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_KMOV,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_PP2,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_SHA,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_CET_WRSS,
ZYDIS_EXCEPTION_CLASS_APX_EVEX_CET_WRUSS,
ZYDIS_EXCEPTION_CLASS_APX_LEGACY_JMPABS,

/**
* Maximum value of this enum.
*/
ZYDIS_EXCEPTION_CLASS_MAX_VALUE = ZYDIS_EXCEPTION_CLASS_AMXE6,
ZYDIS_EXCEPTION_CLASS_MAX_VALUE = ZYDIS_EXCEPTION_CLASS_APX_LEGACY_JMPABS,
/**
* The minimum number of bits required to represent all values of this enum.
*/
Expand Down
2 changes: 2 additions & 0 deletions include/Zydis/Generated/EnumISAExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ typedef enum ZydisISAExt_
ZYDIS_ISA_EXT_AMX_FP16,
ZYDIS_ISA_EXT_AMX_INT8,
ZYDIS_ISA_EXT_AMX_TILE,
ZYDIS_ISA_EXT_APXEVEX,
ZYDIS_ISA_EXT_APX_F,
ZYDIS_ISA_EXT_AVX,
ZYDIS_ISA_EXT_AVX2,
ZYDIS_ISA_EXT_AVX2GATHER,
Expand Down
6 changes: 6 additions & 0 deletions include/Zydis/Generated/EnumISASet.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ typedef enum ZydisISASet_
ZYDIS_ISA_SET_AMX_FP16,
ZYDIS_ISA_SET_AMX_INT8,
ZYDIS_ISA_SET_AMX_TILE,
ZYDIS_ISA_SET_APX_F,
ZYDIS_ISA_SET_APX_F_AMX,
ZYDIS_ISA_SET_APX_F_KOPB,
ZYDIS_ISA_SET_APX_F_KOPD,
ZYDIS_ISA_SET_APX_F_KOPQ,
ZYDIS_ISA_SET_APX_F_KOPW,
ZYDIS_ISA_SET_AVX,
ZYDIS_ISA_SET_AVX2,
ZYDIS_ISA_SET_AVX2GATHER,
Expand Down
1 change: 1 addition & 0 deletions include/Zydis/Generated/EnumInstructionCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ typedef enum ZydisInstructionCategory_
ZYDIS_CATEGORY_AES,
ZYDIS_CATEGORY_AMD3DNOW,
ZYDIS_CATEGORY_AMX_TILE,
ZYDIS_CATEGORY_APX,
ZYDIS_CATEGORY_AVX,
ZYDIS_CATEGORY_AVX2,
ZYDIS_CATEGORY_AVX2GATHER,
Expand Down
71 changes: 71 additions & 0 deletions include/Zydis/Generated/EnumMnemonic.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,40 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_BZHI,
ZYDIS_MNEMONIC_CALL,
ZYDIS_MNEMONIC_CBW,
ZYDIS_MNEMONIC_CCMPB,
ZYDIS_MNEMONIC_CCMPBE,
ZYDIS_MNEMONIC_CCMPF,
ZYDIS_MNEMONIC_CCMPL,
ZYDIS_MNEMONIC_CCMPLE,
ZYDIS_MNEMONIC_CCMPNB,
ZYDIS_MNEMONIC_CCMPNBE,
ZYDIS_MNEMONIC_CCMPNL,
ZYDIS_MNEMONIC_CCMPNLE,
ZYDIS_MNEMONIC_CCMPNO,
ZYDIS_MNEMONIC_CCMPNS,
ZYDIS_MNEMONIC_CCMPNZ,
ZYDIS_MNEMONIC_CCMPO,
ZYDIS_MNEMONIC_CCMPS,
ZYDIS_MNEMONIC_CCMPT,
ZYDIS_MNEMONIC_CCMPZ,
ZYDIS_MNEMONIC_CDQ,
ZYDIS_MNEMONIC_CDQE,
ZYDIS_MNEMONIC_CFCMOVB,
ZYDIS_MNEMONIC_CFCMOVBE,
ZYDIS_MNEMONIC_CFCMOVL,
ZYDIS_MNEMONIC_CFCMOVLE,
ZYDIS_MNEMONIC_CFCMOVNB,
ZYDIS_MNEMONIC_CFCMOVNBE,
ZYDIS_MNEMONIC_CFCMOVNL,
ZYDIS_MNEMONIC_CFCMOVNLE,
ZYDIS_MNEMONIC_CFCMOVNO,
ZYDIS_MNEMONIC_CFCMOVNP,
ZYDIS_MNEMONIC_CFCMOVNS,
ZYDIS_MNEMONIC_CFCMOVNZ,
ZYDIS_MNEMONIC_CFCMOVO,
ZYDIS_MNEMONIC_CFCMOVP,
ZYDIS_MNEMONIC_CFCMOVS,
ZYDIS_MNEMONIC_CFC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_MNEMONIC_CTESTNB,
ZYDIS_MNEMONIC_CTESTNBE,
ZYDIS_MNEMONIC_CTESTNL,
ZYDIS_MNEMONIC_CTESTNLE,
ZYDIS_MNEMONIC_CTESTNO,
ZYDIS_MNEMONIC_CTESTNS,
ZYDIS_MNEMONIC_CTESTNZ,
ZYDIS_MNEMONIC_CTESTO,
ZYDIS_MNEMONIC_CTESTS,
ZYDIS_MNEMONIC_CTESTT,
ZYDIS_MNEMONIC_CTESTZ,
ZYDIS_MNEMONIC_CVTDQ2PD,
ZYDIS_MNEMONIC_CVTDQ2PS,
ZYDIS_MNEMONIC_CVTPD2DQ,
Expand Down Expand Up @@ -315,6 +379,7 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_JL,
ZYDIS_MNEMONIC_JLE,
ZYDIS_MNEMONIC_JMP,
ZYDIS_MNEMONIC_JMPABS,
ZYDIS_MNEMONIC_JNB,
ZYDIS_MNEMONIC_JNBE,
ZYDIS_MNEMONIC_JNL,
Expand Down Expand Up @@ -613,12 +678,15 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_PMULLW,
ZYDIS_MNEMONIC_PMULUDQ,
ZYDIS_MNEMONIC_POP,
ZYDIS_MNEMONIC_POP2,
ZYDIS_MNEMONIC_POP2P,
ZYDIS_MNEMONIC_POPA,
ZYDIS_MNEMONIC_POPAD,
ZYDIS_MNEMONIC_POPCNT,
ZYDIS_MNEMONIC_POPF,
ZYDIS_MNEMONIC_POPFD,
ZYDIS_MNEMONIC_POPFQ,
ZYDIS_MNEMONIC_POPP,
ZYDIS_MNEMONIC_POR,
ZYDIS_MNEMONIC_PREFETCH,
ZYDIS_MNEMONIC_PREFETCHIT0,
Expand Down Expand Up @@ -669,11 +737,14 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_PUNPCKLQDQ,
ZYDIS_MNEMONIC_PUNPCKLWD,
ZYDIS_MNEMONIC_PUSH,
ZYDIS_MNEMONIC_PUSH2,
ZYDIS_MNEMONIC_PUSH2P,
ZYDIS_MNEMONIC_PUSHA,
ZYDIS_MNEMONIC_PUSHAD,
ZYDIS_MNEMONIC_PUSHF,
ZYDIS_MNEMONIC_PUSHFD,
ZYDIS_MNEMONIC_PUSHFQ,
ZYDIS_MNEMONIC_PUSHP,
ZYDIS_MNEMONIC_PVALIDATE,
ZYDIS_MNEMONIC_PXOR,
ZYDIS_MNEMONIC_RCL,
Expand Down
18 changes: 18 additions & 0 deletions include/Zydis/Generated/EnumRegister.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,24 @@ typedef enum ZydisRegister_
ZYDIS_REGISTER_BNDCFG,
ZYDIS_REGISTER_BNDSTATUS,

// DFV pseudo registers
ZYDIS_REGISTER_DFV0,
ZYDIS_REGISTER_DFV1,
ZYDIS_REGISTER_DFV2,
ZYDIS_REGISTER_DFV3,
ZYDIS_REGISTER_DFV4,
ZYDIS_REGISTER_DFV5,
ZYDIS_REGISTER_DFV6,
ZYDIS_REGISTER_DFV7,
ZYDIS_REGISTER_DFV8,
ZYDIS_REGISTER_DFV9,
ZYDIS_REGISTER_DFV10,
ZYDIS_REGISTER_DFV11,
ZYDIS_REGISTER_DFV12,
ZYDIS_REGISTER_DFV13,
ZYDIS_REGISTER_DFV14,
ZYDIS_REGISTER_DFV15,

// Uncategorized
ZYDIS_REGISTER_MXCSR,
ZYDIS_REGISTER_PKRU,
Expand Down
18 changes: 17 additions & 1 deletion include/Zydis/Internal/DecoderData.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,23 @@ enum ZydisDecoderTreeNodeTypes
/**
* Reference to a IPREFETCH-mode filter.
*/
ZYDIS_NODETYPE_FILTER_MODE_IPREFETCH = 0x1C
ZYDIS_NODETYPE_FILTER_MODE_IPREFETCH = 0x1C,
/**
* Reference to an EVEX.nd filter.
*/
ZYDIS_NODETYPE_FILTER_EVEX_ND = 0x1D,
/**
* Reference to an EVEX.nf filter.
*/
ZYDIS_NODETYPE_FILTER_EVEX_NF = 0x1E,
/**
* Reference to an EVEX.scc filter.
*/
ZYDIS_NODETYPE_FILTER_EVEX_SCC = 0x1F,
/**
* Reference to a REX2 filter.
*/
ZYDIS_NODETYPE_FILTER_REX2 = 0x20
};

/* ---------------------------------------------------------------------------------------------- */
Expand Down
4 changes: 3 additions & 1 deletion include/Zydis/Internal/SharedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ typedef enum ZydisSemanticOperandType_
ZYDIS_SEMANTIC_OPTYPE_AGEN,
ZYDIS_SEMANTIC_OPTYPE_MOFFS,
ZYDIS_SEMANTIC_OPTYPE_MIB,
ZYDIS_SEMANTIC_OPTYPE_DFV,

/**
* Maximum value of this enum.
*/
ZYDIS_SEMANTIC_OPTYPE_MAX_VALUE = ZYDIS_SEMANTIC_OPTYPE_MIB,
ZYDIS_SEMANTIC_OPTYPE_MAX_VALUE = ZYDIS_SEMANTIC_OPTYPE_DFV,
/**
* The minimum number of bits required to represent all values of this enum.
*/
Expand All @@ -121,6 +122,7 @@ typedef enum ZydisInternalElementType_
ZYDIS_IELEMENT_TYPE_INT16X2,
ZYDIS_IELEMENT_TYPE_INT32,
ZYDIS_IELEMENT_TYPE_INT64,
ZYDIS_IELEMENT_TYPE_INT128,
ZYDIS_IELEMENT_TYPE_UINT8,
ZYDIS_IELEMENT_TYPE_UINT8X4,
ZYDIS_IELEMENT_TYPE_UINT16,
Expand Down
9 changes: 7 additions & 2 deletions include/Zydis/Register.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ typedef enum ZydisRegisterKind_
ZYDIS_REGKIND_DEBUG,
ZYDIS_REGKIND_MASK,
ZYDIS_REGKIND_BOUND,
ZYDIS_REGKIND_DFV,

/**
* Maximum value of this enum.
*/
ZYDIS_REGKIND_MAX_VALUE = ZYDIS_REGKIND_BOUND,
ZYDIS_REGKIND_MAX_VALUE = ZYDIS_REGKIND_DFV,
/**
* The minimum number of bits required to represent all values of this enum.
*/
Expand Down Expand Up @@ -184,11 +185,15 @@ typedef enum ZydisRegisterClass_
* Bound registers.
*/
ZYDIS_REGCLASS_BOUND,
/**
* DFV pseudo registers.
*/
ZYDIS_REGCLASS_DFV,

/**
* Maximum value of this enum.
*/
ZYDIS_REGCLASS_MAX_VALUE = ZYDIS_REGCLASS_BOUND,
ZYDIS_REGCLASS_MAX_VALUE = ZYDIS_REGCLASS_DFV,
/**
* The minimum number of bits required to represent all values of this enum.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,9 @@ static ZyanStatus ZydisDecodeOperands(const ZydisDecoder* decoder, const ZydisDe
case ZYDIS_SEMANTIC_OPTYPE_MASK:
register_class = ZYDIS_REGCLASS_MASK;
break;
case ZYDIS_SEMANTIC_OPTYPE_DFV:
register_class = ZYDIS_REGCLASS_DFV;
break;
default:
break;
}
Expand Down
12 changes: 12 additions & 0 deletions src/DecoderData.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ const ZydisDecoderTreeNode* ZydisDecoderTreeGetChildNode(const ZydisDecoderTreeN
case ZYDIS_NODETYPE_FILTER_MODE_IPREFETCH:
ZYAN_ASSERT(index < 2);
return &FILTERS_MODE_IPREFETCH[parent->value][index];
case ZYDIS_NODETYPE_FILTER_EVEX_ND:
ZYAN_ASSERT(index < 2);
return &FILTERS_EVEX_ND[parent->value][index];
case ZYDIS_NODETYPE_FILTER_EVEX_NF:
ZYAN_ASSERT(index < 2);
return &FILTERS_EVEX_NF[parent->value][index];
case ZYDIS_NODETYPE_FILTER_EVEX_SCC:
ZYAN_ASSERT(index < 16);
return &FILTERS_EVEX_SCC[parent->value][index];
case ZYDIS_NODETYPE_FILTER_REX2:
ZYAN_ASSERT(index < 2);
return &FILTERS_REX2[parent->value][index];
default:
ZYAN_UNREACHABLE;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Generated/AccessedFlags.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static const ZydisDefinitionAccessedFlags ACCESSED_FLAGS[] =
{ { 0x1000, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x800, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x800, 0x800, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x800, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x400, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x1400, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x0, 0x400, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
Expand Down Expand Up @@ -40,6 +41,7 @@ static const ZydisDefinitionAccessedFlags ACCESSED_FLAGS[] =
{ { 0x1, 0x8D5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x1, 0x8C5, 0x0, 0x0, 0x10 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x1, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x801, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x1, 0x0, 0x0, 0x800 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x41, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x440, 0x8D5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
Expand All @@ -54,6 +56,7 @@ static const ZydisDefinitionAccessedFlags ACCESSED_FLAGS[] =
{ { 0x0, 0x3C5FD5, 0x30000, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x45, 0x890, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x45, 0x890, 0x0, 0x0 }, { 0x0, 0x2, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x8C5, 0x0, 0x0, 0x10 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0xC5, 0x0, 0x0, 0x810 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x8C1, 0x14, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
{ { 0x0, 0x41, 0x894, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
Expand Down
17,683 changes: 10,604 additions & 7,079 deletions src/Generated/DecoderTables.inc

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Generated/EnumISAExt.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ static const char* STR_ISAEXT[] =
"AMX_FP16",
"AMX_INT8",
"AMX_TILE",
"APXEVEX",
"APX_F",
"AVX",
"AVX2",
"AVX2GATHER",
Expand Down
6 changes: 6 additions & 0 deletions src/Generated/EnumISASet.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ static const char* STR_ISASET[] =
"AMX_FP16",
"AMX_INT8",
"AMX_TILE",
"APX_F",
"APX_F_AMX",
"APX_F_KOPB",
"APX_F_KOPD",
"APX_F_KOPQ",
"APX_F_KOPW",
"AVX",
"AVX2",
"AVX2GATHER",
Expand Down
1 change: 1 addition & 0 deletions src/Generated/EnumInstructionCategory.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ static const char* STR_INSTRUCTIONCATEGORY[] =
"AES",
"AMD3DNOW",
"AMX_TILE",
"APX",
"AVX",
"AVX2",
"AVX2GATHER",
Expand Down
Loading

0 comments on commit 1ff1048

Please sign in to comment.