theotherjimmy opened PR #12218 from theotherjimmy:s390x-bxd20 to bytecodealliance:main:
Previously, cranelift did not emit memory operations using 20 bit immedates for reg + reg memory modes on s390x. This patch enables that in a type safe manner by exporting a few extractors for 20 bit immediates and changing the argument to the MemArg constructor for reg + reg addressing mode to accept that 20 bit offset instead of the u8 offset.
<!--
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
-->
theotherjimmy requested abrown for a review on PR #12218.
theotherjimmy requested wasmtime-compiler-reviewers for a review on PR #12218.
theotherjimmy updated PR #12218.
theotherjimmy updated PR #12218.
github-actions[bot] commented on PR #12218:
Subscribe to Label Action
cc @cfallin, @fitzgen
<details>
This issue or pull request has been labeled: "cranelift", "isle"Thus the following users have been cc'd because of the following labels:
- cfallin: isle
- fitzgen: isle
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
cfallin commented on PR #12218:
cc @uweigand -- would you mind taking a look?
uweigand commented on PR #12218:
Hi @theotherjimmy this makes sense in principle, but I have a couple of comments:
- The
biasnaming was intended to reflect small offset generated by the back-end to access part of a value (e.g. when accessing a 16-byte value as two 8-byte values, the second value needs to have the address biased by 8); it was not intended to act as a generic displacement. If we want that, we should probably rename the function toreg_plus_reg_plus_offor something.- With your code, we're now greedily generating reg+reg+simm20 always, and retroactively fix things if the instruction doesn't have that addressing mode. That is probably the right thing to do in general, but in many cases we already know that the addressing mode isn't available (e.g. vector instructions always only have uimm12 displacements). We'll likely get better code if we leave the addition separately from the beginning in those cases.
theotherjimmy commented on PR #12218:
Thanks for the review @uweigand
I think I'll rework this to write a new extractor with your suggested name, and migrate to that new extractor where we know the instructions support the extended offset. That should resolve your concerns.
theotherjimmy updated PR #12218.
theotherjimmy updated PR #12218.
theotherjimmy commented on PR #12218:
@uweigand Is this more in line with what you expected?
uweigand created PR review comment:
This doesn't appear to be used anywhere?
uweigand submitted PR review:
This looks generally good to me. As a small enhancement it might be interesting to also extend the
lower_address_biasversion with amemarg_reg_plus_reg_plus_offclause (which would add the bias to the offset); this probably doesn't have much effect on performance but would preserve the symmetry.A much bigger (future) enhancement could be to be more specific in generating proper addressing modes for the target instruction in the first place:
- Avoid using the generic
RegOffsetmode but rather generate explicit code to begin with (e.g. along the lines of the AArch64amoderules).- Use more specific flavors of
lower_address(e.g.lower_address_bdaddr12,lower_address_bdaddr20,lower_address_bdxaddr12,lower_address_bdxaddr20to follow LLWM nomenclature) and update the various rules to use the specific flavors instead of the generic, as appropriate for the target instruction of each rule.
theotherjimmy updated PR #12218.
uweigand submitted PR review.
uweigand created PR review comment:
The above rule should now be redundant, shouldn't it? With offset 0 the rule below should always match and give the same result.
theotherjimmy updated PR #12218.
theotherjimmy submitted PR review.
theotherjimmy created PR review comment:
Deleted, tests still pass.
uweigand submitted PR review:
This LGTM now, thanks!
cfallin submitted PR review:
Thanks Ulrich for the review on this!
cfallin merged PR #12218.
Last updated: Feb 24 2026 at 07:22 UTC