refactor(joinir): Phase 30 F-2.0/F-3 - PHI箱インベントリと旧APIレガシー削除
F-3 レガシー削除: - generic_case_a.rs: 旧API関数4個削除(_with_scope 移行完了) - loop_scope_shape.rs: CaseAContext::new() 削除(from_scope() に統一) - mod.rs: 不要な pub use 削除 - #[allow(dead_code)] 除去(5関数) - 未使用import削除(コード削減約150行) F-2.0 PHI箱インベントリ: - PHI_BOX_INVENTORY.md 作成: 13箱+11補助構造体の棚卸し - 削除順ポリシー: 早期/中期/最終の3段階 - TASKS.md/CURRENT_TASK.md 更新 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -9,8 +9,6 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::mir::join_ir::lowering::loop_scope_shape::CaseAContext;
|
||||
// Phase 30: LoopScopeShape は将来の _with_scope API 追加時に再インポート
|
||||
// use crate::mir::join_ir::lowering::loop_scope_shape::LoopScopeShape;
|
||||
use crate::mir::join_ir::lowering::value_id_ranges;
|
||||
use crate::mir::join_ir::lowering::value_id_ranges::skip_ws as vid;
|
||||
use crate::mir::join_ir::lowering::value_id_ranges::stage1_using_resolver as stage1_vid;
|
||||
@ -18,45 +16,7 @@ use crate::mir::join_ir::{
|
||||
BinOpKind, CompareOp, ConstValue, JoinContId, JoinFuncId, JoinFunction, JoinInst, JoinModule,
|
||||
LoopExitShape, LoopHeaderShape, MirLikeInst,
|
||||
};
|
||||
use crate::mir::loop_form::LoopForm;
|
||||
use crate::mir::phi_core::loop_exit_liveness::LoopExitLivenessBox;
|
||||
use crate::mir::phi_core::loop_var_classifier::LoopVarClassBox;
|
||||
use crate::mir::{MirFunction, MirQuery, ValueId};
|
||||
|
||||
/// v1: minimal_ssa_skip_ws 専用の汎用 Case A ロワー
|
||||
///
|
||||
/// - LoopForm / VarClass / ExitLiveness は形の検証にのみ使う(パターンが合わなければ None)
|
||||
/// - JoinModule の形は hand-written skip_ws と同一になるように組み立てる
|
||||
pub fn lower_case_a_loop_to_joinir_for_minimal_skip_ws(
|
||||
loop_form: &LoopForm,
|
||||
var_classes: &LoopVarClassBox,
|
||||
exit_live: &LoopExitLivenessBox,
|
||||
query: &impl MirQuery,
|
||||
mir_func: &MirFunction,
|
||||
) -> Option<JoinModule> {
|
||||
// 追加の latch チェック(skip_ws 固有)
|
||||
if loop_form.latch != loop_form.body && loop_form.latch != loop_form.header {
|
||||
eprintln!(
|
||||
"[joinir/generic_case_a] unexpected latch {:?} (body={:?}, header={:?}), fallback",
|
||||
loop_form.latch, loop_form.body, loop_form.header
|
||||
);
|
||||
return None;
|
||||
}
|
||||
|
||||
// CaseAContext で共通ロジックを実行
|
||||
let ctx = CaseAContext::new(
|
||||
loop_form,
|
||||
var_classes,
|
||||
exit_live,
|
||||
query,
|
||||
mir_func,
|
||||
"skip_ws",
|
||||
|offset| vid::loop_step(offset),
|
||||
)?;
|
||||
|
||||
// コア実装に委譲(Phase 30: _with_scope と共通化)
|
||||
lower_case_a_skip_ws_core(&ctx)
|
||||
}
|
||||
use crate::mir::ValueId;
|
||||
|
||||
/// Phase 30: LoopScopeShape を直接受け取る skip_ws lowerer
|
||||
///
|
||||
@ -267,28 +227,24 @@ fn lower_case_a_skip_ws_core(ctx: &CaseAContext) -> Option<JoinModule> {
|
||||
Some(join_module)
|
||||
}
|
||||
|
||||
/// Placeholder: trim minimal 用の generic Case A ロワー(v0, 未実装)
|
||||
/// Phase 30 F-3.0.3: LoopScopeShape を直接受け取る trim lowerer
|
||||
///
|
||||
/// - いまは構造チェックのみで必ず None を返し、呼び元でフォールバックさせる
|
||||
/// - 将来 trim_minimal を generic_case_a で置き換える際の導線として用意
|
||||
pub fn lower_case_a_loop_to_joinir_for_trim_minimal(
|
||||
loop_form: &LoopForm,
|
||||
var_classes: &LoopVarClassBox,
|
||||
exit_live: &LoopExitLivenessBox,
|
||||
query: &impl MirQuery,
|
||||
mir_func: &MirFunction,
|
||||
/// 呼び出し元で LoopScopeShape を明示的に構築し、この関数に渡す。
|
||||
/// CaseAContext::from_scope() 経由で ctx を作成。
|
||||
pub(crate) fn lower_case_a_trim_with_scope(
|
||||
scope: crate::mir::join_ir::lowering::loop_scope_shape::LoopScopeShape,
|
||||
) -> Option<JoinModule> {
|
||||
// CaseAContext で共通ロジックを実行
|
||||
let ctx = CaseAContext::new(
|
||||
loop_form,
|
||||
var_classes,
|
||||
exit_live,
|
||||
query,
|
||||
mir_func,
|
||||
"trim",
|
||||
|offset| value_id_ranges::funcscanner_trim::loop_step(offset),
|
||||
)?;
|
||||
let ctx = CaseAContext::from_scope(scope, "trim", |offset| {
|
||||
value_id_ranges::funcscanner_trim::loop_step(offset)
|
||||
})?;
|
||||
lower_case_a_trim_core(&ctx)
|
||||
}
|
||||
|
||||
/// trim JoinModule 構築のコア実装
|
||||
///
|
||||
/// CaseAContext から JoinModule を構築する共通ロジック。
|
||||
/// `_for_trim_minimal` と `_with_scope` の両方から呼ばれる。
|
||||
fn lower_case_a_trim_core(ctx: &CaseAContext) -> Option<JoinModule> {
|
||||
let string_key = ctx.pinned_name_or_first(0)?;
|
||||
let base_key = ctx.pinned_name_or_first(1).unwrap_or_else(|| string_key.clone());
|
||||
let carrier_key = ctx.carrier_name_or_first(0)?;
|
||||
@ -747,28 +703,24 @@ pub fn lower_case_a_loop_to_joinir_for_trim_minimal(
|
||||
Some(join_module)
|
||||
}
|
||||
|
||||
/// append_defs_minimal 用の generic Case A ロワー(LoopForm/VarClass/ExitLiveness ベース)
|
||||
/// Phase 30 F-3.0.4: LoopScopeShape を直接受け取る append_defs lowerer
|
||||
///
|
||||
/// - LoopForm が単一 header/latch でない場合や、必要な変数がマッピングできない場合は None を返す。
|
||||
/// - 既存の手書き JoinIR(append_defs_entry + loop_step)と同じ形を目指す。
|
||||
pub fn lower_case_a_loop_to_joinir_for_append_defs_minimal(
|
||||
loop_form: &LoopForm,
|
||||
var_classes: &LoopVarClassBox,
|
||||
exit_live: &LoopExitLivenessBox,
|
||||
query: &impl MirQuery,
|
||||
mir_func: &MirFunction,
|
||||
/// 呼び出し元で LoopScopeShape を明示的に構築し、この関数に渡す。
|
||||
/// CaseAContext::from_scope() 経由で ctx を作成。
|
||||
pub(crate) fn lower_case_a_append_defs_with_scope(
|
||||
scope: crate::mir::join_ir::lowering::loop_scope_shape::LoopScopeShape,
|
||||
) -> Option<JoinModule> {
|
||||
// CaseAContext で共通ロジックを実行
|
||||
let ctx = CaseAContext::new(
|
||||
loop_form,
|
||||
var_classes,
|
||||
exit_live,
|
||||
query,
|
||||
mir_func,
|
||||
"append_defs",
|
||||
|offset| value_id_ranges::funcscanner_append_defs::loop_step(offset),
|
||||
)?;
|
||||
let ctx = CaseAContext::from_scope(scope, "append_defs", |offset| {
|
||||
value_id_ranges::funcscanner_append_defs::loop_step(offset)
|
||||
})?;
|
||||
lower_case_a_append_defs_core(&ctx)
|
||||
}
|
||||
|
||||
/// append_defs JoinModule 構築のコア実装
|
||||
///
|
||||
/// CaseAContext から JoinModule を構築する共通ロジック。
|
||||
/// `_for_append_defs_minimal` と `_with_scope` の両方から呼ばれる。
|
||||
fn lower_case_a_append_defs_core(ctx: &CaseAContext) -> Option<JoinModule> {
|
||||
let dst_key = ctx.pinned_name_or_first(0)?;
|
||||
let defs_key = ctx.pinned_name_or_first(1).unwrap_or_else(|| dst_key.clone());
|
||||
let n_key = ctx.pinned_name_or_first(2).unwrap_or_else(|| defs_key.clone());
|
||||
@ -904,25 +856,23 @@ pub fn lower_case_a_loop_to_joinir_for_append_defs_minimal(
|
||||
Some(join_module)
|
||||
}
|
||||
|
||||
/// Stage1UsingResolver minimal 用の generic Case A ロワー(LoopForm/VarClass/ExitLiveness ベース)
|
||||
pub fn lower_case_a_loop_to_joinir_for_stage1_usingresolver_minimal(
|
||||
loop_form: &LoopForm,
|
||||
var_classes: &LoopVarClassBox,
|
||||
exit_live: &LoopExitLivenessBox,
|
||||
query: &impl MirQuery,
|
||||
mir_func: &MirFunction,
|
||||
/// Phase 30 F-3.0.5: LoopScopeShape を直接受け取る Stage-1 UsingResolver lowerer
|
||||
///
|
||||
/// 呼び出し元で LoopScopeShape を明示的に構築し、この関数に渡す。
|
||||
/// CaseAContext::from_scope() 経由で ctx を作成。
|
||||
pub(crate) fn lower_case_a_stage1_usingresolver_with_scope(
|
||||
scope: crate::mir::join_ir::lowering::loop_scope_shape::LoopScopeShape,
|
||||
) -> Option<JoinModule> {
|
||||
// CaseAContext で共通ロジックを実行
|
||||
let ctx = CaseAContext::new(
|
||||
loop_form,
|
||||
var_classes,
|
||||
exit_live,
|
||||
query,
|
||||
mir_func,
|
||||
"stage1",
|
||||
|offset| stage1_vid::loop_step(offset),
|
||||
)?;
|
||||
let ctx =
|
||||
CaseAContext::from_scope(scope, "stage1", |offset| stage1_vid::loop_step(offset))?;
|
||||
lower_case_a_stage1_usingresolver_core(&ctx)
|
||||
}
|
||||
|
||||
/// Stage-1 UsingResolver JoinModule 構築のコア実装
|
||||
///
|
||||
/// CaseAContext から JoinModule を構築する共通ロジック。
|
||||
/// `_for_stage1_usingresolver_minimal` と `_with_scope` の両方から呼ばれる。
|
||||
fn lower_case_a_stage1_usingresolver_core(ctx: &CaseAContext) -> Option<JoinModule> {
|
||||
let entries_key = ctx.pinned_name_or_first(0)?;
|
||||
let n_key = ctx.pinned_name_or_first(1).unwrap_or_else(|| entries_key.clone());
|
||||
let modules_key = ctx.pinned_name_or_first(2).unwrap_or_else(|| entries_key.clone());
|
||||
|
||||
Reference in New Issue
Block a user