#[cfg(test)]
use stdarch_test::assert_instr;
use crate::mem::transmute;
types! {
#![unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub struct int16x2_t(2 x i16);
pub struct uint16x2_t(2 x u16);
}
extern "unadjusted" {
#[link_name = "llvm.arm.smulbb"]
fn arm_smulbb(a: i32, b: i32) -> i32;
#[link_name = "llvm.arm.smulbt"]
fn arm_smulbt(a: i32, b: i32) -> i32;
#[link_name = "llvm.arm.smultb"]
fn arm_smultb(a: i32, b: i32) -> i32;
#[link_name = "llvm.arm.smultt"]
fn arm_smultt(a: i32, b: i32) -> i32;
#[link_name = "llvm.arm.smulwb"]
fn arm_smulwb(a: i32, b: i32) -> i32;
#[link_name = "llvm.arm.smulwt"]
fn arm_smulwt(a: i32, b: i32) -> i32;
#[link_name = "llvm.arm.qadd"]
fn arm_qadd(a: i32, b: i32) -> i32;
#[link_name = "llvm.arm.qsub"]
fn arm_qsub(a: i32, b: i32) -> i32;
#[link_name = "llvm.arm.smlabb"]
fn arm_smlabb(a: i32, b: i32, c: i32) -> i32;
#[link_name = "llvm.arm.smlabt"]
fn arm_smlabt(a: i32, b: i32, c: i32) -> i32;
#[link_name = "llvm.arm.smlatb"]
fn arm_smlatb(a: i32, b: i32, c: i32) -> i32;
#[link_name = "llvm.arm.smlatt"]
fn arm_smlatt(a: i32, b: i32, c: i32) -> i32;
#[link_name = "llvm.arm.smlawb"]
fn arm_smlawb(a: i32, b: i32, c: i32) -> i32;
#[link_name = "llvm.arm.smlawt"]
fn arm_smlawt(a: i32, b: i32, c: i32) -> i32;
}
#[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))
}
#[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))
}
#[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))
}
#[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))
}
#[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)
}
#[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)
}
#[inline]
#[cfg_attr(test, assert_instr(qadd))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __qadd(a: i32, b: i32) -> i32 {
arm_qadd(a, b)
}
#[inline]
#[cfg_attr(test, assert_instr(qsub))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __qsub(a: i32, b: i32) -> i32 {
arm_qsub(a, b)
}
#[inline]
#[cfg_attr(test, assert_instr(qadd))]
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub unsafe fn __qdbl(a: i32) -> i32 {
arm_qadd(a, a)
}
#[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)
}
#[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)
}
#[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)
}
#[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)
}
#[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)
}
#[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)
}
#[cfg(test)]
mod tests {
use crate::core_arch::{
arm::*,
simd::{i16x2, i8x4, u8x4},
};
use std::mem::transmute;
use stdarch_test::simd_test;
#[test]
fn smulbb() {
unsafe {
let a = i16x2::new(10, 20);
let b = i16x2::new(30, 40);
assert_eq!(super::__smulbb(transmute(a), transmute(b)), 10 * 30);
}
}
#[test]
fn smulbt() {
unsafe {
let a = i16x2::new(10, 20);
let b = i16x2::new(30, 40);
assert_eq!(super::__smulbt(transmute(a), transmute(b)), 10 * 40);
}
}
#[test]
fn smultb() {
unsafe {
let a = i16x2::new(10, 20);
let b = i16x2::new(30, 40);
assert_eq!(super::__smultb(transmute(a), transmute(b)), 20 * 30);
}
}
#[test]
fn smultt() {
unsafe {
let a = i16x2::new(10, 20);
let b = i16x2::new(30, 40);
assert_eq!(super::__smultt(transmute(a), transmute(b)), 20 * 40);
}
}
#[test]
fn smulwb() {
unsafe {
let a = i16x2::new(10, 20);
let b = 30;
assert_eq!(super::__smulwb(transmute(a), b), 20 * b);
}
}
#[test]
fn smulwt() {
unsafe {
let a = i16x2::new(10, 20);
let b = 30;
assert_eq!(super::__smulwt(transmute(a), b), (10 * b) >> 16);
}
}
#[test]
fn qadd() {
unsafe {
assert_eq!(super::__qadd(-10, 60), 50);
assert_eq!(super::__qadd(i32::MAX, 10), i32::MAX);
assert_eq!(super::__qadd(i32::MIN, -10), i32::MIN);
}
}
#[test]
fn qsub() {
unsafe {
assert_eq!(super::__qsub(10, 60), -50);
assert_eq!(super::__qsub(i32::MAX, -10), i32::MAX);
assert_eq!(super::__qsub(i32::MIN, 10), i32::MIN);
}
}
fn qdbl() {
unsafe {
assert_eq!(super::__qdbl(10), 20);
assert_eq!(super::__qdbl(i32::MAX), i32::MAX);
}
}
fn smlabb() {
unsafe {
let a = i16x2::new(10, 20);
let b = i16x2::new(30, 40);
let c = 50;
let r = (10 * 30) + c;
assert_eq!(super::__smlabb(transmute(a), transmute(b), c), r);
}
}
fn smlabt() {
unsafe {
let a = i16x2::new(10, 20);
let b = i16x2::new(30, 40);
let c = 50;
let r = (10 * 40) + c;
assert_eq!(super::__smlabt(transmute(a), transmute(b), c), r);
}
}
fn smlatb() {
unsafe {
let a = i16x2::new(10, 20);
let b = i16x2::new(30, 40);
let c = 50;
let r = (20 * 30) + c;
assert_eq!(super::__smlabt(transmute(a), transmute(b), c), r);
}
}
fn smlatt() {
unsafe {
let a = i16x2::new(10, 20);
let b = i16x2::new(30, 40);
let c = 50;
let r = (20 * 40) + c;
assert_eq!(super::__smlatt(transmute(a), transmute(b), c), r);
}
}
fn smlawb() {
unsafe {
let a: i32 = 10;
let b = i16x2::new(30, 40);
let c: i32 = 50;
let r: i32 = ((a * 30) + (c << 16)) >> 16;
assert_eq!(super::__smlawb(a, transmute(b), c), r);
}
}
fn smlawt() {
unsafe {
let a: i32 = 10;
let b = i16x2::new(30, 40);
let c: i32 = 50;
let r: i32 = ((a * 40) + (c << 16)) >> 16;
assert_eq!(super::__smlawt(a, transmute(b), c), r);
}
}
}