docs(normalization): Update README for Phase 142 P0
- Document statement-level normalization unit change - Add Phase 142 P0 section to Pattern Detection - Mark Phase 132-135 patterns as LEGACY - Update suffix_router description - Clarify LoopWithPost deprecation status Phase 142 P0: Normalization unit changed from "block suffix" to "statement" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -28,7 +28,10 @@ Consolidate the two separate entry points for Normalized shadow processing into
|
|||||||
|
|
||||||
**Two callers, one SSOT decision**:
|
**Two callers, one SSOT decision**:
|
||||||
- `routing.rs::try_normalized_shadow()`: Loop-only patterns (Phase 131)
|
- `routing.rs::try_normalized_shadow()`: Loop-only patterns (Phase 131)
|
||||||
- `suffix_router_box::try_lower_loop_suffix()`: Loop + post patterns (Phase 132-133)
|
- `suffix_router_box::try_lower_loop_suffix()`: Loop patterns at block suffix (Phase 131+)
|
||||||
|
- **Phase 142 P0**: Now accepts both LoopOnly and LoopWithPost (deprecated)
|
||||||
|
- Statement-level normalization: only the loop is normalized (consumed=1)
|
||||||
|
- Subsequent statements (return, assignments) handled by normal MIR lowering
|
||||||
- Both call `NormalizationPlanBox::plan_block_suffix()` for detection
|
- Both call `NormalizationPlanBox::plan_block_suffix()` for detection
|
||||||
|
|
||||||
### Box Responsibilities
|
### Box Responsibilities
|
||||||
@ -54,8 +57,9 @@ pub struct NormalizationPlan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum PlanKind {
|
pub enum PlanKind {
|
||||||
LoopOnly, // Phase 131: loop(true) { ... break } alone
|
LoopOnly, // Phase 131+142 P0: loop(true) { ... break } alone
|
||||||
LoopWithPost { // Phase 132-133: loop + post assigns + return
|
#[deprecated] // Phase 142 P0: DEPRECATED - statement-level normalization
|
||||||
|
LoopWithPost { // Phase 132-133 (legacy): loop + post assigns + return
|
||||||
post_assign_count: usize,
|
post_assign_count: usize,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -87,7 +91,7 @@ pub enum PlanKind {
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Pattern Detection (Phase 131-135)
|
## Pattern Detection (Phase 131-135, updated Phase 142 P0)
|
||||||
|
|
||||||
### Phase 131: Loop-Only
|
### Phase 131: Loop-Only
|
||||||
- Pattern: `loop(true) { ... break }` (single statement, no return)
|
- Pattern: `loop(true) { ... break }` (single statement, no return)
|
||||||
@ -107,13 +111,24 @@ pub enum PlanKind {
|
|||||||
- Kind: `PlanKind::LoopWithPost { post_assign_count: N }`
|
- Kind: `PlanKind::LoopWithPost { post_assign_count: N }`
|
||||||
- Example: `loop(true) { x = 1; break }; x = x + 2; x = x + 3; return x`
|
- Example: `loop(true) { x = 1; break }; x = x + 2; x = x + 3; return x`
|
||||||
|
|
||||||
### Phase 135: Loop + Return (Zero Post Assigns) **NEW**
|
### Phase 135: Loop + Return (Zero Post Assigns) **LEGACY**
|
||||||
- Pattern: `loop(true) { ... break }; return <expr>` (0 post-loop assignments)
|
- Pattern: `loop(true) { ... break }; return <expr>` (0 post-loop assignments)
|
||||||
- Consumed: 2 statements (loop, return)
|
- Consumed: 2 statements (loop, return)
|
||||||
- Kind: `PlanKind::LoopWithPost { post_assign_count: 0 }`
|
- Kind: `PlanKind::LoopWithPost { post_assign_count: 0 }`
|
||||||
- Example: `loop(true) { x = 1; break }; return x`
|
- Example: `loop(true) { x = 1; break }; return x`
|
||||||
- **Improvement**: Unifies Phase 131 and Phase 132-133 patterns under `LoopWithPost` enum
|
- **Improvement**: Unifies Phase 131 and Phase 132-133 patterns under `LoopWithPost` enum
|
||||||
- **Compatibility**: Phase 131 (loop-only, no return) remains as `PlanKind::LoopOnly`
|
- **Compatibility**: Phase 131 (loop-only, no return) remains as `PlanKind::LoopOnly`
|
||||||
|
- **Status**: Deprecated in Phase 142 P0 (see below)
|
||||||
|
|
||||||
|
### Phase 142 P0: Statement-Level Normalization **CURRENT**
|
||||||
|
- **Change**: Normalization unit changed from "block suffix" to "statement (loop only)"
|
||||||
|
- **Pattern**: `loop(true) { ... break }` - always returns `LoopOnly`, regardless of subsequent statements
|
||||||
|
- **Consumed**: Always 1 statement (the loop itself)
|
||||||
|
- **Kind**: `PlanKind::LoopOnly`
|
||||||
|
- **Subsequent statements**: Handled by normal MIR lowering (not normalized)
|
||||||
|
- **Example**: `loop(true) { break }; return s.length()` → loop normalized (consumed=1), return handled normally
|
||||||
|
- **Impact**: Prevents pattern explosion by separating loop normalization from post-loop statements
|
||||||
|
- **Deprecated**: `LoopWithPost` variant no longer created, kept for backward compatibility only
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user