Fix maximum SIMD lane count, and expose it to other crates. Disallow SIMD vectors with non-power-of-two lengths.
This commit is contained in:
parent
07db2bfe39
commit
8451656fe7
17 changed files with 151 additions and 172 deletions
|
@ -12,6 +12,7 @@ use rustc_hir::{ItemKind, Node};
|
|||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::layout::MAX_SIMD_LANES;
|
||||
use rustc_middle::ty::subst::GenericArgKind;
|
||||
use rustc_middle::ty::util::{Discr, IntTypeExt, Representability};
|
||||
use rustc_middle::ty::{self, ParamEnv, RegionKind, ToPredicate, Ty, TyCtxt};
|
||||
|
@ -1108,12 +1109,22 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
|||
if len == 0 {
|
||||
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
return;
|
||||
} else if len > 65536 {
|
||||
} else if !len.is_power_of_two() {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
sp,
|
||||
E0075,
|
||||
"SIMD vector cannot have more than 65536 elements"
|
||||
"SIMD vector length must be a power of two"
|
||||
)
|
||||
.emit();
|
||||
return;
|
||||
} else if len > MAX_SIMD_LANES {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
sp,
|
||||
E0075,
|
||||
"SIMD vector cannot have more than {} elements",
|
||||
MAX_SIMD_LANES,
|
||||
)
|
||||
.emit();
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue