feat(mir/llvm): Phase 273 P0-P1 DomainPlan→CorePlan + LLVM arg fix

Phase 273 P0-P1: Two-layer plan architecture
- DomainPlan: Pattern-specific knowledge (ScanWithInit)
- CorePlan: Fixed vocabulary (Seq, Loop, If, Effect, Exit)
- ValueId references only (String expressions forbidden)
- Pipeline: Extractor→Normalizer→Verifier→Lowerer

New plan/ module:
- mod.rs: Type definitions, SSOT spec
- normalizer.rs: DomainPlan→CorePlan + ID allocation
- verifier.rs: V1-V6 invariant checks (fail-fast)
- lowerer.rs: CorePlan→MIR (pattern-agnostic)

LLVM fix (ChatGPT):
- function_lower.py: Fix argument reference bug
- Phase 258 index_of_string now PASS on LLVM backend

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-22 22:42:56 +09:00
parent f07c2e7874
commit 960241795d
20 changed files with 1728 additions and 388 deletions

View File

@ -0,0 +1,34 @@
# Phase 273 P0: Plan Extractor (pure) + PlanLowerer SSOT — completion
Status: ✅ completed (2025-12-22)
Goal:
- Pattern を “Plan抽出プラグイン” に降格し、CFG/PHI/block/value 生成の責務を PlanLowerer に集約して、裾広がりを止める。
What changed (P0):
- Plan 語彙を最小導入P0 は PoC として pattern-specific を 1 個だけ許容)
- Extractor は purebuilder を触らない)
- Lowerer が block/value/phi を作る唯一の場所
- terminator SSOT`Frag → emit_frag()`)は維持
PoC target:
- Pattern6scan with init
Behavior / limits:
- `dynamic_needle=true` は当時 `Ok(None)` で fallthroughP1+
- `step_lit != 1`reverse scan`Ok(None)` で fallthroughP1+
Regression:
- `tools/smokes/v2/profiles/integration/apps/phase254_p0_index_of_vm.sh` PASS
Files:
- `src/mir/builder/control_flow/plan/mod.rs`
- `src/mir/builder/control_flow/plan/lowerer.rs`
- `src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs`
- `src/mir/builder/control_flow/joinir/patterns/router.rs`
Next (P1+):
- Plan語彙を固定`Seq/Loop/If/Effect/Exit`へ畳み、pattern-specific Plan の増殖を止める。
Note (follow-up):
- その後の修正で `dynamic_needle`Phase 258 の string index_of 系)も PlanLowerer 側で handling され、JoinIR freeze 下でも fallthrough しない経路に寄せている(詳細は Phase 273 README を参照)。