Commit Graph

7 Commits

Author SHA1 Message Date
b8893787dc feat(joinir): L-5.3 Phase 1 - progress carrier guard for generic_case_a
## 実装内容

1. has_safe_progress() helper 追加 (loop_to_join.rs:186-195)
   - Phase 1: scope.progress_carrier.is_some() をチェック (保守的)
   - Phase 2 (future): MirQuery で Add 命令チェック予定

2. is_supported_case_a_loop_view() に progress guard 追加 (256-266)
   - 無限ループの可能性があるループを事前にフォールバック
   - デバッグログで reject 理由を出力

## テスト結果

 25 passed; 0 failed - JoinIR 関連テスト全通過
 skip_ws / trim / append_defs / Stage‑1 UsingResolver 全ケース PASS
 既存テストへの影響なし

## 技術メモ

- 保守的アプローチ: progress_carrier.is_some() のみチェック
- LoopScopeShape で progress_carrier を carriers の先頭として設定済み
- ignored テスト失敗は MIR 自体の PHI バグで、本変更とは無関係 (git stash で確認済み)

関連: Phase 29 L-5.3 (TASKS.md), CURRENT_TASK.md 1-00v
2025-11-26 16:08:49 +09:00
9d769e9217 refactor(joinir): L-2.2 Step-1 - Unify Stage-B lowering via LoopToJoinLowerer
Stage-B minimal JoinIR lowering統一化:

1. Add Case-A helpers to loop_to_join.rs:
   - lower_case_a_for_stageb_body (StageBBodyExtractorBox.build_body_src/2)
   - lower_case_a_for_stageb_funcscanner (StageBFuncScannerBox.scan_all_boxes/1)

2. Update stageb_body.rs and stageb_funcscanner.rs:
   - Replace manual LoopForm construction with construct_simple_while_loopform
   - Route through LoopToJoinLowerer like other Case-A functions
   - Remove unused imports (LoopForm, MirQuery)

Now all 6 JoinIR lowering modules use the same unified pattern:
- skip_ws, trim, append_defs, stage1_resolver, stageb_body, stageb_funcscanner
All route through LoopToJoinLowerer for consistency.

Test results: JSON snapshot 6/6 PASS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 10:47:35 +09:00
853cb36800 refactor(joinir): L-1.3 - Rename minimal helpers to Case-A helpers
LoopToJoinLowerer API cleanup:

1. Rename methods to reflect their purpose as Case-A helpers:
   - lower_minimal_skip_ws_case_a → lower_case_a_for_skip_ws
   - lower_minimal_trim_case_a → lower_case_a_for_trim
   - lower_minimal_append_defs_case_a → lower_case_a_for_append_defs
   - lower_minimal_stage1_case_a → lower_case_a_for_stage1_resolver

2. Update comments to clarify these are thin wrappers over `lower()`
   - "Case-A 汎用 lowerer の薄いラッパー"
   - Actual logic is centralized in `lower` method

3. Update all 4 call sites:
   - skip_ws.rs
   - funcscanner_trim.rs
   - funcscanner_append_defs.rs
   - stage1_using_resolver.rs

Test results: standalone (2/2), JSON snapshot (6/6) PASS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 10:28:03 +09:00
7d0581c9a4 refactor(joinir): Extract construct_simple_while_loopform helper, delete legacy code
Phase 32 cleanup:

1. Delete legacy is_supported_case_a_loop function from loop_to_join.rs
   - Replaced by is_supported_case_a_loop_view() in Phase 32 Step 3

2. Extract construct_simple_while_loopform helper to common.rs
   - Unified LoopForm construction for simple while loops
   - Parameters: entry_is_preheader (trim=true, stage1=false)
                 has_break (trim=true, stage1=false)
   - Sets latch=body to satisfy is_simple_case_a_loop check

3. Update lowering modules to use the common helper:
   - funcscanner_trim.rs: entry_is_preheader=true, has_break=true
   - stage1_using_resolver.rs: entry_is_preheader=false, has_break=false

Test results: JSON snapshot 6/6 PASS, VM bridge trim 2/2 PASS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 10:15:31 +09:00
ec69b49446 feat(mir): Phase 32 Step 0-3B - LoopRegion/LoopControlShape view methods
Phase 32 introduces a "view pattern" for loop structures, enabling
gradual migration without breaking existing code.

Changes:
- control_form.rs: Add new ID types (LoopId, ExitEdgeId, ContinueEdgeId)
  and structures (LoopRegion, LoopControlShape, ExitEdge, ContinueEdge)
- control_form.rs: Add view methods on LoopShape:
  - to_region_view() - returns LoopRegion
  - to_control_view() - returns LoopControlShape
  - to_exit_edges() - returns Vec<ExitEdge>
  - to_continue_edges() - returns Vec<ContinueEdge>
- loop_scope_shape.rs: Use views in from_existing_boxes_legacy()
- loop_to_join.rs: Add debug logging with Phase 32 views

All 4 minimal lowerers (skip_ws/trim/append_defs/stage1) now use
view-based block ID extraction via shared from_existing_boxes_legacy().

Tests: joinir_runner_standalone_*, joinir_vm_bridge_trim_* PASS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 08:01:32 +09:00
acffd9974b feat(phase31): Step 3-A/B - Add early return and structure checks to LoopToJoinLowerer
Phase 31 Step 3-A: Add early return using is_case_a_minimal_target() filter
- Check before LoopScopeShape construction for efficiency
- Returns None immediately for non-target functions

Phase 31 Step 3-B: Add structural validation to is_supported_case_a_loop()
- Single exit check: loop_form.break_targets.len() <= 1
- Variable presence check: !carriers.is_empty() || !pinned.is_empty()
- Debug logging for rejection reasons

Also refactored lower_with_scope() from if-else chain to match expression for clarity.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 06:02:52 +09:00
ef9fd4417a feat(phase31): Add LoopToJoinLowerer unified box
Phase 31 Step 1 complete:
- Create src/mir/join_ir/lowering/loop_to_join.rs
- Add LoopToJoinLowerer struct with lower() method
- Implement lower_minimal_skip_ws_case_a() via generic_case_a
- Support for trim, append_defs, stage1 patterns
- Re-export from mod.rs

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 01:18:32 +09:00