Impl StatementKind::CopyNonOverlapping

This commit is contained in:
kadmin 2020-10-03 20:57:47 +00:00
parent 3a5d45f68c
commit 0fdc07e197
4 changed files with 57 additions and 2 deletions

View File

@ -293,7 +293,8 @@ fn visit_local(&mut self, &local: &mir::Local, context: PlaceContext, location:
| MutatingUseContext::AsmOutput
| MutatingUseContext::Borrow
| MutatingUseContext::AddressOf
| MutatingUseContext::Projection,
| MutatingUseContext::Projection
| MutatingUseContext::CopyNonOverlapping,
)
| PlaceContext::NonMutatingUse(
NonMutatingUseContext::Inspect
@ -301,7 +302,8 @@ fn visit_local(&mut self, &local: &mir::Local, context: PlaceContext, location:
| NonMutatingUseContext::UniqueBorrow
| NonMutatingUseContext::ShallowBorrow
| NonMutatingUseContext::AddressOf
| NonMutatingUseContext::Projection,
| NonMutatingUseContext::Projection
| NonMutatingUseContext::CopyNonOverlapping,
) => {
self.not_ssa(local);
}

View File

@ -115,6 +115,21 @@ pub fn codegen_statement(&mut self, mut bx: Bx, statement: &mir::Statement<'tcx>
self.codegen_coverage(&mut bx, coverage.clone());
bx
}
mir::StatementKind::CopyNonOverlapping(box mir::CopyNonOverlapping {
ref src,
ref dst,
ref size,
}) => {
bx.memcpy(
dst,
todo!(),
src,
todo!(),
size,
todo!(),
);
bx
}
mir::StatementKind::FakeRead(..)
| mir::StatementKind::Retag { .. }
| mir::StatementKind::AscribeUserType(..)

View File

@ -1541,6 +1541,11 @@ pub enum StatementKind<'tcx> {
/// counter varible at runtime, each time the code region is executed.
Coverage(Box<Coverage>),
/// Denotes a call to the intrinsic function copy_overlapping, where `src_dst` denotes the
/// memory being read from and written to(one field to save memory), and size
/// indicates how many bytes are being copied over.
CopyNonOverlapping(Box<CopyNonOverlapping<'tcx>>),
/// No-op. Useful for deleting instructions without affecting statement indices.
Nop,
}
@ -1659,6 +1664,11 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
write!(fmt, "Coverage::{:?}", coverage.kind)
}
}
CopyNonOverlapping(box crate::mir::CopyNonOverlapping {
ref src,
ref dst,
ref size,
}) => write!(fmt, "src {:?} -> dst {:?}, {:?} bytes", src, dst, size),
Nop => write!(fmt, "nop"),
}
}
@ -1670,6 +1680,13 @@ pub struct Coverage {
pub code_region: Option<CodeRegion>,
}
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
pub struct CopyNonOverlapping<'tcx> {
pub src: Place<'tcx>,
pub dst: Place<'tcx>,
pub size: Operand<'tcx>,
}
///////////////////////////////////////////////////////////////////////////
// Places

View File

@ -436,6 +436,23 @@ fn super_statement(&mut self,
location
)
}
StatementKind::CopyNonOverlapping(box crate::mir::CopyNonOverlapping{
ref $($mutability)? src,
ref $($mutability)? dst,
ref $($mutability)? size,
}) => {
self.visit_place(
src,
PlaceContext::NonMutatingUse(NonMutatingUseContext::CopyNonOverlapping),
location
);
self.visit_place(
dst,
PlaceContext::MutatingUse(MutatingUseContext::CopyNonOverlapping),
location
);
self.visit_operand(size, location)
}
StatementKind::Nop => {}
}
}
@ -1151,6 +1168,8 @@ pub enum NonMutatingUseContext {
/// f(&x.y);
///
Projection,
/// Source from copy_nonoverlapping.
CopyNonOverlapping,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -1180,6 +1199,8 @@ pub enum MutatingUseContext {
Projection,
/// Retagging, a "Stacked Borrows" shadow state operation
Retag,
/// Memory written to in copy_nonoverlapping.
CopyNonOverlapping,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]