Skip to content

Commit d640fe3

Browse files
committed
add vshl and vshr neon instructions
1 parent e374266 commit d640fe3

File tree

5 files changed

+4902
-3220
lines changed

5 files changed

+4902
-3220
lines changed

crates/core_arch/src/aarch64/neon/generated.rs

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,6 +3514,132 @@ pub unsafe fn vreinterpretq_f32_f64(a: float64x2_t) -> float32x4_t {
35143514
transmute(a)
35153515
}
35163516

3517+
/// Signed shift left long
3518+
#[inline]
3519+
#[target_feature(enable = "neon")]
3520+
#[cfg_attr(test, assert_instr(sshll2, N = 2))]
3521+
#[rustc_legacy_const_generics(1)]
3522+
pub unsafe fn vshll_high_n_s8<const N: i32>(a: int8x16_t) -> int16x8_t {
3523+
static_assert!(N : i32 where N >= 0 && N <= 8);
3524+
let b: int8x8_t = simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15]);
3525+
vshll_n_s8::<N>(b)
3526+
}
3527+
3528+
/// Signed shift left long
3529+
#[inline]
3530+
#[target_feature(enable = "neon")]
3531+
#[cfg_attr(test, assert_instr(sshll2, N = 2))]
3532+
#[rustc_legacy_const_generics(1)]
3533+
pub unsafe fn vshll_high_n_s16<const N: i32>(a: int16x8_t) -> int32x4_t {
3534+
static_assert!(N : i32 where N >= 0 && N <= 16);
3535+
let b: int16x4_t = simd_shuffle4(a, a, [4, 5, 6, 7]);
3536+
vshll_n_s16::<N>(b)
3537+
}
3538+
3539+
/// Signed shift left long
3540+
#[inline]
3541+
#[target_feature(enable = "neon")]
3542+
#[cfg_attr(test, assert_instr(sshll2, N = 2))]
3543+
#[rustc_legacy_const_generics(1)]
3544+
pub unsafe fn vshll_high_n_s32<const N: i32>(a: int32x4_t) -> int64x2_t {
3545+
static_assert!(N : i32 where N >= 0 && N <= 32);
3546+
let b: int32x2_t = simd_shuffle2(a, a, [2, 3]);
3547+
vshll_n_s32::<N>(b)
3548+
}
3549+
3550+
/// Signed shift left long
3551+
#[inline]
3552+
#[target_feature(enable = "neon")]
3553+
#[cfg_attr(test, assert_instr(ushll2, N = 2))]
3554+
#[rustc_legacy_const_generics(1)]
3555+
pub unsafe fn vshll_high_n_u8<const N: i32>(a: uint8x16_t) -> uint16x8_t {
3556+
static_assert!(N : i32 where N >= 0 && N <= 8);
3557+
let b: uint8x8_t = simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15]);
3558+
vshll_n_u8::<N>(b)
3559+
}
3560+
3561+
/// Signed shift left long
3562+
#[inline]
3563+
#[target_feature(enable = "neon")]
3564+
#[cfg_attr(test, assert_instr(ushll2, N = 2))]
3565+
#[rustc_legacy_const_generics(1)]
3566+
pub unsafe fn vshll_high_n_u16<const N: i32>(a: uint16x8_t) -> uint32x4_t {
3567+
static_assert!(N : i32 where N >= 0 && N <= 16);
3568+
let b: uint16x4_t = simd_shuffle4(a, a, [4, 5, 6, 7]);
3569+
vshll_n_u16::<N>(b)
3570+
}
3571+
3572+
/// Signed shift left long
3573+
#[inline]
3574+
#[target_feature(enable = "neon")]
3575+
#[cfg_attr(test, assert_instr(ushll2, N = 2))]
3576+
#[rustc_legacy_const_generics(1)]
3577+
pub unsafe fn vshll_high_n_u32<const N: i32>(a: uint32x4_t) -> uint64x2_t {
3578+
static_assert!(N : i32 where N >= 0 && N <= 32);
3579+
let b: uint32x2_t = simd_shuffle2(a, a, [2, 3]);
3580+
vshll_n_u32::<N>(b)
3581+
}
3582+
3583+
/// Shift right narrow
3584+
#[inline]
3585+
#[target_feature(enable = "neon")]
3586+
#[cfg_attr(test, assert_instr(shrn2, N = 2))]
3587+
#[rustc_legacy_const_generics(2)]
3588+
pub unsafe fn vshrn_high_n_s16<const N: i32>(a: int8x8_t, b: int16x8_t) -> int8x16_t {
3589+
static_assert!(N : i32 where N >= 1 && N <= 8);
3590+
simd_shuffle16(a, vshrn_n_s16::<N>(b), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
3591+
}
3592+
3593+
/// Shift right narrow
3594+
#[inline]
3595+
#[target_feature(enable = "neon")]
3596+
#[cfg_attr(test, assert_instr(shrn2, N = 2))]
3597+
#[rustc_legacy_const_generics(2)]
3598+
pub unsafe fn vshrn_high_n_s32<const N: i32>(a: int16x4_t, b: int32x4_t) -> int16x8_t {
3599+
static_assert!(N : i32 where N >= 1 && N <= 16);
3600+
simd_shuffle8(a, vshrn_n_s32::<N>(b), [0, 1, 2, 3, 4, 5, 6, 7])
3601+
}
3602+
3603+
/// Shift right narrow
3604+
#[inline]
3605+
#[target_feature(enable = "neon")]
3606+
#[cfg_attr(test, assert_instr(shrn2, N = 2))]
3607+
#[rustc_legacy_const_generics(2)]
3608+
pub unsafe fn vshrn_high_n_s64<const N: i32>(a: int32x2_t, b: int64x2_t) -> int32x4_t {
3609+
static_assert!(N : i32 where N >= 1 && N <= 32);
3610+
simd_shuffle4(a, vshrn_n_s64::<N>(b), [0, 1, 2, 3])
3611+
}
3612+
3613+
/// Shift right narrow
3614+
#[inline]
3615+
#[target_feature(enable = "neon")]
3616+
#[cfg_attr(test, assert_instr(shrn2, N = 2))]
3617+
#[rustc_legacy_const_generics(2)]
3618+
pub unsafe fn vshrn_high_n_u16<const N: i32>(a: uint8x8_t, b: uint16x8_t) -> uint8x16_t {
3619+
static_assert!(N : i32 where N >= 1 && N <= 8);
3620+
simd_shuffle16(a, vshrn_n_u16::<N>(b), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
3621+
}
3622+
3623+
/// Shift right narrow
3624+
#[inline]
3625+
#[target_feature(enable = "neon")]
3626+
#[cfg_attr(test, assert_instr(shrn2, N = 2))]
3627+
#[rustc_legacy_const_generics(2)]
3628+
pub unsafe fn vshrn_high_n_u32<const N: i32>(a: uint16x4_t, b: uint32x4_t) -> uint16x8_t {
3629+
static_assert!(N : i32 where N >= 1 && N <= 16);
3630+
simd_shuffle8(a, vshrn_n_u32::<N>(b), [0, 1, 2, 3, 4, 5, 6, 7])
3631+
}
3632+
3633+
/// Shift right narrow
3634+
#[inline]
3635+
#[target_feature(enable = "neon")]
3636+
#[cfg_attr(test, assert_instr(shrn2, N = 2))]
3637+
#[rustc_legacy_const_generics(2)]
3638+
pub unsafe fn vshrn_high_n_u64<const N: i32>(a: uint32x2_t, b: uint64x2_t) -> uint32x4_t {
3639+
static_assert!(N : i32 where N >= 1 && N <= 32);
3640+
simd_shuffle4(a, vshrn_n_u64::<N>(b), [0, 1, 2, 3])
3641+
}
3642+
35173643
/// Transpose vectors
35183644
#[inline]
35193645
#[target_feature(enable = "neon")]
@@ -7385,6 +7511,108 @@ mod test {
73857511
assert_eq!(r, e);
73867512
}
73877513

7514+
#[simd_test(enable = "neon")]
7515+
unsafe fn test_vshll_high_n_s8() {
7516+
let a: i8x16 = i8x16::new(0, 0, 1, 2, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8);
7517+
let e: i16x8 = i16x8::new(4, 8, 12, 16, 20, 24, 28, 32);
7518+
let r: i16x8 = transmute(vshll_high_n_s8::<2>(transmute(a)));
7519+
assert_eq!(r, e);
7520+
}
7521+
7522+
#[simd_test(enable = "neon")]
7523+
unsafe fn test_vshll_high_n_s16() {
7524+
let a: i16x8 = i16x8::new(0, 0, 1, 2, 1, 2, 3, 4);
7525+
let e: i32x4 = i32x4::new(4, 8, 12, 16);
7526+
let r: i32x4 = transmute(vshll_high_n_s16::<2>(transmute(a)));
7527+
assert_eq!(r, e);
7528+
}
7529+
7530+
#[simd_test(enable = "neon")]
7531+
unsafe fn test_vshll_high_n_s32() {
7532+
let a: i32x4 = i32x4::new(0, 0, 1, 2);
7533+
let e: i64x2 = i64x2::new(4, 8);
7534+
let r: i64x2 = transmute(vshll_high_n_s32::<2>(transmute(a)));
7535+
assert_eq!(r, e);
7536+
}
7537+
7538+
#[simd_test(enable = "neon")]
7539+
unsafe fn test_vshll_high_n_u8() {
7540+
let a: u8x16 = u8x16::new(0, 0, 1, 2, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8);
7541+
let e: u16x8 = u16x8::new(4, 8, 12, 16, 20, 24, 28, 32);
7542+
let r: u16x8 = transmute(vshll_high_n_u8::<2>(transmute(a)));
7543+
assert_eq!(r, e);
7544+
}
7545+
7546+
#[simd_test(enable = "neon")]
7547+
unsafe fn test_vshll_high_n_u16() {
7548+
let a: u16x8 = u16x8::new(0, 0, 1, 2, 1, 2, 3, 4);
7549+
let e: u32x4 = u32x4::new(4, 8, 12, 16);
7550+
let r: u32x4 = transmute(vshll_high_n_u16::<2>(transmute(a)));
7551+
assert_eq!(r, e);
7552+
}
7553+
7554+
#[simd_test(enable = "neon")]
7555+
unsafe fn test_vshll_high_n_u32() {
7556+
let a: u32x4 = u32x4::new(0, 0, 1, 2);
7557+
let e: u64x2 = u64x2::new(4, 8);
7558+
let r: u64x2 = transmute(vshll_high_n_u32::<2>(transmute(a)));
7559+
assert_eq!(r, e);
7560+
}
7561+
7562+
#[simd_test(enable = "neon")]
7563+
unsafe fn test_vshrn_high_n_s16() {
7564+
let a: i8x8 = i8x8::new(1, 2, 5, 6, 5, 6, 7, 8);
7565+
let b: i16x8 = i16x8::new(20, 24, 28, 32, 52, 56, 60, 64);
7566+
let e: i8x16 = i8x16::new(1, 2, 5, 6, 5, 6, 7, 8, 5, 6, 7, 8, 13, 14, 15, 16);
7567+
let r: i8x16 = transmute(vshrn_high_n_s16::<2>(transmute(a), transmute(b)));
7568+
assert_eq!(r, e);
7569+
}
7570+
7571+
#[simd_test(enable = "neon")]
7572+
unsafe fn test_vshrn_high_n_s32() {
7573+
let a: i16x4 = i16x4::new(1, 2, 5, 6);
7574+
let b: i32x4 = i32x4::new(20, 24, 28, 32);
7575+
let e: i16x8 = i16x8::new(1, 2, 5, 6, 5, 6, 7, 8);
7576+
let r: i16x8 = transmute(vshrn_high_n_s32::<2>(transmute(a), transmute(b)));
7577+
assert_eq!(r, e);
7578+
}
7579+
7580+
#[simd_test(enable = "neon")]
7581+
unsafe fn test_vshrn_high_n_s64() {
7582+
let a: i32x2 = i32x2::new(1, 2);
7583+
let b: i64x2 = i64x2::new(20, 24);
7584+
let e: i32x4 = i32x4::new(1, 2, 5, 6);
7585+
let r: i32x4 = transmute(vshrn_high_n_s64::<2>(transmute(a), transmute(b)));
7586+
assert_eq!(r, e);
7587+
}
7588+
7589+
#[simd_test(enable = "neon")]
7590+
unsafe fn test_vshrn_high_n_u16() {
7591+
let a: u8x8 = u8x8::new(1, 2, 5, 6, 5, 6, 7, 8);
7592+
let b: u16x8 = u16x8::new(20, 24, 28, 32, 52, 56, 60, 64);
7593+
let e: u8x16 = u8x16::new(1, 2, 5, 6, 5, 6, 7, 8, 5, 6, 7, 8, 13, 14, 15, 16);
7594+
let r: u8x16 = transmute(vshrn_high_n_u16::<2>(transmute(a), transmute(b)));
7595+
assert_eq!(r, e);
7596+
}
7597+
7598+
#[simd_test(enable = "neon")]
7599+
unsafe fn test_vshrn_high_n_u32() {
7600+
let a: u16x4 = u16x4::new(1, 2, 5, 6);
7601+
let b: u32x4 = u32x4::new(20, 24, 28, 32);
7602+
let e: u16x8 = u16x8::new(1, 2, 5, 6, 5, 6, 7, 8);
7603+
let r: u16x8 = transmute(vshrn_high_n_u32::<2>(transmute(a), transmute(b)));
7604+
assert_eq!(r, e);
7605+
}
7606+
7607+
#[simd_test(enable = "neon")]
7608+
unsafe fn test_vshrn_high_n_u64() {
7609+
let a: u32x2 = u32x2::new(1, 2);
7610+
let b: u64x2 = u64x2::new(20, 24);
7611+
let e: u32x4 = u32x4::new(1, 2, 5, 6);
7612+
let r: u32x4 = transmute(vshrn_high_n_u64::<2>(transmute(a), transmute(b)));
7613+
assert_eq!(r, e);
7614+
}
7615+
73887616
#[simd_test(enable = "neon")]
73897617
unsafe fn test_vtrn1_s8() {
73907618
let a: i8x8 = i8x8::new(0, 2, 4, 6, 8, 10, 12, 14);

0 commit comments

Comments
 (0)