@@ -17,76 +17,52 @@ fn validate_simd_type(fx: &mut FunctionCx<'_, '_, '_>, intrinsic: Symbol, span:
17
17
18
18
macro simd_cmp( $fx: expr, $cc_u: ident|$cc_s: ident|$cc_f: ident( $x: ident, $y: ident) -> $ret: ident) {
19
19
// FIXME use vector instructions when possible
20
- simd_pair_for_each_lane (
21
- $fx,
22
- $x,
23
- $y,
24
- $ret,
25
- & |fx, lane_layout, res_lane_layout, x_lane, y_lane| {
26
- let res_lane = match lane_layout. ty . kind ( ) {
27
- ty:: Uint ( _) => fx. bcx . ins ( ) . icmp ( IntCC :: $cc_u, x_lane, y_lane) ,
28
- ty:: Int ( _) => fx. bcx . ins ( ) . icmp ( IntCC :: $cc_s, x_lane, y_lane) ,
29
- ty:: Float ( _) => fx. bcx . ins ( ) . fcmp ( FloatCC :: $cc_f, x_lane, y_lane) ,
30
- _ => unreachable ! ( "{:?}" , lane_layout. ty) ,
31
- } ;
20
+ simd_pair_for_each_lane ( $fx, $x, $y, $ret, & |fx, lane_ty, res_lane_ty, x_lane, y_lane| {
21
+ let res_lane = match lane_ty. kind ( ) {
22
+ ty:: Uint ( _) => fx. bcx . ins ( ) . icmp ( IntCC :: $cc_u, x_lane, y_lane) ,
23
+ ty:: Int ( _) => fx. bcx . ins ( ) . icmp ( IntCC :: $cc_s, x_lane, y_lane) ,
24
+ ty:: Float ( _) => fx. bcx . ins ( ) . fcmp ( FloatCC :: $cc_f, x_lane, y_lane) ,
25
+ _ => unreachable ! ( "{:?}" , lane_ty) ,
26
+ } ;
32
27
33
- let ty = fx. clif_type ( res_lane_layout . ty ) . unwrap ( ) ;
28
+ let ty = fx. clif_type ( res_lane_ty ) . unwrap ( ) ;
34
29
35
- let res_lane = fx. bcx . ins ( ) . bint ( ty, res_lane) ;
36
- fx. bcx . ins ( ) . ineg ( res_lane)
37
- } ,
38
- ) ;
30
+ let res_lane = fx. bcx . ins ( ) . bint ( ty, res_lane) ;
31
+ fx. bcx . ins ( ) . ineg ( res_lane)
32
+ } ) ;
39
33
}
40
34
41
35
macro simd_int_binop ( $fx: expr, $op_u: ident|$op_s: ident( $x: ident, $y: ident) -> $ret: ident) {
42
36
// FIXME use vector instructions when possible
43
- simd_pair_for_each_lane (
44
- $fx,
45
- $x,
46
- $y,
47
- $ret,
48
- & |fx, lane_layout, _ret_lane_layout, x_lane, y_lane| {
49
- match lane_layout. ty . kind ( ) {
50
- ty:: Uint ( _) => fx. bcx . ins ( ) . $op_u( x_lane, y_lane) ,
51
- ty:: Int ( _) => fx. bcx . ins ( ) . $op_s( x_lane, y_lane) ,
52
- _ => unreachable ! ( "{:?}" , lane_layout. ty) ,
53
- }
54
- } ,
55
- ) ;
37
+ simd_pair_for_each_lane ( $fx, $x, $y, $ret, & |fx, lane_ty, _ret_lane_ty, x_lane, y_lane| {
38
+ match lane_ty. kind ( ) {
39
+ ty:: Uint ( _) => fx. bcx . ins ( ) . $op_u( x_lane, y_lane) ,
40
+ ty:: Int ( _) => fx. bcx . ins ( ) . $op_s( x_lane, y_lane) ,
41
+ _ => unreachable ! ( "{:?}" , lane_ty) ,
42
+ }
43
+ } ) ;
56
44
}
57
45
58
46
macro simd_int_flt_binop ( $fx: expr, $op_u: ident|$op_s: ident|$op_f: ident( $x: ident, $y: ident) -> $ret: ident) {
59
47
// FIXME use vector instructions when possible
60
- simd_pair_for_each_lane (
61
- $fx,
62
- $x,
63
- $y,
64
- $ret,
65
- & |fx, lane_layout, _ret_lane_layout, x_lane, y_lane| {
66
- match lane_layout. ty . kind ( ) {
67
- ty:: Uint ( _) => fx. bcx . ins ( ) . $op_u( x_lane, y_lane) ,
68
- ty:: Int ( _) => fx. bcx . ins ( ) . $op_s( x_lane, y_lane) ,
69
- ty:: Float ( _) => fx. bcx . ins ( ) . $op_f( x_lane, y_lane) ,
70
- _ => unreachable ! ( "{:?}" , lane_layout. ty) ,
71
- }
72
- } ,
73
- ) ;
48
+ simd_pair_for_each_lane ( $fx, $x, $y, $ret, & |fx, lane_ty, _ret_lane_ty, x_lane, y_lane| {
49
+ match lane_ty. kind ( ) {
50
+ ty:: Uint ( _) => fx. bcx . ins ( ) . $op_u( x_lane, y_lane) ,
51
+ ty:: Int ( _) => fx. bcx . ins ( ) . $op_s( x_lane, y_lane) ,
52
+ ty:: Float ( _) => fx. bcx . ins ( ) . $op_f( x_lane, y_lane) ,
53
+ _ => unreachable ! ( "{:?}" , lane_ty) ,
54
+ }
55
+ } ) ;
74
56
}
75
57
76
58
macro simd_flt_binop ( $fx: expr, $op: ident( $x: ident, $y: ident) -> $ret: ident) {
77
59
// FIXME use vector instructions when possible
78
- simd_pair_for_each_lane (
79
- $fx,
80
- $x,
81
- $y,
82
- $ret,
83
- & |fx, lane_layout, _ret_lane_layout, x_lane, y_lane| {
84
- match lane_layout. ty . kind ( ) {
85
- ty:: Float ( _) => fx. bcx . ins ( ) . $op( x_lane, y_lane) ,
86
- _ => unreachable ! ( "{:?}" , lane_layout. ty) ,
87
- }
88
- } ,
89
- ) ;
60
+ simd_pair_for_each_lane ( $fx, $x, $y, $ret, & |fx, lane_ty, _ret_lane_ty, x_lane, y_lane| {
61
+ match lane_ty. kind ( ) {
62
+ ty:: Float ( _) => fx. bcx . ins ( ) . $op( x_lane, y_lane) ,
63
+ _ => unreachable ! ( "{:?}" , lane_ty) ,
64
+ }
65
+ } ) ;
90
66
}
91
67
92
68
pub ( super ) fn codegen_simd_intrinsic_call < ' tcx > (
@@ -105,13 +81,13 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
105
81
106
82
simd_cast, ( c a) {
107
83
validate_simd_type( fx, intrinsic, span, a. layout( ) . ty) ;
108
- simd_for_each_lane( fx, a, ret, & |fx, lane_layout , ret_lane_layout , lane| {
109
- let ret_lane_ty = fx. clif_type( ret_lane_layout . ty ) . unwrap( ) ;
84
+ simd_for_each_lane( fx, a, ret, & |fx, lane_ty , ret_lane_ty , lane| {
85
+ let ret_lane_clif_ty = fx. clif_type( ret_lane_ty ) . unwrap( ) ;
110
86
111
- let from_signed = type_sign( lane_layout . ty ) ;
112
- let to_signed = type_sign( ret_lane_layout . ty ) ;
87
+ let from_signed = type_sign( lane_ty ) ;
88
+ let to_signed = type_sign( ret_lane_ty ) ;
113
89
114
- clif_int_or_float_cast( fx, lane, from_signed, ret_lane_ty , to_signed)
90
+ clif_int_or_float_cast( fx, lane, from_signed, ret_lane_clif_ty , to_signed)
115
91
} ) ;
116
92
} ;
117
93
@@ -277,8 +253,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
277
253
278
254
simd_neg, ( c a) {
279
255
validate_simd_type( fx, intrinsic, span, a. layout( ) . ty) ;
280
- simd_for_each_lane( fx, a, ret, & |fx, lane_layout , _ret_lane_layout , lane| {
281
- match lane_layout . ty . kind( ) {
256
+ simd_for_each_lane( fx, a, ret, & |fx, lane_ty , _ret_lane_ty , lane| {
257
+ match lane_ty . kind( ) {
282
258
ty:: Int ( _) => fx. bcx. ins( ) . ineg( lane) ,
283
259
ty:: Float ( _) => fx. bcx. ins( ) . fneg( lane) ,
284
260
_ => unreachable!( ) ,
@@ -288,14 +264,14 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
288
264
289
265
simd_fabs, ( c a) {
290
266
validate_simd_type( fx, intrinsic, span, a. layout( ) . ty) ;
291
- simd_for_each_lane( fx, a, ret, & |fx, _lane_layout , _ret_lane_layout , lane| {
267
+ simd_for_each_lane( fx, a, ret, & |fx, _lane_ty , _ret_lane_ty , lane| {
292
268
fx. bcx. ins( ) . fabs( lane)
293
269
} ) ;
294
270
} ;
295
271
296
272
simd_fsqrt, ( c a) {
297
273
validate_simd_type( fx, intrinsic, span, a. layout( ) . ty) ;
298
- simd_for_each_lane( fx, a, ret, & |fx, _lane_layout , _ret_lane_layout , lane| {
274
+ simd_for_each_lane( fx, a, ret, & |fx, _lane_ty , _ret_lane_ty , lane| {
299
275
fx. bcx. ins( ) . sqrt( lane)
300
276
} ) ;
301
277
} ;
@@ -318,8 +294,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
318
294
} ;
319
295
simd_rem, ( c x, c y) {
320
296
validate_simd_type( fx, intrinsic, span, x. layout( ) . ty) ;
321
- simd_pair_for_each_lane( fx, x, y, ret, & |fx, lane_layout , _ret_lane_layout , x_lane, y_lane| {
322
- match lane_layout . ty . kind( ) {
297
+ simd_pair_for_each_lane( fx, x, y, ret, & |fx, lane_ty , _ret_lane_ty , x_lane, y_lane| {
298
+ match lane_ty . kind( ) {
323
299
ty:: Uint ( _) => fx. bcx. ins( ) . urem( x_lane, y_lane) ,
324
300
ty:: Int ( _) => fx. bcx. ins( ) . srem( x_lane, y_lane) ,
325
301
ty:: Float ( FloatTy :: F32 ) => fx. lib_call(
@@ -334,7 +310,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
334
310
vec![ AbiParam :: new( types:: F64 ) ] ,
335
311
& [ x_lane, y_lane] ,
336
312
) [ 0 ] ,
337
- _ => unreachable!( "{:?}" , lane_layout . ty ) ,
313
+ _ => unreachable!( "{:?}" , lane_ty ) ,
338
314
}
339
315
} ) ;
340
316
} ;
@@ -393,8 +369,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
393
369
394
370
simd_round, ( c a) {
395
371
validate_simd_type( fx, intrinsic, span, a. layout( ) . ty) ;
396
- simd_for_each_lane( fx, a, ret, & |fx, lane_layout , _ret_lane_layout , lane| {
397
- match lane_layout . ty . kind( ) {
372
+ simd_for_each_lane( fx, a, ret, & |fx, lane_ty , _ret_lane_ty , lane| {
373
+ match lane_ty . kind( ) {
398
374
ty:: Float ( FloatTy :: F32 ) => fx. lib_call(
399
375
"roundf" ,
400
376
vec![ AbiParam :: new( types:: F32 ) ] ,
@@ -407,33 +383,33 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
407
383
vec![ AbiParam :: new( types:: F64 ) ] ,
408
384
& [ lane] ,
409
385
) [ 0 ] ,
410
- _ => unreachable!( "{:?}" , lane_layout . ty ) ,
386
+ _ => unreachable!( "{:?}" , lane_ty ) ,
411
387
}
412
388
} ) ;
413
389
} ;
414
390
simd_ceil, ( c a) {
415
391
validate_simd_type( fx, intrinsic, span, a. layout( ) . ty) ;
416
- simd_for_each_lane( fx, a, ret, & |fx, _lane_layout , _ret_lane_layout , lane| {
392
+ simd_for_each_lane( fx, a, ret, & |fx, _lane_ty , _ret_lane_ty , lane| {
417
393
fx. bcx. ins( ) . ceil( lane)
418
394
} ) ;
419
395
} ;
420
396
simd_floor, ( c a) {
421
397
validate_simd_type( fx, intrinsic, span, a. layout( ) . ty) ;
422
- simd_for_each_lane( fx, a, ret, & |fx, _lane_layout , _ret_lane_layout , lane| {
398
+ simd_for_each_lane( fx, a, ret, & |fx, _lane_ty , _ret_lane_ty , lane| {
423
399
fx. bcx. ins( ) . floor( lane)
424
400
} ) ;
425
401
} ;
426
402
simd_trunc, ( c a) {
427
403
validate_simd_type( fx, intrinsic, span, a. layout( ) . ty) ;
428
- simd_for_each_lane( fx, a, ret, & |fx, _lane_layout , _ret_lane_layout , lane| {
404
+ simd_for_each_lane( fx, a, ret, & |fx, _lane_ty , _ret_lane_ty , lane| {
429
405
fx. bcx. ins( ) . trunc( lane)
430
406
} ) ;
431
407
} ;
432
408
433
409
simd_reduce_add_ordered | simd_reduce_add_unordered, ( c v, v acc) {
434
410
validate_simd_type( fx, intrinsic, span, v. layout( ) . ty) ;
435
- simd_reduce( fx, v, Some ( acc) , ret, & |fx, lane_layout , a, b| {
436
- if lane_layout . ty . is_floating_point( ) {
411
+ simd_reduce( fx, v, Some ( acc) , ret, & |fx, lane_ty , a, b| {
412
+ if lane_ty . is_floating_point( ) {
437
413
fx. bcx. ins( ) . fadd( a, b)
438
414
} else {
439
415
fx. bcx. ins( ) . iadd( a, b)
@@ -443,8 +419,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
443
419
444
420
simd_reduce_mul_ordered | simd_reduce_mul_unordered, ( c v, v acc) {
445
421
validate_simd_type( fx, intrinsic, span, v. layout( ) . ty) ;
446
- simd_reduce( fx, v, Some ( acc) , ret, & |fx, lane_layout , a, b| {
447
- if lane_layout . ty . is_floating_point( ) {
422
+ simd_reduce( fx, v, Some ( acc) , ret, & |fx, lane_ty , a, b| {
423
+ if lane_ty . is_floating_point( ) {
448
424
fx. bcx. ins( ) . fmul( a, b)
449
425
} else {
450
426
fx. bcx. ins( ) . imul( a, b)
@@ -464,23 +440,23 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
464
440
465
441
simd_reduce_and, ( c v) {
466
442
validate_simd_type( fx, intrinsic, span, v. layout( ) . ty) ;
467
- simd_reduce( fx, v, None , ret, & |fx, _layout , a, b| fx. bcx. ins( ) . band( a, b) ) ;
443
+ simd_reduce( fx, v, None , ret, & |fx, _ty , a, b| fx. bcx. ins( ) . band( a, b) ) ;
468
444
} ;
469
445
470
446
simd_reduce_or, ( c v) {
471
447
validate_simd_type( fx, intrinsic, span, v. layout( ) . ty) ;
472
- simd_reduce( fx, v, None , ret, & |fx, _layout , a, b| fx. bcx. ins( ) . bor( a, b) ) ;
448
+ simd_reduce( fx, v, None , ret, & |fx, _ty , a, b| fx. bcx. ins( ) . bor( a, b) ) ;
473
449
} ;
474
450
475
451
simd_reduce_xor, ( c v) {
476
452
validate_simd_type( fx, intrinsic, span, v. layout( ) . ty) ;
477
- simd_reduce( fx, v, None , ret, & |fx, _layout , a, b| fx. bcx. ins( ) . bxor( a, b) ) ;
453
+ simd_reduce( fx, v, None , ret, & |fx, _ty , a, b| fx. bcx. ins( ) . bxor( a, b) ) ;
478
454
} ;
479
455
480
456
simd_reduce_min, ( c v) {
481
457
validate_simd_type( fx, intrinsic, span, v. layout( ) . ty) ;
482
- simd_reduce( fx, v, None , ret, & |fx, layout , a, b| {
483
- let lt = match layout . ty. kind( ) {
458
+ simd_reduce( fx, v, None , ret, & |fx, ty , a, b| {
459
+ let lt = match ty. kind( ) {
484
460
ty:: Int ( _) => fx. bcx. ins( ) . icmp( IntCC :: SignedLessThan , a, b) ,
485
461
ty:: Uint ( _) => fx. bcx. ins( ) . icmp( IntCC :: UnsignedLessThan , a, b) ,
486
462
ty:: Float ( _) => fx. bcx. ins( ) . fcmp( FloatCC :: LessThan , a, b) ,
@@ -492,8 +468,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
492
468
493
469
simd_reduce_max, ( c v) {
494
470
validate_simd_type( fx, intrinsic, span, v. layout( ) . ty) ;
495
- simd_reduce( fx, v, None , ret, & |fx, layout , a, b| {
496
- let gt = match layout . ty. kind( ) {
471
+ simd_reduce( fx, v, None , ret, & |fx, ty , a, b| {
472
+ let gt = match ty. kind( ) {
497
473
ty:: Int ( _) => fx. bcx. ins( ) . icmp( IntCC :: SignedGreaterThan , a, b) ,
498
474
ty:: Uint ( _) => fx. bcx. ins( ) . icmp( IntCC :: UnsignedGreaterThan , a, b) ,
499
475
ty:: Float ( _) => fx. bcx. ins( ) . fcmp( FloatCC :: GreaterThan , a, b) ,
0 commit comments