Commit Graph

6 Commits

Author SHA1 Message Date
53a869136f 📚 ABI統合ドキュメント整理 & LLVM BuilderCursor改善
## ABI関連
- docs/reference/abi/ABI_INDEX.md 作成(統合インデックス)
- 分散していたABI/TypeBoxドキュメントへのリンク集約
- CLAUDE.mdに「ABI統合インデックス」リンク追加
- ABI移行タイミング詳細検討(LLVM完成後のPhase 15.5推奨)

## LLVM改善(ChatGPT5協力)
- BuilderCursor導入でposition管理を構造化
- emit_return/jump/branchをcursor経由に統一
- PHI/terminator問題への対策改善
- より明確なbasic block位置管理

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 14:12:54 +09:00
696b282ae8 🔍 Add extensive LLVM debug logging and builder position tracking
ChatGPT5's investigation revealed builder position management issues:
- Added verbose logging for block lowering and terminator emission
- Enhanced position_at_end calls before all terminator operations
- Added debug output for emit_jump/emit_branch operations
- Improved snapshot vs vmap fallback reporting in seal_block

Key findings:
- Sealed SSA snapshot mechanism is working correctly
- Block terminator issues persist due to builder position drift
- Main.has_in_stack/2 shows terminator missing after emit

Next steps:
- Add immediate terminator verification after each emit
- Track builder position changes in complex operations
- Investigate specific functions where builder drift occurs

This commit adds diagnostic infrastructure to pinpoint
where LLVM IR builder position gets misaligned.
2025-09-12 13:20:59 +09:00
a28fcac368 🔧 Add sealed SSA mode for PHI debugging (ChatGPT5)
Added NYASH_LLVM_PHI_SEALED env var to toggle PHI wiring modes:
- NYASH_LLVM_PHI_SEALED=0 (default): immediate PHI wiring
- NYASH_LLVM_PHI_SEALED=1: sealed SSA style (wire after block completion)
- Added seal_block() function for deferred PHI incoming setup
- Enhanced PHI tracing with NYASH_LLVM_TRACE_PHI=1

This helps debug 'phi incoming value missing' errors by
comparing immediate vs sealed wiring approaches.
2025-09-12 12:30:42 +09:00
4fe1212d36 🚀 Major LLVM breakthrough by ChatGPT5\!
PHI type coercion and core-first routing fixes:
- Auto type conversion for PHI nodes (i64↔i8*↔i1↔f64)
- Fixed ArrayBox.get misrouting to Map path
- Core-first strategy for Array/Map creation
- Added comprehensive debug logging ([PHI], [ARR], [MAP])

Results:
 Array smoke test: 'Result: 3'
 Map smoke test: 'Map: v=42, size=1'

After 34+ minutes of battling Rust lifetime errors,
ChatGPT5 achieved a major breakthrough\!

Key insight: The bug wasn't in PHI/SSA logic but in
Box type routing - ArrayBox.get was incorrectly caught
by Map fallback due to missing annotations.

We're SO CLOSE to Nyash self-hosting paradise\! 🌟
Once this stabilizes, everything can be written in
simple, beautiful Nyash code instead of Rust complexity.
2025-09-12 12:07:07 +09:00
1f5ba5f829 💢 The truth about Rust + LLVM development hell
ChatGPT5 struggling for 34+ minutes with Rust lifetime/build errors...
This perfectly illustrates why we need Phase 22 (Nyash LLVM compiler)\!

Key insights:
- 'Rust is safe and beautiful' - Gemini (who never fought lifetime errors)
- Reality: 500-line error messages, 34min debug sessions, lifetime hell
- C would just work: void* compile(void* mir) { done; }
- Python would work: 100 lines with llvmlite
- ANY language with C ABI would work\!

The frustration is real:
- We're SO CLOSE to Nyash self-hosting paradise
- Once bootstrapped, EVERYTHING can be written in Nyash
- No more Rust complexity, no more 5-7min builds
- Just simple, beautiful Box-based code

Current status:
- PHI/SSA hardening in progress (ChatGPT5)
- 'phi incoming value missing' in Main.esc_json/1
- Sealed SSA approach being implemented

The dream is near: Everything is Box, even the compiler\! 🌟
2025-09-12 05:48:59 +09:00
3ac4a383e4 refactor(llvm): Modularize instructions.rs into focused submodules by ChatGPT
Successfully split the massive instructions.rs (1400+ lines) into organized submodules:

Structure:
- instructions/mod.rs - Module exports and wiring
- instructions/blocks.rs - Basic block creation and PHI setup
- instructions/flow.rs - Control flow (Return, Jump, Branch)
- instructions/externcall.rs - External call handling
- instructions/newbox.rs - NewBox operations
- instructions/boxcall.rs - BoxCall lowering (main dispatch)
- instructions/strings.rs - String fast-paths (concat, length)
- instructions/arrays.rs - Array operations (get/set/push/length)
- instructions/maps.rs - Map operations (size/get/set/has)
- instructions/arith.rs - Arithmetic operations (UnaryOp, BinOp, Compare)
- instructions/mem.rs - Memory operations (Load, Store)
- instructions/consts.rs - Constant value handling

Benefits:
- Improved maintainability (each file ~200-400 lines)
- Clear separation of concerns
- No behavior changes (pure refactoring)
- All existing smoke tests pass

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 23:58:10 +09:00