Document a little. (#3289)

This commit is contained in:
chriseth
2025-09-17 11:00:11 +02:00
committed by GitHub
parent 6e4143e3be
commit 9f6a35270b
2 changed files with 12 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ use crate::blocks::BasicBlock;
use crate::bus_map::{BusMap, BusType};
use crate::evaluation::AirStats;
use crate::expression_conversion::algebraic_to_grouped_expression;
use crate::symbolic_machine_generator::convert_machine;
use crate::symbolic_machine_generator::convert_machine_field_type;
use expression::{AlgebraicExpression, AlgebraicReference};
use itertools::Itertools;
use powdr::UniqueReferences;
@@ -382,7 +382,7 @@ pub fn build<A: Adapter>(
metrics::counter!("after_opt_interactions", &labels)
.absolute(machine.unique_references().count() as u64);
let machine = convert_machine(machine, &A::into_field);
let machine = convert_machine_field_type(machine, &A::into_field);
let apc = Apc {
block,

View File

@@ -10,20 +10,21 @@ use crate::{
SymbolicMachine,
};
pub fn convert_machine<T, U>(
/// Converts the field type of a symbolic machine.
pub fn convert_machine_field_type<T, U>(
machine: SymbolicMachine<T>,
convert: &impl Fn(T) -> U,
convert_field_element: &impl Fn(T) -> U,
) -> SymbolicMachine<U> {
SymbolicMachine {
constraints: machine
.constraints
.into_iter()
.map(|c| convert_symbolic_constraint(c, convert))
.map(|c| convert_symbolic_constraint(c, convert_field_element))
.collect(),
bus_interactions: machine
.bus_interactions
.into_iter()
.map(|i| convert_bus_interaction(i, convert))
.map(|i| convert_bus_interaction(i, convert_field_element))
.collect(),
}
}
@@ -81,6 +82,10 @@ fn convert_expression<T, U>(
}
}
/// Converts a basic block into a symbolic machine and a vector
/// that contains, for each instruction in the basic block,
/// a mapping from local column IDs to global column IDs
/// (in the form of a vector).
pub fn statements_to_symbolic_machine<A: Adapter>(
block: &BasicBlock<A::Instruction>,
instruction_handler: &A::InstructionHandler,
@@ -98,7 +103,7 @@ pub fn statements_to_symbolic_machine<A: Adapter>(
.clone();
let machine: SymbolicMachine<<A as Adapter>::PowdrField> =
convert_machine(machine, &|x| A::from_field(x));
convert_machine_field_type(machine, &|x| A::from_field(x));
// It is sufficient to provide the initial PC, because the PC update should be
// deterministic within a basic block. Therefore, all future PCs can be derived