mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 09:53:26 +00:00
parent
c674c2c46c
commit
8b9c2135d0
@ -332,7 +332,7 @@ impl<'tcx> CPlace<'tcx> {
|
||||
|
||||
let stack_slot = fx.bcx.create_stack_slot(StackSlotData {
|
||||
kind: StackSlotKind::ExplicitSlot,
|
||||
size: layout.size.bytes() as u32,
|
||||
size: u32::try_from(layout.size.bytes()).unwrap(),
|
||||
offset: None,
|
||||
});
|
||||
CPlace {
|
||||
@ -530,6 +530,13 @@ impl<'tcx> CPlace<'tcx> {
|
||||
dst_ty: Type,
|
||||
) {
|
||||
let src_ty = fx.bcx.func.dfg.value_type(data);
|
||||
assert_eq!(
|
||||
src_ty.bytes(),
|
||||
dst_ty.bytes(),
|
||||
"write_cvalue_transmute: {:?} -> {:?}",
|
||||
src_ty,
|
||||
dst_ty,
|
||||
);
|
||||
let data = match (src_ty, dst_ty) {
|
||||
(_, _) if src_ty == dst_ty => data,
|
||||
|
||||
@ -541,6 +548,17 @@ impl<'tcx> CPlace<'tcx> {
|
||||
_ if src_ty.is_vector() && dst_ty.is_vector() => {
|
||||
fx.bcx.ins().raw_bitcast(dst_ty, data)
|
||||
}
|
||||
_ if src_ty.is_vector() || dst_ty.is_vector() => {
|
||||
// FIXME do something more efficient for transmutes between vectors and integers.
|
||||
let stack_slot = fx.bcx.create_stack_slot(StackSlotData {
|
||||
kind: StackSlotKind::ExplicitSlot,
|
||||
size: src_ty.bytes(),
|
||||
offset: None,
|
||||
});
|
||||
let ptr = Pointer::stack_slot(stack_slot);
|
||||
ptr.store(fx, data, MemFlags::trusted());
|
||||
ptr.load(fx, dst_ty, MemFlags::trusted())
|
||||
}
|
||||
_ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty),
|
||||
};
|
||||
fx.bcx
|
||||
|
Loading…
Reference in New Issue
Block a user