diff --git a/src/mir/builder/control_flow/plan/lowerer.rs b/src/mir/builder/control_flow/plan/lowerer.rs
index 2e036ade..4743aeaf 100644
--- a/src/mir/builder/control_flow/plan/lowerer.rs
+++ b/src/mir/builder/control_flow/plan/lowerer.rs
@@ -17,7 +17,7 @@
//! - Legacy fallback has been removed (Fail-Fast on missing fields)
//! - Pattern-specific emission functions (emit_scan_with_init_edgecfg) no longer used
-use super::{CoreEffectPlan, CoreLoopPlan, CorePlan};
+use super::{CoreEffectPlan, CoreExitPlan, CoreIfPlan, CoreLoopPlan, CorePlan};
use crate::mir::builder::control_flow::joinir::patterns::router::LoopPatternContext;
use crate::mir::builder::MirBuilder;
use crate::mir::{MirInstruction, ValueId};
@@ -41,18 +41,12 @@ impl PlanLowerer {
match plan {
CorePlan::Seq(plans) => Self::lower_seq(builder, plans, ctx),
CorePlan::Loop(loop_plan) => Self::lower_loop(builder, loop_plan, ctx),
- CorePlan::If(_if_plan) => {
- // P1: If is handled inline in Loop body
- Err("[lowerer] Standalone CorePlan::If not yet supported".to_string())
- }
+ CorePlan::If(if_plan) => Self::lower_if(builder, if_plan, ctx),
CorePlan::Effect(effect) => {
Self::emit_effect(builder, &effect)?;
Ok(None)
}
- CorePlan::Exit(_exit) => {
- // P1: Exit is handled by edge CFG in Loop
- Err("[lowerer] Standalone CorePlan::Exit not yet supported".to_string())
- }
+ CorePlan::Exit(exit) => Self::lower_exit(builder, exit),
}
}
@@ -103,6 +97,74 @@ impl PlanLowerer {
Self::lower_loop_generalized(builder, loop_plan, ctx)
}
+ /// If: emit Branch and lower then/else plans (standalone)
+ fn lower_if(
+ builder: &mut MirBuilder,
+ if_plan: CoreIfPlan,
+ ctx: &LoopPatternContext,
+ ) -> Result