feat(mir): Phase 136 Step 2/7 - CoreContext extraction complete

Extract core ID generation fields from MirBuilder to improve organization:
- value_gen: ValueIdGenerator
- block_gen: BasicBlockIdGenerator
- next_binding_id: u32 (Phase 74)
- temp_slot_counter: u32
- debug_join_counter: u32

Implementation:
- Created src/mir/builder/core_context.rs (215 lines)
- Added core_ctx field to MirBuilder as SSOT
- Deprecated legacy fields with backward compat
- ID allocation methods use core_ctx and sync legacy fields
- Added next_block_id() helper, replaced 30+ block_gen.next() calls

Testing:
- cargo build --release: SUCCESS (193 warnings expected)
- cargo test --release --lib: 1004/1004 PASS (+7 tests)
- phase135_trim_mir_verify.sh: PASS
- phase132_exit_phi_parity.sh: 3/3 PASS

Progress: 2/7 Context extractions complete (TypeContext + CoreContext)

🤖 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-15 20:10:36 +09:00
parent 076f193f76
commit 81d79161e4
12 changed files with 325 additions and 61 deletions

View File

@ -35,12 +35,16 @@ impl super::MirBuilder {
/// Phase 201-A: Skips reserved ValueIds (PHI dsts from LoopHeaderPhiBuilder)
/// to prevent carrier value corruption in JoinIR loops.
#[inline]
#[allow(deprecated)]
pub(crate) fn next_value_id(&mut self) -> super::ValueId {
loop {
let candidate = if let Some(ref mut f) = self.current_function {
f.next_value_id() // Function context
} else {
self.value_gen.next() // Module context
// Phase 136 Step 2/7: Use core_ctx as SSOT, sync legacy field
let id = self.core_ctx.next_value();
self.value_gen = self.core_ctx.value_gen.clone();
id
};
// Phase 201-A: Skip reserved PHI dst ValueIds
@ -54,6 +58,17 @@ impl super::MirBuilder {
}
}
/// Allocate a new BasicBlockId
///
/// Phase 136 Step 2/7: Uses core_ctx as SSOT, syncs legacy field.
#[inline]
#[allow(deprecated)]
pub(crate) fn next_block_id(&mut self) -> super::BasicBlockId {
let id = self.core_ctx.next_block();
self.block_gen = self.core_ctx.block_gen.clone();
id
}
// ---- LocalSSA convenience (readability helpers) ----
#[allow(dead_code)]
#[inline]