@@ -5,6 +5,7 @@ use rustc_middle::mir::*;
5
5
use rustc_middle:: ty:: subst:: SubstsRef ;
6
6
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
7
7
use rustc_span:: symbol:: { sym, Symbol } ;
8
+ use rustc_span:: Span ;
8
9
use rustc_target:: spec:: abi:: Abi ;
9
10
10
11
pub struct LowerIntrinsics ;
@@ -119,6 +120,9 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
119
120
terminator. kind = TerminatorKind :: Goto { target } ;
120
121
}
121
122
}
123
+ _ if intrinsic_name. as_str ( ) . starts_with ( "simd_shuffle" ) => {
124
+ validate_simd_shuffle ( tcx, args, terminator. source_info . span ) ;
125
+ }
122
126
_ => { }
123
127
}
124
128
}
@@ -132,9 +136,19 @@ fn resolve_rust_intrinsic(
132
136
) -> Option < ( Symbol , SubstsRef < ' tcx > ) > {
133
137
if let ty:: FnDef ( def_id, substs) = * func_ty. kind ( ) {
134
138
let fn_sig = func_ty. fn_sig ( tcx) ;
135
- if fn_sig . abi ( ) == Abi :: RustIntrinsic {
139
+ if let Abi :: RustIntrinsic | Abi :: PlatformIntrinsic = fn_sig . abi ( ) {
136
140
return Some ( ( tcx. item_name ( def_id) , substs) ) ;
137
141
}
138
142
}
139
143
None
140
144
}
145
+
146
+ fn validate_simd_shuffle ( tcx : TyCtxt < ' tcx > , args : & [ Operand < ' tcx > ] , span : Span ) {
147
+ match & args[ 2 ] {
148
+ Operand :: Constant ( _) => { } // all good
149
+ _ => {
150
+ let msg = format ! ( "last argument of `simd_shuffle` is required to be a `const` item" ) ;
151
+ tcx. sess . span_err ( span, & msg) ;
152
+ }
153
+ }
154
+ }
0 commit comments