Skip to content

Commit

Permalink
Update instruction table to capture the correct state of EFlags (#53806)
Browse files Browse the repository at this point in the history
* Update instruction table with accurate EFlags information

* Revert "Add issues.targets entry for the GitHub_13822 test to make CI green (#53789)"

This reverts commit bd9ba59.

* minor fixup

* Fix some more instructions

* review comments
  • Loading branch information
kunalspathak committed Jun 8, 2021
1 parent d737521 commit 54fdd26
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 216 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool emitter::IsDstSrcSrcAVXInstruction(instruction ins)
//
bool emitter::DoesWriteZeroFlag(instruction ins)
{
return (CodeGenInterface::instInfo[ins] & INS_FLAGS_WritesZF) != 0;
return (CodeGenInterface::instInfo[ins] & Writes_ZF) != 0;
}

//------------------------------------------------------------------------
Expand All @@ -176,7 +176,7 @@ bool emitter::DoesWriteZeroFlag(instruction ins)
//
bool emitter::DoesResetOverflowAndCarryFlags(instruction ins)
{
return (CodeGenInterface::instInfo[ins] & INS_FLAGS_Resets_CF_OF_Flags) != 0;
return (CodeGenInterface::instInfo[ins] & (Resets_OF | Resets_CF)) == (Resets_OF | Resets_CF);
}

//------------------------------------------------------------------------
Expand Down
72 changes: 38 additions & 34 deletions src/coreclr/jit/instr.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,52 +86,56 @@ enum GCtype : unsigned
};

#if defined(TARGET_XARCH)

enum insFlags : uint32_t
{
INS_FLAGS_None = 0,

// Reads EFLAGS
INS_FLAGS_ReadsCF = 1 << 0,
INS_FLAGS_ReadsPF = 1 << 1,
INS_FLAGS_ReadsAF = 1 << 2,
INS_FLAGS_ReadsZF = 1 << 3,
INS_FLAGS_ReadsSF = 1 << 4,
INS_FLAGS_ReadsDF = 1 << 5,
INS_FLAGS_ReadsOF = 1 << 6,
INS_FLAGS_ReadsAllFlagsExceptAF = INS_FLAGS_ReadsCF | INS_FLAGS_ReadsPF | INS_FLAGS_ReadsZF | INS_FLAGS_ReadsSF | INS_FLAGS_ReadsOF,
INS_FLAGS_Reads_CF_ZF_Flags = INS_FLAGS_ReadsCF | INS_FLAGS_ReadsZF,
INS_FLAGS_Reads_OF_SF_Flags = INS_FLAGS_ReadsOF | INS_FLAGS_ReadsSF,
INS_FLAGS_Reads_OF_SF_ZF_Flags = INS_FLAGS_ReadsOF | INS_FLAGS_ReadsSF | INS_FLAGS_ReadsZF,
INS_FLAGS_ReadsAllFlags = INS_FLAGS_ReadsAF | INS_FLAGS_ReadsAllFlagsExceptAF,

// Writes EFLAGS
INS_FLAGS_WritesCF = 1 << 7,
INS_FLAGS_WritesPF = 1 << 8,
INS_FLAGS_WritesAF = 1 << 9,
INS_FLAGS_WritesZF = 1 << 10,
INS_FLAGS_WritesSF = 1 << 11,
INS_FLAGS_WritesDF = 1 << 12,
INS_FLAGS_WritesOF = 1 << 13,
INS_FLAGS_WritesAllFlagsExceptCF = INS_FLAGS_WritesPF | INS_FLAGS_WritesAF | INS_FLAGS_WritesZF | INS_FLAGS_WritesSF | INS_FLAGS_WritesOF,
INS_FLAGS_WritesAllFlagsExceptOF = INS_FLAGS_WritesCF | INS_FLAGS_WritesPF | INS_FLAGS_WritesAF | INS_FLAGS_WritesZF | INS_FLAGS_WritesSF,
INS_FLAGS_WritesAllFlags = INS_FLAGS_WritesCF | INS_FLAGS_WritesAllFlagsExceptCF,

// Resets EFLAGS
INS_FLAGS_Resets_OF_Flags = 1 << 14,
INS_FLAGS_Resets_CF_OF_Flags = 1 << 15,
INS_FLAGS_Resets_OF_SF_PF_Flags = 1 << 16,
INS_FLAGS_ResetsAllFlagsExceptZF = 1 << 17,
// Reads
Reads_OF = 1 << 0,
Reads_SF = 1 << 1,
Reads_ZF = 1 << 2,
Reads_PF = 1 << 3,
Reads_CF = 1 << 4,
Reads_DF = 1 << 5,

// Writes
Writes_OF = 1 << 6,
Writes_SF = 1 << 7,
Writes_ZF = 1 << 8,
Writes_AF = 1 << 9,
Writes_PF = 1 << 10,
Writes_CF = 1 << 11,

// Resets
Resets_OF = 1 << 12,
Resets_SF = 1 << 13,
Resets_AF = 1 << 14,
Resets_PF = 1 << 15,
Resets_CF = 1 << 16,

// Undefined
Undefined_OF = 1 << 17,
Undefined_SF = 1 << 18,
Undefined_ZF = 1 << 19,
Undefined_AF = 1 << 20,
Undefined_PF = 1 << 21,
Undefined_CF = 1 << 22,

// Restore
Restore_SF_ZF_AF_PF_CF = 1 << 23,

// x87 instruction
INS_FLAGS_x87Instr = 1 << 18,
INS_FLAGS_x87Instr = 1 << 24,

// Avx
INS_Flags_IsDstDstSrcAVXInstruction = 1 << 19,
INS_Flags_IsDstSrcSrcAVXInstruction = 1 << 20,
INS_Flags_IsDstDstSrcAVXInstruction = 1 << 25,
INS_Flags_IsDstSrcSrcAVXInstruction = 1 << 26,

// TODO-Cleanup: Remove this flag and its usage from TARGET_XARCH
INS_FLAGS_DONT_CARE = 0x00,
};

#elif defined(TARGET_ARM) || defined(TARGET_ARM64)
// TODO-Cleanup: Move 'insFlags' under TARGET_ARM
enum insFlags: unsigned
Expand Down
Loading

0 comments on commit 54fdd26

Please sign in to comment.