pub fn generate_lut(
input: &str,
output: &str,
handler_mod: &str,
ctx_type: &str,
) -> Result<(), Box<dyn Error>>Expand description
Generate a function-pointer LUT from a .chipi spec file.
Produces a Rust source file containing:
pub type Handler = fn(&mut Ctx, u32)- Static dispatch tables (
_T0,_T1, …) indexed by opcode bit ranges pub fn dispatch(ctx: &mut Ctx, opcode: u32)
handler_mod is the module path where handler functions live, e.g.
"crate::cpu::interpreter"Each instruction foo in the spec must have
a corresponding pub fn foo(ctx: &mut Ctx, opcode: u32) there.
ctx_type is the mutable context passed to every handler, e.g.
"crate::gekko::Gekko".
§Example (build.rs)
ⓘ
chipi::generate_lut(
"cpu.chipi",
out_dir.join("cpu_lut.rs").to_str().unwrap(),
"crate::cpu::interpreter",
"crate::Cpu",
)?;