Skip to content

Commit 3d738b0

Browse files
Inline is_machine into check_simd
1 parent d03683c commit 3d738b0

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

compiler/rustc_middle/src/ty/sty.rs

-8
Original file line numberDiff line numberDiff line change
@@ -1888,14 +1888,6 @@ impl<'tcx> TyS<'tcx> {
18881888
matches!(self.kind(), Int(ty::IntTy::Isize) | Uint(ty::UintTy::Usize))
18891889
}
18901890

1891-
#[inline]
1892-
pub fn is_machine(&self) -> bool {
1893-
// Yes, RawPtr is a "machine" type for these purposes.
1894-
// LLVM uses a vector-of-pointers model for scatter/gather ops,
1895-
// which typically use a base pointer and vector of signed integers.
1896-
matches!(self.kind(), Int(..) | Uint(..) | Float(..) | RawPtr(..))
1897-
}
1898-
18991891
#[inline]
19001892
pub fn has_concrete_skeleton(&self) -> bool {
19011893
!matches!(self.kind(), Param(_) | Infer(_) | Error(_))

compiler/rustc_typeck/src/check/check.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1214,10 +1214,19 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
12141214
}
12151215
}
12161216

1217+
// Check that we use types valid for use in the lanes of a SIMD "vector register"
1218+
// These are scalar types which directly match a "machine" type
1219+
// Yes: Integers, floats, "thin" pointers
1220+
// No: char, "fat" pointers, compound types
12171221
match e.kind() {
1218-
ty::Param(_) => { /* struct<T>(T, T, T, T) is ok */ }
1219-
_ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ }
1220-
ty::Array(ty, _c) if ty.is_machine() => { /* struct([f32; 4]) */ }
1222+
ty::Param(_) => (), // pass struct<T>(T, T, T, T) through, let monomorphization catch errors
1223+
ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_) => (), // struct(u8, u8, u8, u8) is ok
1224+
ty::Array(t, _clen)
1225+
if matches!(
1226+
t.kind(),
1227+
ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_)
1228+
) =>
1229+
{ /* struct([f32; 4]) is ok */ }
12211230
_ => {
12221231
struct_span_err!(
12231232
tcx.sess,

0 commit comments

Comments
 (0)