Skip to content

Commit

Permalink
Provide support for LZCNT and TZCNT in X86Ops.ins
Browse files Browse the repository at this point in the history
  • Loading branch information
VidushiGit committed May 18, 2023
1 parent de6212d commit bbfea5c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
30 changes: 30 additions & 0 deletions compiler/x/codegen/X86Ops.ins
Original file line number Diff line number Diff line change
Expand Up @@ -2545,6 +2545,21 @@ INSTRUCTION(LEA8RegMem, lea,
PROPERTY0(IA32OpProp_ModifiesTarget),
PROPERTY1(IA32OpProp1_LongSource | IA32OpProp1_LongTarget | IA32OpProp1_SourceIsMemRef),
FEATURES(0)),
INSTRUCTION(LZCNT2RegReg, lzcnt,
BINARY(VEX_L___, VEX_vNONE, PREFIX_F3, REX__, ESCAPE_0F__, 0xbd, 0, ModRM_RM__, Immediate_0),
PROPERTY0(IA32OpProp_ModifiesTarget | IA32OpProp_ShortTarget | IA32OpProp_ShortSource | IA32OpProp_ModifiesZeroFlag | IA32OpProp_ModifiesCarryFlag | IA32OpProp_SourceRegisterInModRM ),
PROPERTY1(0),
FEATURES(0)),
INSTRUCTION(LZCNT4RegReg, lzcnt,
BINARY(VEX_L___, VEX_vNONE, PREFIX_F3, REX__, ESCAPE_0F__, 0xbd, 0, ModRM_RM__, Immediate_0),
PROPERTY0(IA32OpProp_ModifiesTarget | IA32OpProp_IntSource | IA32OpProp_IntTarget | IA32OpProp_ModifiesZeroFlag | IA32OpProp_ModifiesCarryFlag | IA32OpProp_SourceRegisterInModRM ),
PROPERTY1(0),
FEATURES(0)),
INSTRUCTION(LZCNT8RegReg, lzcnt,
BINARY(VEX_L___, VEX_vNONE, PREFIX_F3, REX_W, ESCAPE_0F__, 0xbd, 0, ModRM_RM__, Immediate_0),
PROPERTY0(IA32OpProp_ModifiesTarget | IA32OpProp_ModifiesZeroFlag | IA32OpProp_ModifiesCarryFlag | IA32OpProp_SourceRegisterInModRM ),
PROPERTY1(IA32OpProp1_LongSource | IA32OpProp1_LongTarget),
FEATURES(0)),
INSTRUCTION(S1MemReg, mov,
BINARY(VEX_L___, VEX_vNONE, PREFIX___, REX__, ESCAPE_____, 0x88, 0, ModRM_MR__, Immediate_0),
PROPERTY0(IA32OpProp_ModifiesTarget | IA32OpProp_ByteSource | IA32OpProp_ByteTarget),
Expand Down Expand Up @@ -5144,6 +5159,21 @@ INSTRUCTION(TEST8MemReg, test,
PROPERTY0(IA32OpProp_ModifiesOverflowFlag | IA32OpProp_ModifiesSignFlag | IA32OpProp_ModifiesZeroFlag | IA32OpProp_ModifiesParityFlag | IA32OpProp_ModifiesCarryFlag | IA32OpProp_UsesTarget),
PROPERTY1(IA32OpProp1_LongSource | IA32OpProp1_LongTarget | IA32OpProp1_FusableCompare),
FEATURES(0)),
INSTRUCTION(TZCNT2RegReg, tzcnt,
BINARY(VEX_L___, VEX_vNONE, PREFIX_F3, REX__, ESCAPE_0F__, 0xbc, 0, ModRM_RM__, Immediate_0),
PROPERTY0(IA32OpProp_ModifiesTarget | IA32OpProp_ShortTarget | IA32OpProp_ShortSource | IA32OpProp_ModifiesZeroFlag | IA32OpProp_ModifiesCarryFlag | IA32OpProp_SourceRegisterInModRM ),
PROPERTY1(0),
FEATURES(0)),
INSTRUCTION(TZCNT4RegReg, tzcnt,
BINARY(VEX_L___, VEX_vNONE, PREFIX_F3, REX__, ESCAPE_0F__, 0xbc, 0, ModRM_RM__, Immediate_0),
PROPERTY0(IA32OpProp_ModifiesTarget | IA32OpProp_IntTarget | IA32OpProp_IntSource | IA32OpProp_ModifiesZeroFlag | IA32OpProp_ModifiesCarryFlag | IA32OpProp_SourceRegisterInModRM ),
PROPERTY1(0),
FEATURES(0)),
INSTRUCTION(TZCNT8RegReg, tzcnt,
BINARY(VEX_L___, VEX_vNONE, PREFIX_F3, REX_W, ESCAPE_0F__, 0xbc, 0, ModRM_RM__, Immediate_0),
PROPERTY0(IA32OpProp_ModifiesTarget | IA32OpProp_ModifiesZeroFlag | IA32OpProp_ModifiesCarryFlag | IA32OpProp_SourceRegisterInModRM ),
PROPERTY1(IA32OpProp1_LongSource | IA32OpProp1_LongTarget),
FEATURES(0)),
INSTRUCTION(UD2, ud2,
BINARY(VEX_L___, VEX_vNONE, PREFIX___, REX__, ESCAPE_0F__, 0x0b, 0, ModRM_NONE, Immediate_0),
PROPERTY0(0),
Expand Down
8 changes: 8 additions & 0 deletions fvtest/compilerunittest/x/BinaryEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,14 @@ INSTANTIATE_TEST_CASE_P(AVX512MaskRegSimdEVEX512Test, XRegRegEncEncodingTest, ::
std::make_tuple(TR::InstOpCode::VPMOVB2MRegReg, TR::RealRegister::k2, TR::RealRegister::xmm5, OMR::X86::EVEX_L128, "62f27e0829d5")
)));

