feat(joinir): Phase 61-4-F ToplevelOps and production path integration

Phase 61-4-F: Loop-outside If JoinIR production path

Changes:
- F.1: Add ToplevelOps struct implementing PhiBuilderOps for MirBuilder
  - Enables emit_toplevel_phis() to emit PHI instructions via MirBuilder
  - Uses insert_phi_at_head_spanned for proper PHI placement
  - ~70 lines, thin wrapper following box theory

- F.2: Integrate production path with emit_toplevel_phis
  - Replace TODO with actual PHI emission call
  - Build IfShape from branch blocks
  - Log PHI count on dry-run

- Add IfToplevelTest.* to try_lower_if_to_joinir allowed list
  - Fixes function name guard that blocked testing

Note: Pattern matching currently only supports return patterns
(IfMerge/IfSelect). Local variable assignment patterns fall back
to existing PHI generation, which correctly produces valid MIR.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-29 15:32:40 +09:00
parent 3439de0f65
commit 3194cc1e6c
2 changed files with 102 additions and 6 deletions

View File

@ -157,6 +157,7 @@ pub fn try_lower_if_to_joinir(
func.signature.name.starts_with("IfSelectTest.") ||
func.signature.name.starts_with("IfSelectLocalTest.") || // Phase 33-10 test
func.signature.name.starts_with("IfMergeTest.") ||
func.signature.name.starts_with("IfToplevelTest.") || // Phase 61-4: loop-outside if test
func.signature.name.starts_with("Stage1JsonScannerTestBox.") || // Phase 33-5 test
// Stage-1 rollout (env-controlled)