Revert "add ir unknowninc instruction"

This reverts commit ebd62485df.
This commit is contained in:
Folkert 2021-05-16 21:52:30 +02:00
parent 7520dfee06
commit bb3fe92251
7 changed files with 14 additions and 56 deletions

View file

@ -453,7 +453,7 @@ pub fn build_rc_wrapper<'a, 'ctx, 'env>(
match rc_operation { match rc_operation {
Mode::Inc => { Mode::Inc => {
// we hardcode the 1 here // we hardcode the 1 here
let n = env.ptr_int().const_int(1, false); let n = 1;
increment_refcount_layout(env, function_value, layout_ids, n, value, layout); increment_refcount_layout(env, function_value, layout_ids, n, value, layout);
} }
Mode::Dec => { Mode::Dec => {

View file

@ -2263,22 +2263,14 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
let layout = *layout; let layout = *layout;
if layout.contains_refcounted() { if layout.contains_refcounted() {
let amount = env.ptr_int().const_int(*inc_amount, false); increment_refcount_layout(
increment_refcount_layout(env, parent, layout_ids, amount, value, &layout); env,
} parent,
layout_ids,
build_exp_stmt(env, layout_ids, scope, parent, cont) *inc_amount,
} value,
IncUnknown { &layout,
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) build_exp_stmt(env, layout_ids, scope, parent, cont)

View file

@ -289,8 +289,7 @@ pub fn list_get_unsafe<'a, 'ctx, 'env>(
let result = builder.build_load(elem_ptr, "List.get"); let result = builder.build_load(elem_ptr, "List.get");
let n = env.ptr_int().const_int(1, false); increment_refcount_layout(env, parent, layout_ids, 1, result, elem_layout);
increment_refcount_layout(env, parent, layout_ids, n, result, elem_layout);
result result
} }

View file

@ -423,15 +423,16 @@ pub fn increment_refcount_layout<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>, env: &Env<'a, 'ctx, 'env>,
parent: FunctionValue<'ctx>, parent: FunctionValue<'ctx>,
layout_ids: &mut LayoutIds<'a>, layout_ids: &mut LayoutIds<'a>,
inc_amount: IntValue<'ctx>, inc_amount: u64,
value: BasicValueEnum<'ctx>, value: BasicValueEnum<'ctx>,
layout: &Layout<'a>, layout: &Layout<'a>,
) { ) {
let amount = env.ptr_int().const_int(inc_amount, false);
modify_refcount_layout( modify_refcount_layout(
env, env,
parent, parent,
layout_ids, layout_ids,
CallMode::Inc(inc_amount), CallMode::Inc(amount),
value, value,
layout, layout,
); );

View file

@ -575,17 +575,6 @@ fn expand_and_cancel<'a>(env: &mut Env<'a, '_>, stmt: &'a Stmt<'a>) -> &'a Stmt<
expand_and_cancel(env, cont) expand_and_cancel(env, cont)
} }
Refcounting(
ModifyRc::IncUnknown {
to_increment: _,
amount: _,
},
cont,
) => {
// TODO
expand_and_cancel(env, cont)
}
Refcounting(ModifyRc::Inc(symbol, inc_amount), cont) => { Refcounting(ModifyRc::Inc(symbol, inc_amount), cont) => {
let count = env.deferred.inc_dec_map.entry(*symbol).or_insert(0); let count = env.deferred.inc_dec_map.entry(*symbol).or_insert(0);
*count += *inc_amount as i64; *count += *inc_amount as i64;

View file

@ -468,16 +468,7 @@ impl<'a> Context<'a> {
arguments, arguments,
}); });
let mut b = Stmt::Let(z, v, l, b); &*self.arena.alloc(Stmt::Let(z, v, l, b))
if !ps[1].borrow {
b = Stmt::Refcounting(
ModifyRc::Inc(arguments[2], 2),
self.arena.alloc(b),
)
}
&*self.arena.alloc(b)
} }
None => unreachable!(), None => unreachable!(),
} }

View file

@ -902,10 +902,6 @@ impl<'a> BranchInfo<'a> {
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub enum ModifyRc { pub enum ModifyRc {
Inc(Symbol, u64), Inc(Symbol, u64),
IncUnknown {
to_increment: Symbol,
amount: Symbol,
},
Dec(Symbol), Dec(Symbol),
DecRef(Symbol), DecRef(Symbol),
} }
@ -929,15 +925,6 @@ impl ModifyRc {
.append(alloc.text(format!("{}", n))) .append(alloc.text(format!("{}", n)))
.append(symbol_to_doc(alloc, *symbol)) .append(symbol_to_doc(alloc, *symbol))
.append(";"), .append(";"),
IncUnknown {
to_increment,
amount,
} => alloc
.text("inc ")
.append(symbol_to_doc(alloc, *to_increment))
.append(" by ")
.append(symbol_to_doc(alloc, *amount))
.append(";"),
Dec(symbol) => alloc Dec(symbol) => alloc
.text("dec ") .text("dec ")
.append(symbol_to_doc(alloc, *symbol)) .append(symbol_to_doc(alloc, *symbol))
@ -954,7 +941,6 @@ impl ModifyRc {
match self { match self {
Inc(symbol, _) => *symbol, Inc(symbol, _) => *symbol,
IncUnknown { to_increment, .. } => *to_increment,
Dec(symbol) => *symbol, Dec(symbol) => *symbol,
DecRef(symbol) => *symbol, DecRef(symbol) => *symbol,
} }