Skip to content

Commit

Permalink
feat: Evaluate TASM AIR from dynamic locations
Browse files Browse the repository at this point in the history
Previously, the addresses for the input of the AIR evaluator had to be
known ahead of time, and were baked into the assembly.
Now, there is an additional piece of TASM evaluating the AIR available.
It expects pointers to the various inputs on top of the stack, meaning
they are dynamic in nature.
  • Loading branch information
jan-ferdinand committed Aug 14, 2024
2 parents 3b5bc12 + 89aa21d commit 33bc62c
Show file tree
Hide file tree
Showing 14 changed files with 1,135 additions and 652 deletions.
18 changes: 16 additions & 2 deletions constraint-evaluation-generator/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ pub(crate) struct TasmBackend {
scope: HashSet<usize>,

/// The number of elements written to the output list.
///
/// See [`TasmBackend::doc_comment`] for details.
elements_written: usize,

/// Whether the code that is to be generated can assume statically provided
/// addresses for the various input arrays.
input_location_is_static: bool,
}

#[cfg(test)]
pub mod tests {
use super::*;

pub fn print_constraints<B: Codegen>(constraints: &Constraints) {
let code = B::constraint_evaluation_code(constraints);
let syntax_tree = syn::parse2(code).unwrap();
let code = prettyplease::unparse(&syntax_tree);
println!("{code}");
}
}
17 changes: 6 additions & 11 deletions constraint-evaluation-generator/src/codegen/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ impl RustBackend {
mod tests {
use twenty_first::prelude::*;

use crate::codegen::tests::print_constraints;

use super::*;

#[test]
Expand All @@ -352,20 +354,13 @@ mod tests {
assert_eq!(expected, RustBackend::tokenize_xfe(xfe).to_string());
}

fn print_constraints_as_rust(constraints: &Constraints) {
let rust = RustBackend::constraint_evaluation_code(constraints);
let syntax_tree = syn::parse2(rust).unwrap();
let code = prettyplease::unparse(&syntax_tree);
println!("{code}");
}

#[test]
fn print_mini_constraints_as_rust() {
print_constraints_as_rust(&Constraints::mini_constraints());
fn print_mini_constraints() {
print_constraints::<RustBackend>(&Constraints::mini_constraints());
}

#[test]
fn print_test_constraints_as_rust() {
print_constraints_as_rust(&Constraints::test_constraints());
fn print_test_constraints() {
print_constraints::<RustBackend>(&Constraints::test_constraints());
}
}
Loading

0 comments on commit 33bc62c

Please sign in to comment.