pub fn compile_function(
module: &Module,
func: FuncId,
options: &Options,
) -> Result<Function, CompileError>Expand description
Selects and allocates one function: the MIR on physical registers that
emit or an Emitter encodes.
§Errors
§Examples
use backend_lang::Options;
use ir_lang::{Linkage, Module, Signature, Type};
let mut m = Module::new("m");
let f = m.declare_function("seven", &Signature::new(&[], &[Type::I32]), Linkage::Export)?;
let mut b = m.build(f)?;
let k = b.iconst(Type::I32, 7)?;
b.ret(&[k])?;
let mir = backend_lang::compile_function(&m, f, &Options::sysv())?;
assert!(mir.to_string().contains("rax"));