mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
implement some missing checked operations in the dev backend
This commit is contained in:
parent
e850f94d05
commit
124b533bc0
2 changed files with 47 additions and 9 deletions
|
@ -1264,7 +1264,7 @@ impl<
|
|||
num_layout: &InLayout<'a>,
|
||||
return_layout: &InLayout<'a>,
|
||||
) {
|
||||
use Builtin::Int;
|
||||
use Builtin::{Float, Int};
|
||||
|
||||
let buf = &mut self.buf;
|
||||
|
||||
|
@ -1303,11 +1303,32 @@ impl<
|
|||
)) => {
|
||||
todo!("addChecked for unsigned integers")
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F64)) => {
|
||||
todo!("addChecked for f64")
|
||||
LayoutRepr::Builtin(Int(int_width @ (IntWidth::U128 | IntWidth::I128))) => {
|
||||
self.build_fn_call(
|
||||
dst,
|
||||
bitcode::NUM_ADD_CHECKED_INT[int_width].to_string(),
|
||||
&[*src1, *src2],
|
||||
&[*num_layout, *num_layout],
|
||||
return_layout,
|
||||
);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F32)) => {
|
||||
todo!("addChecked for f32")
|
||||
LayoutRepr::Builtin(Float(float_width @ (FloatWidth::F64 | FloatWidth::F32))) => {
|
||||
self.build_fn_call(
|
||||
dst,
|
||||
bitcode::NUM_ADD_CHECKED_FLOAT[float_width].to_string(),
|
||||
&[*src1, *src2],
|
||||
&[*num_layout, *num_layout],
|
||||
return_layout,
|
||||
);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Decimal) => {
|
||||
self.build_fn_call(
|
||||
dst,
|
||||
bitcode::DEC_ADD_WITH_OVERFLOW.to_string(),
|
||||
&[*src1, *src2],
|
||||
&[*num_layout, *num_layout],
|
||||
return_layout,
|
||||
);
|
||||
}
|
||||
x => todo!("NumAdd: layout, {:?}", x),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue