@@ -21,10 +21,6 @@ use rustc_target::abi::Align;
21
21
use crate :: builder:: Builder ;
22
22
#[ cfg( feature="master" ) ]
23
23
use crate :: context:: CodegenCx ;
24
- #[ cfg( feature="master" ) ]
25
- use crate :: errors:: {
26
- InvalidMonomorphizationExpectedSimd ,
27
- } ;
28
24
29
25
pub fn generic_simd_intrinsic < ' a , ' gcc , ' tcx > (
30
26
bx : & mut Builder < ' a , ' gcc , ' tcx > ,
@@ -50,16 +46,8 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
50
46
} ;
51
47
}
52
48
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)
63
51
} ;
64
52
}
65
53
@@ -69,7 +57,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
69
57
let arg_tys = sig. inputs ( ) ;
70
58
71
59
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 ] } ) ;
73
61
let ( len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
74
62
75
63
let expected_int_bits = ( len. max ( 8 ) - 1 ) . next_power_of_two ( ) ;
@@ -122,7 +110,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
122
110
}
123
111
124
112
// 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 ] } ) ;
126
114
let in_ty = arg_tys[ 0 ] ;
127
115
128
116
let comparison = match name {
@@ -137,7 +125,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
137
125
138
126
let ( in_len, in_elem) = arg_tys[ 0 ] . simd_size_and_type ( bx. tcx ( ) ) ;
139
127
if let Some ( cmp_op) = comparison {
140
- require_simd ! ( ret_ty, "return" ) ;
128
+ require_simd ! ( ret_ty, InvalidMonomorphization :: SimdReturn { span , name , ty : ret_ty } ) ;
141
129
142
130
let ( out_len, out_ty) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
143
131
require ! (
@@ -193,7 +181,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
193
181
} )
194
182
} ;
195
183
196
- require_simd ! ( ret_ty, "return" ) ;
184
+ require_simd ! ( ret_ty, InvalidMonomorphization :: SimdReturn { span , name , ty : ret_ty } ) ;
197
185
198
186
let ( out_len, out_ty) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
199
187
require ! (
@@ -240,7 +228,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
240
228
if name == sym:: simd_select {
241
229
let m_elem_ty = in_elem;
242
230
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 ] } ) ;
244
232
let ( v_len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
245
233
require ! (
246
234
m_len == v_len,
@@ -255,7 +243,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
255
243
256
244
#[ cfg( feature="master" ) ]
257
245
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 } ) ;
259
247
let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
260
248
require ! (
261
249
in_len == out_len,
@@ -557,10 +545,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
557
545
// * M: any integer width is supported, will be truncated to i1
558
546
559
547
// 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 } ) ;
564
552
565
553
// Of the same length:
566
554
let ( out_len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
@@ -665,9 +653,9 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
665
653
// * M: any integer width is supported, will be truncated to i1
666
654
667
655
// 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 ] } ) ;
671
659
672
660
// Of the same length:
673
661
let ( element_len1, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
0 commit comments