pub enum SegTerminator<'d> {
Goto(SegId),
CondGoto {
cond: Expression<'d>,
t: SegId,
f: SegId,
},
Suspend {
point: SuspendPoint<'d>,
resume: SegId,
live_out: Vec<u32>,
},
End {
loop_back: Option<SegId>,
},
SwitchGoto {
on: SwitchOn<'d>,
arms: Vec<SegId>,
default: SegId,
report: Option<SourceLoc>,
},
CondGotoCounter {
counter: RepeatCounterId,
t: SegId,
f: SegId,
},
ForkJoin {
kind: StatementBlockKind,
branches: Vec<ProcessCfg<'d>>,
join_blk: SegId,
live_out: Vec<u32>,
},
AssertGoto {
stmt: Statement<'d>,
pass: SegId,
fail: SegId,
done: SegId,
},
CaseGoto {
stmt: Statement<'d>,
arms: Vec<SegId>,
default: SegId,
},
}Expand description
PR-043: covers every Terminator variant with no lossy fallback (see
lower_to_segments’s 1:1 mapping).
Variants§
Goto(SegId)
CondGoto
Suspend
End
SwitchGoto
The lowering of Terminator::Switch.
CondGotoCounter
R-run Task 8: the lossless lowering of Terminator::RepeatCheck –
see that variant’s own doc comment for why a repeat(N) loop’s
per-iteration decision cannot be represented as an ordinary
CondGoto (no cond: Expression exists for “compiler-synthesized
counter != 0”). Deviation from this file’s own module doc comment
(Task 1’s “frozen, codegen-exhausted SegTerminator” policy): that
policy was written to rule out ForkJoin specifically (which has no
honest SegTerminator shape at all, ever, this wave); a suspend
nested inside a repeat body is a genuinely new kind of branch
condition this crate had no way to construct before this task, not a
reachability gap in the pre-existing four variants – recorded in
this task’s own deviations.
ForkJoin
R-run Task 17 (PR-047/PR-061): the lossless lowering of
Terminator::ForkJoin – a real, new SegTerminator shape, added
for the identical reason CondGotoCounter above already documents a
deviation from this file’s own “frozen SegTerminator” policy note:
that note was written to rule out ForkJoin specifically because
NOTHING had implemented fork/join scheduling yet; this task is that
implementation for StatementBlockKind::JoinAll (codegen enforces
the JoinAll-only scope with a named LoweringError for JoinAny/
JoinNone – this type carries kind through losslessly so codegen
has it to check, rather than this crate silently narrowing what it
represents). branches is exactly Terminator::ForkJoin’s own
field, carried through unchanged (each branch is still a full,
independently suspend-capable nested ProcessCfg – codegen
recursively lowers each one into its own real compiled kernel).
join_blk/live_out mirror Suspend’s own resume/live_out
fields exactly: a fork/join site suspends the calling process (until
every spawned child completes, for JoinAll) just as surely as a
Suspend terminator does, so the same permanent-frame-slot
liveness/writeback discipline applies – see lower_to_segments’s
own fill rule.
AssertGoto
The lowering of Terminator::Assertion.
CaseGoto
The lowering of Terminator::Case: goes to arms[i] for the first
item of stmt whose labels match its selector, else default.