Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sleigh vector move operation #4704

Closed
astrelsky opened this issue Nov 1, 2022 · 4 comments
Closed

Sleigh vector move operation #4704

astrelsky opened this issue Nov 1, 2022 · 4 comments
Assignees
Labels
Status: Internal This is being tracked internally by the Ghidra team
Milestone

Comments

@astrelsky
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'm always frustrated when I encounter vectorized code and the decompiler either spews a bunch of nonsense, warns about unimplemented instructions, or emits a placeholder pcodeop.

Describe the solution you'd like
A special operation, or set of operations, which would tell the decompiler that it may use a "best fit" sized varnode for the operation.

Additional context
Some of the AVX instructions are problematic whether it be they are missing, not decoded, unimplemented or using placeholders.

@ghidracadabra ghidracadabra self-assigned this Nov 1, 2022
@ghidracadabra
Copy link
Contributor

How to best handle this situation in general is something we're actively thinking about. We would like to have both accurate emulation and understandable decompilation. There's some related discussion in #4476.

The decompiler does have the ability to split vector registers into independent varnodes in certain cases (based on the vector_lane_sizes attribute in a .pspec file). "Complicated" operations, such as shuffles or various permutations, can be problematic, and of course if there's no associated pcode the decompiler doesn't have much to go on.

If you encounter AVX instructions that are missing or decoding incorrectly please let us know, unless they're AVX-512. We already know about those. 😄

@ghidracadabra ghidracadabra added the Status: Internal This is being tracked internally by the Ghidra team label Nov 1, 2022
@astrelsky
Copy link
Contributor Author

They are indeed AVX-512.

@astrelsky
Copy link
Contributor Author

astrelsky commented Nov 3, 2022

@ghidracadabra I was thinking more along the lines of new pcodeops specifically for common parallel instructions. In my opinion the vector lane registers is an incomplete approach since the registers can be used in non vector instructions and when used there is nothing to tell the decompiler that the register is indeed being used in a vector instruction. This leaves both guesswork and room for error. Having something as simple as parallel(ADD, output, input1, input2, op size, full data size) (crude example) could go a long way. It is explicitly informing both the decompiler and the pcode emulator of what it is doing so it can be handled accordingly.

While this still wouldn't help much for complex operations I still think this could go a long way for improving this area.

@ghidracadabra
Copy link
Contributor

@astrelsky We've considered something like that - it would also make writing the sleigh implementations of vector ops less painful and error-prone. It might be useful for the decompiler as well. There are some complications given the fact that instructions with a natural lane size are often mixed with instructions which are "lane agnostic" (such as bitwise instructions) and instructions which don't really respect lane sizes (like the shuffles or permutes mentioned above). Discussions are ongoing...

@ryanmkurtz ryanmkurtz added this to the 11.1 milestone Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Internal This is being tracked internally by the Ghidra team
Projects
None yet
Development

No branches or pull requests

3 participants