@@ -59,7 +59,7 @@ macro_rules! types {
59
59
$(
60
60
$( #[ $doc: meta] ) *
61
61
$( stability: [ $stability_already: meta] ) *
62
- pub struct $name: ident( $len: literal x $v: vis $elem_type: ty ) ;
62
+ pub struct $name: ident( $len: literal x $v: vis $elem_type: ident ) ;
63
63
) *
64
64
) => ( types! {
65
65
$(
@@ -78,7 +78,7 @@ macro_rules! types {
78
78
$(
79
79
$( #[ $doc: meta] ) *
80
80
$( stability: [ $stability: meta] ) +
81
- pub struct $name: ident( $len: literal x $v: vis $elem_type: ty ) ;
81
+ pub struct $name: ident( $len: literal x $v: vis $elem_type: ident ) ;
82
82
) *
83
83
) => ( $(
84
84
$( #[ $doc] ) *
@@ -132,12 +132,37 @@ macro_rules! types {
132
132
impl crate :: fmt:: Debug for $name {
133
133
#[ inline]
134
134
fn fmt( & self , f: & mut crate :: fmt:: Formatter <' _>) -> crate :: fmt:: Result {
135
- crate :: core_arch:: simd:: debug_simd_finish( f, stringify!( $name) , self . as_array( ) )
135
+ let array = & $crate:: core_arch:: macros:: format_f16_as_hex!( $elem_type, self . as_array( ) ) ;
136
+ crate :: core_arch:: simd:: debug_simd_finish( f, stringify!( $name) , array)
136
137
}
137
138
}
138
139
) * ) ;
139
140
}
140
141
142
+ // the `intrinsic-test` crate compares the output of C and Rust intrinsics. Currently, It uses
143
+ // a string representation of the output value to compare. In C, f16 values are currently printed
144
+ // as hexadecimal integers. Since https://github.com/rust-lang/rust/pull/127013, rust does print
145
+ // them as decimal floating point values. To keep the intrinsics tests working, for now, format
146
+ // vectors containing f16 values like C prints them.
147
+ #[ allow( unused) ]
148
+ macro_rules! format_f16_as_hex {
149
+ ( f16, $arr: expr) => { { $arr. map( |e| $crate:: core_arch:: macros:: HexF16 ( e) ) } } ;
150
+ ( $elem_type: ident, $arr: expr) => {
151
+ * $arr
152
+ } ;
153
+ }
154
+ pub ( crate ) use format_f16_as_hex;
155
+
156
+ pub ( crate ) struct HexF16 ( pub ( crate ) f16 ) ;
157
+
158
+ impl crate :: fmt:: Debug for HexF16 {
159
+ fn fmt ( & self , f : & mut crate :: fmt:: Formatter < ' _ > ) -> crate :: fmt:: Result {
160
+ write ! ( f, "{:#06x?}" , unsafe {
161
+ crate :: mem:: transmute:: <f16, u16 >( self . 0 )
162
+ } )
163
+ }
164
+ }
165
+
141
166
#[ allow( unused) ]
142
167
#[ repr( simd) ]
143
168
pub ( crate ) struct SimdShuffleIdx < const LEN : usize > ( pub ( crate ) [ u32 ; LEN ] ) ;
0 commit comments