Cranelift’s AArch64 backend lacked 128-bit atomic operations, preventing rustc_codegen_cranelift from building the Rust standard library without patches. The work described aims to close that gap using instructions available on baseline ARM targets, rather than relying on optional LSE or LSE128 extensions. On AArch64, 128-bit atomic loads and stores can use paired exclusive instructions, while compare-and-swap and read-modify-write operations need retry loops because the baseline has no single instruction for them. These sequences must also provide sequential consistency, as required by WebAssembly’s atomic model.
The implementation follows LLVM’s established approach: an exclusive paired load marks the address, and a paired exclusive store either completes the operation or signals that it must be retried. Even a sequentially consistent load uses a load-and-store-back loop to participate in the required ordering. The Cranelift work begins by adding a failing AArch64 code-generation test, tracing the existing atomic-load lowering through its ISLE rules, and finding that the current load instruction only supports up to 64 bits. Supporting 128-bit results therefore requires a new machine instruction with two destination registers and a scratch register for the store’s success status, plus lowering logic to emit it. The same pattern extends to the other atomic operations.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.