Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini
This commit is contained in:
@ -19,8 +19,8 @@
|
||||
//!
|
||||
//! Reference: docs/private/roadmap2/phases/phase-188-joinir-loop-pattern-expansion/design.md
|
||||
|
||||
use crate::mir::loop_form::LoopForm;
|
||||
use crate::mir::join_ir::lowering::loop_scope_shape::LoopScopeShape;
|
||||
use crate::mir::loop_form::LoopForm;
|
||||
|
||||
// ============================================================================
|
||||
// Pattern Classification System (Phase 194+)
|
||||
@ -142,7 +142,8 @@ pub struct LoopFeatures {
|
||||
/// Contains UpdateKind (CounterLike/AccumulationLike/Other) for each carrier.
|
||||
/// Used by CaseALoweringShape for more precise shape detection.
|
||||
/// None if carrier names are not available.
|
||||
pub update_summary: Option<crate::mir::join_ir::lowering::loop_update_summary::LoopUpdateSummary>,
|
||||
pub update_summary:
|
||||
Option<crate::mir::join_ir::lowering::loop_update_summary::LoopUpdateSummary>,
|
||||
}
|
||||
|
||||
impl LoopFeatures {
|
||||
@ -196,7 +197,10 @@ impl LoopFeatures {
|
||||
///
|
||||
/// # Returns
|
||||
/// * `LoopFeatures` - Feature vector for pattern classification
|
||||
pub(crate) fn extract_features(loop_form: &LoopForm, scope: Option<&LoopScopeShape>) -> LoopFeatures {
|
||||
pub(crate) fn extract_features(
|
||||
loop_form: &LoopForm,
|
||||
scope: Option<&LoopScopeShape>,
|
||||
) -> LoopFeatures {
|
||||
// Phase 194: Basic feature extraction from LoopForm
|
||||
let has_break = !loop_form.break_targets.is_empty();
|
||||
let has_continue = !loop_form.continue_targets.is_empty();
|
||||
@ -219,7 +223,9 @@ pub(crate) fn extract_features(loop_form: &LoopForm, scope: Option<&LoopScopeSha
|
||||
// Note: carriers is BTreeSet<String>, so each item is already a String
|
||||
let update_summary = scope.map(|s| {
|
||||
let carrier_names: Vec<String> = s.carriers.iter().cloned().collect();
|
||||
crate::mir::join_ir::lowering::loop_update_summary::analyze_loop_updates_by_name(&carrier_names)
|
||||
crate::mir::join_ir::lowering::loop_update_summary::analyze_loop_updates_by_name(
|
||||
&carrier_names,
|
||||
)
|
||||
});
|
||||
|
||||
LoopFeatures {
|
||||
@ -275,7 +281,11 @@ pub fn classify(features: &LoopFeatures) -> LoopPatternKind {
|
||||
|
||||
// Pattern 3: If-PHI (check before Pattern 1)
|
||||
// Phase 212.5: Structural if detection - route to P3 if has_if && carrier_count >= 1
|
||||
if features.has_if && features.carrier_count >= 1 && !features.has_break && !features.has_continue {
|
||||
if features.has_if
|
||||
&& features.carrier_count >= 1
|
||||
&& !features.has_break
|
||||
&& !features.has_continue
|
||||
{
|
||||
return LoopPatternKind::Pattern3IfPhi;
|
||||
}
|
||||
|
||||
@ -326,10 +336,7 @@ pub fn classify_with_diagnosis(features: &LoopFeatures) -> (LoopPatternKind, Str
|
||||
"Simple while loop with no special control flow".to_string()
|
||||
}
|
||||
LoopPatternKind::Unknown => {
|
||||
format!(
|
||||
"Unknown pattern: {}",
|
||||
features.debug_stats()
|
||||
)
|
||||
format!("Unknown pattern: {}", features.debug_stats())
|
||||
}
|
||||
};
|
||||
|
||||
@ -666,8 +673,8 @@ fn has_simple_condition(_loop_form: &LoopForm) -> bool {
|
||||
mod tests;
|
||||
|
||||
// Phase 170-D: Loop Condition Scope Analysis Boxes
|
||||
pub mod loop_condition_scope;
|
||||
pub mod condition_var_analyzer;
|
||||
pub mod loop_condition_scope;
|
||||
|
||||
// Phase 170-ultrathink: Error Message Utilities
|
||||
pub mod error_messages;
|
||||
|
||||
Reference in New Issue
Block a user