srdatalog.ir.dialects.relation.sorted_array.lowerings¶
MIR -> IIR lowering for the sorted_array dialect.
Each milestone extends lower_scan_pipeline to handle more MIR op
kinds. The supported predicate _supported_pipeline documents which
shapes the dialect can faithfully reproduce against the legacy
emitter.
M1: [Scan, InsertInto] M2: [Scan, (Filter | ConstantBind), InsertInto] M3: [CJ_multi (Filter | ConstantBind | CJ_multi), InsertInto]
Counter management mirrors the legacy pipeline.py save/restore
pattern: the body of a root op is lowered with a fresh counter
trajectory, then the root op’s own scaffold takes the counter from
the same starting point. The numeric suffixes baked into IIR names
match what gen_unique_name would have produced in legacy.
Module Contents¶
Classes¶
Mutable state during MIR -> IIR walk. |
|
Pre-narrowed handle info for a Negation that follows a Cartesian. |
Functions¶
Lower a supported pipeline shape to IIR. |
API¶
- class srdatalog.ir.dialects.relation.sorted_array.lowerings.LoweringCtx[source]¶
Mutable state during MIR -> IIR walk.
Mirrors the legacy
CodeGenContextfor the fields that matter to the dialect’s emission decisions today. Other legacy fields (tiled_cartesian state, ws state, etc.) aren’t needed yet — milestones add them as they cover those paths.- neg_pre_narrow: dict[int, srdatalog.ir.dialects.relation.sorted_array.lowerings.NegPreNarrowInfo]¶
‘field(…)’
- class srdatalog.ir.dialects.relation.sorted_array.lowerings.NegPreNarrowInfo[source]¶
Pre-narrowed handle info for a Negation that follows a Cartesian.
When a Negation’s prefix vars are all (or partly) bound before the Cartesian, those vars don’t change inside the Cartesian loop — so we can apply them once cooperatively before the loop, then cheaply check
valid()per iteration. The remaining (in-Cartesian) vars are applied per-thread inside the loop viaprefix_seq.Mirrors the legacy
NegPreNarrowInfoin ir/dialects/target/cuda/context.py.
- srdatalog.ir.dialects.relation.sorted_array.lowerings.lower_scan_pipeline(ops: list[srdatalog.ir.mir.types.MirNode], ctx: srdatalog.ir.dialects.relation.sorted_array.lowerings.LoweringCtx) srdatalog.ir.core.Op[source]¶
Lower a supported pipeline shape to IIR.
The function name is historical (M1 only handled Scan-rooted pipelines); it now dispatches on the head op. Raises ValueError if the shape isn’t supported.