Skip to content

Commit 92bc5f5

Browse files
committed
Expose dfv in apx struct instead of operand
1 parent dce4de0 commit 92bc5f5

File tree

6 files changed

+9263
-9229
lines changed

6 files changed

+9263
-9229
lines changed

Diff for: include/Zydis/DecoderTypes.h

+52-2
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,46 @@ typedef enum ZydisConversionMode_
723723
ZYDIS_CONVERSION_MODE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_CONVERSION_MODE_MAX_VALUE)
724724
} ZydisConversionMode;
725725

726+
/* ---------------------------------------------------------------------------------------------- */
727+
/* APX default flags value */
728+
/* ---------------------------------------------------------------------------------------------- */
729+
730+
/**
731+
* Defines the `ZydisDefaultFlagsValue` data-type.
732+
*/
733+
typedef ZyanU8 ZydisDefaultFlagsValue;
734+
735+
/**
736+
* @defgroup decoder_apx_default_flags APX default flags
737+
* @ingroup decoder
738+
*
739+
* Constants used to determine which status flags are set by certain APX
740+
* instructions when the source condition code `SCC` evaluates to `false`.
741+
*
742+
* @{
743+
*/
744+
745+
/**
746+
* Carry flag.
747+
*/
748+
#define ZYDIS_DFV_CF (1u << 0)
749+
/**
750+
* Zero flag.
751+
*/
752+
#define ZYDIS_DFV_ZF (1u << 1)
753+
/**
754+
* Sign flag.
755+
*/
756+
#define ZYDIS_DFV_SF (1u << 2)
757+
/**
758+
* Overflow flag.
759+
*/
760+
#define ZYDIS_DFV_OF (1u << 3)
761+
762+
/**
763+
* @}
764+
*/
765+
726766
/* ---------------------------------------------------------------------------------------------- */
727767
/* APX source condition code */
728768
/* ---------------------------------------------------------------------------------------------- */
@@ -1220,19 +1260,29 @@ typedef struct ZydisDecodedInstructionApx_
12201260
*/
12211261
ZyanBool uses_egpr;
12221262
/**
1223-
* Signals, if the APX `no flags` functionality enabled for the instruction.
1263+
* Signals, if the APX `no flags` functionality is enabled for the instruction.
12241264
*/
12251265
ZyanBool has_nf;
12261266
/**
1227-
* Signals, if the APX `zero upper` functionality enabled for the instruction.
1267+
* Signals, if the APX `zero upper` functionality is enabled for the instruction.
12281268
*/
12291269
ZyanBool has_zu;
1270+
/**
1271+
* Signals, if the APX `default flags value` functionality is enabled for the instruction.
1272+
*/
1273+
ZyanBool has_dfv;
12301274
/**
12311275
* Signals, if the APX push/pop performance-hint (`PPX`) is enabled for the instruction.
12321276
*
12331277
* This flag is only valid for `push2p` and `pop2p`.
12341278
*/
12351279
ZyanBool has_ppx;
1280+
/**
1281+
* The APX default flags value (DFV).
1282+
*
1283+
* This value is only used, if `has_dfv` is set as well.
1284+
*/
1285+
ZydisDefaultFlagsValue default_flags;
12361286
/**
12371287
* The AVX-512 APX source condition code.
12381288
*/

Diff for: include/Zydis/Internal/SharedData.h

+2
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,8 @@ typedef struct ZydisInstructionDefinitionEVEX_
862862
ZyanU8 is_eevex ZYAN_BITFIELD( 1);
863863
ZyanU8 has_apx_nf ZYAN_BITFIELD( 1);
864864
ZyanU8 has_apx_zu ZYAN_BITFIELD( 1);
865+
ZyanU8 has_apx_dfv ZYAN_BITFIELD( 1);
866+
ZyanU8 has_apx_ppx ZYAN_BITFIELD( 1);
865867
} ZydisInstructionDefinitionEVEX;
866868
#endif
867869

Diff for: src/Decoder.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -5226,6 +5226,12 @@ static ZyanStatus ZydisDecodeInstruction(ZydisDecoderState* state,
52265226

52275227
instruction->apx.has_nf = evex_definition->has_apx_nf;
52285228
instruction->apx.has_zu = evex_definition->has_apx_zu;
5229+
5230+
if (evex_definition->has_apx_dfv)
5231+
{
5232+
instruction->apx.has_dfv = ZYAN_TRUE;
5233+
instruction->apx.default_flags = state->context->vector_unified.vvvv;
5234+
}
52295235
}
52305236

52315237
instruction->mnemonic = definition->mnemonic;
@@ -5262,8 +5268,6 @@ static ZyanStatus ZydisDecodeInstruction(ZydisDecoderState* state,
52625268
break;
52635269
}
52645270

5265-
// TODO: Include DFV
5266-
52675271
const ZydisDefinitionAccessedFlags* flags;
52685272
if (ZydisGetAccessedFlags(definition, &flags))
52695273
{

0 commit comments

Comments
 (0)