Skip to content

Commit

Permalink
Expose dfv in apx struct instead of operand
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed Oct 31, 2024
1 parent dce4de0 commit 39be8ec
Show file tree
Hide file tree
Showing 6 changed files with 9,249 additions and 9,227 deletions.
44 changes: 44 additions & 0 deletions include/Zydis/DecoderTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,46 @@ typedef enum ZydisConversionMode_
ZYDIS_CONVERSION_MODE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_CONVERSION_MODE_MAX_VALUE)
} ZydisConversionMode;

/* ---------------------------------------------------------------------------------------------- */
/* APX default flags value */
/* ---------------------------------------------------------------------------------------------- */

/**
* Defines the `ZydisDefaultFlagsValue` data-type.
*/
typedef ZyanU8 ZydisDefaultFlagsValue;

/**
* @defgroup decoder_apx_default_flags APX default flags
* @ingroup decoder
*
* Constants used to determine which status flags are set by certain APX
* instructions when the source condition code `SCC` evaluates to `false`.
*
* @{
*/

/**
* Carry flag.
*/
#define ZYDIS_DFV_CF (1u << 0)
/**
* Zero flag.
*/
#define ZYDIS_DFV_ZF (1u << 1)
/**
* Sign flag.
*/
#define ZYDIS_DFV_SF (1u << 2)
/**
* Overflow flag.
*/
#define ZYDIS_DFV_OF (1u << 3)

/**
* @}
*/

/* ---------------------------------------------------------------------------------------------- */
/* APX source condition code */
/* ---------------------------------------------------------------------------------------------- */
Expand Down Expand Up @@ -1219,6 +1259,10 @@ typedef struct ZydisDecodedInstructionApx_
* Signals, if the instruction uses the extended GRP registers (R16..R31).
*/
ZyanBool uses_egpr;
/**
* The APX default flags value (DFV).
*/
ZydisDefaultFlagsValue default_flags;
/**
* Signals, if the APX `no flags` functionality enabled for the instruction.
*/
Expand Down
2 changes: 2 additions & 0 deletions include/Zydis/Internal/SharedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ typedef struct ZydisInstructionDefinitionEVEX_
ZyanU8 is_eevex ZYAN_BITFIELD( 1);
ZyanU8 has_apx_nf ZYAN_BITFIELD( 1);
ZyanU8 has_apx_zu ZYAN_BITFIELD( 1);
ZyanU8 has_apx_dfv ZYAN_BITFIELD( 1);
ZyanU8 has_apx_ppx ZYAN_BITFIELD( 1);
} ZydisInstructionDefinitionEVEX;
#endif

Expand Down
7 changes: 5 additions & 2 deletions src/Decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -5226,6 +5226,11 @@ static ZyanStatus ZydisDecodeInstruction(ZydisDecoderState* state,

instruction->apx.has_nf = evex_definition->has_apx_nf;
instruction->apx.has_zu = evex_definition->has_apx_zu;

if (evex_definition->has_apx_dfv)
{
instruction->apx.default_flags = state->context->vector_unified.vvvv;
}
}

instruction->mnemonic = definition->mnemonic;
Expand Down Expand Up @@ -5262,8 +5267,6 @@ static ZyanStatus ZydisDecodeInstruction(ZydisDecoderState* state,
break;
}

// TODO: Include DFV

const ZydisDefinitionAccessedFlags* flags;
if (ZydisGetAccessedFlags(definition, &flags))
{
Expand Down
Loading

0 comments on commit 39be8ec

Please sign in to comment.