abrown opened PR #11272 from abrown:asm-features to bytecodealliance:main:
This adds full boolean term support for instructions emitted in the new assembler (terms like
(_64b | compat) & avx2). Despite doing more checks, this may be quicker too: instead of building up aSmallVec<InstructionSet>to compare against, this generates Rust code like the following that queries what features are available in the target via theAvailableFeaturestrait:#[must_use] // cranelift/assembler-x64/meta/src/generate/inst.rs:227 pub fn is_available(&self, features: &impl AvailableFeatures) -> bool { (features._64b() || features.compat()) && features.avx2() // cranelift/assembler-x64/meta/src/generate/inst.rs:232 }With all of this in place, this PR has a large mechanical translation of all the old, incorrect feature definitions (
_64b | compat | avx2) into their new, correct definitions ((_64b | compat) & avx2). I expect this will see a lot more use of this when using more instructions from AVX512, AVX10, APX, etc.
abrown requested wasmtime-compiler-reviewers for a review on PR #11272.
abrown requested alexcrichton for a review on PR #11272.
abrown submitted PR review.
abrown created PR review comment:
So this is a bit unfortunate at the moment: we've lost the ability to see why this check has failed. I mulled this over for a bit, thinking how we can get this back. One option is to have the assembler just "return the right string" through some other method which we can paste in here. But I'm leaning toward adding a Inst::features() -> Features, much like we had before, but that would return a boolean term like the one we have available at the meta level. Though this would duplicate the some of Features, it would return an enum that is more widely usable than a string while I still have all of this paged in.
Either option, "return a string" or "return a Features", is really fine at this poing and I'm interested in feedback. Also, this seems like something that could get fixed up in a follow-on PR.
abrown edited PR review comment.
abrown commented on PR #11272:
I do expect this to fail in Winch: something about how we're using
-Ccranelift-has-avx2inparam_av2.watdoesn't seem to propagate the right features into the ISA flags used here:
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Inst::featuressounds reasonable to me. Implementation-wise I might recommend a different representation ofFeaturesthat doesn't useBoxinternally but instead uses&'static ...and put everything intoconsts. That way there's no need to actually allocate anything and it's all just pointing at a bunch of static data (which is in theory deduplicated across functions too)
alexcrichton created PR review comment:
I think the discrepancy here with Winch is
use_avx2vshas_avx2perhaps? Here I think it'd be reasonable to switch tohas_*(for other methods too) whereuse_*affects codegen buthas_*is the literal CPU features (in theory)
alexcrichton submitted PR review.
abrown updated PR #11272.
abrown submitted PR review.
abrown created PR review comment:
See de476c2.
abrown submitted PR review.
abrown created PR review comment:
See f529126.
abrown requested alexcrichton for a review on PR #11272.
alexcrichton submitted PR review.
alexcrichton merged PR #11272.
Last updated: Dec 06 2025 at 06:05 UTC