move Option::as_slice to intrinsic
This commit is contained in:
parent
cd6c574af3
commit
27e9ee9bae
8 changed files with 152 additions and 72 deletions
|
@ -6,6 +6,7 @@ use rustc_middle::ty::subst::SubstsRef;
|
|||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
pub struct LowerIntrinsics;
|
||||
|
||||
|
@ -191,6 +192,35 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
|||
terminator.kind = TerminatorKind::Goto { target };
|
||||
}
|
||||
}
|
||||
sym::option_payload_ptr => {
|
||||
if let (Some(target), Some(arg)) = (*target, args[0].place()) {
|
||||
let ty::RawPtr(ty::TypeAndMut { ty: dest_ty, .. }) =
|
||||
destination.ty(local_decls, tcx).ty.kind()
|
||||
else { bug!(); };
|
||||
|
||||
block.statements.push(Statement {
|
||||
source_info: terminator.source_info,
|
||||
kind: StatementKind::Assign(Box::new((
|
||||
*destination,
|
||||
Rvalue::AddressOf(
|
||||
Mutability::Not,
|
||||
arg.project_deeper(
|
||||
&[
|
||||
PlaceElem::Deref,
|
||||
PlaceElem::Downcast(
|
||||
Some(sym::Some),
|
||||
VariantIdx::from_u32(1),
|
||||
),
|
||||
PlaceElem::Field(Field::from_u32(0), *dest_ty),
|
||||
],
|
||||
tcx,
|
||||
),
|
||||
),
|
||||
))),
|
||||
});
|
||||
terminator.kind = TerminatorKind::Goto { target };
|
||||
}
|
||||
}
|
||||
_ if intrinsic_name.as_str().starts_with("simd_shuffle") => {
|
||||
validate_simd_shuffle(tcx, args, terminator.source_info.span);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue