refactor(joinir): Phase 33-17-B LoopHeaderPhiInfo extraction

## Changes
- Extract LoopHeaderPhiInfo Box (116 lines) from loop_header_phi_builder
- loop_header_phi_builder.rs reduced: 318 → 217 lines (-32%)
- Proper separation of data structures from builder logic

## Module Structure
- loop_header_phi_info.rs: LoopHeaderPhiInfo, CarrierPhiEntry structs + tests
- loop_header_phi_builder.rs: LoopHeaderPhiBuilder implementation

## Box Theory Compliance
- Data structures separated from builder logic
- Each file has clear single responsibility
- Clean re-exports through mod.rs

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-07 12:28:11 +09:00
parent 8baca953ca
commit a6a97b3781
4 changed files with 128 additions and 110 deletions

View File

@ -17,13 +17,16 @@ mod value_collector;
mod instruction_rewriter;
mod exit_phi_builder;
pub mod exit_line;
pub mod loop_header_phi_builder;
mod loop_header_phi_info;
mod loop_header_phi_builder;
mod tail_call_classifier;
mod merge_result;
// Phase 33-17: Re-export for use by other modules
pub use merge_result::MergeResult;
pub use tail_call_classifier::{TailCallKind, classify_tail_call};
pub use loop_header_phi_info::{LoopHeaderPhiInfo, CarrierPhiEntry};
pub use loop_header_phi_builder::LoopHeaderPhiBuilder;
use crate::mir::{BasicBlockId, MirModule, ValueId};
use crate::mir::join_ir::lowering::inline_boundary::JoinInlineBoundary;
@ -154,7 +157,7 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
);
}
let phi_info = loop_header_phi_builder::LoopHeaderPhiBuilder::build(
let phi_info = LoopHeaderPhiBuilder::build(
builder,
entry_block_remapped, // header_block (JoinIR's entry block = loop header)
host_entry_block, // entry_block (host's block that jumps to loop header)
@ -182,10 +185,10 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
phi_info
} else {
loop_header_phi_builder::LoopHeaderPhiInfo::empty(entry_block_remapped)
LoopHeaderPhiInfo::empty(entry_block_remapped)
}
} else {
loop_header_phi_builder::LoopHeaderPhiInfo::empty(entry_block_remapped)
LoopHeaderPhiInfo::empty(entry_block_remapped)
};
// Phase 4: Merge blocks and rewrite instructions
@ -212,7 +215,7 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
loop_header_phi_info.carrier_phis.len()
);
}
loop_header_phi_builder::LoopHeaderPhiBuilder::finalize(
LoopHeaderPhiBuilder::finalize(
builder,
&loop_header_phi_info,
debug,