mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Merge pull request #5312 from roc-lang/dev-refcount-seamless-slice
Dev refcount seamless slice
This commit is contained in:
commit
cfcd2a5289
8 changed files with 410 additions and 119 deletions
|
@ -1108,6 +1108,38 @@ impl<
|
|||
}
|
||||
}
|
||||
|
||||
fn build_num_add_saturated(
|
||||
&mut self,
|
||||
dst: Symbol,
|
||||
src1: Symbol,
|
||||
src2: Symbol,
|
||||
layout: InLayout<'a>,
|
||||
) {
|
||||
match self.layout_interner.get(layout).repr {
|
||||
LayoutRepr::Builtin(Builtin::Int(width @ quadword_and_smaller!())) => {
|
||||
let intrinsic = bitcode::NUM_ADD_SATURATED_INT[width].to_string();
|
||||
self.build_fn_call(&dst, intrinsic, &[src1, src2], &[layout, layout], &layout);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F64)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, &dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src1);
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src2);
|
||||
ASM::add_freg64_freg64_freg64(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F32)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, &dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src1);
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src2);
|
||||
ASM::add_freg32_freg32_freg32(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Decimal) => {
|
||||
let intrinsic = bitcode::DEC_ADD_SATURATED.to_string();
|
||||
self.build_fn_call(&dst, intrinsic, &[src1, src2], &[layout, layout], &layout);
|
||||
}
|
||||
x => todo!("NumAddSaturated: layout, {:?}", x),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_num_add_checked(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
|
|
|
@ -1236,8 +1236,8 @@ impl<
|
|||
let reg = self.load_to_float_reg(buf, &symbol);
|
||||
ASM::mov_base32_freg64(buf, base_offset, reg);
|
||||
}
|
||||
_ => {
|
||||
if let LayoutRepr::LambdaSet(lambda_set) = layout_interner.get(layout).repr {
|
||||
_ => match layout_interner.get(layout).repr {
|
||||
LayoutRepr::LambdaSet(lambda_set) => {
|
||||
self.jump_argument_stack_storage(
|
||||
layout_interner,
|
||||
buf,
|
||||
|
@ -1245,13 +1245,18 @@ impl<
|
|||
lambda_set.runtime_representation(),
|
||||
base_offset,
|
||||
);
|
||||
} else {
|
||||
}
|
||||
LayoutRepr::Boxed(_) => {
|
||||
let reg = self.load_to_general_reg(buf, &symbol);
|
||||
ASM::mov_base32_reg64(buf, base_offset, reg);
|
||||
}
|
||||
_ => {
|
||||
internal_error!(
|
||||
r"cannot load non-primitive layout ({:?}) to primitive stack location",
|
||||
layout
|
||||
layout_interner.dbg(layout)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -860,6 +860,9 @@ trait Backend<'a> {
|
|||
);
|
||||
self.build_num_add(sym, &args[0], &args[1], ret_layout)
|
||||
}
|
||||
LowLevel::NumAddSaturated => {
|
||||
self.build_num_add_saturated(*sym, args[0], args[1], *ret_layout);
|
||||
}
|
||||
LowLevel::NumAddWrap => {
|
||||
debug_assert_eq!(
|
||||
2,
|
||||
|
@ -1856,6 +1859,15 @@ trait Backend<'a> {
|
|||
/// build_num_add stores the sum of src1 and src2 into dst.
|
||||
fn build_num_add(&mut self, dst: &Symbol, src1: &Symbol, src2: &Symbol, layout: &InLayout<'a>);
|
||||
|
||||
/// build_num_add_saturated stores the sum of src1 and src2 into dst.
|
||||
fn build_num_add_saturated(
|
||||
&mut self,
|
||||
dst: Symbol,
|
||||
src1: Symbol,
|
||||
src2: Symbol,
|
||||
layout: InLayout<'a>,
|
||||
);
|
||||
|
||||
/// build_num_add_checked stores the sum of src1 and src2 into dst.
|
||||
fn build_num_add_checked(
|
||||
&mut self,
|
||||
|
|
|
@ -324,7 +324,13 @@ fn build_object<'a, B: Backend<'a>>(
|
|||
helper_procs.push(caller_proc.proc);
|
||||
}
|
||||
|
||||
module_id.register_debug_idents(ident_ids);
|
||||
if false {
|
||||
module_id.register_debug_idents(ident_ids);
|
||||
|
||||
for p in &helper_procs {
|
||||
println!("{}", p.to_pretty(_interner, 200, true));
|
||||
}
|
||||
}
|
||||
|
||||
helper_procs
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue