Files
hakorune/docs/papers/active/paper-a-mir13-ir-design/data/mir13-final.md
Moe Charm fb2d8e37d5 🎉 Phase 11.8/12.7: MIR Core-13 完全実装 + 糖衣構文ドキュメント更新
主要な変更:
- MIR Core-13命令セット確定(Load/Store削除の革命的設計)
  - Const, BinOp, Compare(値・計算)
  - Jump, Branch, Return, Phi(制御)
  - Call, BoxCall, ExternCall(呼び出し)
  - TypeOp, Safepoint, Barrier(メタ)
- Phase 12.7糖衣構文ドキュメント整理(超圧縮重視、可逆変換保証)
- MIRビルダーのモジュール分割完了
- vtableテストスイート拡充
- AI協調開発ツール追加(並列リファクタリング支援)

詳細:
- src/mir/instruction_introspection.rs: core13_instruction_names()追加
- MIRビルダー分割: decls.rs, exprs_*.rs, fields.rs
- plugin_loader_v2: errors.rs, host_bridge.rs分離
- 論文用データ: mir13-final.md作成

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-04 11:34:15 +09:00

60 lines
1.9 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.

# MIR13 (Core-13) Final Instruction Set
## The 13 Instructions
### 1. 値・計算 (3命令)
- **Const**: 定数値のロード
- **BinOp**: 二項演算(算術、論理、ビット演算すべて)
- **Compare**: 比較演算(==, !=, <, >, <=, >=
### 2. 制御フロー (4命令)
- **Jump**: 無条件ジャンプ
- **Branch**: 条件分岐
- **Return**: 関数からの戻り
- **Phi**: SSA形式での値の合流
### 3. 呼び出し (3命令)
- **Call**: 通常の関数呼び出し
- **BoxCall**: Boxメソッド呼び出し配列、オブジェクト、すべてのデータ操作
- **ExternCall**: 外部関数呼び出し(システムコール、プラグイン等)
### 4. メタ操作 (3命令)
- **TypeOp**: 型関連操作(型チェック、キャスト)
- **Safepoint**: GCセーフポイント
- **Barrier**: メモリバリア
## 削除された命令とその統合先
| 削除された命令 | 統合方法 |
|--------------|---------|
| Load/Store | BoxCallまたはCall変数もBoxとして扱う |
| UnaryOp | BinOp-x → 0-x, !x → x XOR true |
| ArrayGet/ArraySet | BoxCall |
| NewBox | BoxCallコンストラクタ呼び出し |
| FunctionNew | Const関数も値 |
| RefNew/RefGet/RefSet | BoxCall |
| TypeCheck/Cast | TypeOp |
| Debug/Print | ExternCall |
| Copy/Nop | 不要(最適化で除去) |
## 設計の革新性
### 1. 変数アクセスの統一
すべての変数アクセスが関数呼び出しとして表現される:
```mir
// 従来: %1 = Load %x
%1 = Call @get_local "x"
// 従来: Store %y, %1
Call @set_local "y" %1
```
### 2. Everything is Box の究極形
- 変数もBox
- 関数もBoxConstで表現
- すべての操作がBoxCall
### 3. 実用性とのバランス
- Safepointでガベージコレクションをサポート
- Barrierで並行性を考慮
- ExternCallで拡張性を確保