@@ -21,10 +21,6 @@ use rustc_target::abi::Align;
2121use crate :: builder:: Builder ;
2222#[ cfg( feature="master" ) ]
2323use crate :: context:: CodegenCx ;
24- #[ cfg( feature="master" ) ]
25- use crate :: errors:: {
26- InvalidMonomorphizationExpectedSimd ,
27- } ;
2824
2925pub fn generic_simd_intrinsic < ' a , ' gcc , ' tcx > (
3026 bx : & mut Builder < ' a , ' gcc , ' tcx > ,
@@ -50,16 +46,8 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
5046 } ;
5147 }
5248 macro_rules! require_simd {
53- ( $ty: expr, $position: expr) => {
54- require!(
55- $ty. is_simd( ) ,
56- InvalidMonomorphizationExpectedSimd {
57- span,
58- name,
59- position: $position,
60- found_ty: $ty
61- }
62- )
49+ ( $ty: expr, $diag: expr) => {
50+ require!( $ty. is_simd( ) , $diag)
6351 } ;
6452 }
6553
@@ -69,7 +57,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
6957 let arg_tys = sig. inputs ( ) ;
7058
7159 if name == sym:: simd_select_bitmask {
72- require_simd ! ( arg_tys[ 1 ] , "argument" ) ;
60+ require_simd ! ( arg_tys[ 1 ] , InvalidMonomorphization :: SimdArgument { span , name , ty : arg_tys [ 1 ] } ) ;
7361 let ( len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
7462
7563 let expected_int_bits = ( len. max ( 8 ) - 1 ) . next_power_of_two ( ) ;
@@ -122,7 +110,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
122110 }
123111
124112 // every intrinsic below takes a SIMD vector as its first argument
125- require_simd ! ( arg_tys[ 0 ] , "input" ) ;
113+ require_simd ! ( arg_tys[ 0 ] , InvalidMonomorphization :: SimdInput { span , name , ty : arg_tys [ 0 ] } ) ;
126114 let in_ty = arg_tys[ 0 ] ;
127115
128116 let comparison = match name {
@@ -137,7 +125,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
137125
138126 let ( in_len, in_elem) = arg_tys[ 0 ] . simd_size_and_type ( bx. tcx ( ) ) ;
139127 if let Some ( cmp_op) = comparison {
140- require_simd ! ( ret_ty, "return" ) ;
128+ require_simd ! ( ret_ty, InvalidMonomorphization :: SimdReturn { span , name , ty : ret_ty } ) ;
141129
142130 let ( out_len, out_ty) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
143131 require ! (
@@ -193,7 +181,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
193181 } )
194182 } ;
195183
196- require_simd ! ( ret_ty, "return" ) ;
184+ require_simd ! ( ret_ty, InvalidMonomorphization :: SimdReturn { span , name , ty : ret_ty } ) ;
197185
198186 let ( out_len, out_ty) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
199187 require ! (
@@ -240,7 +228,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
240228 if name == sym:: simd_select {
241229 let m_elem_ty = in_elem;
242230 let m_len = in_len;
243- require_simd ! ( arg_tys[ 1 ] , "argument" ) ;
231+ require_simd ! ( arg_tys[ 1 ] , InvalidMonomorphization :: SimdArgument { span , name , ty : arg_tys [ 1 ] } ) ;
244232 let ( v_len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
245233 require ! (
246234 m_len == v_len,
@@ -255,7 +243,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
255243
256244 #[ cfg( feature="master" ) ]
257245 if name == sym:: simd_cast || name == sym:: simd_as {
258- require_simd ! ( ret_ty, "return" ) ;
246+ require_simd ! ( ret_ty, InvalidMonomorphization :: SimdReturn { span , name , ty : ret_ty } ) ;
259247 let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
260248 require ! (
261249 in_len == out_len,
@@ -557,10 +545,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
557545 // * M: any integer width is supported, will be truncated to i1
558546
559547 // All types must be simd vector types
560- require_simd ! ( in_ty, "first" ) ;
561- require_simd ! ( arg_tys[ 1 ] , "second" ) ;
562- require_simd ! ( arg_tys[ 2 ] , "third" ) ;
563- require_simd ! ( ret_ty, "return" ) ;
548+ require_simd ! ( in_ty, InvalidMonomorphization :: SimdFirst { span , name , ty : in_ty } ) ;
549+ require_simd ! ( arg_tys[ 1 ] , InvalidMonomorphization :: SimdSecond { span , name , ty : arg_tys [ 1 ] } ) ;
550+ require_simd ! ( arg_tys[ 2 ] , InvalidMonomorphization :: SimdThird { span , name , ty : arg_tys [ 2 ] } ) ;
551+ require_simd ! ( ret_ty, InvalidMonomorphization :: SimdReturn { span , name , ty : ret_ty } ) ;
564552
565553 // Of the same length:
566554 let ( out_len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
@@ -665,9 +653,9 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
665653 // * M: any integer width is supported, will be truncated to i1
666654
667655 // All types must be simd vector types
668- require_simd ! ( in_ty, "first" ) ;
669- require_simd ! ( arg_tys[ 1 ] , "second" ) ;
670- require_simd ! ( arg_tys[ 2 ] , "third" ) ;
656+ require_simd ! ( in_ty, InvalidMonomorphization :: SimdFirst { span , name , ty : in_ty } ) ;
657+ require_simd ! ( arg_tys[ 1 ] , InvalidMonomorphization :: SimdSecond { span , name , ty : arg_tys [ 1 ] } ) ;
658+ require_simd ! ( arg_tys[ 2 ] , InvalidMonomorphization :: SimdThird { span , name , ty : arg_tys [ 2 ] } ) ;
671659
672660 // Of the same length:
673661 let ( element_len1, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
0 commit comments