Files
hakorune/docs/development/current/main/phases/phase-146/README.md

129 lines
4.5 KiB
Markdown
Raw Normal View History

feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
# Phase 146: Loop/If Condition ANF Implementation
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
**Status**: P0/P1/P147 complete
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
**Date**: 2025-12-19
**Context**: Phase 145 P0/P1/P2 complete (ANF infrastructure). Phase 146/147 adds condition expression support.
## Overview
Phase 146 enables ANF (A-Normal Form) transformation for loop and if conditions, extending Phase 145's compound expression support to control flow conditions.
## Phase 146 P0: ANF Routing SSOT 統一
**Goal**: Add scope check to ANF routing, unify SSOT, remove legacy inline lowering.
### Implementation
1. **expr_lowerer_box.rs**: Added scope check to ANF routing (L54-79)
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
- `PureOnly` scope: Skip ANF (P1 で dev-only 有効化)
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
- `WithImpure` scope: Try ANF (Phase 145 behavior)
2. **post_if_post_k.rs**: Replaced legacy inline lowering with SSOT (L271-285)
- Use `NormalizedExprLowererBox::lower_expr_with_scope()` first
- Fallback to `lower_condition_legacy()` helper if needed
- Added helper function `lower_condition_legacy()` (L379-413)
3. **contract.rs**: Already has `CondLoweringFailed` variant (L84)
### Files Modified (3 files)
- `src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs` (+10 lines)
- `src/mir/control_tree/normalized_shadow/post_if_post_k.rs` (+44 lines, -25 lines legacy)
- `src/mir/control_tree/normalized_shadow/anf/contract.rs` (no change, already has variant)
### Files Created (4 files)
- `apps/tests/phase146_p0_if_cond_unified_min.hako` (exit code 7)
- `tools/smokes/.../phase146_p0_if_cond_unified_vm.sh`
- `tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh`
- `docs/development/current/main/phases/phase-146/README.md` (this file)
### Acceptance Criteria (P0)
- [x] Scope check added to ANF routing
- [x] Legacy inline lowering removed from post_if_post_k.rs
- [x] SSOT unified (lower_expr_with_scope is only entry point)
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
- [x] Build passes (cargo build --release)
- [x] Tests pass (cargo test --release --lib)
- [x] Phase 145 regression: 0 failures
- [x] Fixture exit code: 7 (VM + LLVM EXE)
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
## Phase 146 P1: 条件式 ANF 有効化done
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
**Goal**: Enable ANF in conditions for `PureOnly` scope behind a dev flag, starting with whitelisted intrinsic (`String.length()`).
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
### Implementation
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
1. **expr_lowerer_box.rs**: Allow ANF for PureOnly with `HAKO_ANF_ALLOW_PURE=1`
2. **anf/execute_box.rs**: Add Compare operator support (`== != < <= > >=`)
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
3. **config/env/joinir_dev.rs**: Add `anf_allow_pure_enabled()` function
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
4. **Whitelist**: KnownIntrinsic registry を利用し、`String.length()` のみ許可
### Files Created (P1)
- `apps/tests/phase146_p1_if_cond_intrinsic_min.hako` (exit code 7)
- `tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh`
- `tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh`
### Acceptance Criteria (P1)
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
- [x] `HAKO_ANF_ALLOW_PURE=1` で PureOnly scope の ANF が有効化される
- [x] `String.length()` のみ許可され、他の MethodCall は out-of-scope
- [x] Fixture exit code: 7 (VM + LLVM EXE)
## Phase 147 P0: 複合条件の順序固定done
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
**Goal**: Extend recursive ANF to Compare operators for compound conditions.
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
### Implementation
1. **anf/contract.rs**: `AnfParentKind::Compare` を追加
2. **anf/plan_box.rs**: Compare vs BinaryOp を判別して ParentKind を決定
3. **anf/execute_box.rs**: Compare でも再帰的 ANF を適用left-to-right
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
### Acceptance Criteria (P147)
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
- [x] Compare を含む複合条件でも評価順序が固定される
- [x] ANF の再帰が Compare にも適用される
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
## Testing
### P0 Smoke Tests
```bash
# VM
./tools/smokes/v2/profiles/integration/apps/phase146_p0_if_cond_unified_vm.sh
# Expected: exit 7
# LLVM EXE
./tools/smokes/v2/profiles/integration/apps/phase146_p0_if_cond_unified_llvm_exe.sh
# Expected: exit 7
```
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix ## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering Pattern 6 detects index_of/find/contains-style loops: - Loop condition: i < x.length() - Loop body: if with method call condition + early return - Step: i = i + 1 - Post-loop: return not-found value (-1) Key features: - Minimal lowering: main/loop_step/k_exit functions - substring hoisted to init-time BoxCall - Two k_exit jumps (found: i, not found: -1) - Tests: phase254_p0_index_of_min.hako ## Phase 255 P0: Multi-param Loop CarrierInfo Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i): - i: LoopState (header PHI + exit PHI) - s, ch: ConditionOnly (header PHI only) - Alphabetical ordering for determinism - All 3 PHI nodes created correctly - Eliminates "undefined ValueId" errors ## Phase 255 P1: Exit PHI DCE Fix Prevents exit PHI from being deleted by DCE: - PostLoopEarlyReturnStepBox emits post-loop guard - if (i != -1) { return i } forces exit PHI usage - Proven pattern from Pattern 2 (balanced_depth_scan) - VM/LLVM backends working ## Test Results ✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1) ✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock) ✅ Quick profile: json_lint_vm PASS (progresses past index_of) ✅ Pattern 1-5: No regressions ## Files Added - src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs - src/mir/join_ir/lowering/scan_with_init_minimal.rs - apps/tests/phase254_p0_index_of_min.hako - docs/development/current/main/phases/phase-254/README.md - docs/development/current/main/phases/phase-255/README.md 🧠 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
### P1 Smoke Tests
```bash
# VM (dev-only)
HAKO_ANF_DEV=1 HAKO_ANF_ALLOW_PURE=1 \
./tools/smokes/v2/profiles/integration/apps/phase146_p1_if_cond_intrinsic_vm.sh
# Expected: exit 7
# LLVM EXE (dev-only)
HAKO_ANF_DEV=1 HAKO_ANF_ALLOW_PURE=1 \
./tools/smokes/v2/profiles/integration/apps/phase146_p1_if_cond_intrinsic_llvm_exe.sh
# Expected: exit 7
```
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
### Regression Tests
Phase 145 smokes must still pass:
- `phase145_p1_anf_length_min` → exit 12
- `phase145_p2_compound_expr_binop_min` → exit 18
- `phase145_p2_compound_expr_double_intrinsic_min` → exit 5
## References
- **Plan File**: `/home/tomoaki/.claude/plans/buzzing-strolling-volcano.md`
- **Phase 145**: `docs/development/current/main/phases/phase-145-anf/README.md`
- **ANF Contract**: `docs/development/current/main/phases/phase-144-anf/INSTRUCTIONS.md`