Skip to main content

Crate nova_mir

Crate nova_mir 

Source
Expand description

Mid-level IR for the Nova compiler.

MIR is a 3-address-style IR over a control-flow graph of basic blocks, produced from typed HIR (nova-hir) and consumed by the codegen backends. Lowering to MIR performs:

  • Monomorphization: generic functions are instantiated per unique concrete type-argument list, reachable from main (spec 14-CODEGEN.md §6.3). MIR contains no generic types.
  • Pattern-match compilation: match lowers to a tag Switch over sum values (or value switches / equality chains for primitives).
  • Short-circuit lowering: && / || become control flow.

Sum values are boxed: { tag: i64, fields: 8 bytes each }, allocated through the runtime. Strings and function values are opaque pointers.

Structs§

Block
A basic block: straight-line statements plus one terminator.
BlockId
A basic block id within one function; BlockId(0) is the entry.
ExternDecl
An imported external (C-ABI) function: its raw symbol and ABI classes.
Function
A monomorphized function.
Module
A monomorphized module ready for codegen.
Temp
A virtual register within one function.

Enums§

MirTy
A machine-level value class for one MIR temporary.
OperandClass
Numeric class of a binary operation’s operands.
RtFunc
Runtime support functions provided by nova-runtime.
Stmt
A single 3-address statement.
Terminator
Block terminators.

Constants§

FUTURE_SLOT_POLL
The async ABI this compiler generates against: the state object’s slot layout, the future value’s slot layout, and the poll statuses.
FUTURE_SLOT_STATE
The async ABI this compiler generates against: the state object’s slot layout, the future value’s slot layout, and the poll statuses.
MAX_ARRAY_LEN
The largest element count ArrayAlloc may be handed.
POLL_PENDING
The async ABI this compiler generates against: the state object’s slot layout, the future value’s slot layout, and the poll statuses.
POLL_READY
The async ABI this compiler generates against: the state object’s slot layout, the future value’s slot layout, and the poll statuses.
STATE_MIN_SIZE
The async ABI this compiler generates against: the state object’s slot layout, the future value’s slot layout, and the poll statuses.
STATE_SLOT_OUTPUT
The async ABI this compiler generates against: the state object’s slot layout, the future value’s slot layout, and the poll statuses.
STATE_SLOT_TAG
The async ABI this compiler generates against: the state object’s slot layout, the future value’s slot layout, and the poll statuses.
STATE_SLOT_TEMPS
The async ABI this compiler generates against: the state object’s slot layout, the future value’s slot layout, and the poll statuses.

Functions§

lower_module
Lower a typed HIR module to monomorphized MIR.
mangle
Mangle a function instance into a unique symbol name.
mir_ty
Map a concrete HIR type to its machine class.