ty::TyStruct(..) => {
if t.is_simd() {
- let llet = type_of(cx, t.simd_type(cx.tcx()));
+ let e = t.simd_type(cx.tcx());
+ if !e.is_machine() {
+ cx.sess().fatal(&format!("monomorphising SIMD type `{}` with \
+ a non-machine element type `{}`",
+ t, e))
+ }
+ let llet = type_of(cx, e);
let n = t.simd_size(cx.tcx()) as u64;
ensure_array_fits_in_address_space(cx, llet, n, t);
Type::vector(&llet, n)
}
ty::TyStruct(def, ref substs) => {
if t.is_simd() {
- let llet = in_memory_type_of(cx, t.simd_type(cx.tcx()));
+ let e = t.simd_type(cx.tcx());
+ if !e.is_machine() {
+ cx.sess().fatal(&format!("monomorphising SIMD type `{}` with \
+ a non-machine element type `{}`",
+ t, e))
+ }
+ let llet = in_memory_type_of(cx, e);
let n = t.simd_size(cx.tcx()) as u64;
ensure_array_fits_in_address_space(cx, llet, n, t);
Type::vector(&llet, n)
pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
let t = tcx.node_id_to_type(id);
- if t.needs_subst() {
- span_err!(tcx.sess, sp, E0074, "SIMD vector cannot be generic");
- return;
- }
match t.sty {
ty::TyStruct(def, substs) => {
let fields = &def.struct_variant().fields;
span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous");
return;
}
- if !e.is_machine() {
- span_err!(tcx.sess, sp, E0077,
- "SIMD vector element type should be machine type");
- return;
+ match e.sty {
+ ty::TyParam(_) => { /* struct<T>(T, T, T, T) is ok */ }
+ _ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ }
+ _ => {
+ span_err!(tcx.sess, sp, E0077,
+ "SIMD vector element type should be machine type");
+ return;
+ }
}
}
_ => ()