mirl is the intermediate representation and code generator of the mach toolchain. It is a library and a program written in mach. A front end builds mirl IR through the builder API, or writes it as text, and mirl optimises it, legalises it for a target, selects instructions, allocates registers, lays out frames, applies calling conventions and produces debug information.
mach -> mirl -> masc -> mink
- mach is the language front end. It hands mirl the IR.
- mirl is the IR and code generation. It hands masc assembly in masc's model.
- masc is the assembler. It owns instruction sets, registers and encodings, and hands mink objects.
- mink is the linker. It owns object formats, architecture identity and relocations.
mirl never reaches past masc. A front end asks mirl for data layout and calling conventions and never computes either itself.
mirl.irholds the types, values, instructions and modules, andmirl.ir.textthe text form. The IR is in SSA form with block parameters, and every opcode's typing rule and effects live in one table.mirl.buildis the builder andmirl.verifythe verifier.mirl.targetis the target record. A target declares its capabilities, data layout and calling conventions as data, and the pipeline is chosen from those declarations. Each family sits inmirl.target.<family>, with the register family's members, such as RISC-V, one level below it.mirl.passholds the pass contract and schedule,mirl.optthe optimisation passes andmirl.legallegalisation.mirl.machineis the machine form below the IR, with selection, register allocation, frames, block layout and emission as its children.mirl.debugproduces debug information from the IR's debug tables, andmirl.ctpreserves and validates secrecy and constant time.mirl.structureturns any control flow graph into structured regions for the SPIR-V (mirl.target.spirv) and WebAssembly (mirl.target.wasm) families.
The IR is specified in doc/ir.md.
mirl builds with mach 6.10.1 or later.
mach dep pull .
mach build .
mach test . -a '*'