feat(joinir): Phase 202-B Pattern 3 uses JoinValueSpace

Replace sequential value_counter (0u32) with JoinValueSpace allocator
in Pattern 3 (If-PHI) lowering for unified ValueId management.

Changes:
- loop_with_if_phi_minimal.rs: Replace value_counter with join_value_space.alloc_local()
- pattern3_with_if_phi.rs: Create JoinValueSpace and pass to lowerer
- loop_patterns/with_if_phi.rs: Update legacy wrapper to use JoinValueSpace

Benefits:
- Consistent with Pattern 2 implementation (Phase 201)
- Prevents ValueId collision in Local region (1000+)
- Clean separation: Param region (100-999) vs Local region (1000+)

Test status:
- All unit tests pass (5/5)
- E2E tests pass: loop_if_phi.hako, loop_if_phi_continue.hako

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-09 19:14:01 +09:00
parent 6e778948db
commit 98e81b2650
4 changed files with 265 additions and 11 deletions

View File

@ -85,6 +85,7 @@ pub fn lower_loop_with_conditional_phi_to_joinir(
) -> Option<JoinInst> {
// Phase 188-Impl-3: Delegate to minimal lowerer
// TODO: Extract LoopScopeShape from loop_form for generic implementation
use crate::mir::join_ir::lowering::join_value_space::JoinValueSpace;
use crate::mir::join_ir::lowering::loop_scope_shape::LoopScopeShape;
use crate::mir::join_ir::lowering::loop_with_if_phi_minimal::lower_loop_with_if_phi_pattern;
use crate::mir::BasicBlockId;
@ -105,8 +106,11 @@ pub fn lower_loop_with_conditional_phi_to_joinir(
variable_definitions: BTreeMap::new(),
};
// Phase 202-B: Create JoinValueSpace for unified ValueId allocation
let mut join_value_space = JoinValueSpace::new();
// Generate JoinIR module
let _join_module = lower_loop_with_if_phi_pattern(placeholder_scope)?;
let _join_module = lower_loop_with_if_phi_pattern(placeholder_scope, &mut join_value_space)?;
// Phase 188-Impl-3: Pattern 3 is now integrated via the router
// This function delegates to loop_with_if_phi_minimal which generates JoinModule