@@ -2,7 +2,7 @@ use rustc_index::vec::Idx;
2
2
use rustc:: middle:: lang_items;
3
3
use rustc:: ty:: { self , Ty , TypeFoldable , Instance } ;
4
4
use rustc:: ty:: layout:: { self , LayoutOf , HasTyCtxt , FnTypeExt } ;
5
- use rustc:: mir:: { self , Place , PlaceBase , Static , StaticKind } ;
5
+ use rustc:: mir:: { self , PlaceBase , Static , StaticKind } ;
6
6
use rustc:: mir:: interpret:: PanicInfo ;
7
7
use rustc_target:: abi:: call:: { ArgType , FnType , PassMode } ;
8
8
use rustc_target:: spec:: abi:: Abi ;
@@ -630,53 +630,43 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
630
630
// checked by const-qualification, which also
631
631
// promotes any complex rvalues to constants.
632
632
if i == 2 && intrinsic. unwrap ( ) . starts_with ( "simd_shuffle" ) {
633
- match * arg {
633
+ match arg {
634
634
// The shuffle array argument is usually not an explicit constant,
635
635
// but specified directly in the code. This means it gets promoted
636
636
// and we can then extract the value by evaluating the promoted.
637
- mir:: Operand :: Copy (
638
- Place {
639
- base : PlaceBase :: Static ( box Static {
640
- kind : StaticKind :: Promoted ( promoted, _) ,
637
+ mir:: Operand :: Copy ( place) | mir:: Operand :: Move ( place) => {
638
+ if let mir:: PlaceRef {
639
+ base :
640
+ & PlaceBase :: Static ( box Static {
641
+ kind : StaticKind :: Promoted ( promoted, _) ,
642
+ ty,
643
+ def_id : _,
644
+ } ) ,
645
+ projection : & [ ] ,
646
+ } = place. as_ref ( )
647
+ {
648
+ let param_env = ty:: ParamEnv :: reveal_all ( ) ;
649
+ let cid = mir:: interpret:: GlobalId {
650
+ instance : self . instance ,
651
+ promoted : Some ( promoted) ,
652
+ } ;
653
+ let c = bx. tcx ( ) . const_eval ( param_env. and ( cid) ) ;
654
+ let ( llval, ty) = self . simd_shuffle_indices (
655
+ & bx,
656
+ terminator. source_info . span ,
641
657
ty,
642
- def_id : _,
643
- } ) ,
644
- projection : box [ ] ,
658
+ c,
659
+ ) ;
660
+ return OperandRef {
661
+ val : Immediate ( llval) ,
662
+ layout : bx. layout_of ( ty) ,
663
+ } ;
664
+ } else {
665
+ span_bug ! ( span, "shuffle indices must be constant" ) ;
645
666
}
646
- ) |
647
- mir:: Operand :: Move (
648
- Place {
649
- base : PlaceBase :: Static ( box Static {
650
- kind : StaticKind :: Promoted ( promoted, _) ,
651
- ty,
652
- def_id : _,
653
- } ) ,
654
- projection : box [ ] ,
655
- }
656
- ) => {
657
- let param_env = ty:: ParamEnv :: reveal_all ( ) ;
658
- let cid = mir:: interpret:: GlobalId {
659
- instance : self . instance ,
660
- promoted : Some ( promoted) ,
661
- } ;
662
- let c = bx. tcx ( ) . const_eval ( param_env. and ( cid) ) ;
663
- let ( llval, ty) = self . simd_shuffle_indices (
664
- & bx,
665
- terminator. source_info . span ,
666
- ty,
667
- c,
668
- ) ;
669
- return OperandRef {
670
- val : Immediate ( llval) ,
671
- layout : bx. layout_of ( ty) ,
672
- } ;
673
-
674
- }
675
- mir:: Operand :: Copy ( _) |
676
- mir:: Operand :: Move ( _) => {
677
- span_bug ! ( span, "shuffle indices must be constant" ) ;
678
667
}
679
- mir:: Operand :: Constant ( ref constant) => {
668
+
669
+ mir:: Operand :: Constant ( constant) => {
680
670
let c = self . eval_mir_constant ( constant) ;
681
671
let ( llval, ty) = self . simd_shuffle_indices (
682
672
& bx,
@@ -1117,10 +1107,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1117
1107
if fn_ret. is_ignore ( ) {
1118
1108
return ReturnDest :: Nothing ;
1119
1109
}
1120
- let dest = if let mir:: Place {
1121
- base : mir:: PlaceBase :: Local ( index) ,
1122
- projection : box [ ] ,
1123
- } = * dest {
1110
+ let dest = if let Some ( index) = dest. as_local ( ) {
1124
1111
match self . locals [ index] {
1125
1112
LocalRef :: Place ( dest) => dest,
1126
1113
LocalRef :: UnsizedPlace ( _) => bug ! ( "return type must be sized" ) ,
@@ -1178,10 +1165,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1178
1165
src : & mir:: Operand < ' tcx > ,
1179
1166
dst : & mir:: Place < ' tcx >
1180
1167
) {
1181
- if let mir:: Place {
1182
- base : mir:: PlaceBase :: Local ( index) ,
1183
- projection : box [ ] ,
1184
- } = * dst {
1168
+ if let Some ( index) = dst. as_local ( ) {
1185
1169
match self . locals [ index] {
1186
1170
LocalRef :: Place ( place) => self . codegen_transmute_into ( bx, src, place) ,
1187
1171
LocalRef :: UnsizedPlace ( _) => bug ! ( "transmute must not involve unsized locals" ) ,
0 commit comments