feat(sync/atomic): riscv64 arms#309
Merged
Merged
Conversation
Add riscv64 implementations for all 8 atomic ops, mirroring the x86_64/aarch64 arms: - load: full FENCEs bracket a plain aligned ld (seq-cst load) - store: amoswap.d.aqrl discarding the old value (seq-cst store) - cas: lr.d.aqrl/sc.d.aqrl retry loop - fetch_add: amoadd.d.aqrl - fetch_sub: neg then amoadd.d.aqrl (no amosub) - exchange: amoswap.d.aqrl - fence: fence - spin_hint: pause Each op uses the RISC-V A extension with .aqrl ordering for sequential consistency. Additive and comptime-gated, so x86_64/aarch64 are unaffected. Closes #308
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #308
Adds riscv64 implementations for all 8 atomic ops in
src/sync/atomic.mach, mirroring the existing x86_64/aarch64 arms. Uses the RISC-V A extension with.aqrlordering for sequential consistency:fencebrackets a plain alignedldamoswap.d.aqrl zero, v, (ptr)(discards old)lr.d.aqrl/sc.d.aqrlretry loopamoadd.d.aqrlnegthenamoadd.d.aqrl(no amosub)amoswap.d.aqrlfencepauseAdditive and comptime-gated, so x86_64/aarch64 are unaffected.
Verification
mach test .-> 563/563 pass (all 12 atomic tests included).qemu-riscv64-> exit 0 (every assertion passed). Each instruction sequence was also unit-verified standalone under qemu.Requires a mach with RV64A inline-asm support (mach#1668, on mach
dev); CI seeds from the latest mach release, so this goes green once the riscv64 batch ships in v2.9.0.