Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Design model

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Lowering is the last semantic gate before any backend runs. Inputs are a post-merge program snapshot (HIR + ModuleIndex + resolved types); output is an immutable CodegenArtifact containing Cranelift modules, data descriptors, extern imports, and debug metadata.

Backends must not re-run parse, mod host, or semantic rules on the artifact.

flowchart TB
  subgraph analysis [beskid_analysis]
    hir[HIR + ModuleIndex]
  end
  subgraph codegen [beskid_codegen]
    lower[lower_program / lower_source]
    art[CodegenArtifact]
  end
  subgraph backends [beskid_engine]
    jit[JitModule]
    aot[AOT object emit]
  end
  hir --> lower --> art
  art --> jit
  art --> aot
SliceRole
CLIF modulesPer-compilation-unit functions and globals
Builtin importsdeclare_builtin_imports from BUILTIN_SPECS
ExternImport rowsUser contract symbols for link step
Type descriptorsGC layout + array/string shapes for alloc
  • Lowering runs only when syntax_generation_id matches the merged tree used by semantic rules (stage ordering).
  • Panic/abort paths use AbiReturnKind::Never imports so unreachable blocks are correct.
  • JIT and AOT consume the same artifact type; divergence happens only after CodegenArtifact is sealed.
  • beskid_codegen::lower_source in compiler/crates/beskid_codegen
  • CodegenArtifact construction in compiler/crates/beskid_codegen
  • JitModule in compiler/crates/beskid_engine/src/jit_module.rs
  • Runtime smoke: compiler/crates/beskid_tests/src/runtime/jit.rs