Skip to content

Commit d0265b2

Browse files
Add support for the remaining vget(q)_lane functions. (#1164)
1 parent 3850f83 commit d0265b2

File tree

2 files changed

+443
-0
lines changed

2 files changed

+443
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,26 @@ pub unsafe fn vget_low_p64(a: poly64x2_t) -> poly64x1_t {
17661766
transmute(u64x1::new(simd_extract(a, 0)))
17671767
}
17681768

1769+
/// Duplicate vector element to vector or scalar
1770+
#[inline]
1771+
#[target_feature(enable = "neon")]
1772+
#[rustc_legacy_const_generics(1)]
1773+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(nop, IMM5 = 0))]
1774+
pub unsafe fn vget_lane_f64<const IMM5: i32>(v: float64x1_t) -> f64 {
1775+
static_assert!(IMM5 : i32 where IMM5 == 0);
1776+
simd_extract(v, IMM5 as u32)
1777+
}
1778+
1779+
/// Duplicate vector element to vector or scalar
1780+
#[inline]
1781+
#[target_feature(enable = "neon")]
1782+
#[rustc_legacy_const_generics(1)]
1783+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(nop, IMM5 = 0))]
1784+
pub unsafe fn vgetq_lane_f64<const IMM5: i32>(v: float64x2_t) -> f64 {
1785+
static_assert_imm1!(IMM5);
1786+
simd_extract(v, IMM5 as u32)
1787+
}
1788+
17691789
/* FIXME: 16-bit float
17701790
/// Vector combine
17711791
#[inline]
@@ -3864,6 +3884,22 @@ mod tests {
38643884
assert_eq!(r, e);
38653885
}
38663886

3887+
#[simd_test(enable = "neon")]
3888+
unsafe fn test_vget_lane_f64() {
3889+
let v = f64x1::new(1.0);
3890+
let r = vget_lane_f64::<0>(transmute(v));
3891+
assert_eq!(r, 1.0);
3892+
}
3893+
3894+
#[simd_test(enable = "neon")]
3895+
unsafe fn test_vgetq_lane_f64() {
3896+
let v = f64x2::new(0.0, 1.0);
3897+
let r = vgetq_lane_f64::<1>(transmute(v));
3898+
assert_eq!(r, 1.0);
3899+
let r = vgetq_lane_f64::<0>(transmute(v));
3900+
assert_eq!(r, 0.0);
3901+
}
3902+
38673903
#[simd_test(enable = "neon")]
38683904
unsafe fn test_vcopy_lane_s64() {
38693905
let a: i64x1 = i64x1::new(1);

0 commit comments

Comments
 (0)