Skip to content

Commit 90bae85

Browse files
lu-zeroAmanieu
authored andcommitted
Add tests for power9-vector instructions
1 parent 107eb8b commit 90bae85

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,17 +1481,27 @@ mod sealed {
14811481
impl_vec_splat! { vector_bool_int, vspltw }
14821482

14831483
macro_rules! splat {
1484-
($name:ident, $v:ident, $r:ident [$instr:ident, $doc:literal]) => {
1484+
($name:ident, $v:ident, $r:ident [$instr_altivec:ident / $instr_pwr9:ident, $doc:literal]) => {
14851485
#[doc = $doc]
14861486
#[inline]
14871487
#[target_feature(enable = "altivec")]
1488-
#[cfg_attr(test, assert_instr($instr, IMM5 = 1))]
1488+
#[cfg_attr(
1489+
all(test, not(target_feature = "vsx")),
1490+
assert_instr($instr_altivec, IMM5 = 1)
1491+
)]
1492+
#[cfg_attr(
1493+
all(test, target_feature = "power9-vector"),
1494+
assert_instr($instr_pwr9, IMM5 = 1)
1495+
)]
14891496
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
14901497
pub unsafe fn $name<const IMM5: i8>() -> s_t_l!($r) {
14911498
static_assert_simm_bits!(IMM5, 5);
14921499
transmute($r::splat(IMM5 as $v))
14931500
}
14941501
};
1502+
($name:ident, $v:ident, $r:ident [$instr:ident, $doc:literal]) => {
1503+
splat! { $name, $v, $r [$instr / $instr, $doc] }
1504+
};
14951505
}
14961506

14971507
macro_rules! splats {
@@ -1514,11 +1524,11 @@ mod sealed {
15141524

15151525
test_impl! { vec_splats_u8 (v: u8) -> vector_unsigned_char [splats_u8, vspltb] }
15161526
test_impl! { vec_splats_u16 (v: u16) -> vector_unsigned_short [splats_u16, vsplth] }
1517-
test_impl! { vec_splats_u32 (v: u32) -> vector_unsigned_int [splats_u32, vspltw / xxspltw] }
1527+
test_impl! { vec_splats_u32 (v: u32) -> vector_unsigned_int [splats_u32, vspltw / xxspltw / mtvsrws] }
15181528
test_impl! { vec_splats_i8 (v: i8) -> vector_signed_char [splats_i8, vspltb] }
15191529
test_impl! { vec_splats_i16 (v: i16) -> vector_signed_short [splats_i16, vsplth] }
1520-
test_impl! { vec_splats_i32 (v: i32) -> vector_signed_int [splats_i32, vspltw / xxspltw] }
1521-
test_impl! { vec_splats_f32 (v: f32) -> vector_float [splats_f32, vspltw / xxspltw] }
1530+
test_impl! { vec_splats_i32 (v: i32) -> vector_signed_int [splats_i32, vspltw / xxspltw / mtvsrws] }
1531+
test_impl! { vec_splats_f32 (v: f32) -> vector_float [splats_f32, vspltw / xxspltw / mtvsrws] }
15221532

15231533
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
15241534
pub trait VectorSplats {
@@ -3823,8 +3833,8 @@ where
38233833
a.vec_splat::<IMM>()
38243834
}
38253835

3826-
splat! { vec_splat_u8, u8, u8x16 [vspltisb, "Vector Splat to Unsigned Byte"] }
3827-
splat! { vec_splat_s8, i8, i8x16 [vspltisb, "Vector Splat to Signed Byte"] }
3836+
splat! { vec_splat_u8, u8, u8x16 [vspltisb / xxspltib, "Vector Splat to Unsigned Byte"] }
3837+
splat! { vec_splat_s8, i8, i8x16 [vspltisb / xxspltib, "Vector Splat to Signed Byte"] }
38283838
splat! { vec_splat_u16, u16, u16x8 [vspltish, "Vector Splat to Unsigned Halfword"] }
38293839
splat! { vec_splat_s16, i16, i16x8 [vspltish, "Vector Splat to Signed Halfword"] }
38303840
splat! { vec_splat_u32, u32, u32x4 [vspltisw, "Vector Splat to Unsigned Word"] }

0 commit comments

Comments
 (0)