diff --git a/executor/src/witgen/jit/compiler.rs b/executor/src/witgen/jit/compiler.rs index 5e058b8938..6814f96600 100644 --- a/executor/src/witgen/jit/compiler.rs +++ b/executor/src/witgen/jit/compiler.rs @@ -547,13 +547,20 @@ fn prover_function_code( codegen.generate_code_for_expression(code)? ), ProverFunctionComputation::ProvideIfUnknown(code) => { + assert!(!f.compute_multi); format!("({}).call()", codegen.generate_code_for_expression(code)?) } }; - + let code = if f.compute_multi { + format!("({code}).as_slice().try_into().unwrap()") + } else { + assert_eq!(f.target.len(), 1); + format!("[{code}]") + }; + let length = f.target.len(); let index = f.index; Ok(format!( - "fn prover_function_{index}(i: u64, args: &[FieldElement]) -> FieldElement {{\n\ + "fn prover_function_{index}(i: u64, args: &[FieldElement]) -> [FieldElement; {length}] {{\n\ let i: ibig::IBig = i.into();\n\ {code} }}" diff --git a/executor/src/witgen/jit/function_cache.rs b/executor/src/witgen/jit/function_cache.rs index a8e0ddbe96..150fc272d9 100644 --- a/executor/src/witgen/jit/function_cache.rs +++ b/executor/src/witgen/jit/function_cache.rs @@ -6,10 +6,7 @@ use powdr_number::{FieldElement, KnownField}; use crate::witgen::{ data_structures::finalizable_data::{ColumnLayout, CompactDataRef}, - jit::{ - effect::{format_code, Effect}, - processor::ProcessorResult, - }, + jit::{effect::format_code, processor::ProcessorResult}, machines::{ profiling::{record_end, record_start}, LookupCell, MachineParts, @@ -170,22 +167,6 @@ impl<'a, T: FieldElement> FunctionCache<'a, T> { ); } - // TODO remove this once code generation for prover functions is working. - if code - .iter() - .flat_map(|e| -> Box>> { - if let Effect::Branch(_, first, second) = e { - Box::new(first.iter().chain(second)) - } else { - Box::new(std::iter::once(e)) - } - }) - .any(|e| matches!(e, Effect::ProverFunctionCall { .. })) - { - log::debug!("Inferred code contains call to prover function, which is not yet implemented. Using runtime solving instead."); - return None; - } - log::trace!("Generated code ({} steps)", code.len()); let known_inputs = cache_key .known_args diff --git a/executor/src/witgen/jit/prover_function_heuristics.rs b/executor/src/witgen/jit/prover_function_heuristics.rs index 9d653cccb1..30d6cc8200 100644 --- a/executor/src/witgen/jit/prover_function_heuristics.rs +++ b/executor/src/witgen/jit/prover_function_heuristics.rs @@ -16,7 +16,6 @@ pub trait TrySymbolByName: Copy { fn try_symbol_by_name<'a>(&'a self, name: &str) -> Option<&'a Symbol>; } -#[allow(unused)] #[derive(Clone)] pub struct ProverFunction<'a, T> { pub index: usize, @@ -29,7 +28,6 @@ pub struct ProverFunction<'a, T> { pub computation: ProverFunctionComputation<'a>, } -#[allow(unused)] #[derive(Clone)] pub enum ProverFunctionComputation<'a> { /// The expression `f` in `query |i| std::prover::provide_if_unknown(Y, i, f)`, diff --git a/jit-compiler/src/compiler.rs b/jit-compiler/src/compiler.rs index 1b6d48493b..55bfd2c48c 100644 --- a/jit-compiler/src/compiler.rs +++ b/jit-compiler/src/compiler.rs @@ -106,14 +106,10 @@ pub fn call_cargo(code: &str, opt_level: Option) -> Result PilVec { fn len(&self) -> usize { self.0.len() } + + fn as_slice(&self) -> &[T] { + self.0.as_ref() + } } impl From> for PilVec { fn from(v: Vec) -> Self {