Files
hakorune/tests/phase33/smoke/loopform/while_simple.hako
nyash-codex 1a1d223749 feat(phase33): loopform.hako complete implementation - All Stages (1-4) finished
Phase v2-B loopform.hako 完全実装:

【実装】
- loopform.hako (258行): 6-block LoopForm 完全実装
  - Header PHI: incoming 配列 + computed フラグ
  - Dispatch PHI (tag/payload): break/continue 処理
  - Condition: MIR/Payload/Guard 全モード対応
  - Safepoint: GC 安全点統合
- builder.hako (392行): 9 LLVM instructions 統合
- instructions/*.hako (9ファイル): 全命令実装

【テスト】
- Unit test: test_basic.hako (4 tests, 159行)
- Smoke tests (3本, 130行):
  - while_simple.hako: 基本 while ループ
  - for_counter.hako: payload mode カウンタ
  - if_loop_merge.hako: 複合制御フロー + guard

【進捗】
- Stage 1: スケルトン実装 
- Stage 2: PHI incoming 配列化 
- Stage 3: Safepoint & Condition  (Stage 1に含む)
- Stage 4: スモークテスト3本 

【成果】
- 実装: 258行 (Python 224行 + 機能拡張)
- テスト: 289行 (unit 159行 + smoke 130行)
- ビルド: 成功 (0 errors)

次: Phase v2-C MIR Call 統合 + C++ backend 実装

Ref: docs/private/roadmap/phases/phase-33/PHASE_V2_LOOPFORM_*.md
2025-11-01 08:32:20 +09:00

50 lines
1.3 KiB
Plaintext

// LoopForm Smoke Test 1: Basic while loop
// Tests basic while loop structure with loopform
//
// Expected behavior (when C++ backend implements loopform):
// - Loop from 0 to 4
// - Print each iteration
// - Return final counter value (5)
using "lang/src/llvm_ir/instructions/loopform.hako" as LoopFormInst
static box Main {
main() {
print("=== LoopForm Smoke Test 1: while_simple ===")
// Simulate while loop: while (i < 5) { i++ }
local blocks = new MapBox()
blocks.set("preheader", 0)
blocks.set("header", 1)
blocks.set("body", 2)
blocks.set("dispatch", 3)
blocks.set("latch", 4)
blocks.set("exit", 5)
local options = new MapBox()
options.set("mode", "mir")
options.set("enable_safepoint", 1)
// Generate loopform JSON
local json = LoopFormInst.lower_loopform(1, blocks, 10, options)
// Verify JSON structure
local has_loopform = json.indexOf("\"op\":\"loopform\"")
if has_loopform < 0 {
print("ERROR: loopform op not found")
return 1
}
local has_safepoint = json.indexOf("\"enabled\":true")
if has_safepoint < 0 {
print("ERROR: safepoint not enabled")
return 1
}
print("✓ PASS: while_simple loopform generated")
print("Note: Actual loop execution requires C++ backend implementation")
return 0
}
}