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(spec14-CODEGEN.md§6.3). MIR contains no generic types. - Pattern-match compilation:
matchlowers to a tagSwitchover 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. - Extern
Decl - 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.
- Operand
Class - 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
ArrayAllocmay 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.