remill icon indicating copy to clipboard operation
remill copied to clipboard

Add Semantics for AVX512VL instruction

Open adahsuzixin opened this issue 4 years ago • 6 comments

Hi,team

I have question for adding Semantics for AVX512VL instruction. For example, let's see the following two instructions.

instruction binary
vpshufb %xmm2,%xmm3,%xmm0{%k1}{z} 62 f2 65 89 00 c2
vpshufb %xmm2,%xmm3,%xmm0{%k1} 62 f2 65 09 00 c2

In first situation, it should have 5 arguments in Semantics function. However, the instruction form from docs/XED/xed.txt has only 4 arguments at most.

4386 VPSHUFB VPSHUFB_XMMu8_MASKmskw_XMMu8_XMMu8_AVX512 AVX512 AVX512EVEX AVX512BW_128 ATTRIBUTES: MASKOP_EVEX
 4 
	0 REG0 EXPLICIT W NT_LOOKUP_FN U8 XMM_R3 
	1 REG1 EXPLICIT R NT_LOOKUP_FN I1 MASK1 
	2 REG2 EXPLICIT R NT_LOOKUP_FN U8 XMM_N3 
	3 REG3 EXPLICIT R NT_LOOKUP_FN U8 XMM_B3 

So in this situation, we lost {z} flag after decoding with the help of xed. Is there any good way to get the {z} flag? We need the flag to implement the Semantics shown below.

(KL, VL) = (16, 128), (32, 256), (64, 512)
jmask←(KL-1) & ~0xF
                // 0x00, 0x10, 0x30 depending on the VL
FOR j = 0 TO KL-1
                // dest
    IF kl[ i ] or no_masking
        index←src.byte[ j ];
        IF index & 0x80
            Dest.byte[ j ]←0;
        ELSE
            index←(index & 0xF) + (j & jmask);
                // 16-element in-lane lookup
            Dest.byte[ j ]←src.byte[ index ];
    ELSE if zeroing
        Dest.byte[ j ]←0;
DEST[MAXVL-1:VL] ← 0;

adahsuzixin avatar Jul 13 '20 13:07 adahsuzixin

We'll need to add support for the mask registers to Remill's wrapper around XED's decoder. docs/XED/xed.txt is rather old, it should be updated.

pgoodman avatar Jul 15 '20 16:07 pgoodman

The xed.txt file is produced from XED's xed-tables.c file, or tables.c file. I recall that I manually had to build the xed-tables.c file from XED's repo... it was a long time ago that I made that file.

pgoodman avatar Jul 15 '20 20:07 pgoodman

Thanks for your reply. Can you consider prioritizing avx512-support things up after api_improvement?

adahsuzixin avatar Jul 17 '20 06:07 adahsuzixin

BTW, I wonder whether it will help to update xed to 11.2.0 in cxx-common. It looks like there are some improvements in AVX512.

adahsuzixin avatar Jul 17 '20 06:07 adahsuzixin

It looks to me like the XED version we use is the master branch at the time of producing artifacts. I will look into triggering the workflows to do a rebuild to get a more up-to-date version of XED.

Are you willing to sponsor the development of the AVX512 instruction set extensions to Remill?

pgoodman avatar Jul 17 '20 20:07 pgoodman

Sure, I'd like to help. But due to my recent work priority, I'm not sure whether I can keep up with the community steps :-)

adahsuzixin avatar Jul 20 '20 03:07 adahsuzixin