Skip to content

Commit

Permalink
Merge #70
Browse files Browse the repository at this point in the history
70: aarch64: Use CASP instead of LDXP/STXP for store/RMW if available r=taiki-e a=taiki-e

Follow-up #20

In #20, we postponed this (#20 (comment)), but LLVM 16+ adopted this (llvm/llvm-project@10d34f5), so we'll follow LLVM's behavior.

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e committed Feb 6, 2023
2 parents a913079 + 7e79464 commit 5d36d21
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ status = [
"test (aarch64-apple-darwin)",
"valgrind (aarch64-unknown-linux-gnu)",
]
timeout_sec = 7200
timeout_sec = 10800
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ jobs:
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=+lse ${{ env.RANDOMIZE_LAYOUT }}
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=+lse ${{ env.RANDOMIZE_LAYOUT }}
if: startsWith(matrix.target, 'aarch64') && startsWith(matrix.rust, 'nightly') && !(contains(matrix.target, '-musl') || contains(matrix.target, '-android'))
# TODO: it seems qemu-user has not yet properly implemented FEAT_LSE2: https://github.com/taiki-e/portable-atomic/pull/11#issuecomment-1114044327
# TODO: As of QEMU 7.2, QEMU has not yet implemented FEAT_LSE2: https://linaro.atlassian.net/browse/QEMU-300

# pwr7
# powerpc64- (big-endian) is skipped because it is pre-pwr8 by default
Expand Down
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ fn main() {
}
}
// lqarx and stqcx.
// Note: As of rustc 1.67, target_feature "quadword-atomics" is not available on rustc side:
// https://github.com/rust-lang/rust/blob/1.67.0/compiler/rustc_codegen_ssa/src/target_features.rs#L215
target_feature_if("quadword-atomics", has_pwr8_features, &version, None, false);
}
_ => {}
Expand Down
14 changes: 8 additions & 6 deletions src/imp/atomic128/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

The table of targets that support 128-bit atomics and the instructions used:

| target_arch | load | store | CAS | note |
| ----------- | ----- | ----- | ---- | ---- |
| x86_64 | cmpxchg16b or vmovdqa | cmpxchg16b or vmovdqa | cmpxchg16b | cmpxchg16b target feature required. vmovdqa requires Intel or AMD CPU with AVX. <br> Both compile-time and run-time detection are supported for cmpxchg16b. vmovdqa is currently run-time detection only. <br> Requires rustc 1.59+ when cmpxchg16b target feature is enabled at compile-time, otherwise requires nightly |
| aarch64 | ldxp/stxp or casp or ldp | ldxp/stxp or stp | ldxp/stxp or casp | casp requires lse target feature, ldp/stp requires lse2 target feature. <br> Both compile-time and run-time detection are supported for lse. lse2 is currently compile-time detection only. <br> Requires rustc 1.59+ |
| powerpc64 | lq | stq | lqarx/stqcx. | Little endian or target CPU pwr8+. <br> Requires nightly |
| s390x | lpq | stpq | cdsg | Requires nightly |
| target_arch | load | store | CAS | RMW | note |
| ----------- | ----- | ----- | ---- | ---- | ---- |
| x86_64 | cmpxchg16b or vmovdqa | cmpxchg16b or vmovdqa | cmpxchg16b | cmpxchg16b | cmpxchg16b target feature required. vmovdqa requires Intel or AMD CPU with AVX. <br> Both compile-time and run-time detection are supported for cmpxchg16b. vmovdqa is currently run-time detection only. <br> Requires rustc 1.59+ when cmpxchg16b target feature is enabled at compile-time, otherwise requires nightly |
| aarch64 | ldxp/stxp or casp or ldp | ldxp/stxp or casp or stp | ldxp/stxp or casp | ldxp/stxp or casp | casp requires lse target feature, ldp/stp requires lse2 target feature. <br> Both compile-time and run-time detection are supported for lse. lse2 is currently compile-time detection only. <br> Requires rustc 1.59+ |
| powerpc64 | lq | stq | lqarx/stqcx. | lqarx/stqcx. | Little endian or target CPU pwr8+. <br> Requires nightly |
| s390x | lpq | stpq | cdsg | cdsg | Requires nightly |

Run-time detections are enabled by default and can be disabled with `--cfg portable_atomic_no_outline_atomics`.

See [aarch64.rs](aarch64.rs) module-level comments for more details on the instructions used on aarch64.
Loading

0 comments on commit 5d36d21

Please sign in to comment.