broken LLVM-MC?

Hi,

It seems LLVM-MC is broken with Avx512?

$ echo “vinserti32x4 $1, %xmm21, %zmm5, %zmm17”|./Release+Asserts/bin/llvm-mc -assemble -arch=x86-64 -show-encoding -x86-asm-syntax=att
.text
vinserti32x4 $1, %xmm21, %zmm5, %zmm17 # encoding: [0x62,0xa3,0x55,0x48,0x38,0xcd,0x01]

$ echo “0x62,0xa3,0x55,0x48,0x38,0xcd,0x01” |./Release+Asserts/bin/llvm-mc -disassemble -arch=x86-64
:1:1: warning: invalid instruction encoding

Similarly, 3DNow seems broken, too.

$ echo “pavgusb %mm2, %mm1”|./Release+Asserts/bin/llvm-mc -assemble -arch=x86-64 -show-encoding -x86-asm-syntax=att
.text
pavgusb %mm2, %mm1 # encoding: [0x0f,0x0f,0xca,0xbf]

$ echo “0x0f,0x0f,0xca,0xbf” |./Release+Asserts/bin/llvm-mc -disassemble -arch=x86-64
:1:1: warning: invalid instruction encoding

Or I did not use LLVM-MC properly? Any idea??

Thank you,
Jun

Well, you’ll probably need to specify which CPU for the instructions to be recognized as valid encodings. -mcpu=knl doesn’t seem sufficient, though, so there’s probably something more going on.

Elena, do you know what’s happening here? It’s important that the disassembler work with the new instructions as well as the assembler. I looked but didn’t see any disassembler tests for avx512.

-Jim

Hi,

I changed llvm-mc in my commit 197041. The change is for AVX-512 only.
Now you should invoke -mcpu=knl when you what to assemble any AVX-512 instruction.

echo vinserti32x4 \$1, %xmm21, %zmm5, %zmm17 |./Debug+Asserts/bin/llvm-mc -assemble -arch=x86-64 -show-encoding -x86-asm-syntax=att -mcpu=knl
  .text
  vinserti32x4 $1, %xmm21, %zmm5, %zmm17 # encoding: [0x62,0xa3,0x55,0x48,0x38,0xcd,0x01]

I did this because AVX and AVX-512 have collisions in mnemonics of scalar FP operations, VSQRTSS or VMOVSS for example.

I did not touch other architectures, so 3DNow should work as is.
echo "pavgusb %mm2, %mm1"|./Debug+Asserts/bin/llvm-mc -assemble -arch=x86-64 -show-encoding -x86-asm-syntax=att
  .text
  pavgusb %mm2, %mm1 # encoding: [0x0f,0x0f,0xca,0xbf]

As far as "-disassemble" flag, you are absolutely right, it is a bug and Alexey Bader will take care. He will also and add more disassembly tests.
Thank you for catching this.

- Elena