Skip to main content

Module mir_compiler

Module mir_compiler 

Source
Expand description

MIR-to-Cranelift IR compiler (JIT v2).

Compiles directly from Shape’s MIR (Mid-level IR) to Cranelift IR, preserving CFG structure, ownership semantics (Move/Copy/Drop), liveness, and storage plans that are lost in the bytecode encoding.

§Architecture

AST → MIR (existing) → BorrowAnalysis + Liveness + StoragePlan (existing)
                     → MirToIR (this module) → Cranelift IR → native code

§Key differences from BytecodeToIR

  • 1:1 block mapping: MIR BasicBlocks map directly to Cranelift blocks
  • Ownership-aware: Move nulls the source, Copy retains, Drop releases
  • ~7 statement kinds vs ~100 bytecode opcodes
  • Explicit Drop points: Scope cleanup from MIR, not heuristic

Modules§

bounds_elision
MIR-level bounds-check elision analysis.

Structs§

MirPreflightResult
Result of MIR preflight check.
MirToIR
MIR-to-Cranelift IR compiler.

Functions§

preflight
Check if a function’s MIR can be compiled by MirToIR.