cranelift: Fix iadd_carry/iadd_cout in the interpreter (#5176)
This commit is contained in:
@@ -56,6 +56,7 @@ pub trait Value: Clone + From<DataValue> {
|
||||
fn sqrt(self) -> ValueResult<Self>;
|
||||
fn fma(self, a: Self, b: Self) -> ValueResult<Self>;
|
||||
fn abs(self) -> ValueResult<Self>;
|
||||
fn checked_add(self, other: Self) -> ValueResult<Option<Self>>;
|
||||
|
||||
// Float operations
|
||||
fn neg(self) -> ValueResult<Self>;
|
||||
@@ -187,6 +188,12 @@ macro_rules! binary_match {
|
||||
_ => unimplemented!()
|
||||
}
|
||||
};
|
||||
( option $op:ident($arg1:expr, $arg2:expr); [ $( $data_value_ty:ident ),* ] ) => {
|
||||
match ($arg1, $arg2) {
|
||||
$( (DataValue::$data_value_ty(a), DataValue::$data_value_ty(b)) => { Ok(a.$op(*b).map(DataValue::$data_value_ty)) } )*
|
||||
_ => unimplemented!()
|
||||
}
|
||||
};
|
||||
( $op:tt($arg1:expr, $arg2:expr); [ $( $data_value_ty:ident ),* ] ) => {
|
||||
match ($arg1, $arg2) {
|
||||
$( (DataValue::$data_value_ty(a), DataValue::$data_value_ty(b)) => { Ok(DataValue::$data_value_ty(a $op b)) } )*
|
||||
@@ -615,6 +622,10 @@ impl Value for DataValue {
|
||||
unary_match!(abs(&self); [F32, F64])
|
||||
}
|
||||
|
||||
fn checked_add(self, other: Self) -> ValueResult<Option<Self>> {
|
||||
binary_match!(option checked_add(&self, &other); [I8, I16, I32, I64, I128, U8, U16, U32, U64, U128])
|
||||
}
|
||||
|
||||
fn neg(self) -> ValueResult<Self> {
|
||||
unary_match!(neg(&self); [F32, F64])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user