| Crates.io | air-ir |
| lib.rs | air-ir |
| version | 0.4.0 |
| created_at | 2022-11-10 22:21:46.319481+00 |
| updated_at | 2025-06-21 00:21:59.848298+00 |
| description | Intermediate representation for the AirScript language |
| homepage | |
| repository | https://github.com/0xMiden/air-script |
| max_upload_size | |
| id | 712444 |
| size | 188,356 |
This crate contains the intermediate representation for AirScript, AirIR.
The purpose of the AirIR is to provide a simple and accurate representation of an AIR that allows for optimization and translation to constraint evaluator code in a variety of target languages.
Generate an AirIR from either an AirScript AST (the output of the AirScript parser) or a MIR (the Middle Intermediate Representation for AirScript).
Example usage:
// parse the source string to a Result containing the AST or an Error
let ast = parse(source.as_str()).expect("Parsing failed");
// Create the compilation pipeline needed to translate the AST to AIR
let pipeline_with_mir = air_parser::transforms::ConstantPropagation::new(&diagnostics)
.chain(mir::passes::AstToMir::new(&diagnostics))
.chain(mir::passes::Inlining::new(&diagnostics))
.chain(mir::passes::Unrolling::new(&diagnostics))
.chain(air_ir::passes::MirToAir::new(&diagnostics))
.chain(air_ir::passes::BusOpExpand::new(&diagnostics));
let pipeline_without_mir = air_parser::transforms::ConstantPropagation::new(&diagnostics)
.chain(air_parser::transforms::Inlining::new(&diagnostics))
.chain(air_ir::passes::AstToAir::new(&diagnostics));
// process the AST to get a Result containing the AIR or a CompileError
let air_from_ast = pipeline_without_mir.run(ast)
let air_from_mir = pipeline_with_mir.run(ast)
Although generation of an AirIR uses a symbol table while processing the source AST, the internal representation only consists of the following:
AirIR.main and auxiliary).ConstraintRoot for each trace segment (e.g. main or auxiliary), where ConstraintRoot contains the node index in the graph where each of the constraint starts and the constraint domain which specifies the row(s) accessed by each of the constraints.