@@ -59,7 +59,7 @@ macro_rules! types {
5959 $(
6060 $( #[ $doc: meta] ) *
6161 $( 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 ) ;
6363 ) *
6464 ) => ( types! {
6565 $(
@@ -78,7 +78,7 @@ macro_rules! types {
7878 $(
7979 $( #[ $doc: meta] ) *
8080 $( 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 ) ;
8282 ) *
8383 ) => ( $(
8484 $( #[ $doc] ) *
@@ -132,12 +132,37 @@ macro_rules! types {
132132 impl crate :: fmt:: Debug for $name {
133133 #[ inline]
134134 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)
136137 }
137138 }
138139 ) * ) ;
139140}
140141
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+
141166#[ allow( unused) ]
142167#[ repr( simd) ]
143168pub ( crate ) struct SimdShuffleIdx < const LEN : usize > ( pub ( crate ) [ u32 ; LEN ] ) ;
0 commit comments