Fix some things
This commit is contained in:
parent
de32ddad23
commit
d629d97f25
2 changed files with 22 additions and 4 deletions
|
@ -88,6 +88,9 @@ pub fn clif_intcast<'a, 'tcx: 'a>(
|
|||
} else {
|
||||
fx.bcx.ins().uextend(to, val)
|
||||
}
|
||||
} else if from == types::I128 {
|
||||
let (lsb, msb) = fx.bcx.ins().isplit(val);
|
||||
fx.bcx.ins().ireduce(to, lsb)
|
||||
} else {
|
||||
fx.bcx.ins().ireduce(to, val)
|
||||
}
|
||||
|
|
|
@ -44,6 +44,21 @@ fn store_scalar<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value
|
|||
}
|
||||
}
|
||||
|
||||
fn load_scalar<'a, 'tcx: 'a>(
|
||||
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||
clif_ty: Type,
|
||||
addr: Value,
|
||||
offset: i32,
|
||||
) -> Value {
|
||||
if clif_ty == types::I128 {
|
||||
let a = fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset);
|
||||
let b = fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset + 8);
|
||||
fx.bcx.ins().iconcat(a, b)
|
||||
} else {
|
||||
fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> CValue<'tcx> {
|
||||
pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> {
|
||||
CValue(CValueInner::ByRef(value), layout)
|
||||
|
@ -89,7 +104,7 @@ impl<'tcx> CValue<'tcx> {
|
|||
_ => unreachable!(),
|
||||
};
|
||||
let clif_ty = scalar_to_clif_type(fx.tcx, scalar);
|
||||
fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0)
|
||||
load_scalar(fx, clif_ty, addr, 0)
|
||||
}
|
||||
CValueInner::ByVal(value) => value,
|
||||
CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"),
|
||||
|
@ -111,10 +126,10 @@ impl<'tcx> CValue<'tcx> {
|
|||
let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar);
|
||||
let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone());
|
||||
let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone());
|
||||
let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0);
|
||||
let val2 = fx.bcx.ins().load(
|
||||
let val1 = load_scalar(fx, clif_ty1, addr, 0);
|
||||
let val2 = load_scalar(
|
||||
fx,
|
||||
clif_ty2,
|
||||
MemFlags::new(),
|
||||
addr,
|
||||
b_offset,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue