Skip to content

Commit 56a05aa

Browse files
committed
Keep Debug the same
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.
1 parent 264b1ff commit 56a05aa

File tree

14 files changed

+92
-121
lines changed

14 files changed

+92
-121
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ use crate::{
2121
use stdarch_test::assert_instr;
2222

2323
types! {
24+
#![stable(feature = "neon_intrinsics", since = "1.59.0")]
25+
2426
/// ARM-specific 64-bit wide vector of one packed `f64`.
25-
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
2627
pub struct float64x1_t(1 x f64); // FIXME: check this!
2728
/// ARM-specific 128-bit wide vector of two packed `f64`.
28-
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
2929
pub struct float64x2_t(2 x f64);
3030
}
3131

crates/core_arch/src/arm/dsp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ use crate::intrinsics::simd::simd_shuffle;
2727
use crate::mem::transmute;
2828

2929
types! {
30+
#![unstable(feature = "stdarch_arm_dsp", issue = "117237")]
31+
3032
/// ARM-specific 32-bit wide vector of two packed `i16`.
31-
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
3233
pub struct int16x2_t(2 x i16);
3334
/// ARM-specific 32-bit wide vector of two packed `u16`.
34-
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
3535
pub struct uint16x2_t(2 x u16);
3636
}
3737

crates/core_arch/src/arm/simd32.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ use crate::intrinsics::simd::simd_shuffle;
6969
use crate::{core_arch::arm::dsp::int16x2_t, mem::transmute};
7070

7171
types! {
72+
#![unstable(feature = "stdarch_arm_dsp", issue = "117237")]
73+
7274
/// ARM-specific 32-bit wide vector of four packed `i8`.
73-
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
7475
pub struct int8x4_t(4 x i8);
7576
/// ARM-specific 32-bit wide vector of four packed `u8`.
76-
#[unstable(feature = "stdarch_arm_dsp", issue = "117237")]
7777
pub struct uint8x4_t(4 x u8);
7878
}
7979

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

+3-48
Original file line numberDiff line numberDiff line change
@@ -17,106 +17,61 @@ pub(crate) type p64 = u64;
1717
pub(crate) type p128 = u128;
1818

1919
types! {
20+
#![cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
21+
#![cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
22+
2023
/// ARM-specific 64-bit wide vector of eight packed `i8`.
21-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
22-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
2324
pub struct int8x8_t(8 x pub(crate) i8);
2425
/// ARM-specific 64-bit wide vector of eight packed `u8`.
25-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
26-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
2726
pub struct uint8x8_t(8 x pub(crate) u8);
2827
/// ARM-specific 64-bit wide polynomial vector of eight packed `p8`.
29-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
30-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
3128
pub struct poly8x8_t(8 x pub(crate) p8);
3229
/// ARM-specific 64-bit wide vector of four packed `i16`.
33-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
34-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
3530
pub struct int16x4_t(4 x pub(crate) i16);
3631
/// ARM-specific 64-bit wide vector of four packed `u16`.
37-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
38-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
3932
pub struct uint16x4_t(4 x pub(crate) u16);
4033
// FIXME: ARM-specific 64-bit wide vector of four packed `f16`.
4134
// pub struct float16x4_t(f16, f16, f16, f16);
4235
/// ARM-specific 64-bit wide vector of four packed `p16`.
43-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
44-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
4536
pub struct poly16x4_t(4 x pub(crate) p16);
4637
/// ARM-specific 64-bit wide vector of two packed `i32`.
47-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
48-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
4938
pub struct int32x2_t(2 x pub(crate) i32);
5039
/// ARM-specific 64-bit wide vector of two packed `u32`.
51-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
52-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
5340
pub struct uint32x2_t(2 x pub(crate) u32);
5441
/// ARM-specific 64-bit wide vector of two packed `f32`.
55-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
56-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
5742
pub struct float32x2_t(2 x pub(crate) f32);
5843
/// ARM-specific 64-bit wide vector of one packed `i64`.
59-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
60-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
6144
pub struct int64x1_t(1 x pub(crate) i64);
6245
/// ARM-specific 64-bit wide vector of one packed `u64`.
63-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
64-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
6546
pub struct uint64x1_t(1 x pub(crate) u64);
6647
/// ARM-specific 64-bit wide vector of one packed `p64`.
67-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
68-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
6948
pub struct poly64x1_t(1 x pub(crate) p64);
7049

7150
/// ARM-specific 128-bit wide vector of sixteen packed `i8`.
72-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
73-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
7451
pub struct int8x16_t(16 x pub(crate) i8);
7552
/// ARM-specific 128-bit wide vector of sixteen packed `u8`.
76-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
77-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
7853
pub struct uint8x16_t(16 x pub(crate) u8);
7954
/// ARM-specific 128-bit wide vector of sixteen packed `p8`.
80-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
81-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
8255
pub struct poly8x16_t(16 x pub(crate) p8);
8356
/// ARM-specific 128-bit wide vector of eight packed `i16`.
84-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
85-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
8657
pub struct int16x8_t(8 x pub(crate) i16);
8758
/// ARM-specific 128-bit wide vector of eight packed `u16`.
88-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
89-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
9059
pub struct uint16x8_t(8 x pub(crate) u16);
9160
// FIXME: ARM-specific 128-bit wide vector of eight packed `f16`.
9261
// pub struct float16x8_t(f16, f16, f16, f16, f16, f16, f16);
9362
/// ARM-specific 128-bit wide vector of eight packed `p16`.
94-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
95-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
9663
pub struct poly16x8_t(8 x pub(crate) p16);
9764
/// ARM-specific 128-bit wide vector of four packed `i32`.
98-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
99-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
10065
pub struct int32x4_t(4 x pub(crate) i32);
10166
/// ARM-specific 128-bit wide vector of four packed `u32`.
102-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
103-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
10467
pub struct uint32x4_t(4 x pub(crate) u32);
10568
/// ARM-specific 128-bit wide vector of four packed `f32`.
106-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
107-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
10869
pub struct float32x4_t(4 x pub(crate) f32);
10970
/// ARM-specific 128-bit wide vector of two packed `i64`.
110-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
111-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
11271
pub struct int64x2_t(2 x pub(crate) i64);
11372
/// ARM-specific 128-bit wide vector of two packed `u64`.
114-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
115-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
11673
pub struct uint64x2_t(2 x pub(crate) u64);
11774
/// ARM-specific 128-bit wide vector of two packed `p64`.
118-
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
119-
#[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))]
12075
pub struct poly64x2_t(2 x pub(crate) p64);
12176
}
12277

crates/core_arch/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
core_intrinsics,
1515
intrinsics,
1616
no_core,
17+
fmt_helpers_for_derive,
1718
rustc_attrs,
1819
staged_api,
1920
doc_cfg,
@@ -88,4 +89,4 @@ pub mod arch {
8889
}
8990

9091
#[allow(unused_imports)]
91-
use core::{convert, ffi, hint, intrinsics, marker, mem, ops, ptr, sync};
92+
use core::{array, convert, ffi, fmt, hint, intrinsics, marker, mem, ops, ptr, sync};
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,33 @@
11
types! {
2+
#![unstable(feature = "stdarch_loongarch", issue = "117427")]
3+
24
/// LOONGARCH-specific 256-bit wide vector of 32 packed `i8`.
3-
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
45
pub struct v32i8(32 x pub(crate) i8);
56

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

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

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

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

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

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

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

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

3831
/// LOONGARCH-specific 256-bit wide vector of 4 packed `f64`.
39-
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
4032
pub struct v4f64(4 x pub(crate) f64);
4133
}
+2-10
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,33 @@
11
types! {
2+
#![unstable(feature = "stdarch_loongarch", issue = "117427")]
3+
24
/// LOONGARCH-specific 128-bit wide vector of 16 packed `i8`.
3-
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
45
pub struct v16i8(16 x pub(crate) i8);
56

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

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

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

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

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

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

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

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

3831
/// LOONGARCH-specific 128-bit wide vector of 2 packed `f64`.
39-
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
4032
pub struct v2f64(2 x pub(crate) f64);
4133
}

crates/core_arch/src/macros.rs

+40-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,38 @@ macro_rules! static_assert_simm_bits {
5050

5151
#[allow(unused)]
5252
macro_rules! types {
53-
($(
54-
$(#[$doc:meta])*
55-
pub struct $name:ident($len:literal x $v:vis $elem_type:ty);
56-
)*) => ($(
53+
(
54+
#![$stability_first:meta]
55+
$(
56+
#![$stability_more:meta]
57+
)*
58+
59+
$(
60+
$(#[$doc:meta])*
61+
pub struct $name:ident($len:literal x $v:vis $elem_type:ty);
62+
)*
63+
) => (types! {
64+
$(
65+
#![$stability_more]
66+
)*
67+
68+
$(
69+
$(#[$doc])*
70+
stability: [$stability_first]
71+
pub struct $name($len x $v $elem_type);
72+
)*
73+
});
74+
75+
(
76+
$(
77+
$(#[$doc:meta])*
78+
$(stability: [$stability: meta])+
79+
pub struct $name:ident($len:literal x $v:vis $elem_type:ty);
80+
)*
81+
) => ($(
5782
$(#[$doc])*
58-
#[derive(Copy, Clone, Debug)]
83+
$(#[$stability])+
84+
#[derive(Copy, Clone)]
5985
#[allow(non_camel_case_types)]
6086
#[repr(simd)]
6187
#[allow(clippy::missing_inline_in_public_items)]
@@ -75,7 +101,15 @@ macro_rules! types {
75101
unsafe { simd_shuffle!(one, one, [0; $len]) }
76102
}
77103
}
78-
)*)
104+
105+
$(#[$stability])+
106+
impl crate::fmt::Debug for $name {
107+
#[inline]
108+
fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result {
109+
crate::core_arch::simd::debug_simd_finish(f, stringify!($name), self.0)
110+
}
111+
}
112+
)*);
79113
}
80114

81115
#[allow(unused)]

crates/core_arch/src/mips/msa.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,36 @@ use stdarch_test::assert_instr;
1111
use crate::mem;
1212

1313
types! {
14+
#![unstable(feature = "stdarch_mips", issue = "111198")]
15+
1416
/// MIPS-specific 128-bit wide vector of 16 packed `i8`.
15-
#[unstable(feature = "stdarch_mips", issue = "111198")]
1617
pub struct v16i8(16 x i8);
1718

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)