pkgw / elfx86exts

Decode binaries and print out which instruction set extensions they use. This program's name is a lie: it supports not just x86/ELF but also ARM64, MachO, and possibly more.
MIT License
209 stars 14 forks source link

Add AMD and some others. #88

Closed dargor closed 2 years ago

dargor commented 2 years ago

NOVLX is a tangled nightmare, seems to be used in LLVM sources to determine which AVX instructions to use when AVX512 VLX is not available. Maybe rework/split logic later to better analyze current mnemonic, and ignore NOVLX group ? The same should probably be done for VLX, as :

https://www.felixcloutier.com/x86/pxor https://www.felixcloutier.com/x86/movaps.html

I can create a separate issue concerning this VLX/NOVLX stuff, if you want.

pkgw commented 2 years ago

I am going to be honest, I don't actually understand anything about the different CPU generation information —this use of the tool far exceeds my initial motivation for creating it. So I am going to go ahead and merge these even though I don't really understand what you're doing! I am happy to accept more patches.

More broadly, I don't actually use this tool myself anymore, so I'm not going to put any time into it beyond basic maintenance (which does include reviewing PRs in my mind). I am more than happy to hand off maintenance to someone with a more active interest in it.

dargor commented 2 years ago

To be honest too, I don't really understand this VLX/NOVLX mess. For example on my work laptop, I get :

$ elfx86exts /bin/ls
MODE64 (call)
AVX (vmovdqu)
CMOV (cmovne)
AVX512 (vpbroadcastq) # so, AVX512
VLX (vpbroadcastq) # AVX512VL implies VLX, so we are fine here
AVX2 (vinserti128)
BMI (andn)
BWI (vmovdqu8)
NOVLX (vpaddq) # why are you here ?
BMI2 (rorx)
DQI (kxorb)
CPU Generation: Unknown

This CPU has avx512f avx512dq avx512cd avx512bw avx512vl avx512vbmi so it has VLX, but I still get a NOVLX somehow. My guess is the compiler chose an AVX/AVX2 version of vpaddq over an AVX512 one, there are quite a few variants https://hjlebbink.github.io/x86doc/html/PADDB_PADDW_PADDD_PADDQ.html

I am not sure about this "cpu generation" feature either, it seems quite brittle.

And I use your tool mostly to check if my compiler flags are really doing something, or are overriden somewhere :-) That being said it is a nice tool, does the job nicely.