feat(joinir): Phase 184 If lowering mainline & JOINIR_IF_TARGETS
Establish If lowering infrastructure with dedicated JOINIR_IF_TARGETS table, separate from loop lowering (JOINIR_TARGETS). Implementation: - Add JOINIR_IF_TARGETS table with 6 representative functions - Add is_if_lowered_function() for table-based lookup - Update is_if_mainline_target() to use table (SSOT) - Update is_joinir_if_toplevel_target() with table-first lookup - Export via join_ir_vm_bridge_dispatch public API Representative functions: - IfSelectTest.test/1 (simple return pattern) - IfSelectLocalTest.main/0 (local variable pattern) - IfMergeTest.simple_true/0, simple_false/0 (multiple variables) - JsonShapeToMap._read_value_from_pair/1 (Stage-1 production) - Stage1JsonScannerBox.value_start_after_key_pos/2 (Stage-B production) Architecture: Loop/If separation complete (1関数につき1 lowering) Verification: All representative paths pass with NYASH_JOINIR_DEBUG=1 Phase 184 complete → Phase 185+ ready 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -20,7 +20,9 @@ use lower_only_routes::{
|
||||
try_run_stage1_usingresolver, try_run_stageb_body, try_run_stageb_funcscanner,
|
||||
};
|
||||
use targets::find_joinir_target;
|
||||
pub use targets::{JoinIrBridgeKind, JoinIrTargetDesc, JOINIR_TARGETS};
|
||||
pub use targets::{
|
||||
is_if_lowered_function, JoinIrBridgeKind, JoinIrTargetDesc, JOINIR_IF_TARGETS, JOINIR_TARGETS,
|
||||
};
|
||||
|
||||
use crate::mir::MirModule;
|
||||
|
||||
|
||||
@ -25,15 +25,16 @@ pub struct JoinIrTargetDesc {
|
||||
pub default_enabled: bool,
|
||||
}
|
||||
|
||||
/// JoinIR ブリッジ対象テーブル(SSOT)
|
||||
/// JoinIR ループ lowering 対象テーブル(SSOT)
|
||||
///
|
||||
/// Phase 32 L-4: 全対象関数を一覧化し、Exec/LowerOnly の区分を明示する。
|
||||
/// Phase 82: このテーブルが唯一の SSOT。is_loop_lowered_function() はここから参照。
|
||||
/// Phase 182: representative paths 対応(3 upgrades - LOOP ONLY)
|
||||
/// Phase 184: Loop/If 分離を明文化(If は JOINIR_IF_TARGETS へ)
|
||||
///
|
||||
/// **重要**: このテーブルは LOOP lowering 専用です。
|
||||
/// If lowering の関数を追加すると、is_loop_lowered_function() で除外され、
|
||||
/// if-lowering が機能しなくなります。If 関数は is_joinir_if_toplevel_target() で管理。
|
||||
/// if-lowering が機能しなくなります。If 関数は JOINIR_IF_TARGETS で管理。
|
||||
///
|
||||
/// | 関数 | Kind | デフォルト有効 | 備考 |
|
||||
/// |-----|------|---------------|------|
|
||||
@ -89,3 +90,81 @@ pub(crate) fn find_joinir_target(module: &MirModule) -> Option<&'static JoinIrTa
|
||||
.iter()
|
||||
.find(|target| module.functions.contains_key(target.func_name))
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Phase 184: JoinIR If Lowering Targets (Separate from Loop Targets)
|
||||
// ============================================================================
|
||||
|
||||
/// JoinIR If lowering 対象テーブル(SSOT)
|
||||
///
|
||||
/// Phase 184: Loop lowering(JOINIR_TARGETS)と分離した If lowering 専用テーブル。
|
||||
/// Phase 182 で判明した設計制約(JOINIR_TARGETS は Loop 専用)に基づく責務分離。
|
||||
///
|
||||
/// **責務**:
|
||||
/// - If/Else → Select/IfMerge lowering の対象関数を一覧化
|
||||
/// - Loop lowering と独立して管理(1関数につき1 lowering の原則)
|
||||
///
|
||||
/// **使用箇所**:
|
||||
/// - `is_if_mainline_target()`: Core ON 時の本線化判定
|
||||
/// - `try_lower_if_to_joinir()`: If lowering 試行時のホワイトリスト
|
||||
///
|
||||
/// | 関数 | Kind | デフォルト有効 | 備考 |
|
||||
/// |-----|------|---------------|------|
|
||||
/// | IfSelectTest.test/1 | Exec | Yes | Phase 33-2/33-3 simple return pattern |
|
||||
/// | IfSelectLocalTest.main/0 | Exec | Yes | Phase 33-10 local variable pattern |
|
||||
/// | IfMergeTest.simple_true/0 | Exec | Yes | Phase 33-7 multiple variables (IfMerge) |
|
||||
/// | IfMergeTest.simple_false/0 | Exec | Yes | Phase 33-7 multiple variables (IfMerge) |
|
||||
/// | JsonShapeToMap._read_value_from_pair/1 | Exec | Yes | Phase 33-4 Stage-1 実用関数 |
|
||||
/// | Stage1JsonScannerBox.value_start_after_key_pos/2 | Exec | Yes | Phase 33-4 Stage-B 実用関数 |
|
||||
///
|
||||
/// Phase 184 設計ドキュメント:
|
||||
/// - docs/private/roadmap2/phases/phase-184/if_lowering_inventory.md
|
||||
/// - docs/private/roadmap2/phases/phase-184/README.md
|
||||
pub const JOINIR_IF_TARGETS: &[JoinIrTargetDesc] = &[
|
||||
// Test functions (Phase 33 series)
|
||||
JoinIrTargetDesc {
|
||||
func_name: "IfSelectTest.test/1",
|
||||
kind: JoinIrBridgeKind::Exec,
|
||||
default_enabled: true, // Simple return pattern (Phase 33-2/33-3)
|
||||
},
|
||||
JoinIrTargetDesc {
|
||||
func_name: "IfSelectLocalTest.main/0",
|
||||
kind: JoinIrBridgeKind::Exec,
|
||||
default_enabled: true, // Local variable pattern (Phase 33-10)
|
||||
},
|
||||
JoinIrTargetDesc {
|
||||
func_name: "IfMergeTest.simple_true/0",
|
||||
kind: JoinIrBridgeKind::Exec,
|
||||
default_enabled: true, // Multiple variables (Phase 33-7)
|
||||
},
|
||||
JoinIrTargetDesc {
|
||||
func_name: "IfMergeTest.simple_false/0",
|
||||
kind: JoinIrBridgeKind::Exec,
|
||||
default_enabled: true, // Multiple variables (Phase 33-7)
|
||||
},
|
||||
// Selfhost/Production functions (Phase 33-4 explicit approvals)
|
||||
JoinIrTargetDesc {
|
||||
func_name: "JsonShapeToMap._read_value_from_pair/1",
|
||||
kind: JoinIrBridgeKind::Exec,
|
||||
default_enabled: true, // Stage-1 実用関数
|
||||
},
|
||||
JoinIrTargetDesc {
|
||||
func_name: "Stage1JsonScannerBox.value_start_after_key_pos/2",
|
||||
kind: JoinIrBridgeKind::Exec,
|
||||
default_enabled: true, // Stage-B 実用関数
|
||||
},
|
||||
];
|
||||
|
||||
/// Phase 184: If lowering 対象関数の判定
|
||||
///
|
||||
/// JOINIR_IF_TARGETS テーブルから対象関数を検索し、
|
||||
/// default_enabled が true の関数のみを本線対象とする。
|
||||
///
|
||||
/// **用途**:
|
||||
/// - `is_if_mainline_target()`: Core ON 時の本線化判定
|
||||
/// - `should_try_joinir_mainline(func_name, is_loop=false)` 経由で使用
|
||||
pub fn is_if_lowered_function(name: &str) -> bool {
|
||||
JOINIR_IF_TARGETS
|
||||
.iter()
|
||||
.any(|t| t.func_name == name && t.default_enabled)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user