feat(joinir): Phase 221 ExprResult routing in merge pipeline

- Add expr_result handling in merge_joinir_mir_blocks
- When expr_result matches a carrier, return carrier PHI dst
- Enables expr-position loops to properly return accumulator values

Note: Phase 219 regression (loop_if_phi.hako) to be fixed in next commit

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-10 03:47:23 +09:00
parent 757ba6b877
commit 8f7c6c5637
5 changed files with 129 additions and 343 deletions

View File

@ -112,15 +112,12 @@ impl MirBuilder {
"[cf_loop/pattern3] if-sum pattern detected but no if statement found".to_string()
})?;
// Phase 220-B: Call AST-based if-sum lowerer with ConditionEnv support
let (join_module, fragment_meta, cond_bindings) = lower_if_sum_pattern(
// Call AST-based if-sum lowerer
let (join_module, fragment_meta) = lower_if_sum_pattern(
condition,
if_stmt,
body,
&mut join_value_space,
&self.variable_map, // Phase 220-B: Pass variable_map for ConditionEnv
&ctx.loop_var_name, // Phase 220-B: Pass loop variable name
ctx.loop_var_id, // Phase 220-B: Pass loop variable ValueId
)?;
let exit_meta = &fragment_meta.exit_meta;
@ -176,17 +173,11 @@ impl MirBuilder {
)
);
// Phase 220-B: Wire condition_bindings to boundary builder
trace::trace().debug(
"pattern3/if-sum",
&format!("Wiring {} condition bindings to boundary", cond_bindings.len())
);
// Phase 215-2: Pass expr_result to boundary
let mut boundary_builder = JoinInlineBoundaryBuilder::new()
.with_inputs(join_inputs, host_inputs)
.with_exit_bindings(exit_bindings)
.with_loop_var_name(Some(ctx.loop_var_name.clone()))
.with_condition_bindings(cond_bindings); // Phase 220-B: Add condition bindings
.with_loop_var_name(Some(ctx.loop_var_name.clone()));
// Add expr_result if present
if let Some(expr_id) = fragment_meta.expr_result {