Skip to content

Commit dbaa61b

Browse files
committed
add vdupb_lane_p8 and vduph_lane_p8
1 parent a12b296 commit dbaa61b

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,46 @@ pub unsafe fn vdupd_laneq_u64<const N: i32>(a: uint64x2_t) -> u64 {
19041904
simd_extract(a, N as u32)
19051905
}
19061906

1907+
/// Set all vector lanes to the same value
1908+
#[inline]
1909+
#[target_feature(enable = "neon")]
1910+
#[cfg_attr(test, assert_instr(str, N = 4))]
1911+
#[rustc_legacy_const_generics(1)]
1912+
pub unsafe fn vdupb_lane_p8<const N: i32>(a: poly8x8_t) -> p8 {
1913+
static_assert_imm3!(N);
1914+
simd_extract(a, N as u32)
1915+
}
1916+
1917+
/// Set all vector lanes to the same value
1918+
#[inline]
1919+
#[target_feature(enable = "neon")]
1920+
#[cfg_attr(test, assert_instr(str, N = 8))]
1921+
#[rustc_legacy_const_generics(1)]
1922+
pub unsafe fn vdupb_laneq_p8<const N: i32>(a: poly8x16_t) -> p8 {
1923+
static_assert_imm4!(N);
1924+
simd_extract(a, N as u32)
1925+
}
1926+
1927+
/// Set all vector lanes to the same value
1928+
#[inline]
1929+
#[target_feature(enable = "neon")]
1930+
#[cfg_attr(test, assert_instr(str, N = 2))]
1931+
#[rustc_legacy_const_generics(1)]
1932+
pub unsafe fn vduph_lane_p16<const N: i32>(a: poly16x4_t) -> p16 {
1933+
static_assert_imm2!(N);
1934+
simd_extract(a, N as u32)
1935+
}
1936+
1937+
/// Set all vector lanes to the same value
1938+
#[inline]
1939+
#[target_feature(enable = "neon")]
1940+
#[cfg_attr(test, assert_instr(str, N = 4))]
1941+
#[rustc_legacy_const_generics(1)]
1942+
pub unsafe fn vduph_laneq_p16<const N: i32>(a: poly16x8_t) -> p16 {
1943+
static_assert_imm3!(N);
1944+
simd_extract(a, N as u32)
1945+
}
1946+
19071947
/// Set all vector lanes to the same value
19081948
#[inline]
19091949
#[target_feature(enable = "neon")]
@@ -6496,6 +6536,38 @@ mod test {
64966536
assert_eq!(r, e);
64976537
}
64986538

6539+
#[simd_test(enable = "neon")]
6540+
unsafe fn test_vdupb_lane_p8() {
6541+
let a: i8x8 = i8x8::new(1, 1, 1, 4, 1, 6, 7, 8);
6542+
let e: p8 = 1;
6543+
let r: p8 = transmute(vdupb_lane_p8::<4>(transmute(a)));
6544+
assert_eq!(r, e);
6545+
}
6546+
6547+
#[simd_test(enable = "neon")]
6548+
unsafe fn test_vdupb_laneq_p8() {
6549+
let a: i8x16 = i8x16::new(1, 1, 1, 4, 1, 6, 7, 8, 1, 10, 11, 12, 13, 14, 15, 16);
6550+
let e: p8 = 1;
6551+
let r: p8 = transmute(vdupb_laneq_p8::<8>(transmute(a)));
6552+
assert_eq!(r, e);
6553+
}
6554+
6555+
#[simd_test(enable = "neon")]
6556+
unsafe fn test_vduph_lane_p16() {
6557+
let a: i16x4 = i16x4::new(1, 1, 1, 4);
6558+
let e: p16 = 1;
6559+
let r: p16 = transmute(vduph_lane_p16::<2>(transmute(a)));
6560+
assert_eq!(r, e);
6561+
}
6562+
6563+
#[simd_test(enable = "neon")]
6564+
unsafe fn test_vduph_laneq_p16() {
6565+
let a: i16x8 = i16x8::new(1, 1, 1, 4, 1, 6, 7, 8);
6566+
let e: p16 = 1;
6567+
let r: p16 = transmute(vduph_laneq_p16::<4>(transmute(a)));
6568+
assert_eq!(r, e);
6569+
}
6570+
64996571
#[simd_test(enable = "neon")]
65006572
unsafe fn test_vdups_lane_f32() {
65016573
let a: f32x2 = f32x2::new(1., 1.);

crates/stdarch-gen/neon.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ validate 1
10171017
aarch64 = str
10181018
generate int8x8_t:i8, int8x16_t:i8, int16x4_t:i16, int16x8_t:i16, int32x2_t:i32, int32x4_t:i32, int64x1_t:i64, int64x2_t:i64
10191019
generate uint8x8_t:u8, uint8x16_t:u8, uint16x4_t:u16, uint16x8_t:u16, uint32x2_t:u32, uint32x4_t:u32, uint64x1_t:u64, uint64x2_t:u64
1020+
generate poly8x8_t:p8, poly8x16_t:p8, poly16x4_t:p16, poly16x8_t:p16
10201021

10211022
/// Set all vector lanes to the same value
10221023
name = vdup

crates/stdarch-gen/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ fn type_len(t: &str) -> usize {
8080
"poly16x8_t" => 8,
8181
"poly64x1_t" => 1,
8282
"poly64x2_t" => 2,
83-
"i8" | "i16" | "i32" | "i64" | "u8" | "u16" | "u32" | "u64" | "f32" | "f64" => 1,
83+
"i8" | "i16" | "i32" | "i64" | "u8" | "u16" | "u32" | "u64" | "f32" | "f64" | "p8"
84+
| "p16" => 1,
8485
_ => panic!("unknown type: {}", t),
8586
}
8687
}
@@ -179,6 +180,8 @@ fn type_to_suffix(t: &str) -> &str {
179180
"u64" => "d_u64",
180181
"f32" => "s_f32",
181182
"f64" => "d_f64",
183+
"p8" => "b_p8",
184+
"p16" => "h_p16",
182185
_ => panic!("unknown type: {}", t),
183186
}
184187
}
@@ -370,6 +373,8 @@ fn type_to_global_type(t: &str) -> &str {
370373
"u64" => "u64",
371374
"f32" => "f32",
372375
"f64" => "f64",
376+
"p8" => "p8",
377+
"p16" => "p16",
373378
_ => panic!("unknown type: {}", t),
374379
}
375380
}

0 commit comments

Comments
 (0)