srdatalog.ir.hir

HIR main orchestrator. Mirrors src/srdatalog/hir/hir.nim.

Entry point: compile_to_hir(program) runs the default pipeline (currently: stratification only; future passes will be appended here as they are ported from Nim).

A DIALECT catalog is also exposed (see srdatalog.ir.core.dialect) so HIR participates in the framework registry alongside iir.cf, relation.sorted_array, etc. The HIR types here are not yet Op-subclassed or frozen — that’s the next standardization step. The catalog is purely metadata today.

Submodules

Package Contents

Functions

compile_to_hir

Run the default HIR pipeline on a Program.

compile_to_mir

End-to-end: Program -> HIR -> MIR. Returns a mir_types.Program.

default_pipeline

Build the standard HIR pipeline.

Data

API

srdatalog.ir.hir.DIALECT

‘Dialect(…)’

srdatalog.ir.hir.compile_to_hir(program: srdatalog.dsl.Program, verbose: bool = False) srdatalog.ir.hir.types.HirProgram[source]

Run the default HIR pipeline on a Program.

srdatalog.ir.hir.compile_to_mir(program: srdatalog.dsl.Program, *, hir: srdatalog.ir.hir.types.HirProgram | None = None, verbose: bool = False, apply_mir_passes: bool = True)[source]

End-to-end: Program -> HIR -> MIR. Returns a mir_types.Program.

By default runs the ported MIR optimization passes (pre_reconstruct_rebuild, clause_order_reorder, prefix_source_reorder). Pass apply_mir_passes=False to stop at the raw output of lower_hir_to_mir_steps.

Pass hir=... to reuse an already-computed HirProgram. The default (hir=None) runs compile_to_hir(program, verbose=verbose) internally. Callers that already have HIR (e.g. ir.pipeline.compile_program) should pass it to avoid the redundant pass.

srdatalog.ir.hir.default_pipeline(verbose: bool = False) srdatalog.ir.hir.pass_.Pipeline[source]

Build the standard HIR pipeline.

Nim reference (compileToHir): Pass 0 rewriteConstants [rule-rewrite, ported] Pass 1 rewriteHeadConstants [rule-rewrite, ported] Pass 1.5 optimizeSemiJoins [rule-rewrite, ported] Pass 2 stratify [HIR entry — fixed, built in] Pass 3 generateVariants [HIR transform, ported] Pass 4 planJoins [HIR transform, ported] Pass 5 selectIndices [HIR transform, ported]