LIR — Low-level IR

LIR is an SSA-form intermediate representation with virtual registers, basic blocks, and explicit control flow.

Key types

(arity, locals, captures, cell/lbox masks)

Terminator

branch, emit, tail call)

keyword, nil, true, false)

From HIR to LIR

The lowerer (src/lir/lower/) transforms HIR trees into LIR:

1. Flatten — nested expressions → linear instruction sequences 2. Register allocation — each intermediate value gets a virtual register 3. Block construction — control flow (if, loops, match) creates basic blocks connected by terminators 4. Escape analysis — determines which scopes can use region-based allocation (RegionEnter/RegionExit)

Emit metadata

LIR collects emit-site and call-site information during emission. The JIT uses this for yield-through-call support — knowing which calls might emit so it can generate proper save/restore sequences.

Files

src/lir/types.rs          LirFunction, BasicBlock, Reg, etc.
src/lir/display.rs        Debug printing of LIR
src/lir/lower/            Lowering passes

See also