Skip to content

Fix types for ARM SIMD32 intrinsics #1679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ jobs:
os: ubuntu-latest
- tuple: thumbv7em-none-eabihf
os: ubuntu-latest
- tuple: loongarch64-unknown-linux-gnu
os: ubuntu-latest
- tuple: wasm32-wasip1
os: ubuntu-latest
# Temporarily disabled due to fallout from SIMD ABI checking.
#- tuple: loongarch64-unknown-linux-gnu
# os: ubuntu-latest
#- tuple: wasm32-wasip1
# os: ubuntu-latest

# macOS targets
- tuple: x86_64-apple-darwin
Expand Down
59 changes: 24 additions & 35 deletions crates/core_arch/src/arm/dsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@
#[cfg(test)]
use stdarch_test::assert_instr;

use crate::mem::transmute;

types! {
#![unstable(feature = "stdarch_arm_dsp", issue = "117237")]

/// ARM-specific 32-bit wide vector of two packed `i16`.
pub struct int16x2_t(2 x i16);
/// ARM-specific 32-bit wide vector of two packed `u16`.
pub struct uint16x2_t(2 x u16);
}

extern "unadjusted" {
#[link_name = "llvm.arm.smulbb"]
fn arm_smulbb(a: i32, b: i32) -> i32;
Expand Down Expand Up @@ -85,8 +74,8 @@ extern "unadjusted" {
#[inline]
#[cfg_attr(test, assert_instr(smulbb))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smulbb(a: int16x2_t, b: int16x2_t) -> i32 {
arm_smulbb(transmute(a), transmute(b))
pub unsafe fn __smulbb(a: i32, b: i32) -> i32 {
arm_smulbb(a, b)
}

/// Insert a SMULTB instruction
Expand All @@ -96,8 +85,8 @@ pub unsafe fn __smulbb(a: int16x2_t, b: int16x2_t) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smultb))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smultb(a: int16x2_t, b: int16x2_t) -> i32 {
arm_smultb(transmute(a), transmute(b))
pub unsafe fn __smultb(a: i32, b: i32) -> i32 {
arm_smultb(a, b)
}

/// Insert a SMULTB instruction
Expand All @@ -107,8 +96,8 @@ pub unsafe fn __smultb(a: int16x2_t, b: int16x2_t) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smulbt))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smulbt(a: int16x2_t, b: int16x2_t) -> i32 {
arm_smulbt(transmute(a), transmute(b))
pub unsafe fn __smulbt(a: i32, b: i32) -> i32 {
arm_smulbt(a, b)
}

/// Insert a SMULTT instruction
Expand All @@ -118,8 +107,8 @@ pub unsafe fn __smulbt(a: int16x2_t, b: int16x2_t) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smultt))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smultt(a: int16x2_t, b: int16x2_t) -> i32 {
arm_smultt(transmute(a), transmute(b))
pub unsafe fn __smultt(a: i32, b: i32) -> i32 {
arm_smultt(a, b)
}

/// Insert a SMULWB instruction
Expand All @@ -130,8 +119,8 @@ pub unsafe fn __smultt(a: int16x2_t, b: int16x2_t) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smulwb))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smulwb(a: int16x2_t, b: i32) -> i32 {
arm_smulwb(transmute(a), b)
pub unsafe fn __smulwb(a: i32, b: i32) -> i32 {
arm_smulwb(a, b)
}

/// Insert a SMULWT instruction
Expand All @@ -142,8 +131,8 @@ pub unsafe fn __smulwb(a: int16x2_t, b: i32) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smulwt))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smulwt(a: int16x2_t, b: i32) -> i32 {
arm_smulwt(transmute(a), b)
pub unsafe fn __smulwt(a: i32, b: i32) -> i32 {
arm_smulwt(a, b)
}

/// Signed saturating addition
Expand Down Expand Up @@ -187,8 +176,8 @@ pub unsafe fn __qdbl(a: i32) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smlabb))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smlabb(a: int16x2_t, b: int16x2_t, c: i32) -> i32 {
arm_smlabb(transmute(a), transmute(b), c)
pub unsafe fn __smlabb(a: i32, b: i32, c: i32) -> i32 {
arm_smlabb(a, b, c)
}

/// Insert a SMLABT instruction
Expand All @@ -199,8 +188,8 @@ pub unsafe fn __smlabb(a: int16x2_t, b: int16x2_t, c: i32) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smlabt))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smlabt(a: int16x2_t, b: int16x2_t, c: i32) -> i32 {
arm_smlabt(transmute(a), transmute(b), c)
pub unsafe fn __smlabt(a: i32, b: i32, c: i32) -> i32 {
arm_smlabt(a, b, c)
}

/// Insert a SMLATB instruction
Expand All @@ -211,8 +200,8 @@ pub unsafe fn __smlabt(a: int16x2_t, b: int16x2_t, c: i32) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smlatb))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smlatb(a: int16x2_t, b: int16x2_t, c: i32) -> i32 {
arm_smlatb(transmute(a), transmute(b), c)
pub unsafe fn __smlatb(a: i32, b: i32, c: i32) -> i32 {
arm_smlatb(a, b, c)
}

/// Insert a SMLATT instruction
Expand All @@ -223,8 +212,8 @@ pub unsafe fn __smlatb(a: int16x2_t, b: int16x2_t, c: i32) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smlatt))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smlatt(a: int16x2_t, b: int16x2_t, c: i32) -> i32 {
arm_smlatt(transmute(a), transmute(b), c)
pub unsafe fn __smlatt(a: i32, b: i32, c: i32) -> i32 {
arm_smlatt(a, b, c)
}

/// Insert a SMLAWB instruction
Expand All @@ -235,8 +224,8 @@ pub unsafe fn __smlatt(a: int16x2_t, b: int16x2_t, c: i32) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smlawb))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smlawb(a: i32, b: int16x2_t, c: i32) -> i32 {
arm_smlawb(a, transmute(b), c)
pub unsafe fn __smlawb(a: i32, b: i32, c: i32) -> i32 {
arm_smlawb(a, b, c)
}

/// Insert a SMLAWT instruction
Expand All @@ -247,8 +236,8 @@ pub unsafe fn __smlawb(a: i32, b: int16x2_t, c: i32) -> i32 {
#[inline]
#[cfg_attr(test, assert_instr(smlawt))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __smlawt(a: i32, b: int16x2_t, c: i32) -> i32 {
arm_smlawt(a, transmute(b), c)
pub unsafe fn __smlawt(a: i32, b: i32, c: i32) -> i32 {
arm_smlawt(a, b, c)
}

#[cfg(test)]
Expand Down
27 changes: 19 additions & 8 deletions crates/core_arch/src/arm/simd32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,27 @@
#[cfg(test)]
use stdarch_test::assert_instr;

use crate::{core_arch::arm::dsp::int16x2_t, mem::transmute};
use crate::mem::transmute;

types! {
#![unstable(feature = "stdarch_arm_dsp", issue = "117237")]
/// ARM-specific vector of four packed `i8` packed into a 32-bit integer.
#[allow(non_camel_case_types)]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub type int8x4_t = i32;

/// ARM-specific 32-bit wide vector of four packed `i8`.
pub struct int8x4_t(4 x i8);
/// ARM-specific 32-bit wide vector of four packed `u8`.
pub struct uint8x4_t(4 x u8);
}
/// ARM-specific vector of four packed `u8` packed into a 32-bit integer.
#[allow(non_camel_case_types)]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub type uint8x4_t = u32;

/// ARM-specific vector of two packed `i16` packed into a 32-bit integer.
#[allow(non_camel_case_types)]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub type int16x2_t = i32;

/// ARM-specific vector of two packed `u16` packed into a 32-bit integer.
#[allow(non_camel_case_types)]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub type uint16x2_t = u32;

macro_rules! dsp_call {
($name:expr, $a:expr, $b:expr) => {
Expand Down