fmt
This commit is contained in:
parent
bf31cdb08a
commit
e6a4a1b12e
@ -1033,7 +1033,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
) {
|
||||
// Floating point value is NaN (flagged with INVALID_OP) or outside the range
|
||||
// of values of the integer type (flagged with OVERFLOW or UNDERFLOW).
|
||||
return None
|
||||
return None;
|
||||
} else {
|
||||
// Floating point value can be represented by the integer type after rounding.
|
||||
// The INEXACT flag is ignored on purpose to allow rounding.
|
||||
@ -1051,7 +1051,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
) {
|
||||
// Floating point value is NaN (flagged with INVALID_OP) or outside the range
|
||||
// of values of the integer type (flagged with OVERFLOW or UNDERFLOW).
|
||||
return None
|
||||
return None;
|
||||
} else {
|
||||
// Floating point value can be represented by the integer type after rounding.
|
||||
// The INEXACT flag is ignored on purpose to allow rounding.
|
||||
|
@ -65,12 +65,16 @@ impl<'mir, 'tcx> EvalContextExt<'tcx> for super::MiriInterpCx<'mir, 'tcx> {
|
||||
right.to_scalar().to_target_usize(self)?,
|
||||
self.machine.layouts.usize,
|
||||
);
|
||||
let (result, overflowing) =
|
||||
self.overflowing_binary_op(bin_op, &left, &right)?;
|
||||
let (result, overflowing) = self.overflowing_binary_op(bin_op, &left, &right)?;
|
||||
// Construct a new pointer with the provenance of `ptr` (the LHS).
|
||||
let result_ptr =
|
||||
Pointer::new(ptr.provenance, Size::from_bytes(result.to_scalar().to_target_usize(self)?));
|
||||
(ImmTy::from_scalar(Scalar::from_maybe_pointer(result_ptr, self), left.layout), overflowing)
|
||||
let result_ptr = Pointer::new(
|
||||
ptr.provenance,
|
||||
Size::from_bytes(result.to_scalar().to_target_usize(self)?),
|
||||
);
|
||||
(
|
||||
ImmTy::from_scalar(Scalar::from_maybe_pointer(result_ptr, self), left.layout),
|
||||
overflowing,
|
||||
)
|
||||
}
|
||||
|
||||
_ => span_bug!(self.cur_span(), "Invalid operator on pointers: {:?}", bin_op),
|
||||
|
@ -61,11 +61,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
let right = this.int_to_int_or_float(&right, twice_wide)?;
|
||||
|
||||
// Calculate left + right + 1
|
||||
let added = this.wrapping_binary_op(
|
||||
mir::BinOp::Add,
|
||||
&left,
|
||||
&right,
|
||||
)?;
|
||||
let added = this.wrapping_binary_op(mir::BinOp::Add, &left, &right)?;
|
||||
let added = this.wrapping_binary_op(
|
||||
mir::BinOp::Add,
|
||||
&added,
|
||||
@ -80,10 +76,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
)?;
|
||||
|
||||
// Narrow back to the original type
|
||||
let res = this.int_to_int_or_float(
|
||||
÷d,
|
||||
dest.layout,
|
||||
)?;
|
||||
let res = this.int_to_int_or_float(÷d, dest.layout)?;
|
||||
this.write_immediate(*res, &dest)?;
|
||||
}
|
||||
}
|
||||
@ -110,11 +103,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
let right = this.int_to_int_or_float(&right, twice_wide)?;
|
||||
|
||||
// Multiply
|
||||
let multiplied = this.wrapping_binary_op(
|
||||
mir::BinOp::Mul,
|
||||
&left,
|
||||
&right,
|
||||
)?;
|
||||
let multiplied = this.wrapping_binary_op(mir::BinOp::Mul, &left, &right)?;
|
||||
// Keep the high half
|
||||
let high = this.wrapping_binary_op(
|
||||
mir::BinOp::Shr,
|
||||
@ -123,10 +112,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
)?;
|
||||
|
||||
// Narrow back to the original type
|
||||
let res = this.int_to_int_or_float(
|
||||
&high,
|
||||
dest.layout,
|
||||
)?;
|
||||
let res = this.int_to_int_or_float(&high, dest.layout)?;
|
||||
this.write_immediate(*res, &dest)?;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user