33#![ allow( non_camel_case_types) ]
44
55#[ inline( always) ]
6- pub ( crate ) unsafe fn simd_imax < T : Copy > ( a : T , b : T ) -> T {
6+ #[ rustc_const_unstable( feature = "stdarch_const_helpers" , issue = "none" ) ]
7+ pub ( crate ) const unsafe fn simd_imax < T : Copy > ( a : T , b : T ) -> T {
78 let mask: T = crate :: intrinsics:: simd:: simd_gt ( a, b) ;
89 crate :: intrinsics:: simd:: simd_select ( mask, a, b)
910}
1011
1112#[ inline( always) ]
12- pub ( crate ) unsafe fn simd_imin < T : Copy > ( a : T , b : T ) -> T {
13+ #[ rustc_const_unstable( feature = "stdarch_const_helpers" , issue = "none" ) ]
14+ pub ( crate ) const unsafe fn simd_imin < T : Copy > ( a : T , b : T ) -> T {
1315 let mask: T = crate :: intrinsics:: simd:: simd_lt ( a, b) ;
1416 crate :: intrinsics:: simd:: simd_select ( mask, a, b)
1517}
@@ -35,7 +37,8 @@ macro_rules! simd_ty {
3537 }
3638 // FIXME: Workaround rust@60637
3739 #[ inline( always) ]
38- pub ( crate ) fn splat( value: $elem_type) -> Self {
40+ #[ rustc_const_unstable( feature = "stdarch_const_helpers" , issue = "none" ) ]
41+ pub ( crate ) const fn splat( value: $elem_type) -> Self {
3942 #[ derive( Copy , Clone ) ]
4043 #[ repr( simd) ]
4144 struct JustOne ( [ $elem_type; 1 ] ) ;
@@ -50,12 +53,12 @@ macro_rules! simd_ty {
5053 /// Use for testing only.
5154 // FIXME: Workaround rust@60637
5255 #[ inline( always) ]
53- pub ( crate ) fn extract( & self , index: usize ) -> $elem_type {
56+ pub ( crate ) const fn extract( & self , index: usize ) -> $elem_type {
5457 self . as_array( ) [ index]
5558 }
5659
5760 #[ inline]
58- pub ( crate ) fn as_array( & self ) -> & [ $elem_type; $len] {
61+ pub ( crate ) const fn as_array( & self ) -> & [ $elem_type; $len] {
5962 let simd_ptr: * const Self = self ;
6063 let array_ptr: * const [ $elem_type; $len] = simd_ptr. cast( ) ;
6164 // SAFETY: We can always read the prefix of a simd type as an array.
@@ -65,7 +68,8 @@ macro_rules! simd_ty {
6568 }
6669 }
6770
68- impl core:: cmp:: PartialEq for $id {
71+ #[ rustc_const_unstable( feature = "stdarch_const_helpers" , issue = "none" ) ]
72+ const impl core:: cmp:: PartialEq for $id {
6973 #[ inline]
7074 fn eq( & self , other: & Self ) -> bool {
7175 self . as_array( ) == other. as_array( )
@@ -101,7 +105,8 @@ macro_rules! simd_m_ty {
101105
102106 // FIXME: Workaround rust@60637
103107 #[ inline( always) ]
104- pub ( crate ) fn splat( value: bool ) -> Self {
108+ #[ rustc_const_unstable( feature = "stdarch_const_helpers" , issue = "none" ) ]
109+ pub ( crate ) const fn splat( value: bool ) -> Self {
105110 #[ derive( Copy , Clone ) ]
106111 #[ repr( simd) ]
107112 struct JustOne ( [ $elem_type; 1 ] ) ;
@@ -112,7 +117,7 @@ macro_rules! simd_m_ty {
112117 }
113118
114119 #[ inline]
115- pub ( crate ) fn as_array( & self ) -> & [ $elem_type; $len] {
120+ pub ( crate ) const fn as_array( & self ) -> & [ $elem_type; $len] {
116121 let simd_ptr: * const Self = self ;
117122 let array_ptr: * const [ $elem_type; $len] = simd_ptr. cast( ) ;
118123 // SAFETY: We can always read the prefix of a simd type as an array.
@@ -122,7 +127,8 @@ macro_rules! simd_m_ty {
122127 }
123128 }
124129
125- impl core:: cmp:: PartialEq for $id {
130+ #[ rustc_const_unstable( feature = "stdarch_const_helpers" , issue = "none" ) ]
131+ const impl core:: cmp:: PartialEq for $id {
126132 #[ inline]
127133 fn eq( & self , other: & Self ) -> bool {
128134 self . as_array( ) == other. as_array( )
0 commit comments