From 3bfa7593a77c8b82980b632e4ebda1b7a3cbaf77 Mon Sep 17 00:00:00 2001 From: SparrowLii Date: Thu, 4 Mar 2021 22:29:04 +0800 Subject: [PATCH] use transmute in vceqz instructions in aarch64/neon/generated.rs --- .../core_arch/src/aarch64/neon/generated.rs | 36 ++++++------- .../stdarch/crates/core_arch/src/macros.rs | 4 +- .../stdarch/crates/stdarch-gen/src/main.rs | 54 ++++++++++++++----- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs index a74aa578d8b8..da9bce257baa 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs @@ -78,7 +78,7 @@ pub unsafe fn vceqq_f64(a: float64x2_t, b: float64x2_t) -> uint64x2_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_s8(a: int8x8_t) -> uint8x8_t { - simd_eq(a, int8x8_t(0, 0, 0, 0, 0, 0, 0, 0)) + simd_eq(a, transmute(i8x8::new(0, 0, 0, 0, 0, 0, 0, 0))) } /// Signed Compare bitwise equal to zero @@ -86,7 +86,7 @@ pub unsafe fn vceqz_s8(a: int8x8_t) -> uint8x8_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_s8(a: int8x16_t) -> uint8x16_t { - simd_eq(a, int8x16_t(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) + simd_eq(a, transmute(i8x16::new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))) } /// Signed Compare bitwise equal to zero @@ -94,7 +94,7 @@ pub unsafe fn vceqzq_s8(a: int8x16_t) -> uint8x16_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_s16(a: int16x4_t) -> uint16x4_t { - simd_eq(a, int16x4_t(0, 0, 0, 0)) + simd_eq(a, transmute(i16x4::new(0, 0, 0, 0))) } /// Signed Compare bitwise equal to zero @@ -102,7 +102,7 @@ pub unsafe fn vceqz_s16(a: int16x4_t) -> uint16x4_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_s16(a: int16x8_t) -> uint16x8_t { - simd_eq(a, int16x8_t(0, 0, 0, 0, 0, 0, 0, 0)) + simd_eq(a, transmute(i16x8::new(0, 0, 0, 0, 0, 0, 0, 0))) } /// Signed Compare bitwise equal to zero @@ -110,7 +110,7 @@ pub unsafe fn vceqzq_s16(a: int16x8_t) -> uint16x8_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_s32(a: int32x2_t) -> uint32x2_t { - simd_eq(a, int32x2_t(0, 0)) + simd_eq(a, transmute(i32x2::new(0, 0))) } /// Signed Compare bitwise equal to zero @@ -118,7 +118,7 @@ pub unsafe fn vceqz_s32(a: int32x2_t) -> uint32x2_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_s32(a: int32x4_t) -> uint32x4_t { - simd_eq(a, int32x4_t(0, 0, 0, 0)) + simd_eq(a, transmute(i32x4::new(0, 0, 0, 0))) } /// Signed Compare bitwise equal to zero @@ -126,7 +126,7 @@ pub unsafe fn vceqzq_s32(a: int32x4_t) -> uint32x4_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_s64(a: int64x1_t) -> uint64x1_t { - simd_eq(a, int64x1_t(0)) + simd_eq(a, transmute(i64x1::new(0))) } /// Signed Compare bitwise equal to zero @@ -134,7 +134,7 @@ pub unsafe fn vceqz_s64(a: int64x1_t) -> uint64x1_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_s64(a: int64x2_t) -> uint64x2_t { - simd_eq(a, int64x2_t(0, 0)) + simd_eq(a, transmute(i64x2::new(0, 0))) } /// Signed Compare bitwise equal to zero @@ -142,7 +142,7 @@ pub unsafe fn vceqzq_s64(a: int64x2_t) -> uint64x2_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_p64(a: poly64x1_t) -> uint64x1_t { - simd_eq(a, poly64x1_t(0)) + simd_eq(a, transmute(i64x1::new(0))) } /// Signed Compare bitwise equal to zero @@ -150,7 +150,7 @@ pub unsafe fn vceqz_p64(a: poly64x1_t) -> uint64x1_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_p64(a: poly64x2_t) -> uint64x2_t { - simd_eq(a, poly64x2_t(0, 0)) + simd_eq(a, transmute(i64x2::new(0, 0))) } /// Unsigned Compare bitwise equal to zero @@ -158,7 +158,7 @@ pub unsafe fn vceqzq_p64(a: poly64x2_t) -> uint64x2_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_u8(a: uint8x8_t) -> uint8x8_t { - simd_eq(a, uint8x8_t(0, 0, 0, 0, 0, 0, 0, 0)) + simd_eq(a, transmute(u8x8::new(0, 0, 0, 0, 0, 0, 0, 0))) } /// Unsigned Compare bitwise equal to zero @@ -166,7 +166,7 @@ pub unsafe fn vceqz_u8(a: uint8x8_t) -> uint8x8_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_u8(a: uint8x16_t) -> uint8x16_t { - simd_eq(a, uint8x16_t(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) + simd_eq(a, transmute(u8x16::new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))) } /// Unsigned Compare bitwise equal to zero @@ -174,7 +174,7 @@ pub unsafe fn vceqzq_u8(a: uint8x16_t) -> uint8x16_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_u16(a: uint16x4_t) -> uint16x4_t { - simd_eq(a, uint16x4_t(0, 0, 0, 0)) + simd_eq(a, transmute(u16x4::new(0, 0, 0, 0))) } /// Unsigned Compare bitwise equal to zero @@ -182,7 +182,7 @@ pub unsafe fn vceqz_u16(a: uint16x4_t) -> uint16x4_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_u16(a: uint16x8_t) -> uint16x8_t { - simd_eq(a, uint16x8_t(0, 0, 0, 0, 0, 0, 0, 0)) + simd_eq(a, transmute(u16x8::new(0, 0, 0, 0, 0, 0, 0, 0))) } /// Unsigned Compare bitwise equal to zero @@ -190,7 +190,7 @@ pub unsafe fn vceqzq_u16(a: uint16x8_t) -> uint16x8_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_u32(a: uint32x2_t) -> uint32x2_t { - simd_eq(a, uint32x2_t(0, 0)) + simd_eq(a, transmute(u32x2::new(0, 0))) } /// Unsigned Compare bitwise equal to zero @@ -198,7 +198,7 @@ pub unsafe fn vceqz_u32(a: uint32x2_t) -> uint32x2_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_u32(a: uint32x4_t) -> uint32x4_t { - simd_eq(a, uint32x4_t(0, 0, 0, 0)) + simd_eq(a, transmute(u32x4::new(0, 0, 0, 0))) } /// Unsigned Compare bitwise equal to zero @@ -206,7 +206,7 @@ pub unsafe fn vceqzq_u32(a: uint32x4_t) -> uint32x4_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqz_u64(a: uint64x1_t) -> uint64x1_t { - simd_eq(a, uint64x1_t(0)) + simd_eq(a, transmute(u64x1::new(0))) } /// Unsigned Compare bitwise equal to zero @@ -214,7 +214,7 @@ pub unsafe fn vceqz_u64(a: uint64x1_t) -> uint64x1_t { #[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(vceqz))] pub unsafe fn vceqzq_u64(a: uint64x2_t) -> uint64x2_t { - simd_eq(a, uint64x2_t(0, 0)) + simd_eq(a, transmute(u64x2::new(0, 0))) } /// Compare signed greater than diff --git a/library/stdarch/crates/core_arch/src/macros.rs b/library/stdarch/crates/core_arch/src/macros.rs index 5d05adfa6ac8..87e49fba4bcb 100644 --- a/library/stdarch/crates/core_arch/src/macros.rs +++ b/library/stdarch/crates/core_arch/src/macros.rs @@ -426,13 +426,13 @@ macro_rules! constify_imm3 { macro_rules! types { ($( $(#[$doc:meta])* - pub struct $name:ident($field:ty$(, $fields:ty)*$(,)?); + pub struct $name:ident($($fields:tt)*); )*) => ($( $(#[$doc])* #[derive(Copy, Clone, Debug)] #[allow(non_camel_case_types)] #[repr(simd)] #[allow(clippy::missing_inline_in_public_items)] - pub struct $name(pub $field$(, pub $fields)*); + pub struct $name($($fields)*); )*) } diff --git a/library/stdarch/crates/stdarch-gen/src/main.rs b/library/stdarch/crates/stdarch-gen/src/main.rs index 7498ab93ff50..39836bd916dc 100644 --- a/library/stdarch/crates/stdarch-gen/src/main.rs +++ b/library/stdarch/crates/stdarch-gen/src/main.rs @@ -299,7 +299,7 @@ fn gen_aarch64( in_t: &str, out_t: &str, current_tests: &[(Vec, Vec, Vec)], - has_b: bool, + single_para: bool, fixed: &Option, ) -> (String, String) { let _global_t = type_to_global_type(in_t); @@ -335,7 +335,7 @@ fn gen_aarch64( } else { String::new() }; - let call = if has_b { + let call = if !single_para { format!( r#"pub unsafe fn {}(a: {}, b: {}) -> {} {{ {}{}(a, b) @@ -350,9 +350,15 @@ fn gen_aarch64( } format!( r#"pub unsafe fn {}(a: {}) -> {} {{ - {}{}(a, {}({})) + {}{}(a, transmute({}::new({}))) }}"#, - name, in_t, out_t, ext_c, current_fn, in_t, fixed_vals, + name, + in_t, + out_t, + ext_c, + current_fn, + type_to_global_type(in_t), + fixed_vals, ) } else { String::new() @@ -368,7 +374,14 @@ fn gen_aarch64( current_comment, current_aarch64, call ); - let test = gen_test(name, &in_t, &out_t, current_tests, type_len(in_t), has_b); + let test = gen_test( + name, + &in_t, + &out_t, + current_tests, + type_len(in_t), + single_para, + ); (function, test) } @@ -378,7 +391,7 @@ fn gen_test( out_t: &str, current_tests: &[(Vec, Vec, Vec)], len: usize, - has_b: bool, + single_para: bool, ) -> String { let mut test = format!( r#" @@ -390,7 +403,7 @@ fn gen_test( let a: Vec = a.iter().take(len).cloned().collect(); let b: Vec = b.iter().take(len).cloned().collect(); let e: Vec = e.iter().take(len).cloned().collect(); - let t = if has_b { + let t = if !single_para { format!( r#" let a{}; @@ -437,7 +450,7 @@ fn gen_arm( in_t: &str, out_t: &str, current_tests: &[(Vec, Vec, Vec)], - has_b: bool, + single_para: bool, fixed: &Option, ) -> (String, String) { let _global_t = type_to_global_type(in_t); @@ -486,7 +499,7 @@ fn gen_arm( } else { String::new() }; - let call = if has_b { + let call = if !single_para { format!( r#"pub unsafe fn {}(a: {}, b: {}) -> {} {{ {}{}(a, b) @@ -501,9 +514,15 @@ fn gen_arm( } format!( r#"pub unsafe fn {}(a: {}) -> {} {{ - {}{}(a, {}({})) + {}{}(a, transmute({}::new({}))) }}"#, - name, in_t, out_t, ext_c, current_fn, in_t, fixed_vals, + name, + in_t, + out_t, + ext_c, + current_fn, + type_to_global_type(in_t), + fixed_vals, ) } else { String::new() @@ -523,7 +542,14 @@ fn gen_arm( expand_intrinsic(¤t_aarch64, in_t), call, ); - let test = gen_test(name, &in_t, &out_t, current_tests, type_len(in_t), has_b); + let test = gen_test( + name, + &in_t, + &out_t, + current_tests, + type_len(in_t), + single_para, + ); (function, test) } @@ -752,7 +778,7 @@ mod test { &in_t, &out_t, ¤t_tests, - b.len() > 0, + b.len() == 0, &fixed, ); out_arm.push_str(&function); @@ -767,7 +793,7 @@ mod test { &in_t, &out_t, ¤t_tests, - b.len() > 0, + b.len() == 0, &fixed, ); out_aarch64.push_str(&function);