Skip to content

Commit

Permalink
Rename PILGraph to MachineInstanceGraph. (powdr-labs#2001)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored Oct 31, 2024
1 parent 5c37eba commit a3f7eac
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions airgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::collections::BTreeMap;

use powdr_ast::{
asm_analysis::{self, combine_flags, AnalysisASMFile, LinkDefinition, MachineDegree},
object::{Link, LinkFrom, LinkTo, Location, Machine, Object, Operation, PILGraph},
object::{Link, LinkFrom, LinkTo, Location, Machine, MachineInstanceGraph, Object, Operation},
parsed::{
asm::{parse_absolute_path, AbsoluteSymbolPath, CallableRef, MachineParams},
Expression, PilStatement,
Expand All @@ -21,7 +21,7 @@ use powdr_analysis::utils::parse_pil_statement;
const MAIN_MACHINE: &str = "::Main";
const MAIN_FUNCTION: &str = "main";

pub fn compile(input: AnalysisASMFile) -> PILGraph {
pub fn compile(input: AnalysisASMFile) -> MachineInstanceGraph {
let main_location = Location::main();

let non_std_non_rom_machines = input
Expand All @@ -41,7 +41,7 @@ pub fn compile(input: AnalysisASMFile) -> PILGraph {
operation_id: None,
call_selectors: None,
};
return PILGraph {
return MachineInstanceGraph {
main,
entry_points: Default::default(),
objects: [(main_location, Default::default())].into(),
Expand Down Expand Up @@ -184,7 +184,7 @@ pub fn compile(input: AnalysisASMFile) -> PILGraph {
})
.collect();

PILGraph {
MachineInstanceGraph {
main,
entry_points,
objects,
Expand Down
4 changes: 2 additions & 2 deletions ast/src/object/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use std::fmt::{Display, Formatter, Result};

use crate::{asm_analysis::combine_flags, write_items_indented};

use super::{Link, LinkFrom, LinkTo, Location, Machine, Object, Operation, PILGraph};
use super::{Link, LinkFrom, LinkTo, Location, Machine, MachineInstanceGraph, Object, Operation};

impl Display for Location {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{}", self.limbs.join("_"))
}
}

impl Display for PILGraph {
impl Display for MachineInstanceGraph {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
writeln!(f, "// Utilities")?;
for (module_path, statements) in &self.statements {
Expand Down
2 changes: 1 addition & 1 deletion ast/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Location {
}

#[derive(Clone)]
pub struct PILGraph {
pub struct MachineInstanceGraph {
pub main: Machine,
pub entry_points: Vec<Operation>,
pub objects: BTreeMap<Location, Object>,
Expand Down
10 changes: 5 additions & 5 deletions linker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use lazy_static::lazy_static;
use powdr_analysis::utils::parse_pil_statement;
use powdr_ast::{
asm_analysis::{combine_flags, MachineDegree},
object::{Link, Location, PILGraph},
object::{Link, Location, MachineInstanceGraph},
parsed::{
asm::{AbsoluteSymbolPath, SymbolPath},
build::{index_access, lookup, namespaced_reference, permutation, selected},
Expand Down Expand Up @@ -48,7 +48,7 @@ fn to_namespace_degree(d: MachineDegree) -> NamespaceDegree {
}

/// The optional degree of the namespace is set to that of the object if it's set, to that of the main object otherwise.
pub fn link(graph: PILGraph) -> Result<PILFile, Vec<String>> {
pub fn link(graph: MachineInstanceGraph) -> Result<PILFile, Vec<String>> {
let main_machine = graph.main;
let main_degree = graph
.objects
Expand Down Expand Up @@ -232,7 +232,7 @@ fn process_link(link: Link) -> PilStatement {
mod test {
use std::{fs, path::PathBuf};

use powdr_ast::object::PILGraph;
use powdr_ast::object::MachineInstanceGraph;
use powdr_number::{FieldElement, GoldilocksField};

use powdr_analysis::convert_asm_to_pil;
Expand All @@ -242,7 +242,7 @@ mod test {

use crate::{link, MAX_DEGREE_LOG, MIN_DEGREE_LOG};

fn parse_analyze_and_compile_file<T: FieldElement>(file: &str) -> PILGraph {
fn parse_analyze_and_compile_file<T: FieldElement>(file: &str) -> MachineInstanceGraph {
let contents = fs::read_to_string(file).unwrap();
let parsed = parse_asm(Some(file), &contents).unwrap_or_else(|e| {
e.output_to_stderr();
Expand All @@ -254,7 +254,7 @@ mod test {
powdr_airgen::compile(convert_asm_to_pil::<T>(resolved).unwrap())
}

fn parse_analyze_and_compile<T: FieldElement>(input: &str) -> PILGraph {
fn parse_analyze_and_compile<T: FieldElement>(input: &str) -> MachineInstanceGraph {
let parsed = parse_asm(None, input).unwrap_or_else(|e| {
e.output_to_stderr();
panic!();
Expand Down
8 changes: 4 additions & 4 deletions pipeline/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use mktemp::Temp;
use powdr_ast::{
analyzed::Analyzed,
asm_analysis::AnalysisASMFile,
object::PILGraph,
object::MachineInstanceGraph,
parsed::{asm::ASMProgram, PILFile},
};
use powdr_backend::{Backend, BackendOptions, BackendType, Proof};
Expand Down Expand Up @@ -58,7 +58,7 @@ pub struct Artifacts<T: FieldElement> {
constrained_machine_collection: Option<AnalysisASMFile>,
/// The airgen graph, i.e. a collection of constrained machines with resolved
/// links between them.
linked_machine_graph: Option<PILGraph>,
linked_machine_graph: Option<MachineInstanceGraph>,
/// A single parsed pil file.
parsed_pil_file: Option<PILFile>,
/// The path to a single .pil file.
Expand Down Expand Up @@ -805,7 +805,7 @@ impl<T: FieldElement> Pipeline<T> {
.unwrap())
}

pub fn compute_linked_machine_graph(&mut self) -> Result<&PILGraph, Vec<String>> {
pub fn compute_linked_machine_graph(&mut self) -> Result<&MachineInstanceGraph, Vec<String>> {
if self.artifact.linked_machine_graph.is_none() {
self.artifact.linked_machine_graph = Some({
self.compute_constrained_machine_collection()?;
Expand All @@ -823,7 +823,7 @@ impl<T: FieldElement> Pipeline<T> {
Ok(self.artifact.linked_machine_graph.as_ref().unwrap())
}

pub fn linked_machine_graph(&self) -> Result<&PILGraph, Vec<String>> {
pub fn linked_machine_graph(&self) -> Result<&MachineInstanceGraph, Vec<String>> {
Ok(self.artifact.linked_machine_graph.as_ref().unwrap())
}

Expand Down

0 comments on commit a3f7eac

Please sign in to comment.