pub fn select(
module: &Module,
func: FuncId,
options: &Options,
) -> Result<Function, IselError>Expand description
Selects func of a validated module into a MIR function on virtual
registers, named after the function and under the calling convention its
signature selects. The module is validated first.
§Errors
§Examples
use backend_lang::Options;
use ir_lang::{Linkage, Module, Overflow, Signature, Type};
let mut m = Module::new("m");
let f = m.declare_function("inc", &Signature::new(&[Type::I64], &[Type::I64]), Linkage::Export)?;
let mut b = m.build(f)?;
let x = b.param(0)?;
let one = b.iconst(Type::I64, 1)?;
let y = b.add(x, one, Overflow::Wrap)?;
b.ret(&[y])?;
let mir = backend_lang::isel::select(&m, f, &Options::sysv())?;
assert_eq!(mir.name(), "inc");
assert!(mir.to_string().contains("add64"));