lifting-bits / remill

Library for lifting machine code to LLVM bitcode
Apache License 2.0
1.22k stars 141 forks source link

add KMOW #561

Closed yjxxin closed 2 years ago

yjxxin commented 2 years ago

Hi team

When we added the semantic function of AVX512 instructions, we found that remill did not implement the reading of the k register. For example, the following AVX512 instruction:

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

instruction | binary -- | -- kmovw   %ebx, %k1 | c5 f8 92 cb

In the above instruction, the k1 register is used as the result operand, and it is also indicated in docs/XED/xed.txt that the K mask register needs to be used:

2630 KMOVW KMOVW_MASKmskw_MASKu16_AVX512 KMASK AVX512VEX AVX512F_KOP ATTRIBUTES: KMASK 2 0 REG0 EXPLICIT W NT_LOOKUP_FN I1 MASK_R 1 REG1 EXPLICIT R NT_LOOKUP_FN U16 MASK_B

But remill does not provide a method to read the K register. To solve this problem, we need to add a variable to store the value of the K register in State.h, and add the size of the K register to the State variable.

I have submitted a PR and implemented the KMOVW instruction, hoping to provide valuable comments