Files
hakorune/docs/private/papers/paper-d-ssa-construction/abstract.md
Selfhosting Dev 043472c170 docs(papers): Update MIR13 to MIR14 and create SSA construction paper
Major changes:
- Update all MIR13 references to MIR14 throughout paper-a-mir13-ir-design/
- Add evolution history: 27 → 13 → 14 instructions (UnaryOp restoration)
- Create new paper-d-ssa-construction/ for SSA implementation struggles
- Add PAPER_INDEX.md consolidating ChatGPT5's 3-paper analysis

MIR14 updates:
- README.md: Add instruction evolution timeline
- abstract.md: Emphasize practical balance over pure minimalism
- main-paper*.md: Update titles and core concepts
- MIR13_CORE13_SPEC.md: Add UnaryOp to instruction list
- chapters/01-introduction.md: Reframe as "14-Instruction Balance"
- RENAME_NOTE.md: Document folder naming consideration

SSA paper structure:
- README.md: Paper overview and positioning
- current-struggles.md: Raw implementation challenges
- technical-details.md: BuilderCursor, Sealed SSA, type normalization
- abstract.md: English/Japanese abstracts

LoopForm experiments continue in parallel (minor adjustments to detection).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 15:58:20 +09:00

33 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Abstract
## Practical SSA Construction for a Box-Oriented Language
Building Static Single Assignment (SSA) form for dynamically-typed languages presents unique challenges, particularly when the language philosophy mandates that "Everything is Box." This paper presents our practical experience constructing SSA form for Nyash, a Box-oriented language targeting LLVM IR.
We identify three main challenges: (1) PHI node placement in complex control flow with mixed handle/pointer types, (2) maintaining correct insertion points across nested scopes and loops, and (3) ensuring dominance properties while supporting dynamic Box operations.
Our contributions include:
- **BuilderCursor**: A structured approach to LLVM builder position management that prevents post-terminator insertions
- **Sealed SSA with snapshots**: Block-end value snapshots for reliable PHI wiring in gradually-constructed CFGs
- **Type normalization strategy**: Unified i64 handle representation with on-demand pointer conversions
We evaluate our approach on real-world Nyash programs, including a self-hosting compiler component (`dep_tree_min_string.nyash`). While achieving functional SSA construction, we identify remaining challenges and propose LoopForm IR as a future direction for simplifying control flow representation.
This work provides practical insights for language implementers facing similar challenges when bridging high-level Box abstractions to low-level SSA form.
---
## 和文要旨
動的型付け言語、特に「Everything is Box」を哲学とする言語において、静的単一代入SSA形式を構築することは独特の課題を提示する。本稿では、LLVM IRを対象とするBox指向言語Nyashにおける、SSA形式構築の実践的経験を報告する。
主要な課題として、(1)ハンドル/ポインタ混在型での複雑な制御フローにおけるPHIード配置、(2)ネストしたスコープとループにまたがる挿入位置の維持、(3)動的Box操作をサポートしながらのdominance特性の保証、の3点を特定した。
本稿の貢献は以下の通りである:
- **BuilderCursor**終端後挿入を防ぐ構造化されたLLVMビルダー位置管理
- **スナップショット付きSealed SSA**段階的に構築されるCFGでの確実なPHI配線のためのブロック終端値スナップショット
- **型正規化戦略**オンデマンドポインタ変換を伴う統一的i64ハンドル表現
実世界のNyashプログラムセルフホスティングコンパイラコンポーネント`dep_tree_min_string.nyash`を含むで評価を行った。機能的なSSA構築を達成する一方で、残存する課題を特定し、制御フロー表現を簡素化する将来の方向性としてLoopForm IRを提案する。
本研究は、高レベルBox抽象を低レベルSSA形式に橋渡しする際に同様の課題に直面する言語実装者に、実践的な洞察を提供する。