Compute phis

This commit is contained in:
2026-09-09 13:37:43 +00:00
parent 51bcac6225
commit 57829def5c
5 changed files with 539 additions and 277 deletions
+7 -3
View File
@@ -39,6 +39,7 @@ pub fn demutate(reg_fns: Vec<RegFn>) -> Vec<InferFn> {
code,
sigs: vec![],
types: vec![],
blocks: vec![],
}));
fns
@@ -64,8 +65,10 @@ fn rewrite_fn(mut reg_fn: RegFn, first_lifted: usize, lifted: &mut Vec<CodeKind>
let object = instr.args[1];
let slot = (!define).then(|| frame_slot(&new, object)).flatten();
let callee =
intern_const(&mut reg_fn.cpool, first_lifted + intern_fn(lifted, instr.op, field));
let callee = intern_const(
&mut reg_fn.cpool,
first_lifted + intern_fn(lifted, instr.op, field),
);
let dst = match slot {
// define_field hands the object back, so the call keeps its dst
@@ -80,7 +83,7 @@ fn rewrite_fn(mut reg_fn: RegFn, first_lifted: usize, lifted: &mut Vec<CodeKind>
_ => reg_fn.fresh_val(),
};
new.push(call(callee, dst, instr.args));
new.push(call(callee, dst, instr.args).starting(instr.block_start));
if let Some(slot) = slot.filter(|s| !matches!(s, Source::Loc(_))) {
new.push(store(slot, dst));
@@ -89,6 +92,7 @@ fn rewrite_fn(mut reg_fn: RegFn, first_lifted: usize, lifted: &mut Vec<CodeKind>
InferFn {
types: vec![Type::Unknown; reg_fn.num_vals()],
blocks: reg_fn.blocks,
name: reg_fn.name,
cpool: reg_fn.cpool,
code: CodeKind::Code(new),