INSTANTIATE_TEST_CASE_P(GeneralPurposeRegRegTest, XRegRegEncEncodingTest, ::testing::ValuesIn(*TRTest::MakeVector<std::tuple<TR::InstOpCode::Mnemonic, TR::RealRegister::RegNum, TR::RealRegister::RegNum, OMR::X86::Encoding, TRTest::BinaryInstruction>>(
std::make_tuple(TR::InstOpCode::LZCNT4RegReg, TR::RealRegister::eax, TR::RealRegister::ecx, OMR::X86::Default, "f30fbdc1"),
std::make_tuple(TR::InstOpCode::LZCNT8RegReg, TR::RealRegister::eax, TR::RealRegister::ecx, OMR::X86::Default, "f3480fbdc1"),

std::make_tuple(TR::InstOpCode::TZCNT4RegReg, TR::RealRegister::eax, TR::RealRegister::ecx, OMR::X86::Default, "f30fbcc1"),
std::make_tuple(TR::InstOpCode::TZCNT8RegReg, TR::RealRegister::eax, TR::RealRegister::ecx, OMR::X86::Default, "f3480fbcc1")
)));

INSTANTIATE_TEST_CASE_P(Branch, XRegRegEncodingTest, ::testing::ValuesIn(*TRTest::MakeVector<std::tuple<TR::InstOpCode::Mnemonic, TR::RealRegister::RegNum, TR::RealRegister::RegNum, TRTest::BinaryInstruction>>(
std::make_tuple(TR::InstOpCode::XOR4RegReg, TR::RealRegister::eax, TR::RealRegister::eax, "33c0"),
std::make_tuple(TR::InstOpCode::XOR4RegReg, TR::RealRegister::ecx, TR::RealRegister::ebp, "33cd"),
Expand Down

0 comments on commit bbfea5c

Please sign in to comment.