mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
add ir unknowninc instruction
This commit is contained in:
parent
c2108d4ecd
commit
ebd62485df
7 changed files with 56 additions and 14 deletions
|
@ -453,7 +453,7 @@ pub fn build_rc_wrapper<'a, 'ctx, 'env>(
|
|||
match rc_operation {
|
||||
Mode::Inc => {
|
||||
// we hardcode the 1 here
|
||||
let n = 1;
|
||||
let n = env.ptr_int().const_int(1, false);
|
||||
increment_refcount_layout(env, function_value, layout_ids, n, value, layout);
|
||||
}
|
||||
Mode::Dec => {
|
||||
|
|
|
@ -2263,14 +2263,22 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
|||
let layout = *layout;
|
||||
|
||||
if layout.contains_refcounted() {
|
||||
increment_refcount_layout(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
*inc_amount,
|
||||
value,
|
||||
&layout,
|
||||
);
|
||||
let amount = env.ptr_int().const_int(*inc_amount, false);
|
||||
increment_refcount_layout(env, parent, layout_ids, amount, value, &layout);
|
||||
}
|
||||
|
||||
build_exp_stmt(env, layout_ids, scope, parent, cont)
|
||||
}
|
||||
IncUnknown {
|
||||
to_increment,
|
||||
amount: amount_symbol,
|
||||
} => {
|
||||
let (value, layout) = load_symbol_and_layout(scope, to_increment);
|
||||
let layout = *layout;
|
||||
|
||||
if layout.contains_refcounted() {
|
||||
let amount = load_symbol(scope, amount_symbol).into_int_value();
|
||||
increment_refcount_layout(env, parent, layout_ids, amount, value, &layout);
|
||||
}
|
||||
|
||||
build_exp_stmt(env, layout_ids, scope, parent, cont)
|
||||
|
|
|
@ -289,7 +289,8 @@ pub fn list_get_unsafe<'a, 'ctx, 'env>(
|
|||
|
||||
let result = builder.build_load(elem_ptr, "List.get");
|
||||
|
||||
increment_refcount_layout(env, parent, layout_ids, 1, result, elem_layout);
|
||||
let n = env.ptr_int().const_int(1, false);
|
||||
increment_refcount_layout(env, parent, layout_ids, n, result, elem_layout);
|
||||
|
||||
result
|
||||
}
|
||||
|
|
|
@ -423,16 +423,15 @@ pub fn increment_refcount_layout<'a, 'ctx, 'env>(
|
|||
env: &Env<'a, 'ctx, 'env>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
inc_amount: u64,
|
||||
inc_amount: IntValue<'ctx>,
|
||||
value: BasicValueEnum<'ctx>,
|
||||
layout: &Layout<'a>,
|
||||
) {
|
||||
let amount = env.ptr_int().const_int(inc_amount, false);
|
||||
modify_refcount_layout(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
CallMode::Inc(amount),
|
||||
CallMode::Inc(inc_amount),
|
||||
value,
|
||||
layout,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue