jlb6740 opened PR #10695 from jlb6740:add-initial-vex-encoding-support-1-of-2 to bytecodealliance:main:
Patch is first, one or two more will be pushed for enabling.
<!--
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
-->
jlb6740 requested abrown for a review on PR #10695.
jlb6740 requested wasmtime-compiler-reviewers for a review on PR #10695.
jlb6740 requested alexcrichton for a review on PR #10695.
jlb6740 requested wasmtime-core-reviewers for a review on PR #10695.
jlb6740 updated PR #10695.
jlb6740 updated PR #10695.
jlb6740 updated PR #10695.
jlb6740 updated PR #10695.
jlb6740 updated PR #10695.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Would it be possible to duplicate necessary types here? The intent is that the meta crate is only used at build-time and isn't a runtime dependency but this is otherwise adding the meta crate as a runtime dependency as well
cfallin submitted PR review.
cfallin created PR review comment:
In the cranelift-codegen cinematic universe of crates, we have
-metaand-shared; the-sharedcrate is depended on by both the meta and main crate. Perhaps the same split makes sense here?
jlb6740 submitted PR review.
jlb6740 created PR review comment:
Hi @alexcrichton, I think so. I did it this way as it seemed to be required for a previous iteration of this patch set, plus it assures consistency and avoids duplication, but I understand we don't want a dependency on the meta crate and that duplication is ok. If I do believe there is a dependency we want to keep, I'll follow @cfallin advise and see if a shared crate makes sense here. Also note, there are a few unnecessary elements in the vex struct in the meta crate that I am removing along with commented out code intended to help develop the follow-up patch 2 of 2 to be submitted later when we enable this.
jlb6740 updated PR #10695.
jlb6740 submitted PR review.
jlb6740 created PR review comment:
@alexcrichton .. I believe this is addressed now.
abrown submitted PR review:
I got about halfway through reviewing this; here are some comments.
abrown created PR review comment:
I think at the DSL level we may want to have separate booleans for each bit, e.g.:
r: bool, x: bool, b: bool, w: bool,As it stands, this duplicates the
rbit.
abrown created PR review comment:
This is the same as
rm128... I'm not convinced adding these unused variants is necessary at this point, either.
abrown created PR review comment:
It will be helpful to check here for invalid instruction definitions: that way we can find them early, at codegen time.
abrown created PR review comment:
We shouldn't need to create a default (i.e., invalid) VEX instruction ever, right?
abrown created PR review comment:
This duplicates one of the definitions in
add.rs, right? Let's just keep all the addition in that file to avoid this kind of mistake.
abrown created PR review comment:
This is not right:
self.bits() / 8
abrown created PR review comment:
// test a single input, append `.seed(0x<failing seed>)`.
abrown created PR review comment:
This seems a bit redundant to match here in any case...
abrown created PR review comment:
When you're adding brace-delimited blocks, you can use
Formatter::add_blockto get the indentation right, avoid forgetting to add a closing brace, and to match the rest of this crate:f.add_block("match &self.xmm_m128", |f| { fmtln!(f, "XmmMem::Xmm(r) => {{vex.rm = XmmMem::Xmm(r.clone());}}"); fmtln!(f, "XmmMem::Mem(m) => {{vex.rm = XmmMem::Mem(m.clone());}}"); });
abrown created PR review comment:
Instead of creating a default (i.e., invalid) instruction here, why not use a
newconstructor or a builder pattern (e.g.,op(...).reg(...)...) to create only valid instructions?
jlb6740 submitted PR review.
jlb6740 created PR review comment:
Yes, I am not positive, but I don't even think any of these bits will need to be set at the DSL level. For now I'll just remove the rxb and add the b and w bits as suggested here (but maybe we can remove later).
jlb6740 created PR review comment:
For the final vex support I removed the one in add.rs (but put it back for this pr). The reason is simple, I was organizing the instructions the same way they are organized in the manual by opcode (specifically Vol 2A 3-34). The ADDPD opcode instruction section covers rex, vex, and evex. What do you think about this organization of grouping instructions consistent with the manual?
jlb6740 submitted PR review.
jlb6740 edited PR review comment.
jlb6740 submitted PR review.
jlb6740 created PR review comment:
I don't think so. Will remove this.
jlb6740 submitted PR review.
jlb6740 created PR review comment:
Yes agreed .. can we implement this validate in the next PR where we turn the plumbing on and we can see that the validation is actually doing the right thing against those first few instructions or would you like to see a little more of this filled out now?
jlb6740 submitted PR review.
jlb6740 created PR review comment:
I was wanting to be consistent with the manual here:
ADDPD xmm1, xmm2/m128
VADDPD xmm1, xmm2, xmm3/m128and writing something like this:
inst( "vaddpd", fmt("B", [w(xmm1), r(xmm2), r(xmm_m128)]), vex(0x58).length(_128).pp(_66).mmmmm(_OF), _64b | compat | sse, ),instead of like this:
inst( "vaddpd", fmt("B", [w(xmm1), r(xmm2), r(rm128)]), vex(0x58).length(_128).pp(_66).mmmmm(_OF), _64b | compat | sse, ),I kept the rm128 because I didn't know if it would fly during review that I replaced in in all the rex encoded instructions but using the naming xmm_m128 is more consistent with the manual. What do you think?
jlb6740 edited PR review comment.
jlb6740 closed without merge PR #10695.
jlb6740 commented on PR #10695:
Hi @cfallin @alexcrichton @abrown I've attempted to address all comments or at least touch base with the reviewer offline. I've moved this PR to https://github.com/bytecodealliance/wasmtime/pull/10754 where instead of doing this in 2 parts, well just attempt to switch on the lowering of vaddpd and vaddps. I'll close this PR.
Last updated: Dec 06 2025 at 07:03 UTC