@@ -792,7 +792,7 @@ fn generic_simd_intrinsic(
792
792
_ => return_error ! ( "`{}` is not an integral type" , in_ty) ,
793
793
} ;
794
794
require_simd ! ( arg_tys[ 1 ] , "argument" ) ;
795
- let v_len = arg_tys[ 1 ] . simd_size ( tcx) ;
795
+ let ( v_len, _ ) = arg_tys[ 1 ] . simd_size_and_type ( bx . tcx ( ) ) ;
796
796
require ! (
797
797
// Allow masks for vectors with fewer than 8 elements to be
798
798
// represented with a u8 or i8.
@@ -812,8 +812,6 @@ fn generic_simd_intrinsic(
812
812
// every intrinsic below takes a SIMD vector as its first argument
813
813
require_simd ! ( arg_tys[ 0 ] , "input" ) ;
814
814
let in_ty = arg_tys[ 0 ] ;
815
- let in_elem = arg_tys[ 0 ] . simd_type ( tcx) ;
816
- let in_len = arg_tys[ 0 ] . simd_size ( tcx) ;
817
815
818
816
let comparison = match name {
819
817
sym:: simd_eq => Some ( hir:: BinOpKind :: Eq ) ,
@@ -825,14 +823,15 @@ fn generic_simd_intrinsic(
825
823
_ => None ,
826
824
} ;
827
825
826
+ let ( in_len, in_elem) = arg_tys[ 0 ] . simd_size_and_type ( bx. tcx ( ) ) ;
828
827
if let Some ( cmp_op) = comparison {
829
828
require_simd ! ( ret_ty, "return" ) ;
830
829
831
- let out_len = ret_ty. simd_size ( tcx) ;
830
+ let ( out_len, out_ty ) = ret_ty. simd_size_and_type ( bx . tcx ( ) ) ;
832
831
require ! (
833
832
in_len == out_len,
834
833
"expected return type with length {} (same as input type `{}`), \
835
- found `{}` with length {}",
834
+ found `{}` with length {}",
836
835
in_len,
837
836
in_ty,
838
837
ret_ty,
@@ -842,7 +841,7 @@ fn generic_simd_intrinsic(
842
841
bx. type_kind( bx. element_type( llret_ty) ) == TypeKind :: Integer ,
843
842
"expected return type with integer elements, found `{}` with non-integer `{}`" ,
844
843
ret_ty,
845
- ret_ty . simd_type ( tcx )
844
+ out_ty
846
845
) ;
847
846
848
847
return Ok ( compare_simd_types (
@@ -862,7 +861,7 @@ fn generic_simd_intrinsic(
862
861
863
862
require_simd ! ( ret_ty, "return" ) ;
864
863
865
- let out_len = ret_ty. simd_size ( tcx) ;
864
+ let ( out_len, out_ty ) = ret_ty. simd_size_and_type ( bx . tcx ( ) ) ;
866
865
require ! (
867
866
out_len == n,
868
867
"expected return type of length {}, found `{}` with length {}" ,
@@ -871,13 +870,13 @@ fn generic_simd_intrinsic(
871
870
out_len
872
871
) ;
873
872
require ! (
874
- in_elem == ret_ty . simd_type ( tcx ) ,
873
+ in_elem == out_ty ,
875
874
"expected return element type `{}` (element of input `{}`), \
876
- found `{}` with element type `{}`",
875
+ found `{}` with element type `{}`",
877
876
in_elem,
878
877
in_ty,
879
878
ret_ty,
880
- ret_ty . simd_type ( tcx )
879
+ out_ty
881
880
) ;
882
881
883
882
let total_len = u128:: from ( in_len) * 2 ;
@@ -946,7 +945,7 @@ fn generic_simd_intrinsic(
946
945
let m_elem_ty = in_elem;
947
946
let m_len = in_len;
948
947
require_simd ! ( arg_tys[ 1 ] , "argument" ) ;
949
- let v_len = arg_tys[ 1 ] . simd_size ( tcx) ;
948
+ let ( v_len, _ ) = arg_tys[ 1 ] . simd_size_and_type ( bx . tcx ( ) ) ;
950
949
require ! (
951
950
m_len == v_len,
952
951
"mismatched lengths: mask length `{}` != other vector length `{}`" ,
@@ -1173,25 +1172,27 @@ fn generic_simd_intrinsic(
1173
1172
require_simd ! ( ret_ty, "return" ) ;
1174
1173
1175
1174
// Of the same length:
1175
+ let ( out_len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1176
+ let ( out_len2, _) = arg_tys[ 2 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1176
1177
require ! (
1177
- in_len == arg_tys [ 1 ] . simd_size ( tcx ) ,
1178
+ in_len == out_len ,
1178
1179
"expected {} argument with length {} (same as input type `{}`), \
1179
- found `{}` with length {}",
1180
+ found `{}` with length {}",
1180
1181
"second" ,
1181
1182
in_len,
1182
1183
in_ty,
1183
1184
arg_tys[ 1 ] ,
1184
- arg_tys [ 1 ] . simd_size ( tcx )
1185
+ out_len
1185
1186
) ;
1186
1187
require ! (
1187
- in_len == arg_tys [ 2 ] . simd_size ( tcx ) ,
1188
+ in_len == out_len2 ,
1188
1189
"expected {} argument with length {} (same as input type `{}`), \
1189
- found `{}` with length {}",
1190
+ found `{}` with length {}",
1190
1191
"third" ,
1191
1192
in_len,
1192
1193
in_ty,
1193
1194
arg_tys[ 2 ] ,
1194
- arg_tys [ 2 ] . simd_size ( tcx )
1195
+ out_len2
1195
1196
) ;
1196
1197
1197
1198
// The return type must match the first argument type
@@ -1215,39 +1216,40 @@ fn generic_simd_intrinsic(
1215
1216
1216
1217
// The second argument must be a simd vector with an element type that's a pointer
1217
1218
// to the element type of the first argument
1218
- let ( pointer_count , underlying_ty ) = match arg_tys[ 1 ] . simd_type ( tcx ) . kind ( ) {
1219
- ty :: RawPtr ( p ) if p . ty == in_elem => {
1220
- ( ptr_count ( arg_tys [ 1 ] . simd_type ( tcx ) ) , non_ptr ( arg_tys [ 1 ] . simd_type ( tcx ) ) )
1221
- }
1219
+ let ( _ , element_ty0 ) = arg_tys[ 0 ] . simd_size_and_type ( bx . tcx ( ) ) ;
1220
+ let ( _ , element_ty1 ) = arg_tys [ 1 ] . simd_size_and_type ( bx . tcx ( ) ) ;
1221
+ let ( pointer_count , underlying_ty ) = match element_ty1 . kind ( ) {
1222
+ ty :: RawPtr ( p ) if p . ty == in_elem => ( ptr_count ( element_ty1 ) , non_ptr ( element_ty1 ) ) ,
1222
1223
_ => {
1223
1224
require ! (
1224
1225
false ,
1225
1226
"expected element type `{}` of second argument `{}` \
1226
- to be a pointer to the element type `{}` of the first \
1227
- argument `{}`, found `{}` != `*_ {}`",
1228
- arg_tys [ 1 ] . simd_type ( tcx ) ,
1227
+ to be a pointer to the element type `{}` of the first \
1228
+ argument `{}`, found `{}` != `*_ {}`",
1229
+ element_ty1 ,
1229
1230
arg_tys[ 1 ] ,
1230
1231
in_elem,
1231
1232
in_ty,
1232
- arg_tys [ 1 ] . simd_type ( tcx ) ,
1233
+ element_ty1 ,
1233
1234
in_elem
1234
1235
) ;
1235
1236
unreachable ! ( ) ;
1236
1237
}
1237
1238
} ;
1238
1239
assert ! ( pointer_count > 0 ) ;
1239
- assert_eq ! ( pointer_count - 1 , ptr_count( arg_tys [ 0 ] . simd_type ( tcx ) ) ) ;
1240
- assert_eq ! ( underlying_ty, non_ptr( arg_tys [ 0 ] . simd_type ( tcx ) ) ) ;
1240
+ assert_eq ! ( pointer_count - 1 , ptr_count( element_ty0 ) ) ;
1241
+ assert_eq ! ( underlying_ty, non_ptr( element_ty0 ) ) ;
1241
1242
1242
1243
// The element type of the third argument must be a signed integer type of any width:
1243
- match arg_tys[ 2 ] . simd_type ( tcx) . kind ( ) {
1244
+ let ( _, element_ty2) = arg_tys[ 2 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1245
+ match element_ty2. kind ( ) {
1244
1246
ty:: Int ( _) => ( ) ,
1245
1247
_ => {
1246
1248
require ! (
1247
1249
false ,
1248
1250
"expected element type `{}` of third argument `{}` \
1249
1251
to be a signed integer type",
1250
- arg_tys [ 2 ] . simd_type ( tcx ) ,
1252
+ element_ty2 ,
1251
1253
arg_tys[ 2 ]
1252
1254
) ;
1253
1255
}
@@ -1299,25 +1301,27 @@ fn generic_simd_intrinsic(
1299
1301
require_simd ! ( arg_tys[ 2 ] , "third" ) ;
1300
1302
1301
1303
// Of the same length:
1304
+ let ( element_len1, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1305
+ let ( element_len2, _) = arg_tys[ 2 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1302
1306
require ! (
1303
- in_len == arg_tys [ 1 ] . simd_size ( tcx ) ,
1307
+ in_len == element_len1 ,
1304
1308
"expected {} argument with length {} (same as input type `{}`), \
1305
- found `{}` with length {}",
1309
+ found `{}` with length {}",
1306
1310
"second" ,
1307
1311
in_len,
1308
1312
in_ty,
1309
1313
arg_tys[ 1 ] ,
1310
- arg_tys [ 1 ] . simd_size ( tcx )
1314
+ element_len1
1311
1315
) ;
1312
1316
require ! (
1313
- in_len == arg_tys [ 2 ] . simd_size ( tcx ) ,
1317
+ in_len == element_len2 ,
1314
1318
"expected {} argument with length {} (same as input type `{}`), \
1315
- found `{}` with length {}",
1319
+ found `{}` with length {}",
1316
1320
"third" ,
1317
1321
in_len,
1318
1322
in_ty,
1319
1323
arg_tys[ 2 ] ,
1320
- arg_tys [ 2 ] . simd_size ( tcx )
1324
+ element_len2
1321
1325
) ;
1322
1326
1323
1327
// This counts how many pointers
@@ -1338,39 +1342,42 @@ fn generic_simd_intrinsic(
1338
1342
1339
1343
// The second argument must be a simd vector with an element type that's a pointer
1340
1344
// to the element type of the first argument
1341
- let ( pointer_count, underlying_ty) = match arg_tys[ 1 ] . simd_type ( tcx) . kind ( ) {
1345
+ let ( _, element_ty0) = arg_tys[ 0 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1346
+ let ( _, element_ty1) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1347
+ let ( _, element_ty2) = arg_tys[ 2 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1348
+ let ( pointer_count, underlying_ty) = match element_ty1. kind ( ) {
1342
1349
ty:: RawPtr ( p) if p. ty == in_elem && p. mutbl == hir:: Mutability :: Mut => {
1343
- ( ptr_count ( arg_tys [ 1 ] . simd_type ( tcx ) ) , non_ptr ( arg_tys [ 1 ] . simd_type ( tcx ) ) )
1350
+ ( ptr_count ( element_ty1 ) , non_ptr ( element_ty1 ) )
1344
1351
}
1345
1352
_ => {
1346
1353
require ! (
1347
1354
false ,
1348
1355
"expected element type `{}` of second argument `{}` \
1349
- to be a pointer to the element type `{}` of the first \
1350
- argument `{}`, found `{}` != `*mut {}`",
1351
- arg_tys [ 1 ] . simd_type ( tcx ) ,
1356
+ to be a pointer to the element type `{}` of the first \
1357
+ argument `{}`, found `{}` != `*mut {}`",
1358
+ element_ty1 ,
1352
1359
arg_tys[ 1 ] ,
1353
1360
in_elem,
1354
1361
in_ty,
1355
- arg_tys [ 1 ] . simd_type ( tcx ) ,
1362
+ element_ty1 ,
1356
1363
in_elem
1357
1364
) ;
1358
1365
unreachable ! ( ) ;
1359
1366
}
1360
1367
} ;
1361
1368
assert ! ( pointer_count > 0 ) ;
1362
- assert_eq ! ( pointer_count - 1 , ptr_count( arg_tys [ 0 ] . simd_type ( tcx ) ) ) ;
1363
- assert_eq ! ( underlying_ty, non_ptr( arg_tys [ 0 ] . simd_type ( tcx ) ) ) ;
1369
+ assert_eq ! ( pointer_count - 1 , ptr_count( element_ty0 ) ) ;
1370
+ assert_eq ! ( underlying_ty, non_ptr( element_ty0 ) ) ;
1364
1371
1365
1372
// The element type of the third argument must be a signed integer type of any width:
1366
- match arg_tys [ 2 ] . simd_type ( tcx ) . kind ( ) {
1373
+ match element_ty2 . kind ( ) {
1367
1374
ty:: Int ( _) => ( ) ,
1368
1375
_ => {
1369
1376
require ! (
1370
1377
false ,
1371
1378
"expected element type `{}` of third argument `{}` \
1372
- to be a signed integer type",
1373
- arg_tys [ 2 ] . simd_type ( tcx ) ,
1379
+ be a signed integer type",
1380
+ element_ty2 ,
1374
1381
arg_tys[ 2 ]
1375
1382
) ;
1376
1383
}
@@ -1567,7 +1574,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
1567
1574
1568
1575
if name == sym:: simd_cast {
1569
1576
require_simd ! ( ret_ty, "return" ) ;
1570
- let out_len = ret_ty. simd_size ( tcx) ;
1577
+ let ( out_len, out_elem ) = ret_ty. simd_size_and_type ( bx . tcx ( ) ) ;
1571
1578
require ! (
1572
1579
in_len == out_len,
1573
1580
"expected return type with length {} (same as input type `{}`), \
@@ -1578,8 +1585,6 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
1578
1585
out_len
1579
1586
) ;
1580
1587
// casting cares about nominal type, not just structural type
1581
- let out_elem = ret_ty. simd_type ( tcx) ;
1582
-
1583
1588
if in_elem == out_elem {
1584
1589
return Ok ( args[ 0 ] . immediate ( ) ) ;
1585
1590
}
@@ -1695,7 +1700,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
1695
1700
return_error ! (
1696
1701
"expected element type `{}` of vector type `{}` \
1697
1702
to be a signed or unsigned integer type",
1698
- arg_tys[ 0 ] . simd_type ( tcx) ,
1703
+ arg_tys[ 0 ] . simd_size_and_type ( bx . tcx( ) ) . 1 ,
1699
1704
arg_tys[ 0 ]
1700
1705
) ;
1701
1706
}
0 commit comments