Files
hakorune/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md

162 lines
9.8 KiB
Markdown
Raw Normal View History

# JoinIR / Selfhost INDEX読み始めガイド
Status: Active
Scope: JoinIR と SelfhostStageB/Stage1/Stage3に関する「最初に読むべき現役ドキュメント」だけを集約した入口。
このファイルは、JoinIR と Selfhost ラインの主戦場をすばやく把握するためのインデックスだよ。
歴史メモや詳細な Phase 文書に飛ぶ前に、まずここに載っている現役ドキュメントから辿っていくことを想定しているよ。
docs の置き場所SSOT/Phase/調査ログの分離ルール)は、先にこれを読むと迷子になりにくいよ。
- `docs/development/current/main/DOCS_LAYOUT.md`
---
## 1. まず全体像だけ掴みたいとき
- JoinIR 全体像SSOT
- `docs/development/current/main/joinir-architecture-overview.md`
- Selfhost / StageB〜3 の代表フロー
- `docs/development/current/main/selfhost_stage3_expected_flow.md`
- 「いまどこまで進んでいるか」の現状サマリ
- `docs/development/current/main/10-Now.md`
- 「JoinIR / Loop / If ライン」
- 「JsonParser / Selfhost depth2 ライン」
- Phase 8690Loop frontendsの要約1枚
- `docs/development/current/main/phase86-90-loop-frontends-summary.md`
---
## 2. JoinIR をこれから触る人向け
JoinIR の箱構造と責務、ループ/if の lowering パターンを把握したいときの読み順だよ。
1. JoinIR の基本設計SSOT
- `docs/development/current/main/joinir-architecture-overview.md`
2. ループパターン空間とパターン番号の意味
- `docs/development/current/main/loop_pattern_space.md`
3. Boundary / ExitLine / Carrier の具体パターン
- `docs/development/current/main/joinir-boundary-builder-pattern.md`
4. JoinIR 設計地図(現役の地図)
- `docs/development/current/main/design/joinir-design-map.md`
- ControlTree / StepTree構造SSOT: `docs/development/current/main/design/control-tree.md`
5. Loop Canonicalizer設計 SSOT
- `docs/development/current/main/design/loop-canonicalizer.md`
feat(mir): Loop Canonicalizer Phase 3 - skip_whitespace pattern recognition ## Summary skip_whitespace パターンを Skeleton→Decision で認識可能に。 dev-only 観測で chosen=Pattern3IfPhi / missing_caps=[] を固定。 ## Changes - src/mir/loop_canonicalizer/mod.rs: - try_extract_skip_whitespace_pattern() 追加 - loop(cond) { ... if check { p = p + 1 } else { break } } パターン認識 - carrier name, delta, body statements を抽出 - canonicalize_loop_expr() 拡張(skip_whitespace 対応) - Pattern3IfPhi 成功時は RoutingDecision::success 返却 - Skeleton に HeaderCond, Body, Update ステップ追加 - CarrierSlot に Counter role 設定 - ExitContract に has_break=true 設定 - Phase 3 unit tests 追加 - test_skip_whitespace_pattern_recognition: 基本パターン - test_skip_whitespace_with_body_statements: body 付きパターン - test_skip_whitespace_fails_without_else: else なし失敗 - test_skip_whitespace_fails_with_wrong_delta: 減算パターン失敗 - Phase 2 obsolete tests 削除 - src/mir/builder/control_flow/joinir/routing.rs: - Debug 出力拡張(chosen pattern 表示) ## Tests - cargo test --release --lib loop_canonicalizer::tests: PASS(11 tests) - cargo test --release --lib: PASS(1044 tests, 退行なし) - HAKO_JOINIR_DEBUG=1 test_pattern3_skip_whitespace.hako: - chosen=Pattern3IfPhi ✅ - missing_caps=[] ✅ ## Validation - ✅ dev-only 観測(HAKO_JOINIR_DEBUG=1)のときだけログ出力 - ✅ フラグ OFF 時は完全不変 - ✅ skip_whitespace パターンで SUCCESS 固定 - ✅ unit tests で全パターン固定 Phase 137-3 complete
2025-12-16 05:38:18 +09:00
- 実装Phase 137-2: `src/mir/loop_canonicalizer/mod.rs`
6. Phase 93: ConditionOnly Derived SlotTrim / body-local
- `docs/development/current/main/phases/phase-93/README.md`
7. Phase 94: P5b “完全E2E”escape skip / derived
- `docs/development/current/main/phases/phase-94/README.md`
8. Phase 95: MiniJsonLoader escape ループPhase 94 基盤の横展開)
- `docs/development/current/main/phases/phase-95/README.md`
9. Phase 96: Trim policy 着手 + next_non_ws ループ
- `docs/development/current/main/phases/phase-96/README.md`
10. Phase 97: MiniJsonLoader LLVM EXE paritynext_non_ws / escape
- `docs/development/current/main/phases/phase-97/README.md`
11. Phase 98: Plugin loader fail-fast + LLVM parity持続化
- `docs/development/current/main/phases/phase-98/README.md`
12. Phase 100: Pinned ReadOnly Captures設計メモ
- `docs/development/current/main/phases/phase-100/README.md`
13. Phase 102: real-app read_quoted loop regressionVM + LLVM EXE
- `docs/development/current/main/phases/phase-102/README.md`
14. Phase 103: if-only regression baselineVM + LLVM EXE / plan
- `docs/development/current/main/phases/phase-103/README.md`
15. Phase 113: if-only partial assign parity片側代入の保持 merge
- `docs/development/current/main/phases/phase-113/README.md`
16. Phase 114: if-only return+post parityearly return + post-if statements
- `docs/development/current/main/phases/phase-114/README.md`
17. Phase 115: if-only call result merge parity関数呼び出し結果 merge
- `docs/development/current/main/phases/phase-115/README.md`
18. Phase 116: if-only keep+call merge parity片側元値保持、片側 call merge
- `docs/development/current/main/phases/phase-116/README.md`
19. Phase 117: if-only nested-if + call merge parityネストif + call merge
- `docs/development/current/main/phases/phase-117/README.md`
20. Phase 118: loop + if-else merge parityloop + if-else 変数更新 merge / carrier PHI contract
- `docs/development/current/main/phases/phase-118/README.md`
21. Phase 104: loop(true) break-only digitsVM + LLVM EXE
- `docs/development/current/main/phases/phase-104/README.md`
22. Phase 107: json_cur find_balanced_* depth scanVM + LLVM EXE
- `docs/development/current/main/phases/phase-107/README.md`
23. Phase 108: Pattern2 policy router SSOT入口の薄さを固定
- `docs/development/current/main/phases/phase-108/README.md`
24. Phase 109: error_tags hints SSOTFail-Fast + hint の語彙固定)
- `docs/development/current/main/phases/phase-109/README.md`
25. MIR BuilderContext 分割の入口)
- `src/mir/builder/README.md`
26. Scope/BindingIdshadowing・束縛同一性の段階移行
- `docs/development/current/main/phase73-scope-manager-design.md`
- `docs/development/current/main/PHASE_74_SUMMARY.md`
- `docs/development/current/main/PHASE_75_SUMMARY.md`
- `docs/development/current/main/PHASE_77_EXECUTIVE_SUMMARY.md`
- `docs/development/current/main/phase78-bindingid-promoted-carriers.md`
- `docs/development/current/main/phase80-bindingid-p3p4-plan.md`P3/P4 への配線計画)
- `docs/development/current/main/phase81-pattern2-exitline-contract.md`promoted carriers の ExitLine 契約検証)
25. Boxification feedbackPhase 7885 の振り返りと Phase 86 推奨)
- `docs/development/current/main/phase78-85-boxification-feedback.md`
26. Phase 86: Carrier Init Builder + Error Tags ✅
- **Status**: COMPLETE (2025-12-13)
- **Modules**:
- `src/mir/builder/control_flow/joinir/merge/carrier_init_builder.rs` (+8 tests)
- `src/mir/join_ir/lowering/error_tags.rs` (+5 tests)
- **Achievements**: SSOT 確立CarrierInit → ValueId 生成統一、エラータグ中央化、DebugOutputBox 完全移行)
- **Impact**: 987/987 tests PASS, +13 unit tests, Single Responsibility validated
27. Phase 87: LLVM Exe Line SSOT ✅
- **Status**: COMPLETE (2025-12-13)
- **SSOT**: `tools/build_llvm.sh` - Single pipeline for .hako → executable
- **Deliverables**:
- Design doc: `phase87-selfhost-llvm-exe-line.md` (full troubleshooting + advanced usage)
- Minimal fixture: `apps/tests/phase87_llvm_exe_min.hako` (exit code 42)
- Integration smoke: `tools/smokes/v2/profiles/integration/apps/phase87_llvm_exe_min.sh` (SKIP if no LLVM)
- **Policy**: No script duplication, integration smoke only (not quick), graceful SKIP
- **Impact**: Standard procedure established, prerequisites documented
28. 代表的な Phase 文書(現役ラインとの接点だけ絞ったもの)
- `docs/development/current/main/phase33-16-INDEX.md`
- `docs/development/current/main/phase33-17-joinir-modularization-analysis.md`
- `docs/development/current/main/phase183-selfhost-depth2-joinir-status.md`
29. Phase 8690Loop frontendsの要約1枚
- `docs/development/current/main/phase86-90-loop-frontends-summary.md`
Phase 文書は歴史や検証ログも含むので、「JoinIR の現役設計を確認した上で、必要なときだけ掘る」という前提で読んでね。
---
## 3. SelfhostStageB / Stage1 / Stage3を触る人向け
自己ホストコンパイラのフローや実行手順、Ny Executor ラインの計画を押さえたいときの読み順だよ。
1. Selfhost 全体フローStageB / Stage1 / Stage3 と JSON v0
- `docs/development/current/main/selfhost_stage3_expected_flow.md`
2. 実行手順・クイックスタート
- `docs/development/selfhosting/quickstart.md`
- `docs/development/testing/selfhost_exe_stageb_quick_guide.md`
3. Ny ExecutorNy で MIR(JSON v0) を実行)のロードマップ
- `docs/development/roadmap/selfhosting-ny-executor.md`
4. Stage3 / depth2 関連で「現役」として参照する Phase 文書
- `docs/development/current/main/phase150_selfhost_stage3_depth1_baseline.md`
- `docs/development/current/main/phase150_selfhost_stage3_depth1_results.md`
- `docs/development/current/main/phase183-selfhost-depth2-joinir-status.md`
- `docs/development/current/main/phase120_selfhost_stable_paths.md`
---
## 4. 迷ったときの読み分けガイド
- JoinIR の箱や契約で迷っているとき
- → 2章の 1〜3 をこの順番で読む。
- Selfhost のビルド / 実行フローで迷っているとき
- → 3章の 1〜3 をこの順番で読む。
- VM backend の Box 解決ConsoleBox / plugin / builtinで迷っているとき
-`docs/development/current/main/phase131-2-box-resolution-map.md`(経路図)
-`docs/development/current/main/phase131-2-summary.md`(要点)
- LLVMPython llvmlitelowering の不具合切り分けで迷っているとき
-`docs/development/current/main/phase131-3-llvm-lowering-inventory.md`(再現ケース表 + 根本原因候補)
-`docs/development/current/main/phase131-11-case-c-summary.md`Case C: `loop(true)` + break/continue の本命計画)
-`docs/development/current/main/case-c-infinite-loop-analysis.md`Case C: 詳細調査ログ)
-`docs/development/current/main/phase131-5-taglink-fix-summary.md`TAG-LINK: symbol 名の修正ログ)
-`docs/development/current/main/phase131-6-ssa-dominance-diagnosis.md`TAG-RUN の初期診断ログ・歴史)
-`docs/development/current/main/phase87-selfhost-llvm-exe-line.md`実行パイプラインのSSOT
- 「この Phase 文書は現役か?」で迷ったとき
- → まず `docs/development/current/main/10-Now.md`
`docs/development/current/main/30-Backlog.md` を確認し、そこで名前が挙がっている Phase 文書を優先して読んでね。