Skip to content

Commit

Permalink
Support Arm64EC
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Apr 12, 2024
1 parent 91ec716 commit 4d94b3c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This crate provides a way to soundly perform such operations.

## Platform Support

Currently, x86, x86_64, ARM, AArch64, RISC-V, LoongArch64, MIPS32, MIPS64, PowerPC, s390x, MSP430, AVR, and Hexagon are supported.
Currently, x86, x86_64, ARM, AArch64, RISC-V, LoongArch64, MIPS32, MIPS64, PowerPC, s390x, MSP430, Arm64EC, AVR, and Hexagon are supported.

| target_arch | primitives | load/store | swap/CAS |
| -------------------------------- | --------------------------------------------------- |:----------:|:--------:|
Expand All @@ -38,6 +38,7 @@ Currently, x86, x86_64, ARM, AArch64, RISC-V, LoongArch64, MIPS32, MIPS64, Power
| powerpc64 (pwr8+) \[4] \[6] | i128,u128 |||
| s390x \[4] | isize,usize,i8,u8,i16,u16,i32,u32,i64,u64,i128,u128 |||
| msp430 \[4] | isize,usize,i8,u8,i16,u16 || |
| arm64ec \[4] (experimental) | isize,usize,i8,u8,i16,u16,i32,u32,i64,u64,i128,u128 |||
| avr \[4] (experimental) | isize,usize,i8,u8,i16,u16 |||
| hexagon \[4] (experimental) | isize,usize,i8,u8,i16,u16,i32,u32,i64,u64 |||

Expand Down
6 changes: 3 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ fn main() {
println!("cargo:rustc-cfg=atomic_maybe_uninit_no_loongarch64_asm");
}
}
"avr" | "hexagon" | "mips" | "mips32r6" | "mips64" | "mips64r6" | "msp430" | "powerpc"
| "powerpc64" => {
"arm64ec" | "avr" | "hexagon" | "mips" | "mips32r6" | "mips64" | "mips64r6" | "msp430"
| "powerpc" | "powerpc64" => {
if version.nightly && is_allowed_feature("asm_experimental_arch") {
println!("cargo:rustc-cfg=atomic_maybe_uninit_unstable_asm_experimental_arch");
}
Expand Down Expand Up @@ -103,7 +103,7 @@ fn main() {
// cmpxchg16b_target_feature stabilized in Rust 1.69.
target_feature_if("cmpxchg16b", has_cmpxchg16b, &version, Stable(69));
}
"aarch64" => {
"aarch64" | "arm64ec" => {
// AArch64 macOS always supports FEAT_LSE/FEAT_LSE2/FEAT_LRCPC because it is ARMv8.5-A:
// https://github.com/llvm/llvm-project/blob/llvmorg-18.1.2/llvm/include/llvm/TargetParser/AArch64TargetParser.h#L728
let mut has_lse = is_macos;
Expand Down
6 changes: 5 additions & 1 deletion src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
target_arch = "loongarch64",
all(
any(
target_arch = "arm64ec",
target_arch = "avr",
target_arch = "hexagon",
target_arch = "mips",
Expand All @@ -44,7 +45,10 @@
#[path = "cfgs/unsupported.rs"]
mod unsupported;

#[cfg(target_arch = "aarch64")]
#[cfg(any(
target_arch = "aarch64",
all(target_arch = "arm64ec", atomic_maybe_uninit_unstable_asm_experimental_arch),
))]
mod aarch64;
#[cfg(target_arch = "arm")]
#[cfg(all(
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This crate provides a way to soundly perform such operations.
## Platform Support
Currently, x86, x86_64, ARM, AArch64, RISC-V, LoongArch64, MIPS32, MIPS64, PowerPC, s390x, MSP430, AVR, and Hexagon are supported.
Currently, x86, x86_64, ARM, AArch64, RISC-V, LoongArch64, MIPS32, MIPS64, PowerPC, s390x, MSP430, Arm64EC, AVR, and Hexagon are supported.
| target_arch | primitives | load/store | swap/CAS |
| -------------------------------- | --------------------------------------------------- |:----------:|:--------:|
Expand All @@ -32,6 +32,7 @@ Currently, x86, x86_64, ARM, AArch64, RISC-V, LoongArch64, MIPS32, MIPS64, Power
| powerpc64 (pwr8+) \[4] \[6] | i128,u128 | ✓ | ✓ |
| s390x \[4] | isize,usize,i8,u8,i16,u16,i32,u32,i64,u64,i128,u128 | ✓ | ✓ |
| msp430 \[4] | isize,usize,i8,u8,i16,u16 | ✓ | |
| arm64ec \[4] (experimental) | isize,usize,i8,u8,i16,u16,i32,u32,i64,u64,i128,u128 | ✓ | ✓ |
| avr \[4] (experimental) | isize,usize,i8,u8,i16,u16 | ✓ | ✓ |
| hexagon \[4] (experimental) | isize,usize,i8,u8,i16,u16,i32,u32,i64,u64 | ✓ | ✓ |
Expand Down
2 changes: 1 addition & 1 deletion src/tests/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ macro_rules! __test_atomic {
#[allow(clippy::ptr_as_ptr)]
if core::mem::size_of::<$int_type>() <= core::mem::size_of::<usize>()
|| cfg!(all(
target_arch = "aarch64",
any(target_arch = "aarch64", target_arch = "arm64ec"),
any(target_feature = "lse2", atomic_maybe_uninit_target_feature = "lse2"),
))
|| cfg!(all(
Expand Down
15 changes: 13 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ zero_extend!(i32, u32, i64, u64, isize, usize);
#[allow(dead_code)]
#[cfg(any(
target_arch = "aarch64",
target_arch = "arm64ec",
target_arch = "powerpc64",
target_arch = "s390x",
target_arch = "x86_64",
Expand Down Expand Up @@ -203,11 +204,21 @@ pub(crate) union MaybeUninit64 {
#[repr(C)]
pub(crate) struct Pair<T: Copy> {
// little endian order
#[cfg(any(target_endian = "little", target_arch = "aarch64", target_arch = "arm"))]
#[cfg(any(
target_endian = "little",
target_arch = "aarch64",
target_arch = "arm64ec",
target_arch = "arm",
))]
pub(crate) lo: MaybeUninit<T>,
pub(crate) hi: MaybeUninit<T>,
// big endian order
#[cfg(not(any(target_endian = "little", target_arch = "aarch64", target_arch = "arm")))]
#[cfg(not(any(
target_endian = "little",
target_arch = "aarch64",
target_arch = "arm64ec",
target_arch = "arm",
)))]
pub(crate) lo: MaybeUninit<T>,
}

Expand Down
4 changes: 4 additions & 0 deletions tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ default_targets=(
# rustc --print target-list | grep -E '^msp430'
msp430-none-elf

# arm64ec
# rustc --print target-list | grep -E '^arm64ec'
arm64ec-pc-windows-msvc

# avr
# rustc --print target-list | grep -E '^avr'
avr-unknown-gnu-atmega2560 # custom target
Expand Down

0 comments on commit 4d94b3c

Please sign in to comment.