Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini
This commit is contained in:
@ -44,7 +44,10 @@ impl CopyTypePropagator {
|
||||
/// # 戻り値
|
||||
///
|
||||
/// 伝播された型の数
|
||||
pub fn propagate(function: &MirFunction, value_types: &mut BTreeMap<ValueId, MirType>) -> usize {
|
||||
pub fn propagate(
|
||||
function: &MirFunction,
|
||||
value_types: &mut BTreeMap<ValueId, MirType>,
|
||||
) -> usize {
|
||||
let mut total_propagated = 0usize;
|
||||
|
||||
// 固定点ループ: 変化がなくなるまで反復
|
||||
@ -91,10 +94,7 @@ impl CopyTypePropagator {
|
||||
propagated += 1;
|
||||
|
||||
if std::env::var("NYASH_COPY_PROP_TRACE").is_ok() {
|
||||
eprintln!(
|
||||
"[copy_prop] {:?} <- {:?} : {:?}",
|
||||
dst, src, src_type
|
||||
);
|
||||
eprintln!("[copy_prop] {:?} <- {:?} : {:?}", dst, src, src_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ impl CopyTypePropagator {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mir::{BasicBlock, BasicBlockId, MirFunction, FunctionSignature, EffectMask};
|
||||
use crate::mir::{BasicBlock, BasicBlockId, EffectMask, FunctionSignature, MirFunction};
|
||||
|
||||
fn make_test_function() -> MirFunction {
|
||||
let sig = FunctionSignature {
|
||||
|
||||
@ -87,10 +87,18 @@ impl LoopSnapshotMergeBox {
|
||||
|
||||
let definitions = build_definitions(header_id, header_vals, exit_snapshots);
|
||||
if debug {
|
||||
crate::runtime::get_global_ring0().log.debug("[Option C] merge_exit_with_classification called");
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[Option C] exit_preds: {:?}", exit_preds));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[Option C] pinned_vars: {:?}", pinned_vars));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[Option C] carrier_vars: {:?}", carrier_vars));
|
||||
crate::runtime::get_global_ring0()
|
||||
.log
|
||||
.debug("[Option C] merge_exit_with_classification called");
|
||||
crate::runtime::get_global_ring0()
|
||||
.log
|
||||
.debug(&format!("[Option C] exit_preds: {:?}", exit_preds));
|
||||
crate::runtime::get_global_ring0()
|
||||
.log
|
||||
.debug(&format!("[Option C] pinned_vars: {:?}", pinned_vars));
|
||||
crate::runtime::get_global_ring0()
|
||||
.log
|
||||
.debug(&format!("[Option C] carrier_vars: {:?}", carrier_vars));
|
||||
}
|
||||
|
||||
// [LoopForm] Case A/B 分岐:
|
||||
@ -126,7 +134,10 @@ impl LoopSnapshotMergeBox {
|
||||
var_name, class, needs_exit_phi
|
||||
));
|
||||
if let Some(defining_blocks) = definitions.get(&var_name) {
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[Option C] defining_blocks: {:?}", defining_blocks));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[Option C] defining_blocks: {:?}",
|
||||
defining_blocks
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -147,7 +147,8 @@ impl LoopFormBuilder {
|
||||
for (i, (bb, snap)) in exit_snapshots.iter().enumerate() {
|
||||
eprintln!(
|
||||
"[DEBUG/exit_phi] snapshot[{}]: block = {:?}, num_vars = {}",
|
||||
i, bb,
|
||||
i,
|
||||
bb,
|
||||
snap.len()
|
||||
);
|
||||
}
|
||||
@ -311,7 +312,8 @@ impl LoopFormBuilder {
|
||||
if debug {
|
||||
eprintln!(
|
||||
"[DEBUG/exit_phi] Creating PHI {:?} for var '{}' with {} inputs",
|
||||
phi_id, var_name,
|
||||
phi_id,
|
||||
var_name,
|
||||
final_inputs.len()
|
||||
);
|
||||
for (bb, val) in &final_inputs {
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
//! This module extracts the exit PHI building logic from loopform_builder.rs
|
||||
//! to improve modularity and testability.
|
||||
|
||||
use crate::mir::{BasicBlockId, ValueId};
|
||||
use crate::mir::control_form::ControlForm;
|
||||
use crate::mir::{BasicBlockId, ValueId};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// Exit PHI builder (currently a delegation wrapper)
|
||||
|
||||
@ -61,24 +61,22 @@
|
||||
//! Phase 193: Complete 4-pass architecture explicit structure
|
||||
|
||||
// Core modules
|
||||
pub mod context;
|
||||
pub mod variable_models;
|
||||
pub mod utils;
|
||||
pub mod exit_phi;
|
||||
pub mod builder_core;
|
||||
pub mod context;
|
||||
pub mod exit_phi;
|
||||
pub mod passes;
|
||||
pub mod utils;
|
||||
pub mod variable_models;
|
||||
|
||||
// Re-export main types for backward compatibility
|
||||
pub use builder_core::{LoopFormBuilder, LoopFormOps};
|
||||
pub use context::LoopFormContext;
|
||||
pub use variable_models::{CarrierVariable, PinnedVariable, LoopBypassFlags};
|
||||
pub use variable_models::{CarrierVariable, LoopBypassFlags, PinnedVariable};
|
||||
|
||||
// Re-export utility functions
|
||||
pub use utils::{
|
||||
is_loopform_debug_enabled,
|
||||
get_loop_bypass_flags,
|
||||
get_loop_bypass_flags, is_joinir_exit_bypass_target, is_loopform_debug_enabled,
|
||||
joinir_exit_bypass_enabled,
|
||||
is_joinir_exit_bypass_target,
|
||||
};
|
||||
|
||||
// Re-export exit PHI function for backward compatibility
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
//! // - pinned: [PinnedVariable { name: "y", param: 2, copy: 5, phi: 6 }]
|
||||
//! ```
|
||||
|
||||
use crate::mir::{ValueId};
|
||||
use crate::mir::ValueId;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::mir::phi_core::loopform::builder_core::{LoopFormBuilder, LoopFormOps};
|
||||
@ -57,11 +57,15 @@ pub fn prepare_structure<O: LoopFormOps>(
|
||||
"[loopform/prepare] === START prepare_structure() === {} variables",
|
||||
current_vars.len()
|
||||
));
|
||||
crate::runtime::get_global_ring0().log.debug("[loopform/prepare] Full variable list:");
|
||||
crate::runtime::get_global_ring0()
|
||||
.log
|
||||
.debug("[loopform/prepare] Full variable list:");
|
||||
let mut sorted_vars: Vec<_> = current_vars.iter().collect();
|
||||
sorted_vars.sort_by_key(|(name, _)| name.as_str());
|
||||
for (name, value) in &sorted_vars {
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[loopform/prepare] - {} = {:?}", name, value));
|
||||
crate::runtime::get_global_ring0()
|
||||
.log
|
||||
.debug(&format!("[loopform/prepare] - {} = {:?}", name, value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,10 +150,21 @@ pub fn prepare_structure<O: LoopFormOps>(
|
||||
}
|
||||
|
||||
if debug_enabled {
|
||||
crate::runtime::get_global_ring0().log.debug("[loopform/prepare] === SUMMARY ===");
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[loopform/prepare] Total vars: {}", current_vars.len()));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[loopform/prepare] Pinned (params): {}", param_count));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[loopform/prepare] Carriers (locals): {}", carrier_count));
|
||||
crate::runtime::get_global_ring0()
|
||||
.log
|
||||
.debug("[loopform/prepare] === SUMMARY ===");
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/prepare] Total vars: {}",
|
||||
current_vars.len()
|
||||
));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/prepare] Pinned (params): {}",
|
||||
param_count
|
||||
));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/prepare] Carriers (locals): {}",
|
||||
carrier_count
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@ -80,8 +80,7 @@ pub fn emit_header_phis<O: LoopFormOps>(
|
||||
// Extract the pin counter and update all lower levels
|
||||
if let Some(idx) = pinned.name.find("$") {
|
||||
if let Some(end_idx) = pinned.name[idx + 1..].find("$") {
|
||||
if let Ok(counter) = pinned.name[idx + 1..idx + 1 + end_idx].parse::<u32>()
|
||||
{
|
||||
if let Ok(counter) = pinned.name[idx + 1..idx + 1 + end_idx].parse::<u32>() {
|
||||
// Update all previous pin levels (1 through counter-1)
|
||||
for i in 1..counter {
|
||||
let alias = format!("__pin${}$@recv", i);
|
||||
|
||||
@ -14,10 +14,10 @@ use crate::mir::ValueId;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CarrierVariable {
|
||||
pub name: String,
|
||||
pub init_value: ValueId, // Initial value from preheader (local variable)
|
||||
pub preheader_copy: ValueId, // Copy allocated in preheader block
|
||||
pub header_phi: ValueId, // PHI node allocated in header block
|
||||
pub latch_value: ValueId, // Updated value computed in latch (set during sealing)
|
||||
pub init_value: ValueId, // Initial value from preheader (local variable)
|
||||
pub preheader_copy: ValueId, // Copy allocated in preheader block
|
||||
pub header_phi: ValueId, // PHI node allocated in header block
|
||||
pub latch_value: ValueId, // Updated value computed in latch (set during sealing)
|
||||
}
|
||||
|
||||
/// A pinned variable: not modified in loop body (loop-invariant, typically parameters)
|
||||
@ -27,9 +27,9 @@ pub struct CarrierVariable {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PinnedVariable {
|
||||
pub name: String,
|
||||
pub param_value: ValueId, // Original parameter or loop-invariant value
|
||||
pub preheader_copy: ValueId, // Copy allocated in preheader block
|
||||
pub header_phi: ValueId, // PHI node allocated in header block
|
||||
pub param_value: ValueId, // Original parameter or loop-invariant value
|
||||
pub preheader_copy: ValueId, // Copy allocated in preheader block
|
||||
pub header_phi: ValueId, // PHI node allocated in header block
|
||||
}
|
||||
|
||||
/// Phase 27.4-C Refactor: JoinIR Loop φ bypass flags
|
||||
|
||||
Reference in New Issue
Block a user