fitzgen requested abrown for a review on PR #11043.
fitzgen opened PR #11043 from fitzgen:x64-op-mem-imm to bytecodealliance:main:
<!--
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
-->
fitzgen requested wasmtime-compiler-reviewers for a review on PR #11043.
fitzgen requested alexcrichton for a review on PR #11043.
fitzgen requested wasmtime-core-reviewers for a review on PR #11043.
fitzgen updated PR #11043.
fitzgen updated PR #11043.
alexcrichton submitted PR review:
What do you think about blocking on the suggestion below to clean up
lower.isle?Also other instructions that might be interesting to add are
xor(probably easy) and shifts (maybe harder? unsure)
alexcrichton created PR review comment:
A possible alternative: what about:
(decl x64_or_mem (Amode Value) SideEffectNoResult)The type could be inferred from the value, and that would also enable dispatching internally based on iconst-or-not to all the various rules. That way we additionally wouldn't need any new rules in
lower.isleand would reduce the duplication there.
fitzgen updated PR #11043.
fitzgen submitted PR review.
fitzgen created PR review comment:
Done! Please take another look
alexcrichton created PR review comment:
This could replace
i64_from_iconstwithi32_from_iconstto avoid theif-let
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Personally I'm always wary to discard the lower bits with
asin lowering rules lest they accidentally get removed. Given thaticonstextraction is generally signed could the above rules do(i16_from_iconst imm)and then the immediate to the instruction is(i16_as_u16 imm)to be clear that there's no data loss it's just reinterpreting the sign bit?
alexcrichton created PR review comment:
Would it make sense to add
i8_from_iconstto make these two cases one-liners too?
fitzgen submitted PR review.
fitzgen created PR review comment:
We can't do that because
i32_from_constwill unconditionally truncate upper bits, but we need to only match this rule when theiconstbits will losslessly fit in ani32.
fitzgen submitted PR review.
fitzgen created PR review comment:
Similarly, this also needs to be fallible
alexcrichton created PR review comment:
I don't think that's correct? The definition of
i32_from_iconstusestry_from? (it very much should or we have a lot of incorrect lowering rules)
alexcrichton submitted PR review.
fitzgen submitted PR review.
fitzgen created PR review comment:
There is no
i16_from_iconstand this is only used to implementu16_from_iconstand our existingfoo_from_iconstextractors (such asu32_from_iconst) already use lossyasconversions and bring the assumption that the caller is choosing a value based on the correct width for their type context.I don't think that is really the correct choice, but I also don't want to do something different and make it so we have multiple idioms here. We already have enough trouble from some things being extractors and some being pure partial constructors and not being able to reuse one kind of thing for the other. All of our
iconstand numerics stuff could definitely be overhauled but, again, I don't really want to do it in this PR. I'd rather just follow the existing code conventions.
fitzgen submitted PR review.
fitzgen created PR review comment:
i32_from_iconstseems to do the checks but then we have these other cases that do not:(decl u32_from_iconst (u32) Value) (extractor (u32_from_iconst x) (u64_from_iconst (u64_as_u32 x))) ;; ... (decl i8_from_iconst (i8) Value) (extractor (i8_from_iconst x) (i32_from_iconst (i32_as_i8 x)))
fitzgen submitted PR review.
fitzgen created PR review comment:
So I guess this particular one can change, but I don't think we can blanket apply this reasoning to the other cases
alexcrichton commented on PR #11043:
Extracting a comment out here since it's not particularly relevant in isolation: I suppose this is fine to land and while on one hand it's not making things worse on the other hand it's also making things worse because it's adding more places to update with a future refactoring. I'll start working on such a refactoring as this is something that's bothered me for quite some time. If you'd like to land this in the meantime I think that's ok too.
fitzgen commented on PR #11043:
I was thinking it would be nice to automatically generate the full combinatorial set of fallible, infallible, checked, and truncating ISLE conversions for numeric types in the meta crate
fitzgen commented on PR #11043:
But yeah, I'll land this now and then we can do the much needed clean up in follow ups.
fitzgen updated PR #11043.
fitzgen has enabled auto merge for PR #11043.
fitzgen merged PR #11043.
Last updated: Dec 06 2025 at 06:05 UTC