Skip to content

x64: Migrate some blend-related instructions #10975

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 2 commits into from
Jun 9, 2025

Conversation

alexcrichton
Copy link
Member

This commit migrates the pblendvb, blendvps, blendvpd, and AVX versions of each to the new assembler. This required a few minor features in the assembler:

  • The fixed physical xmm0 register is now a Location
  • The "/is4" encoding format for VEX instructions is supported
  • The Fixed type now supports both xmm and gpr registers (minor update to its to_string method).

In the end this enables deleting XmmRmRBlend and XmmRmRBlendVex. (yay!)

This commit migrates the `pblendvb`, `blendvps`, `blendvpd`, and AVX
versions of each to the new assembler. This required a few minor
features in the assembler:

* The fixed physical `xmm0` register is now a `Location`
* The "/is4" encoding format for VEX instructions is supported
* The `Fixed` type now supports both xmm and gpr registers (minor update
  to its `to_string` method).

In the end this enables deleting `XmmRmRBlend` and `XmmRmRBlendVex`.
(yay!)
@alexcrichton alexcrichton requested a review from a team as a code owner June 7, 2025 01:43
@alexcrichton alexcrichton requested review from cfallin and removed request for a team June 7, 2025 01:43
; pblendvb %xmm1, %xmm7, %xmm1
; pblendvb %xmm0, %xmm7, %xmm1
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll note that there's no actual register allocation changes here, this is just an artifact of how the instruction used to be printed. The xmm0 argument was omitted by default and the src/destination, which are required to be the same register, were printed twice.

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen labels Jun 7, 2025
@@ -36,5 +36,12 @@ pub fn list() -> Vec<Inst> {

inst("movddup", fmt("A", [w(xmm1), r(xmm_m64)]), rex([0xF2, 0x0F, 0x12]).r(), _64b | compat | sse3),
inst("vmovddup", fmt("A", [w(xmm1), r(xmm_m64)]), vex(L128)._f2()._0f().op(0x12).r(), _64b | compat | avx),

inst("pblendvb", fmt("RM", [rw(xmm1), r(align(xmm_m128)), r(xmm0)]), rex([0x66, 0x0F, 0x38, 0x10]).r(), _64b | compat | sse41),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
inst("pblendvb", fmt("RM", [rw(xmm1), r(align(xmm_m128)), r(xmm0)]), rex([0x66, 0x0F, 0x38, 0x10]).r(), _64b | compat | sse41),
inst("pblendvb", fmt("RM", [rw(xmm1), r(align(xmm_m128)), r(implicit(xmm0))]), rex([0x66, 0x0F, 0x38, 0x10]).r(), _64b | compat | sse41),

Don't we want this to be implicit?

Copy link
Member Author

Choose a reason for hiding this comment

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

I originally thought so yeah but apparently Capstone disassembles this with %xmm0 show it shows up in the instruction listing. It looks like even Intel-style disassembly shows xmm0 as well, so for whatever reason while it's implicit on instructions like div it's not implicit here...

@abrown abrown added this pull request to the merge queue Jun 9, 2025
Merged via the queue into bytecodealliance:main with commit 901b441 Jun 9, 2025
53 checks passed
@alexcrichton alexcrichton deleted the x64-blends branch June 9, 2025 18:36
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.

2 participants