Skip to main content

compile

Function compile 

Source
pub fn compile(
    source: &mut Func,
    names: &mut Interner,
    machine: &Machine,
    elsewhere: &Elsewhere,
    flags: Flags,
) -> Result<Func, Unsupported>
Expand description

Compiles one function, from the IR the middle end produced to machine instructions.

The function is taken by reference that can be written through, because the first pass is an IR to IR rewrite: a construct whose lowering is a new shape of control flow cannot be a rule, since a rule replaces a term with a term and has nowhere to put a block. So the IR that reaches selection is not quite the IR the middle end produced, and this is the only place that is true. --emit=ir prints before any of this runs.

elsewhere is the one thing here that is a fact about the module rather than about the function, and it is passed in rather than looked up because this only ever sees the one function. What it decides is how the address of a name is come by, which is the difference between an address this file can measure to and one only the linker knows.

ยงErrors

The first thing in it this cannot lower, which is what lower::func reports and is the only pass here that can refuse a function. Everything after lowering works on machine instructions that exist, so it either runs or it is a bug in this crate.