Skip to content

x64: EVEX Encoding for new assembler #11153

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

Merged
merged 11 commits into from
Jul 16, 2025

Conversation

rahulchaphalkar
Copy link
Contributor

Adds evex encoding for new assembler.
Adds vaddpd evex instr.

Following items are not implemented in this PR / left out intentionally -

  • Broadcast attribute (bcst). Will be implemented in future pr.
  • Features: Uses avx512vl feature right now, this will be changed to AND of avx512vl and avx512f, and at a later point to avx10.1, avx10.2 etc.
  • vaddpd is not lowered yet

@abrown Ready for review. I'll add a few code comments for some discussion soon, apart from above list of omitted items.

@rahulchaphalkar rahulchaphalkar requested a review from a team as a code owner June 27, 2025 21:46
@rahulchaphalkar rahulchaphalkar requested review from alexcrichton and removed request for a team June 27, 2025 21:46
@alexcrichton alexcrichton requested review from abrown and removed request for alexcrichton June 27, 2025 22:28
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen labels Jun 28, 2025
@abrown
Copy link
Member

abrown commented Jul 7, 2025

I'll probably take over this PR soon since @rahulchaphalkar is out for a bit.

inst("vpaddusw", fmt("B", [w(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66()._0f().op(0xDD).r(), _64b | compat | avx),
inst("vphaddw", fmt("B", [w(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66()._0f38().op(0x01).r(), _64b | compat | avx),
inst("vphaddd", fmt("B", [w(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66()._0f38().op(0x02).r(), _64b | compat | avx),
inst("vaddpd", fmt("C", [w(xmm1).k(1).z(), r(xmm2), r(xmm_m128)]), evex(L128)._66()._0f().w1().op(0x58).r(), _64b | compat | avx512vl),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic should be (AVX512VL AND AVX512F). Additionally, since we need the ability to AND things together, we need to teach the whole expression to mean: (_64b | compat) & (...) (maybe in another PR, since this affects many instructions beyond just this one).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may actually work out? Not to say our current modeling of things is correct, but functionally with | avx512f here I think it has the net effect of requiring more features. Notably we take all the features the assembler says and flag them all as requirements of each instruction, so by listing more features here it's interpreted as effectively requiring all of them. I don't know if that's an accurate reflection of _64b and compat though as we otherwise basically ignore those features right now.

Although rereading your comment now I suspect you're talking about the interactions of _64b and compat with feature flags, which is exactly the gray area for me that iunno much about, so probably just disregard me

@abrown
Copy link
Member

abrown commented Jul 16, 2025

@cfallin or @alexcrichton: can one of you review this? I've changed this PR substantially since it was first opened so I think it needs a new reviewer that is not me.

@abrown abrown requested review from alexcrichton and cfallin July 16, 2025 22:19
@cfallin
Copy link
Member

cfallin commented Jul 16, 2025

Sure, taking a look!

Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Taking your word (and the fuzzer's) on the actual prefix-encoding details!

@cfallin cfallin added this pull request to the merge queue Jul 16, 2025
Merged via the queue into bytecodealliance:main with commit 239f4a8 Jul 16, 2025
165 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants