mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Sync from rust 03a119b0b0
This commit is contained in:
commit
82988111b9
@ -39,8 +39,8 @@ fn codegen_inner(
|
||||
if kind == AllocatorKind::Default {
|
||||
for method in ALLOCATOR_METHODS {
|
||||
let mut arg_tys = Vec::with_capacity(method.inputs.len());
|
||||
for ty in method.inputs.iter() {
|
||||
match *ty {
|
||||
for input in method.inputs.iter() {
|
||||
match input.ty {
|
||||
AllocatorTy::Layout => {
|
||||
arg_tys.push(usize_ty); // size
|
||||
arg_tys.push(usize_ty); // align
|
||||
|
@ -477,7 +477,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
|
||||
#[inline]
|
||||
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
|
||||
if let layout::LayoutError::SizeOverflow(_) = err {
|
||||
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
|
||||
self.0.sess.span_fatal(span, err.to_string())
|
||||
} else {
|
||||
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
|
||||
|
@ -1155,6 +1155,20 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
ret.write_cvalue(fx, CValue::by_val(is_eq_value, ret.layout()));
|
||||
}
|
||||
|
||||
sym::compare_bytes => {
|
||||
intrinsic_args!(fx, args => (lhs_ptr, rhs_ptr, bytes_val); intrinsic);
|
||||
let lhs_ptr = lhs_ptr.load_scalar(fx);
|
||||
let rhs_ptr = rhs_ptr.load_scalar(fx);
|
||||
let bytes_val = bytes_val.load_scalar(fx);
|
||||
|
||||
let params = vec![AbiParam::new(fx.pointer_type); 3];
|
||||
let returns = vec![AbiParam::new(types::I32)];
|
||||
let args = &[lhs_ptr, rhs_ptr, bytes_val];
|
||||
// Here we assume that the `memcmp` provided by the target is a NOP for size 0.
|
||||
let cmp = fx.lib_call("memcmp", params, returns, args)[0];
|
||||
ret.write_cvalue(fx, CValue::by_val(cmp, ret.layout()));
|
||||
}
|
||||
|
||||
sym::const_allocate => {
|
||||
intrinsic_args!(fx, args => (_size, _align); intrinsic);
|
||||
|
||||
|
@ -117,8 +117,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
});
|
||||
}
|
||||
|
||||
// simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U
|
||||
_ if intrinsic.as_str().starts_with("simd_shuffle") => {
|
||||
// simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U
|
||||
sym::simd_shuffle => {
|
||||
let (x, y, idx) = match args {
|
||||
[x, y, idx] => (x, y, idx),
|
||||
_ => {
|
||||
@ -133,36 +133,26 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
return;
|
||||
}
|
||||
|
||||
// If this intrinsic is the older "simd_shuffleN" form, simply parse the integer.
|
||||
// If there is no suffix, use the index array length.
|
||||
let n: u16 = if intrinsic == sym::simd_shuffle {
|
||||
// Make sure this is actually an array, since typeck only checks the length-suffixed
|
||||
// version of this intrinsic.
|
||||
let idx_ty = fx.monomorphize(idx.ty(fx.mir, fx.tcx));
|
||||
match idx_ty.kind() {
|
||||
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => len
|
||||
.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
|
||||
.unwrap_or_else(|| {
|
||||
span_bug!(span, "could not evaluate shuffle index array length")
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
_ => {
|
||||
fx.tcx.sess.span_err(
|
||||
span,
|
||||
format!(
|
||||
"simd_shuffle index must be an array of `u32`, got `{}`",
|
||||
idx_ty,
|
||||
),
|
||||
);
|
||||
// Prevent verifier error
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
return;
|
||||
}
|
||||
// Make sure this is actually an array, since typeck only checks the length-suffixed
|
||||
// version of this intrinsic.
|
||||
let idx_ty = fx.monomorphize(idx.ty(fx.mir, fx.tcx));
|
||||
let n: u16 = match idx_ty.kind() {
|
||||
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => len
|
||||
.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
|
||||
.unwrap_or_else(|| {
|
||||
span_bug!(span, "could not evaluate shuffle index array length")
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
_ => {
|
||||
fx.tcx.sess.span_err(
|
||||
span,
|
||||
format!("simd_shuffle index must be an array of `u32`, got `{}`", idx_ty),
|
||||
);
|
||||
// Prevent verifier error
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// FIXME remove this case
|
||||
intrinsic.as_str()["simd_shuffle".len()..].parse().unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(x.layout(), y.layout());
|
||||
@ -179,7 +169,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
let indexes = {
|
||||
use rustc_middle::mir::interpret::*;
|
||||
let idx_const = crate::constant::mir_operand_get_const_val(fx, idx)
|
||||
.expect("simd_shuffle* idx not const");
|
||||
.expect("simd_shuffle idx not const");
|
||||
|
||||
let idx_bytes = match idx_const {
|
||||
ConstValue::ByRef { alloc, offset } => {
|
||||
|
Loading…
Reference in New Issue
Block a user