refactor(joinir): Replace magic numbers with named constants
Phase 179-A Step 3: Improve code maintainability by replacing hardcoded magic values with descriptive named constants. Changes: - instruction_rewriter.rs: K_EXIT_FUNC_NAME constant for "join_func_2" - pattern3_with_if_phi.rs: PATTERN3_K_EXIT_SUM_FINAL_ID for ValueId(18) Benefits: - Self-documenting code (names explain the meaning) - Easier to maintain (change in one place) - Prevents typos and inconsistencies
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
//!
|
||||
//! Phase 4 Extraction: Separated from merge_joinir_mir_blocks (lines 260-546)
|
||||
//! Phase 33-17: Further modularization - extracted TailCallClassifier and MergeResult
|
||||
//! Phase 179-A Step 3: Named constants for magic values
|
||||
|
||||
use crate::mir::{BasicBlock, BasicBlockId, MirInstruction, MirModule, ValueId};
|
||||
use crate::mir::builder::joinir_id_remapper::JoinIrIdRemapper;
|
||||
@ -14,6 +15,10 @@ use super::tail_call_classifier::{TailCallKind, classify_tail_call};
|
||||
use super::merge_result::MergeResult;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Phase 179-A: Exit continuation function name (MIR convention)
|
||||
/// This is the standard name for k_exit continuations in JoinIR → MIR lowering
|
||||
const K_EXIT_FUNC_NAME: &str = "join_func_2";
|
||||
|
||||
/// Phase 4: Merge ALL functions and rewrite instructions
|
||||
///
|
||||
/// Returns:
|
||||
@ -88,8 +93,8 @@ pub(super) fn merge_and_rewrite(
|
||||
// Phase 33-15: Identify continuation functions (join_func_2 = k_exit, etc.)
|
||||
// Continuation functions receive values from Jump args, not as independent sources
|
||||
// We should NOT collect their Return values for exit_phi_inputs
|
||||
// Note: MIR uses "join_func_N" naming, where N=2 is typically k_exit
|
||||
let is_continuation_func = func_name == "join_func_2" || func_name.ends_with("k_exit");
|
||||
// Phase 179-A: Use named constant for k_exit function name
|
||||
let is_continuation_func = func_name == K_EXIT_FUNC_NAME || func_name.ends_with("k_exit");
|
||||
|
||||
if debug {
|
||||
eprintln!(
|
||||
|
||||
Reference in New Issue
Block a user