Gelbpunkt edited PR #14475.
Gelbpunkt edited PR #14475:
<!--
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 review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.mdPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->This adds support for 128-bit atomics in the
atomic_rmwrule, which for 128-bit parameters is now lowered toatomic_rmw_128_loop.
atomic_rmw_128_loopis modeled closely afteratomic_rmw_loop, but needs a few extra registers to account for the data taking up two 64-bit GPRs. The generated assembly matches LLVM's.
Gelbpunkt updated PR #14475.
Gelbpunkt updated PR #14475.
Gelbpunkt updated PR #14475.
Gelbpunkt updated PR #14475.
Gelbpunkt updated PR #14475.
Gelbpunkt updated PR #14475.
Gelbpunkt updated PR #14475.
Gelbpunkt edited PR #14475:
This adds support for 128-bit atomics in the
atomic_rmwrule, which for 128-bit parameters is now lowered toatomic_rmw_128_loop.
atomic_rmw_128_loopis modeled closely afteratomic_rmw_loop, but needs a few extra registers to account for the data taking up two 64-bit GPRs. The generated assembly matches LLVM's.A similar thing is done for
atomic_cas_128_loop, since we want to be able to support 128-bit atomic compare-and-swap without LSE as well.Also added are special cased implementations of
atomic_loadandatomic_store.See the following Godbolt example for all the assembly generated by LLVM for these cases, which we now match: https://rust.godbolt.org/z/YG6j1z38q
bjorn3 tried this with cg_clif, and it works!
Gelbpunkt updated PR #14475.
Gelbpunkt has marked PR #14475 as ready for review.
Gelbpunkt requested wasmtime-compiler-reviewers for a review on PR #14475.
Gelbpunkt requested alexcrichton for a review on PR #14475.
Gelbpunkt edited PR #14475:
This adds support for 128-bit atomics in the
atomic_rmwrule, which for 128-bit parameters is now lowered toatomic_rmw_128_loop.
atomic_rmw_128_loopis modeled closely afteratomic_rmw_loop, but needs a few extra registers to account for the data taking up two 64-bit GPRs. The generated assembly matches LLVM's.A similar thing is done for
atomic_cas_128_loop, since we want to be able to support 128-bit atomic compare-and-swap without LSE as well.Also added are special cased implementations of
atomic_loadandatomic_store.See the following Godbolt example for all the assembly generated by LLVM for these cases, which we now match: https://rust.godbolt.org/z/YG6j1z38q
bjorn3 tried this with cg_clif, and it works!
Closes #10835
Gelbpunkt updated PR #14475.
Gelbpunkt updated PR #14475.
Gelbpunkt edited PR #14475:
This adds support for 128-bit atomics in the
atomic_rmwrule, which for 128-bit parameters is now lowered toatomic_rmw_128_loop.
atomic_rmw_128_loopis modeled closely afteratomic_rmw_loop, but needs a few extra registers to account for the data taking up two 64-bit GPRs. The generated assembly matches LLVM's.A similar thing is done for
atomic_cas_128_loop, since we want to be able to support 128-bit atomic compare-and-swap without LSE as well.Also added are special cased implementations of
atomic_loadandatomic_store.See the following Godbolt example for all the assembly generated by LLVM for these cases, which we now match: https://rust.godbolt.org/z/YG6j1z38q
bjorn3 tried this with cg_clif, and it works! In rust-lang/rust we currently keep a patch around for cg_clif to remove 128-bit atomic support, which is very painful to maintain, see https://github.com/rust-lang/rust/issues/153488. Out of x86_64, aarch64, riscv64 and s390x, the Rust targets that have 128-bit atomic support enabled are x86_64 on Darwin and Windows, aarch64 and s390x. Out of those, Cranelift currently lacks support for them on aarch64 and s390x.
Closes #10835
alexcrichton commented on PR #14475:
cc @theotherjimmy if you wouldn't mind reviewing this it'd be much appreciated!
:repeat: theotherjimmy submitted PR review:
Minor nits. Aside from some unused labels, this looks good.
:speech_balloon: theotherjimmy created PR review comment:
Unless I'm mistaken, this should work too:
cmp x27, x26 b.ne swap cmp x21, x23 b.ne swapWith the bonus that it's shorter.
This is also the only place I saw cinc and csinc used, so that could be moved out of this PR too.
Note: this is not required, only nice to have.
:speech_balloon: theotherjimmy created PR review comment:
Out label appears to be unused. Can this be removed?
:speech_balloon: theotherjimmy created PR review comment:
This out label also seems unused.
:memo: Gelbpunkt submitted PR review.
:speech_balloon: Gelbpunkt created PR review comment:
Indeed, that should also work, but would deviate from LLVM. I presume LLVM tries to avoid branches as much as possible, but I'll use your suggestion and remove cinc/csinc, I think I prefer a smaller diff here
Gelbpunkt updated PR #14475.
:memo: Gelbpunkt submitted PR review.
:speech_balloon: Gelbpunkt created PR review comment:
(Since we don't want to swap when they're not equal, we branch to the keep case and therefore I switched the swap and keep cases around, but it works as intended now without cinc/csinc)
:memo: Gelbpunkt submitted PR review.
:speech_balloon: Gelbpunkt created PR review comment:
Done
:memo: Gelbpunkt submitted PR review.
:speech_balloon: Gelbpunkt created PR review comment:
Thanks, removed!
Gelbpunkt updated PR #14475.
:memo: theotherjimmy submitted PR review.
:speech_balloon: theotherjimmy created PR review comment:
Ah, good point. My bad.
:thumbs_up: theotherjimmy submitted PR review:
Looks good now.
:thumbs_up: alexcrichton submitted PR review:
(carrying over @theotherjimmy's approval)
alexcrichton added PR #14475 cranelift: Add 128-bit atomics support for AArch64 to the merge queue.
Gelbpunkt commented on PR #14475:
Hm,
inst_size_testfor aarch64 is failing on i686, I presume I could just#[cfg(target_pointer_width = "64")]it like on x64?
github-merge-queue[bot] removed PR #14475 cranelift: Add 128-bit atomics support for AArch64 from the merge queue.
Gelbpunkt updated PR #14475.
:thumbs_up: alexcrichton submitted PR review.
alexcrichton added PR #14475 cranelift: Add 128-bit atomics support for AArch64 to the merge queue.
github-merge-queue[bot] removed PR #14475 cranelift: Add 128-bit atomics support for AArch64 from the merge queue.
alexcrichton commented on PR #14475:
ah just an unused import on 32-bit now
Gelbpunkt updated PR #14475.
Gelbpunkt commented on PR #14475:
Right, that should be resolved now
:thumbs_up: theotherjimmy submitted PR review.
alexcrichton added PR #14475 cranelift: Add 128-bit atomics support for AArch64 to the merge queue.
:check: alexcrichton merged PR #14475.
alexcrichton removed PR #14475 cranelift: Add 128-bit atomics support for AArch64 from the merge queue.
Gelbpunkt commented on PR #14475:
Thanks for the review and quick merge! Hope I'll get around to s390x next week
Last updated: Oct 11 2026 at 04:10 UTC