Skip to content

Commit

Permalink
Keep Debug the same
Browse files Browse the repository at this point in the history
This ended up way more annoying than expected, because I needed to refactor the `types!` macro to separate out the stability attributes to put those on the `Debug` impl without also copying all the `#[doc]`s.  But I like how it came out in the end, reducing duplication in the macro invocations.

But without it all the C-consistency tests fail.
  • Loading branch information
scottmcm committed Aug 7, 2024
1 parent 264b1ff commit 56a05aa
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 121 deletions.
4 changes: 2 additions & 2 deletions crates/core_arch/src/aarch64/neon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ use crate::{
use stdarch_test::assert_instr;

types! {
#![stable(feature = "neon_intrinsics", since = "1.59.0")]

/// ARM-specific 64-bit wide vector of one packed `f64`.
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
pub struct float64x1_t(1 x f64); // FIXME: check this!
/// ARM-specific 128-bit wide vector of two packed `f64`.
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
pub struct float64x2_t(2 x f64);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/core_arch/src/arm/dsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ use crate::intrinsics::simd::simd_shuffle;
use crate::mem::transmute;

types! {
#![unstable(feature = "stdarch_arm_dsp", issue = "117237")]

/// ARM-specific 32-bit wide vector of two packed `i16`.
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub struct int16x2_t(2 x i16);
/// ARM-specific 32-bit wide vector of two packed `u16`.
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub struct uint16x2_t(2 x u16);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/core_arch/src/arm/simd32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ use crate::intrinsics::simd::simd_shuffle;
use crate::{core_arch::arm::dsp::int16x2_t, mem::transmute};

types! {
#![unstable(feature = "stdarch_arm_dsp", issue = "117237")]

/// ARM-specific 32-bit wide vector of four packed `i8`.
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub struct int8x4_t(4 x i8);
/// ARM-specific 32-bit wide vector of four packed `u8`.
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
pub struct uint8x4_t(4 x u8);
}

Expand Down
51 changes: 3 additions & 48 deletions crates/core_arch/src/arm_shared/neon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,106 +17,61 @@ pub(crate) type p64 = u64;
pub(crate) type p128 = u128;

types! {
#![cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#![cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]

/// ARM-specific 64-bit wide vector of eight packed `i8`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct int8x8_t(8 x pub(crate) i8);
/// ARM-specific 64-bit wide vector of eight packed `u8`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct uint8x8_t(8 x pub(crate) u8);
/// ARM-specific 64-bit wide polynomial vector of eight packed `p8`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct poly8x8_t(8 x pub(crate) p8);
/// ARM-specific 64-bit wide vector of four packed `i16`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct int16x4_t(4 x pub(crate) i16);
/// ARM-specific 64-bit wide vector of four packed `u16`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct uint16x4_t(4 x pub(crate) u16);
// FIXME: ARM-specific 64-bit wide vector of four packed `f16`.
// pub struct float16x4_t(f16, f16, f16, f16);
/// ARM-specific 64-bit wide vector of four packed `p16`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct poly16x4_t(4 x pub(crate) p16);
/// ARM-specific 64-bit wide vector of two packed `i32`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct int32x2_t(2 x pub(crate) i32);
/// ARM-specific 64-bit wide vector of two packed `u32`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct uint32x2_t(2 x pub(crate) u32);
/// ARM-specific 64-bit wide vector of two packed `f32`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct float32x2_t(2 x pub(crate) f32);
/// ARM-specific 64-bit wide vector of one packed `i64`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct int64x1_t(1 x pub(crate) i64);
/// ARM-specific 64-bit wide vector of one packed `u64`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct uint64x1_t(1 x pub(crate) u64);
/// ARM-specific 64-bit wide vector of one packed `p64`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct poly64x1_t(1 x pub(crate) p64);

/// ARM-specific 128-bit wide vector of sixteen packed `i8`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct int8x16_t(16 x pub(crate) i8);
/// ARM-specific 128-bit wide vector of sixteen packed `u8`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct uint8x16_t(16 x pub(crate) u8);
/// ARM-specific 128-bit wide vector of sixteen packed `p8`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct poly8x16_t(16 x pub(crate) p8);
/// ARM-specific 128-bit wide vector of eight packed `i16`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct int16x8_t(8 x pub(crate) i16);
/// ARM-specific 128-bit wide vector of eight packed `u16`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct uint16x8_t(8 x pub(crate) u16);
// FIXME: ARM-specific 128-bit wide vector of eight packed `f16`.
// pub struct float16x8_t(f16, f16, f16, f16, f16, f16, f16);
/// ARM-specific 128-bit wide vector of eight packed `p16`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct poly16x8_t(8 x pub(crate) p16);
/// ARM-specific 128-bit wide vector of four packed `i32`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct int32x4_t(4 x pub(crate) i32);
/// ARM-specific 128-bit wide vector of four packed `u32`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct uint32x4_t(4 x pub(crate) u32);
/// ARM-specific 128-bit wide vector of four packed `f32`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct float32x4_t(4 x pub(crate) f32);
/// ARM-specific 128-bit wide vector of two packed `i64`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct int64x2_t(2 x pub(crate) i64);
/// ARM-specific 128-bit wide vector of two packed `u64`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct uint64x2_t(2 x pub(crate) u64);
/// ARM-specific 128-bit wide vector of two packed `p64`.
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
pub struct poly64x2_t(2 x pub(crate) p64);
}

Expand Down
3 changes: 2 additions & 1 deletion crates/core_arch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
core_intrinsics,
intrinsics,
no_core,
fmt_helpers_for_derive,
rustc_attrs,
staged_api,
doc_cfg,
Expand Down Expand Up @@ -88,4 +89,4 @@ pub mod arch {
}

#[allow(unused_imports)]
use core::{convert, ffi, hint, intrinsics, marker, mem, ops, ptr, sync};
use core::{array, convert, ffi, fmt, hint, intrinsics, marker, mem, ops, ptr, sync};
12 changes: 2 additions & 10 deletions crates/core_arch/src/loongarch64/lasx/types.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
types! {
#![unstable(feature = "stdarch_loongarch", issue = "117427")]

/// LOONGARCH-specific 256-bit wide vector of 32 packed `i8`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v32i8(32 x pub(crate) i8);

/// LOONGARCH-specific 256-bit wide vector of 16 packed `i16`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v16i16(16 x pub(crate) i16);

/// LOONGARCH-specific 256-bit wide vector of 8 packed `i32`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v8i32(8 x pub(crate) i32);

/// LOONGARCH-specific 256-bit wide vector of 4 packed `i64`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v4i64(4 x pub(crate) i64);

/// LOONGARCH-specific 256-bit wide vector of 32 packed `u8`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v32u8(32 x pub(crate) u8);

/// LOONGARCH-specific 256-bit wide vector of 16 packed `u16`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v16u16(16 x pub(crate) u16);

/// LOONGARCH-specific 256-bit wide vector of 8 packed `u32`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v8u32(8 x pub(crate) u32);

/// LOONGARCH-specific 256-bit wide vector of 4 packed `u64`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v4u64(4 x pub(crate) u64);

/// LOONGARCH-specific 128-bit wide vector of 8 packed `f32`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v8f32(8 x pub(crate) f32);

/// LOONGARCH-specific 256-bit wide vector of 4 packed `f64`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v4f64(4 x pub(crate) f64);
}
12 changes: 2 additions & 10 deletions crates/core_arch/src/loongarch64/lsx/types.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
types! {
#![unstable(feature = "stdarch_loongarch", issue = "117427")]

/// LOONGARCH-specific 128-bit wide vector of 16 packed `i8`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v16i8(16 x pub(crate) i8);

/// LOONGARCH-specific 128-bit wide vector of 8 packed `i16`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v8i16(8 x pub(crate) i16);

/// LOONGARCH-specific 128-bit wide vector of 4 packed `i32`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v4i32(4 x pub(crate) i32);

/// LOONGARCH-specific 128-bit wide vector of 2 packed `i64`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v2i64(2 x pub(crate) i64);

/// LOONGARCH-specific 128-bit wide vector of 16 packed `u8`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v16u8(16 x pub(crate) u8);

/// LOONGARCH-specific 128-bit wide vector of 8 packed `u16`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v8u16(8 x pub(crate) u16);

/// LOONGARCH-specific 128-bit wide vector of 4 packed `u32`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v4u32(4 x pub(crate) u32);

/// LOONGARCH-specific 128-bit wide vector of 2 packed `u64`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v2u64(2 x pub(crate) u64);

/// LOONGARCH-specific 128-bit wide vector of 4 packed `f32`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v4f32(4 x pub(crate) f32);

/// LOONGARCH-specific 128-bit wide vector of 2 packed `f64`.
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub struct v2f64(2 x pub(crate) f64);
}
46 changes: 40 additions & 6 deletions crates/core_arch/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,38 @@ macro_rules! static_assert_simm_bits {

#[allow(unused)]
macro_rules! types {
($(
$(#[$doc:meta])*
pub struct $name:ident($len:literal x $v:vis $elem_type:ty);
)*) => ($(
(
#![$stability_first:meta]
$(
#![$stability_more:meta]
)*

$(
$(#[$doc:meta])*
pub struct $name:ident($len:literal x $v:vis $elem_type:ty);
)*
) => (types! {
$(
#![$stability_more]
)*

$(
$(#[$doc])*
stability: [$stability_first]
pub struct $name($len x $v $elem_type);
)*
});

(
$(
$(#[$doc:meta])*
$(stability: [$stability: meta])+
pub struct $name:ident($len:literal x $v:vis $elem_type:ty);
)*
) => ($(
$(#[$doc])*
#[derive(Copy, Clone, Debug)]
$(#[$stability])+
#[derive(Copy, Clone)]
#[allow(non_camel_case_types)]
#[repr(simd)]
#[allow(clippy::missing_inline_in_public_items)]
Expand All @@ -75,7 +101,15 @@ macro_rules! types {
unsafe { simd_shuffle!(one, one, [0; $len]) }
}
}
)*)

$(#[$stability])+
impl crate::fmt::Debug for $name {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result {
crate::core_arch::simd::debug_simd_finish(f, stringify!($name), self.0)
}
}
)*);
}

#[allow(unused)]
Expand Down
12 changes: 2 additions & 10 deletions crates/core_arch/src/mips/msa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,36 @@ use stdarch_test::assert_instr;
use crate::mem;

types! {
#![unstable(feature = "stdarch_mips", issue = "111198")]

/// MIPS-specific 128-bit wide vector of 16 packed `i8`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v16i8(16 x i8);

/// MIPS-specific 128-bit wide vector of 8 packed `i16`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v8i16(8 x i16);

/// MIPS-specific 128-bit wide vector of 4 packed `i32`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v4i32(4 x i32);

/// MIPS-specific 128-bit wide vector of 2 packed `i64`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v2i64(2 x i64);

/// MIPS-specific 128-bit wide vector of 16 packed `u8`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v16u8(16 x u8);

/// MIPS-specific 128-bit wide vector of 8 packed `u16`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v8u16(8 x u16);

/// MIPS-specific 128-bit wide vector of 4 packed `u32`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v4u32(4 x u32);

/// MIPS-specific 128-bit wide vector of 2 packed `u64`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v2u64(2 x u64);

// / MIPS-specific 128-bit wide vector of 4 packed `f32`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v4f32(4 x f32);

/// MIPS-specific 128-bit wide vector of 2 packed `f64`.
#[unstable(feature = "stdarch_mips", issue = "111198")]
pub struct v2f64(2 x f64);
}

Expand Down
Loading

0 comments on commit 56a05aa

Please sign in to comment.