mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Update cranelift
This commit is contained in:
parent
37a6c04718
commit
982382dc03
@ -832,6 +832,16 @@ fn codegen_stmt<'tcx>(
|
||||
}
|
||||
}
|
||||
StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"),
|
||||
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
|
||||
src,
|
||||
dst,
|
||||
count,
|
||||
}) => {
|
||||
let dst = codegen_operand(fx, dst).load_scalar(fx);
|
||||
let src = codegen_operand(fx, src).load_scalar(fx);
|
||||
let count = codegen_operand(fx, count).load_scalar(fx);
|
||||
fx.bcx.call_memcpy(fx.cx.module.target_config(), dst, src, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![warn(unused_lifetimes)]
|
||||
#![warn(unreachable_pub)]
|
||||
#![feature(box_patterns)]
|
||||
|
||||
extern crate snap;
|
||||
#[macro_use]
|
||||
|
@ -118,23 +118,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
mir::StatementKind::CopyNonOverlapping(box mir::CopyNonOverlapping {
|
||||
ref src,
|
||||
ref dst,
|
||||
ref size,
|
||||
ref count,
|
||||
}) => {
|
||||
let dst_val = self.codegen_operand(&mut bx, dst);
|
||||
let src_val = self.codegen_operand(&mut bx, src);
|
||||
let size_val = self.codegen_operand(&mut bx, size);
|
||||
let size = size_val.immediate_or_packed_pair(&mut bx);
|
||||
let count_val = self.codegen_operand(&mut bx, count);
|
||||
let count = count_val.immediate_or_packed_pair(&mut bx);
|
||||
let dst = dst_val.immediate_or_packed_pair(&mut bx);
|
||||
let src = src_val.immediate_or_packed_pair(&mut bx);
|
||||
use crate::MemFlags;
|
||||
let flags =
|
||||
(!MemFlags::UNALIGNED) & (!MemFlags::VOLATILE) & (!MemFlags::NONTEMPORAL);
|
||||
let flags = MemFlags::empty();
|
||||
bx.memcpy(
|
||||
dst,
|
||||
dst_val.layout.layout.align.pref,
|
||||
src,
|
||||
src_val.layout.layout.align.pref,
|
||||
size,
|
||||
count,
|
||||
flags,
|
||||
);
|
||||
bx
|
||||
|
@ -1667,8 +1667,10 @@ impl Debug for Statement<'_> {
|
||||
CopyNonOverlapping(box crate::mir::CopyNonOverlapping {
|
||||
ref src,
|
||||
ref dst,
|
||||
ref size,
|
||||
}) => write!(fmt, "copy_nonoverlapping(src={:?}, dst={:?}, size={:?})", src, dst, size),
|
||||
ref count,
|
||||
}) => {
|
||||
write!(fmt, "copy_nonoverlapping(src={:?}, dst={:?}, count={:?})", src, dst, count)
|
||||
}
|
||||
Nop => write!(fmt, "nop"),
|
||||
}
|
||||
}
|
||||
@ -1684,7 +1686,8 @@ pub struct Coverage {
|
||||
pub struct CopyNonOverlapping<'tcx> {
|
||||
pub src: Operand<'tcx>,
|
||||
pub dst: Operand<'tcx>,
|
||||
pub size: Operand<'tcx>,
|
||||
/// Number of elements to copy from src to dest, not bytes.
|
||||
pub count: Operand<'tcx>,
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -439,17 +439,11 @@ macro_rules! make_mir_visitor {
|
||||
StatementKind::CopyNonOverlapping(box crate::mir::CopyNonOverlapping{
|
||||
ref $($mutability)? src,
|
||||
ref $($mutability)? dst,
|
||||
ref $($mutability)? size,
|
||||
ref $($mutability)? count,
|
||||
}) => {
|
||||
self.visit_operand(
|
||||
src,
|
||||
location
|
||||
);
|
||||
self.visit_operand(
|
||||
dst,
|
||||
location
|
||||
);
|
||||
self.visit_operand(size, location)
|
||||
self.visit_operand(src, location);
|
||||
self.visit_operand(dst, location);
|
||||
self.visit_operand(count, location)
|
||||
}
|
||||
StatementKind::Nop => {}
|
||||
}
|
||||
|
@ -95,11 +95,11 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
||||
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
|
||||
ref src,
|
||||
ref dst,
|
||||
ref size,
|
||||
ref count,
|
||||
}) => {
|
||||
self.consume_operand(location, src);
|
||||
self.consume_operand(location, dst);
|
||||
self.consume_operand(location, size);
|
||||
self.consume_operand(location, count);
|
||||
match dst {
|
||||
Operand::Move(ref place) | Operand::Copy(ref place) => {
|
||||
self.mutate_place(location, *place, Deep, JustWrite);
|
||||
|
@ -114,28 +114,36 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
|
||||
// Call CopyNonOverlapping
|
||||
CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping { dst, src, size }) => {
|
||||
let size = self.eval_operand(size, None)?;
|
||||
CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping { dst, src, count }) => {
|
||||
let (src, size) = {
|
||||
let src = self.eval_operand(src, None)?;
|
||||
let size = src.layout.layout.size;
|
||||
let mplace = *src.assert_mem_place(self);
|
||||
let ptr = match mplace.ptr {
|
||||
Scalar::Ptr(ptr) => ptr,
|
||||
_ => panic!(),
|
||||
};
|
||||
(ptr, size)
|
||||
};
|
||||
|
||||
let dst = {
|
||||
let dst = self.eval_operand(dst, None)?;
|
||||
let mplace = *dst.assert_mem_place(self);
|
||||
match mplace.ptr {
|
||||
Scalar::Ptr(ptr) => ptr,
|
||||
_ => panic!(),
|
||||
Scalar::Ptr(ptr) => ptr,
|
||||
_ => panic!(),
|
||||
}
|
||||
};
|
||||
let src = {
|
||||
let src = self.eval_operand(src, None)?;
|
||||
let mplace = *src.assert_mem_place(self);
|
||||
match mplace.ptr {
|
||||
Scalar::Ptr(ptr) => ptr,
|
||||
_ => panic!(),
|
||||
}
|
||||
|
||||
let count = self.eval_operand(count, None)?;
|
||||
let count = self.read_immediate(count)?.to_scalar()?;
|
||||
let count = if let Scalar::Int(i) = count {
|
||||
core::convert::TryFrom::try_from(i).unwrap()
|
||||
} else {
|
||||
panic!();
|
||||
};
|
||||
// Not sure how to convert an MPlaceTy<'_, <M as Machine<'_, '_>>::PointerTag>
|
||||
// to a pointer, or OpTy to a size
|
||||
self.memory.copy(src, dst, size.layout.layout.size, /*nonoverlapping*/ true)?;
|
||||
|
||||
self.memory.copy_repeatedly(src, dst, size, count, /*nonoverlapping*/ true)?;
|
||||
}
|
||||
|
||||
// Statements we do not track.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -219,11 +219,11 @@ fn check_statement(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, statemen
|
||||
StatementKind::LlvmInlineAsm { .. } => Err((span, "cannot use inline assembly in const fn".into())),
|
||||
|
||||
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping{
|
||||
dst, src, size,
|
||||
dst, src, count,
|
||||
}) => {
|
||||
check_operand(tcx, dst, span, body)?;
|
||||
check_operand(tcx, src, span, body)?;
|
||||
check_operand(tcx, size, span, body)
|
||||
check_operand(tcx, count, span, body)
|
||||
},
|
||||
// These are all NOPs
|
||||
StatementKind::StorageLive(_)
|
||||
|
Loading…
Reference in New Issue
Block a user