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 92bc5f5
Show file tree
Hide file tree
Showing 6 changed files with 9,263 additions and 9,229 deletions.
54 changes: 52 additions & 2 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 @@ -1220,19 +1260,29 @@ typedef struct ZydisDecodedInstructionApx_
*/
ZyanBool uses_egpr;
/**
* Signals, if the APX `no flags` functionality enabled for the instruction.
* Signals, if the APX `no flags` functionality is enabled for the instruction.
*/
ZyanBool has_nf;
/**
* Signals, if the APX `zero upper` functionality enabled for the instruction.
* Signals, if the APX `zero upper` functionality is enabled for the instruction.
*/
ZyanBool has_zu;
/**
* Signals, if the APX `default flags value` functionality is enabled for the instruction.
*/
ZyanBool has_dfv;
/**
* Signals, if the APX push/pop performance-hint (`PPX`) is enabled for the instruction.
*
* This flag is only valid for `push2p` and `pop2p`.
*/
ZyanBool has_ppx;
/**
* The APX default flags value (DFV).
*
* This value is only used, if `has_dfv` is set as well.
*/
ZydisDefaultFlagsValue default_flags;
/**
* The AVX-512 APX source condition code.
*/
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
8 changes: 6 additions & 2 deletions src/Decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -5226,6 +5226,12 @@ 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.has_dfv = ZYAN_TRUE;
instruction->apx.default_flags = state->context->vector_unified.vvvv;
}
}

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

// TODO: Include DFV

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

0 comments on commit 92bc5f5

Please sign in to comment.