refactor(plan): Phase 273 P3+ - Legacy code removal
Phase 273 P3+ 完成: レガシーコード削除 + 未使用 import 整理 Removed Legacy Items: 1. emit_scan_with_init_edgecfg() - Pattern6 固有の emission 関数 - File deleted: src/mir/builder/emission/loop_scan_with_init.rs (~144 lines) - Replaced by: generalized Frag API (Phase 273 P2) 2. CoreCarrierInfo struct - Legacy carrier representation - Removed from: src/mir/builder/control_flow/plan/mod.rs (~15 lines) - Replaced by: CorePhiInfo (generalized PHI representation) 3. verify_carrier() function - CoreCarrierInfo validator - Removed from: src/mir/builder/control_flow/plan/verifier.rs (~15 lines) - Replaced by: generalized PHI verification (V7-V9) Code Cleanup: - cargo fix applied: unused imports removed (~30 files) - Verifier invariants updated: V1→V2-V9 (carrier→PHI model) - Module declaration cleanup in emission/mod.rs Impact: - Total lines removed: ~174 lines (net reduction) - Pattern-agnostic architecture strengthened - All legacy Pattern6 references eliminated Tests: - ✅ VM tests PASS (phase254/256/258) - ✅ LLVM tests PASS (phase256/258) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
# Phase 273 P2 Completion (2025-12-22)
|
||||
|
||||
P2 Goal:
|
||||
- Pattern7(split scan)を Plan ライン(DomainPlan→CorePlan→Lowerer)へ移行し、Lowerer の “pattern知識” を増やさない。
|
||||
|
||||
## Delivered
|
||||
|
||||
- CoreEffectPlan: 副作用対応
|
||||
- `MethodCall` が `dst: Option<ValueId>` を持てる(`push` 等の void-return 対応)
|
||||
- `effects: EffectMask` を CorePlan から指定できる(PURE ではない呼び出しを明示)
|
||||
|
||||
- CoreLoopPlan: 一般化(Pattern6/7 の収束点)
|
||||
- `block_effects: Vec<(BasicBlockId, Vec<CoreEffectPlan>)>`
|
||||
- `phis: Vec<CorePhiInfo>`
|
||||
- `frag: Frag`(terminator SSOT: `emit_frag()`)
|
||||
- `final_values: Vec<(String, ValueId)>`(variable_map 更新の SSOT)
|
||||
|
||||
- Pattern7: Plan ライン移行
|
||||
- Extractor は pure(builder を触らない)
|
||||
- Normalizer が split 固有のブロック構造/PHI/Frag を決定(SSOT)
|
||||
- Lowerer は CorePlan を吐くだけ(pattern-agnostic)
|
||||
|
||||
## Regression / Validation
|
||||
|
||||
- VM:
|
||||
- `tools/smokes/v2/profiles/integration/apps/phase256_p0_split_vm.sh` PASS(Pattern7)
|
||||
- `tools/smokes/v2/profiles/integration/apps/phase258_p0_index_of_string_vm.sh` PASS(Pattern6)
|
||||
|
||||
## Notes
|
||||
|
||||
- P2 は “generalized 経路” と “legacy fallback” を共存させた(移行中の安全策)。
|
||||
- 次の P3 で Pattern6 も generalized 経路へ移し、legacy fallback を撤去すると収束が完成する。
|
||||
|
||||
95
docs/development/current/main/phases/phase-273/P3-CLAUDE.md
Normal file
95
docs/development/current/main/phases/phase-273/P3-CLAUDE.md
Normal file
@ -0,0 +1,95 @@
|
||||
# Phase 273 P3 — “Plan Lowering SSOT Finalize” (Claude Code Instructions)
|
||||
|
||||
目的:
|
||||
- Phase 273 P2 で導入した generalized CoreLoopPlan を SSOT として固定し、legacy fallback を撤去して収束を完成させる。
|
||||
|
||||
前提:
|
||||
- Extractor は pure(builder 触り禁止)
|
||||
- Pattern知識は Normalizer に閉じる
|
||||
- Lowerer は CorePlan のみを処理(pattern-agnostic)
|
||||
- terminator SSOT は `Frag → emit_frag()` のみ
|
||||
|
||||
## Scope
|
||||
|
||||
P3 でやる:
|
||||
1. Pattern6 を generalized CoreLoopPlan(`frag/block_effects/phis/final_values`)へ移行
|
||||
2. `lower_loop_legacy()` を撤去し、generalized 経路を SSOT 化(Fail-Fast)
|
||||
3. CoreLoopPlan の `Option<...>` を必須化して “揺れ” を構造で消す(可能なら)
|
||||
|
||||
P3 でやらない:
|
||||
- Pattern8/その他 pattern の Plan 化(別フェーズ)
|
||||
- CorePlan の vocabulary 増殖(variant追加禁止)
|
||||
|
||||
## Tasks
|
||||
|
||||
### Task 1: Pattern6 を generalized CoreLoopPlan へ移行
|
||||
|
||||
対象:
|
||||
- `src/mir/builder/control_flow/plan/normalizer.rs`
|
||||
|
||||
やること:
|
||||
- ScanWithInit の normalize で以下を構築する:
|
||||
- `block_effects`: header/body/step の効果(ValueId は normalizer で生成・型登録)
|
||||
- `phis`: header の loop-carrier PHI
|
||||
- `frag`: header/body の BranchStub + wires(step→header, found→Return(i), after→Return(-1) など現行仕様に合わせる)
|
||||
- `final_values`: `i` の最終値(after で使うならその ValueId)
|
||||
- legacy field(`header_effects/body/step_effects/carriers/cond_*` など)を空/未使用にするか、最終的に削除する。
|
||||
|
||||
注意:
|
||||
- ScanWithInit は “return” を含むので、Frag wires に Return を含める(emit_frag SSOT)。
|
||||
- `ensure_block_exists` が必要なブロック(after/found 等)は Lowerer で担保する。
|
||||
|
||||
### Task 2: Lowerer の legacy fallback を撤去
|
||||
|
||||
対象:
|
||||
- `src/mir/builder/control_flow/plan/lowerer.rs`
|
||||
|
||||
やること:
|
||||
- `lower_loop_legacy()` を削除
|
||||
- `lower_loop()` は generalized フィールドを必須として扱い、欠落時は Err(Fail-Fast)
|
||||
- 例: `block_effects/phis/frag/final_values` が None なら `[lowerer] missing generalized loop fields` で Err
|
||||
|
||||
狙い:
|
||||
- Lowerer から `emit_scan_with_init_edgecfg()` 等の pattern 参照を完全に消す。
|
||||
|
||||
### Task 3: CoreLoopPlan の “必須化”(可能な範囲で)
|
||||
|
||||
対象:
|
||||
- `src/mir/builder/control_flow/plan/mod.rs`
|
||||
|
||||
やること:
|
||||
- `block_effects/phis/frag/final_values` を `Option` から非Optionへ変更(できるなら)
|
||||
- legacy fields を削除(この時点で Pattern6/7 が generalized を使っていることが前提)
|
||||
|
||||
### Task 4: Verifier の拡張(generalized 専用の不変条件)
|
||||
|
||||
対象:
|
||||
- `src/mir/builder/control_flow/plan/verifier.rs`
|
||||
|
||||
例:
|
||||
- `phis` が空でないこと(carrierがある場合)
|
||||
- `frag.entry` が header_bb に一致すること(loopのentry SSOT)
|
||||
- `block_effects` に header/body/step が含まれること(最低限)
|
||||
|
||||
### Task 5: 回帰テスト
|
||||
|
||||
VM:
|
||||
- `bash tools/smokes/v2/profiles/integration/apps/phase254_p0_index_of_vm.sh`
|
||||
- `bash tools/smokes/v2/profiles/integration/apps/phase256_p0_split_vm.sh`
|
||||
- `bash tools/smokes/v2/profiles/integration/apps/phase258_p0_index_of_string_vm.sh`
|
||||
|
||||
LLVM(必ず harness で、mock禁止):
|
||||
- `cargo build --release --features llvm`
|
||||
- `bash tools/smokes/v2/profiles/integration/apps/phase256_p0_split_llvm_exe.sh`
|
||||
- `bash tools/smokes/v2/profiles/integration/apps/phase258_p0_index_of_string_llvm_exe.sh`
|
||||
|
||||
注意:
|
||||
- `NYASH_LLVM_USE_HARNESS=1` で `--features llvm` が無い場合は fail-fast する(mock禁止)。
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- Lowerer から `emit_scan_with_init_edgecfg()` 等の pattern 固有参照が消えている
|
||||
- Pattern6/7 が generalized CoreLoopPlan を使用している
|
||||
- legacy fallback が撤去され、欠落時は Err(Fail-Fast)
|
||||
- 上記 smokes がすべて PASS(VM/LLVM)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Phase 273: Plan Extractor (Pure) + PlanLowerer SSOT
|
||||
|
||||
Status: ✅ P0/P1 completed (2025-12-22)
|
||||
Status: ✅ P0/P1/P2 completed (2025-12-22)
|
||||
|
||||
Goal:
|
||||
- pattern 列挙の裾広がりを止める。
|
||||
@ -9,6 +9,15 @@ Goal:
|
||||
|
||||
---
|
||||
|
||||
## P2 完了 (2025-12-22)
|
||||
|
||||
P2 では Pattern7(split scan)を Plan ラインへ移行し、P1 の CorePlan を保ったまま “収束圧” を上げた。
|
||||
|
||||
- ✅ Pattern7: Extractor → DomainPlan → Normalizer → CorePlan → Lowerer(MIR/Frag/emit_frag)へ統一
|
||||
- ✅ CoreLoopPlan: `block_effects / phis / frag / final_values` で一般化(Pattern6/7 が同一 CorePlan に収束)
|
||||
- ✅ CoreEffectPlan: `dst: Option<ValueId>` + `effects: EffectMask` で副作用(例: `push`)を表現可能にした
|
||||
- ✅ Lowerer: “split” の知識を持たず、CorePlan のみを処理(pattern-agnostic 維持)
|
||||
|
||||
## P1 完了 (2025-12-22)
|
||||
|
||||
### アーキテクチャ
|
||||
@ -52,7 +61,7 @@ pub enum CorePlan {
|
||||
}
|
||||
|
||||
pub enum CoreEffectPlan {
|
||||
MethodCall { dst, object, method, args },
|
||||
MethodCall { dst, object, method, args, effects },
|
||||
BinOp { dst, lhs, op, rhs },
|
||||
Compare { dst, lhs, op, rhs },
|
||||
Const { dst, value },
|
||||
@ -111,6 +120,16 @@ AOT ランタイム(nyrt)は `ny_main()` の返り値が **raw i64** か **h
|
||||
|
||||
- P0 Claude Code: `docs/development/current/main/phases/phase-273/P0-CLAUDE.md`
|
||||
- P1 Claude Code: `docs/development/current/main/phases/phase-273/P1-CLAUDE.md`
|
||||
- P2 Completion: `docs/development/current/main/phases/phase-273/P2-COMPLETION.md`
|
||||
|
||||
## Next (P3 proposal)
|
||||
|
||||
P2 で追加した “legacy fallback” を残したままだと、Lowerer の中に `emit_scan_with_init_edgecfg()` 等の旧経路が残り続ける。
|
||||
収束を完成させるには、次を P3 で行うのが良い:
|
||||
|
||||
- Pattern6 を generalized CoreLoopPlan(`frag/block_effects/phis/final_values`)に移行
|
||||
- `lower_loop_legacy()` を撤去し、generalized 経路を SSOT 化(Fail-Fast)
|
||||
- CoreLoopPlan の `Option<...>` フィールドを必須化(構造で “揺れ” を消す)
|
||||
|
||||
## Future Work (P2+)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user