abrown opened PR #10775 from abrown:refactor-reg-mem-imm to bytecodealliance:main:
While reflecting on why #10762 is hard, it seemed that the underlying problem to many ISLE matching issues is our inability to actually inspect the variants of the register specific versions of
RegMemandRegMemImm. We had been wrapping instances of theseReg*types, but this change pushes the variants down to:GprMem,GprMemImm,XmmMem,XmmMemAligned,XmmMemImm, andXmmMemAlignedImm. With this, it should be possible to match directly on the variants in ISLE. This does not change any functionality.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
abrown requested fitzgen for a review on PR #10775.
abrown requested wasmtime-compiler-reviewers for a review on PR #10775.
abrown submitted PR review.
abrown created PR review comment:
Is it possible to create a
GprMem.Regin ISLE using the wrong kind of register? If so, we could alter this type toGpr?
abrown edited PR review comment.
abrown commented on PR #10775:
I will say, having tried to use this in #10762, that it doesn't just "solve everything." So we should judge this on whether it will make future matching easier. I know that I've reached for this kind of matching in the past but was frustrated it didn't exist.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Would it be possible to type this as
(Gpr (reg Gpr))? That more closely matches the semantics of theGprMemconstructor in Rust
fitzgen created PR review comment:
Following up from today's Cranelift meeting, where we briefly discussed this PR: I want to +1 Alex's comment here.
We want to maintain the invariant that all
Gpr*newtypes can only ever contain GPR registers when they aren't a memory or immediate or whatever. If we expose rawRegs in theseenumvariants, then users can accidentally (say transitively through a series of abstractions) do something likeif let GprMem::Reg { reg } = &mut gpr_mem { std::mem::swap(reg, my_xmm_reg); }which would break that invariant.
In order to both allow matching on
GprMemet al and preserve that invariant, we need to define newenums (to allow matching) but keep the register variants asGprs (to preserve encapsulation and the GPR invariant). This would look like the ISLE equivalent of something like this:enum GprMem { Gpr { reg: Gpr }, Mem { addr: SyntheticAmode }, }Which is, I believe, what Alex is suggesting just above this comment.
fitzgen submitted PR review.
Last updated: Dec 06 2025 at 06:05 UTC