Skip to content

Commit 39be8ec

Browse files
committed
Expose dfv in apx struct instead of operand
1 parent dce4de0 commit 39be8ec

File tree

6 files changed

+9249
-9227
lines changed

6 files changed

+9249
-9227
lines changed

include/Zydis/DecoderTypes.h

+44
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
/* ---------------------------------------------------------------------------------------------- */
@@ -1219,6 +1259,10 @@ typedef struct ZydisDecodedInstructionApx_
12191259
* Signals, if the instruction uses the extended GRP registers (R16..R31).
12201260
*/
12211261
ZyanBool uses_egpr;
1262+
/**
1263+
* The APX default flags value (DFV).
1264+
*/
1265+
ZydisDefaultFlagsValue default_flags;
12221266
/**
12231267
* Signals, if the APX `no flags` functionality enabled for the instruction.
12241268
*/

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

src/Decoder.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -5226,6 +5226,11 @@ 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.default_flags = state->context->vector_unified.vvvv;
5233+
}
52295234
}
52305235

52315236
instruction->mnemonic = definition->mnemonic;
@@ -5262,8 +5267,6 @@ static ZyanStatus ZydisDecodeInstruction(ZydisDecoderState* state,
52625267
break;
52635268
}
52645269

5265-
// TODO: Include DFV
5266-
52675270
const ZydisDefinitionAccessedFlags* flags;
52685271
if (ZydisGetAccessedFlags(definition, &flags))
52695272
{

0 commit comments

Comments
 (0)