Expand description
§chipi-core
Core library for the chipi instruction decoder generator.
This crate provides the parser, validation, IR, and code generation backends.
It is consumed by chipi-cli (the standalone CLI tool) and chipi-build
(the build.rs helper for Rust projects).
§Crate structure
parser: parses.chipifiles into a raw AST (types::DecoderDef)validate: validates and lowers the AST into a language-agnostic IR (types::ValidatedDef)tree: builds an optimal decision tree for instruction dispatchbackend: code generation backends (currently Rust only)config: TOML config schema andconfig::Dispatchenumcodegen: Rust decoder/disassembler code generationlut_gen: Rust emulator dispatch LUT generationinstr_gen: Rust instruction newtype generation
§Quick start
For build.rs usage, prefer chipi-build which wraps this library with
cargo:rerun-if-changed support. For CLI usage, use chipi-cli.
Use chipi-core directly only when you need low-level control.
ⓘ
// Decoder/disassembler generation
chipi_core::CodegenBuilder::new("dsp.chipi")
.type_map("reg5", "crate::dsp::DspReg")
.decoder_dispatch("GcDspExt", chipi_core::Dispatch::JumpTable)
.output("out.rs")
.run()?;
// Emulator dispatch LUT (programmatic)
chipi_core::LutBuilder::new("cpu.chipi")
.handler_mod("crate::cpu::interpreter")
.ctx_type("crate::Cpu")
.group("alu", ["addi", "addis"])
.build_lut("out/lut.rs")?;
// Emulator dispatch LUT (from chipi.toml config)
let cfg = chipi_core::config::load_config(Path::new("chipi.toml"))?;
for target in &cfg.lut {
chipi_core::LutBuilder::run_target(target)?;
}Re-exports§
pub use config::Dispatch;
Modules§
- backend
- Code generation backends.
- codegen
- Rust code generation from validated definitions and decision trees.
- codegen_
binja - Binary Ninja Architecture plugin code generation.
- codegen_
cpp - C++ code generation from validated definitions and decision trees.
- codegen_
ida - IDA Pro processor module code generation.
- codegen_
python - Shared Python code generation helpers.
- config
- Configuration types for chipi code generation.
- error
- Error types and reporting for parsing and validation.
- format_
parser - Character-level parser for format string internals.
- instr_
gen - Instruction type generation - produces a newtype with field accessor methods.
- lut_gen
- Function-pointer LUT generation from a validated definition and dispatch tree.
- parser
- DSL parsing for instruction definitions.
- tree
- Decision tree construction for optimal instruction dispatch.
- types
- Core type definitions for the intermediate representation.
- validate
- Semantic validation for instruction definitions.
Structs§
- Codegen
Builder - Builder for generating a decoder with type mappings and dispatch strategy control.
- LutBuilder
- Builder for generating a function-pointer LUT and handler stubs, with optional grouping of instructions under shared const-generic handlers.
Functions§
- emit
- Validate a parsed definition and write generated Rust code to a file.
- generate
- Full pipeline: parse a
.chipifile and generate a Rust decoder. - generate_
from_ str - Parse, validate, and generate code from source text. Returns the
generated Rust code as a
String. - generate_
instr_ type - Generate an instruction newtype with field accessor methods from a
.chipispec. - generate_
lut - Generate a function-pointer LUT from a
.chipispec file. - parse
- Parse a
.chipifile from a file path and return the decoder definition. - parse_
str - Parse source text directly without reading from a file.