diff --git a/Cargo.toml b/Cargo.toml index ce2507c8ce..ac7ea94f6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,25 +6,25 @@ members = [ "powdr", "number", "parser", - "powdr_cli", + "cli", "executor", "riscv", - "parser_util", - "pil_analyzer", + "parser-util", + "pil-analyzer", "pipeline", "pilopt", - "asm_to_pil", + "asm-to-pil", "halo2", "backend", "ast", "analysis", "linker", - "asm_utils", + "asm-utils", "airgen", - "riscv_executor", + "riscv-executor", ] -exclude = [ "powdr_riscv_rt" ] +exclude = [ "riscv-rt" ] [patch."https://github.com/privacy-scaling-explorations/halo2.git"] # TODO change back to this once the PR is merged diff --git a/airgen/Cargo.toml b/airgen/Cargo.toml index 693c63a148..c4f2e0f7da 100644 --- a/airgen/Cargo.toml +++ b/airgen/Cargo.toml @@ -1,10 +1,11 @@ [package] -name = "airgen" +name = "powdr-airgen" version = "0.1.0" edition = "2021" [dependencies] -log = "0.4.17" -number = { path = "../number" } +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } + num-bigint = "0.4.3" -ast = { path = "../ast" } +log = "0.4.17" diff --git a/airgen/src/lib.rs b/airgen/src/lib.rs index a727237f68..8b2f156faf 100644 --- a/airgen/src/lib.rs +++ b/airgen/src/lib.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; -use ast::{ +use powdr_ast::{ asm_analysis::{AnalysisASMFile, Item, LinkDefinitionStatement, SubmachineDeclaration}, object::{Link, LinkFrom, LinkTo, Location, Object, Operation, PILGraph}, parsed::{ @@ -16,7 +16,7 @@ use ast::{ const MAIN_MACHINE: &str = "::Main"; const MAIN_FUNCTION: &str = "main"; -use number::FieldElement; +use powdr_number::FieldElement; pub fn compile(input: AnalysisASMFile) -> PILGraph { let main_location = Location::main(); @@ -71,7 +71,7 @@ pub fn compile(input: AnalysisASMFile) -> PILGraph { panic!() }; - let main = ast::object::Machine { + let main = powdr_ast::object::Machine { location: main_location, latch: main_ty.latch.clone(), operation_id: main_ty.operation_id.clone(), @@ -204,7 +204,7 @@ impl<'a, T: FieldElement> ASMPILConverter<'a, T> { .operation_definitions() .find(|o| o.name == callable) .map(|d| LinkTo { - machine: ast::object::Machine { + machine: powdr_ast::object::Machine { location: instance_location, latch: instance_ty.latch.clone(), operation_id: instance_ty.operation_id.clone(), diff --git a/analysis/Cargo.toml b/analysis/Cargo.toml index 419764b683..62b3dd691c 100644 --- a/analysis/Cargo.toml +++ b/analysis/Cargo.toml @@ -1,19 +1,19 @@ [package] -name = "analysis" +name = "powdr-analysis" version = "0.1.0" edition = "2021" [dependencies] -ast = { path = "../ast" } +powdr-asm-to-pil = { path = "../asm-to-pil" } +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } +powdr-parser = { path = "../parser" } + itertools = "^0.10" log = "0.4.18" -number = { path = "../number" } -parser = { path = "../parser" } -asm_to_pil = { path = "../asm_to_pil" } [dev-dependencies] -parser = { path = "../parser" } -importer = { path = "../importer" } +powdr-importer = { path = "../importer" } pretty_assertions = "1.3.0" test-log = "0.2.12" env_logger = "0.10.0" diff --git a/analysis/src/block_enforcer.rs b/analysis/src/block_enforcer.rs index acd2f1f411..d67a241c88 100644 --- a/analysis/src/block_enforcer.rs +++ b/analysis/src/block_enforcer.rs @@ -1,7 +1,7 @@ //! For all machines, enforce that the `operation_id` can only change when the `latch` is on -use ast::asm_analysis::AnalysisASMFile; -use number::FieldElement; +use powdr_ast::asm_analysis::AnalysisASMFile; +use powdr_number::FieldElement; use crate::utils::parse_pil_statement; diff --git a/analysis/src/lib.rs b/analysis/src/lib.rs index efaae39fb5..82c18709fc 100644 --- a/analysis/src/lib.rs +++ b/analysis/src/lib.rs @@ -4,8 +4,8 @@ mod block_enforcer; pub mod machine_check; mod vm; -use ast::{asm_analysis::AnalysisASMFile, parsed::asm::ASMProgram, DiffMonitor}; -use number::FieldElement; +use powdr_ast::{asm_analysis::AnalysisASMFile, parsed::asm::ASMProgram, DiffMonitor}; +use powdr_number::FieldElement; pub fn convert_asm_to_pil( file: ASMProgram, @@ -39,7 +39,7 @@ pub fn convert_vms_to_constrained( ) -> AnalysisASMFile { // remove all asm (except external instructions) log::debug!("Run asm_to_pil"); - let file = asm_to_pil::compile(file); + let file = powdr_asm_to_pil::compile(file); monitor.push(&file); // enforce blocks using `operation_id` and `latch` @@ -51,11 +51,11 @@ pub fn convert_vms_to_constrained( } pub mod utils { - use ast::parsed::PilStatement; - use number::FieldElement; + use powdr_ast::parsed::PilStatement; + use powdr_number::FieldElement; pub fn parse_pil_statement(input: &str) -> PilStatement { - parser::powdr::PilStatementParser::new() + powdr_parser::powdr::PilStatementParser::new() .parse(input) .unwrap() } diff --git a/analysis/src/machine_check.rs b/analysis/src/machine_check.rs index 9bf4d8c749..aa0e4aa95a 100644 --- a/analysis/src/machine_check.rs +++ b/analysis/src/machine_check.rs @@ -2,7 +2,7 @@ use std::{collections::BTreeMap, marker::PhantomData}; -use ast::{ +use powdr_ast::{ asm_analysis::{ AnalysisASMFile, AssignmentStatement, CallableSymbolDefinitions, DebugDirective, DegreeStatement, FunctionBody, FunctionStatements, FunctionSymbol, Instruction, @@ -19,7 +19,7 @@ use ast::{ }, }, }; -use number::FieldElement; +use powdr_number::FieldElement; /// Verifies certain properties of each machine and constructs the Machine objects. /// Also transfers generic PIL definitions but does not verify anything about them. @@ -323,9 +323,9 @@ impl TypeChecker { let errors: Vec<_> = statements .iter() .filter_map(|s| match s { - ast::parsed::PilStatement::PolynomialIdentity(_, _) => None, - ast::parsed::PilStatement::PermutationIdentity(_, l, _) - | ast::parsed::PilStatement::PlookupIdentity(_, l, _) => l + powdr_ast::parsed::PilStatement::PolynomialIdentity(_, _) => None, + powdr_ast::parsed::PilStatement::PermutationIdentity(_, l, _) + | powdr_ast::parsed::PilStatement::PlookupIdentity(_, l, _) => l .selector .is_some() .then_some(format!("LHS selector not yet supported in {s}.")), @@ -345,8 +345,8 @@ impl TypeChecker { #[cfg(test)] mod tests { - use importer::load_dependencies_and_resolve_str; - use number::Bn254Field; + use powdr_importer::load_dependencies_and_resolve_str; + use powdr_number::Bn254Field; use super::check; diff --git a/analysis/src/vm/batcher.rs b/analysis/src/vm/batcher.rs index 56e4c847ef..b9b61b8c7a 100644 --- a/analysis/src/vm/batcher.rs +++ b/analysis/src/vm/batcher.rs @@ -2,15 +2,15 @@ use std::marker::PhantomData; -use ast::{ +use itertools::Itertools; +use powdr_ast::{ asm_analysis::{ AnalysisASMFile, BatchMetadata, FunctionStatement, Incompatible, IncompatibleSet, Item, Machine, }, parsed::asm::AbsoluteSymbolPath, }; -use itertools::Itertools; -use number::FieldElement; +use powdr_number::FieldElement; pub fn batch(file: AnalysisASMFile) -> AnalysisASMFile { RomBatcher::default().batch(file) @@ -153,8 +153,8 @@ mod tests { use std::{fs, path::PathBuf}; - use ast::asm_analysis::AnalysisASMFile; - use number::GoldilocksField; + use powdr_ast::asm_analysis::AnalysisASMFile; + use powdr_number::GoldilocksField; use pretty_assertions::assert_eq; use test_log::test; diff --git a/analysis/src/vm/inference.rs b/analysis/src/vm/inference.rs index 332096d0c5..b5e5b60099 100644 --- a/analysis/src/vm/inference.rs +++ b/analysis/src/vm/inference.rs @@ -1,10 +1,10 @@ //! Infer assignment registers in asm statements -use ast::{ +use powdr_ast::{ asm_analysis::{AnalysisASMFile, Expression, FunctionStatement, Item, Machine}, parsed::asm::AssignmentRegister, }; -use number::FieldElement; +use powdr_number::FieldElement; pub fn infer(file: AnalysisASMFile) -> Result, Vec> { let mut errors = vec![]; @@ -99,8 +99,8 @@ fn infer_machine(mut machine: Machine) -> Result, #[cfg(test)] mod tests { - use ast::{asm_analysis::AssignmentStatement, parsed::asm::parse_absolute_path}; - use number::Bn254Field; + use powdr_ast::{asm_analysis::AssignmentStatement, parsed::asm::parse_absolute_path}; + use powdr_number::Bn254Field; use crate::vm::test_utils::infer_str; diff --git a/analysis/src/vm/mod.rs b/analysis/src/vm/mod.rs index 9748e26a1f..bc2502be9e 100644 --- a/analysis/src/vm/mod.rs +++ b/analysis/src/vm/mod.rs @@ -1,8 +1,8 @@ //! Analysis for VM machines, reducing them to constrained machines //! Machines which do not have a pc should be left unchanged by this -use ast::{asm_analysis::AnalysisASMFile, DiffMonitor}; -use number::FieldElement; +use powdr_ast::{asm_analysis::AnalysisASMFile, DiffMonitor}; +use powdr_number::FieldElement; pub mod batcher; pub mod inference; @@ -30,7 +30,7 @@ mod test_utils { /// A test utility to process a source file until after inference pub fn infer_str(source: &str) -> Result, Vec> { let machines = - crate::machine_check::check(importer::load_dependencies_and_resolve_str(source)) + crate::machine_check::check(powdr_importer::load_dependencies_and_resolve_str(source)) .unwrap(); inference::infer(machines) } diff --git a/asm-to-pil/Cargo.toml b/asm-to-pil/Cargo.toml new file mode 100644 index 0000000000..b87f9f917e --- /dev/null +++ b/asm-to-pil/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "powdr-asm-to-pil" +version = "0.1.0" +edition = "2021" + +[dependencies] +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } +powdr-parser = { path = "../parser" } + +log = "0.4.17" +num-bigint = "0.4.3" +pretty_assertions = "1.4.0" + +[dev-dependencies] +powdr-analysis = { path = "../analysis" } diff --git a/asm_to_pil/src/common.rs b/asm-to-pil/src/common.rs similarity index 93% rename from asm_to_pil/src/common.rs rename to asm-to-pil/src/common.rs index ecc830b7ad..b14e50291c 100644 --- a/asm_to_pil/src/common.rs +++ b/asm-to-pil/src/common.rs @@ -1,5 +1,5 @@ /// Values which are common to many steps from asm to PIL -use number::FieldElement; +use powdr_number::FieldElement; use crate::utils::parse_instruction; @@ -31,7 +31,7 @@ pub fn output_at(i: usize) -> String { pub fn return_instruction( output_count: usize, pc_name: &str, -) -> ast::asm_analysis::Instruction { +) -> powdr_ast::asm_analysis::Instruction { parse_instruction(&format!( "{} {{ {pc_name}' = 0 }}", output_registers(output_count).join(", ") diff --git a/asm_to_pil/src/lib.rs b/asm-to-pil/src/lib.rs similarity index 83% rename from asm_to_pil/src/lib.rs rename to asm-to-pil/src/lib.rs index 44ebd253d2..5301222809 100644 --- a/asm_to_pil/src/lib.rs +++ b/asm-to-pil/src/lib.rs @@ -1,7 +1,7 @@ #![deny(clippy::print_stdout)] -use ast::asm_analysis::{AnalysisASMFile, Item}; -use number::FieldElement; +use powdr_ast::asm_analysis::{AnalysisASMFile, Item}; +use powdr_number::FieldElement; use romgen::generate_machine_rom; mod common; mod romgen; @@ -30,7 +30,7 @@ pub fn compile(file: AnalysisASMFile) -> AnalysisASMFile } pub mod utils { - use ast::{ + use powdr_ast::{ asm_analysis::{ AssignmentStatement, FunctionStatement, Instruction, InstructionDefinitionStatement, InstructionStatement, LabelStatement, RegisterDeclarationStatement, RegisterTy, @@ -40,12 +40,12 @@ pub mod utils { PilStatement, }, }; - use number::FieldElement; + use powdr_number::FieldElement; pub fn parse_instruction_definition( input: &str, ) -> InstructionDefinitionStatement { - match parser::powdr::InstructionDeclarationParser::new() + match powdr_parser::powdr::InstructionDeclarationParser::new() .parse(input) .unwrap() { @@ -64,7 +64,7 @@ pub mod utils { } pub fn parse_instruction(input: &str) -> Instruction { - let instr = parser::powdr::InstructionParser::new() + let instr = powdr_parser::powdr::InstructionParser::new() .parse(input) .unwrap(); Instruction { @@ -74,17 +74,17 @@ pub mod utils { } pub fn parse_instruction_body(input: &str) -> InstructionBody { - parser::powdr::InstructionBodyParser::new() + powdr_parser::powdr::InstructionBodyParser::new() .parse(input) .unwrap() } pub fn parse_function_statement(input: &str) -> FunctionStatement { - match parser::powdr::FunctionStatementParser::new() + match powdr_parser::powdr::FunctionStatementParser::new() .parse::(input) .unwrap() { - ast::parsed::asm::FunctionStatement::Assignment(start, lhs, reg, rhs) => { + powdr_ast::parsed::asm::FunctionStatement::Assignment(start, lhs, reg, rhs) => { AssignmentStatement { start, lhs_with_reg: { @@ -97,7 +97,7 @@ pub mod utils { } .into() } - ast::parsed::asm::FunctionStatement::Instruction(start, instruction, inputs) => { + powdr_ast::parsed::asm::FunctionStatement::Instruction(start, instruction, inputs) => { InstructionStatement { start, instruction, @@ -105,7 +105,7 @@ pub mod utils { } .into() } - ast::parsed::asm::FunctionStatement::Label(start, name) => { + powdr_ast::parsed::asm::FunctionStatement::Label(start, name) => { LabelStatement { start, name }.into() } _ => unimplemented!(), @@ -113,7 +113,7 @@ pub mod utils { } pub fn parse_pil_statement(input: &str) -> PilStatement { - parser::powdr::PilStatementParser::new() + powdr_parser::powdr::PilStatementParser::new() .parse(input) .unwrap() } @@ -121,7 +121,7 @@ pub mod utils { pub fn parse_register_declaration( input: &str, ) -> RegisterDeclarationStatement { - match parser::powdr::RegisterDeclarationParser::new() + match powdr_parser::powdr::RegisterDeclarationParser::new() .parse::(input) .unwrap() { diff --git a/asm_to_pil/src/romgen.rs b/asm-to-pil/src/romgen.rs similarity index 96% rename from asm_to_pil/src/romgen.rs rename to asm-to-pil/src/romgen.rs index f6150409f7..a76b15183c 100644 --- a/asm_to_pil/src/romgen.rs +++ b/asm-to-pil/src/romgen.rs @@ -2,17 +2,17 @@ use std::{collections::HashMap, iter::repeat}; -use ast::asm_analysis::{ +use powdr_ast::asm_analysis::{ Batch, CallableSymbol, FunctionStatement, FunctionSymbol, Incompatible, IncompatibleSet, Machine, OperationSymbol, Rom, }; -use ast::parsed::visitor::ExpressionVisitable; -use ast::parsed::NamespacedPolynomialReference; -use ast::parsed::{ +use powdr_ast::parsed::visitor::ExpressionVisitable; +use powdr_ast::parsed::NamespacedPolynomialReference; +use powdr_ast::parsed::{ asm::{OperationId, Param, ParamList, Params}, Expression, }; -use number::FieldElement; +use powdr_number::FieldElement; use crate::{ common::{input_at, output_at, RESET_NAME}, @@ -245,19 +245,19 @@ pub fn generate_machine_rom( mod tests { use std::collections::BTreeMap; - use ast::{ + use powdr_ast::{ asm_analysis::Item, parsed::asm::{parse_absolute_path, AbsoluteSymbolPath}, }; - use number::Bn254Field; + use powdr_number::Bn254Field; use pretty_assertions::assert_eq; // generate the rom from source. Note that only type checking is applied before this. fn generate_rom_str( src: &str, ) -> BTreeMap, Option>)> { - let parsed = parser::parse_asm(None, src).unwrap(); - let checked = analysis::machine_check::check(parsed).unwrap(); + let parsed = powdr_parser::parse_asm(None, src).unwrap(); + let checked = powdr_analysis::machine_check::check(parsed).unwrap(); checked .items .into_iter() diff --git a/asm_to_pil/src/vm_to_constrained.rs b/asm-to-pil/src/vm_to_constrained.rs similarity index 99% rename from asm_to_pil/src/vm_to_constrained.rs rename to asm-to-pil/src/vm_to_constrained.rs index 74b4aba07f..2fe12bdd5a 100644 --- a/asm_to_pil/src/vm_to_constrained.rs +++ b/asm-to-pil/src/vm_to_constrained.rs @@ -5,7 +5,7 @@ use std::{ convert::Infallible, }; -use ast::{ +use powdr_ast::{ asm_analysis::{ AssignmentStatement, Batch, DebugDirective, FunctionStatement, InstructionDefinitionStatement, InstructionStatement, LabelStatement, @@ -22,7 +22,7 @@ use ast::{ }, }; -use number::FieldElement; +use powdr_number::FieldElement; use crate::common::{instruction_flag, return_instruction, RETURN_NAME}; @@ -902,7 +902,7 @@ impl ASMPILConverter { .filter_map(|(n, r)| r.ty.is_read_only().then_some(n)) } - fn return_instruction(&self) -> ast::asm_analysis::Instruction { + fn return_instruction(&self) -> powdr_ast::asm_analysis::Instruction { return_instruction(self.output_count, self.pc_name.as_ref().unwrap()) } diff --git a/asm_utils/Cargo.toml b/asm-utils/Cargo.toml similarity index 76% rename from asm_utils/Cargo.toml rename to asm-utils/Cargo.toml index 10ff37ccc7..2c7d05d2df 100644 --- a/asm_utils/Cargo.toml +++ b/asm-utils/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "asm_utils" +name = "powdr-asm-utils" version = "0.1.0" edition = "2021" diff --git a/asm_utils/src/ast.rs b/asm-utils/src/ast.rs similarity index 100% rename from asm_utils/src/ast.rs rename to asm-utils/src/ast.rs diff --git a/asm_utils/src/data_parser.rs b/asm-utils/src/data_parser.rs similarity index 100% rename from asm_utils/src/data_parser.rs rename to asm-utils/src/data_parser.rs diff --git a/asm_utils/src/data_storage.rs b/asm-utils/src/data_storage.rs similarity index 100% rename from asm_utils/src/data_storage.rs rename to asm-utils/src/data_storage.rs diff --git a/asm_utils/src/lib.rs b/asm-utils/src/lib.rs similarity index 100% rename from asm_utils/src/lib.rs rename to asm-utils/src/lib.rs diff --git a/asm_utils/src/parser.rs b/asm-utils/src/parser.rs similarity index 100% rename from asm_utils/src/parser.rs rename to asm-utils/src/parser.rs diff --git a/asm_utils/src/reachability.rs b/asm-utils/src/reachability.rs similarity index 100% rename from asm_utils/src/reachability.rs rename to asm-utils/src/reachability.rs diff --git a/asm_utils/src/utils.rs b/asm-utils/src/utils.rs similarity index 100% rename from asm_utils/src/utils.rs rename to asm-utils/src/utils.rs diff --git a/asm_to_pil/Cargo.toml b/asm_to_pil/Cargo.toml deleted file mode 100644 index 9570559566..0000000000 --- a/asm_to_pil/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "asm_to_pil" -version = "0.1.0" -edition = "2021" - -[dependencies] -log = "0.4.17" -number = { path = "../number" } -num-bigint = "0.4.3" -ast = { path = "../ast" } -pretty_assertions = "1.4.0" -parser = { path = "../parser" } - -[dev-dependencies] -analysis = { path = "../analysis" } diff --git a/ast/Cargo.toml b/ast/Cargo.toml index 439ac50ecb..2fef2481d2 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -1,12 +1,13 @@ [package] -name = "ast" +name = "powdr-ast" version = "0.1.0" edition = "2021" [dependencies] +powdr-number = { path = "../number" } + itertools = "0.11.0" num-bigint = "0.4.3" -number = { path = "../number" } diff = "0.1" log = "0.4.18" derive_more = "0.99.17" diff --git a/ast/src/analyzed/mod.rs b/ast/src/analyzed/mod.rs index 9d2727ccec..e9c6533891 100644 --- a/ast/src/analyzed/mod.rs +++ b/ast/src/analyzed/mod.rs @@ -6,7 +6,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::fmt::Display; use std::ops::{self, ControlFlow}; -use number::{DegreeType, FieldElement}; +use powdr_number::{DegreeType, FieldElement}; use crate::parsed::utils::expr_any; use crate::parsed::visitor::ExpressionVisitable; diff --git a/ast/src/asm_analysis/display.rs b/ast/src/asm_analysis/display.rs index dac6a5f7ab..b00bebebf9 100644 --- a/ast/src/asm_analysis/display.rs +++ b/ast/src/asm_analysis/display.rs @@ -287,7 +287,7 @@ impl Display for IncompatibleSet { mod test { use super::*; use crate::parsed::asm::parse_absolute_path; - use number::GoldilocksField; + use powdr_number::GoldilocksField; use pretty_assertions::assert_eq; #[test] diff --git a/ast/src/asm_analysis/mod.rs b/ast/src/asm_analysis/mod.rs index 4c2edbb09d..57ca2fb8dd 100644 --- a/ast/src/asm_analysis/mod.rs +++ b/ast/src/asm_analysis/mod.rs @@ -11,7 +11,7 @@ use std::{ use itertools::Either; use num_bigint::BigUint; -use number::FieldElement; +use powdr_number::FieldElement; use crate::parsed::{ asm::{ diff --git a/ast/src/lib.rs b/ast/src/lib.rs index 48c3b116ee..d245668ae1 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -2,8 +2,8 @@ use itertools::Itertools; use log::log_enabled; -use number::FieldElement; use parsed::{BinaryOperator, UnaryOperator}; +use powdr_number::FieldElement; use std::fmt::{Display, Result, Write}; /// Analyzed PIL diff --git a/ast/src/parsed/asm.rs b/ast/src/parsed/asm.rs index 2e24d4b77a..8128609b4f 100644 --- a/ast/src/parsed/asm.rs +++ b/ast/src/parsed/asm.rs @@ -4,7 +4,7 @@ use std::{ }; use itertools::Itertools; -use number::AbstractNumberType; +use powdr_number::AbstractNumberType; use derive_more::From; diff --git a/ast/src/parsed/build.rs b/ast/src/parsed/build.rs index 7b1a6e51a3..16d064eb7f 100644 --- a/ast/src/parsed/build.rs +++ b/ast/src/parsed/build.rs @@ -1,4 +1,4 @@ -use number::FieldElement; +use powdr_number::FieldElement; use crate::parsed::Expression; diff --git a/ast/src/parsed/display.rs b/ast/src/parsed/display.rs index 4e52619280..98057a3204 100644 --- a/ast/src/parsed/display.rs +++ b/ast/src/parsed/display.rs @@ -551,7 +551,7 @@ impl Display for UnaryOperator { #[cfg(test)] mod tests { - use number::GoldilocksField; + use powdr_number::GoldilocksField; use super::*; diff --git a/ast/src/parsed/mod.rs b/ast/src/parsed/mod.rs index 7a095a6e74..d5c5ffe5cb 100644 --- a/ast/src/parsed/mod.rs +++ b/ast/src/parsed/mod.rs @@ -10,7 +10,7 @@ use std::{ ops, }; -use number::{DegreeType, FieldElement}; +use powdr_number::{DegreeType, FieldElement}; use self::asm::{Part, SymbolPath}; diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 13842de843..74422c6243 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,16 +1,17 @@ [package] -name = "backend" +name = "powdr-backend" version = "0.1.0" edition = "2021" [features] -halo2 = ["dep:halo2"] +halo2 = ["dep:powdr-halo2"] [dependencies] -halo2 = { path = "../halo2", optional = true } -pil_analyzer = { path = "../pil_analyzer" } -number = { path = "../number" } -ast = { path = "../ast" } +powdr-ast = { path = "../ast" } +powdr-halo2 = { path = "../halo2", optional = true } +powdr-number = { path = "../number" } +powdr-pil-analyzer = { path = "../pil-analyzer" } + strum = { version = "0.24.1", features = ["derive"] } log = "0.4.17" serde_json = "1.0" diff --git a/backend/src/halo2_impl.rs b/backend/src/halo2_impl.rs index 0d5664a896..a11267eb3f 100644 --- a/backend/src/halo2_impl.rs +++ b/backend/src/halo2_impl.rs @@ -1,9 +1,9 @@ use std::io::{self}; use crate::{BackendImpl, BackendImplWithSetup, Proof}; -use ast::analyzed::Analyzed; -use halo2::Halo2Prover; -use number::{DegreeType, FieldElement}; +use powdr_ast::analyzed::Analyzed; +use powdr_halo2::Halo2Prover; +use powdr_number::{DegreeType, FieldElement}; impl BackendImpl for Halo2Prover { fn new(degree: DegreeType) -> Self { @@ -27,7 +27,7 @@ impl BackendImpl for Halo2Prover { } } -impl BackendImplWithSetup for halo2::Halo2Prover { +impl BackendImplWithSetup for powdr_halo2::Halo2Prover { fn new_from_setup(mut input: &mut dyn io::Read) -> Result { Halo2Prover::assert_field_is_compatible::(); Halo2Prover::new_from_setup(&mut input) @@ -55,7 +55,7 @@ impl BackendImpl for Halo2Mock { unimplemented!("Halo2Mock backend does not support aggregation"); } - halo2::mock_prove(pil, fixed, witness); + powdr_halo2::mock_prove(pil, fixed, witness); (None, None) } diff --git a/backend/src/lib.rs b/backend/src/lib.rs index 9b7402cff6..4beabcd6bb 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -4,8 +4,8 @@ mod halo2_impl; mod pilstark; -use ast::analyzed::Analyzed; -use number::{DegreeType, FieldElement}; +use powdr_ast::analyzed::Analyzed; +use powdr_number::{DegreeType, FieldElement}; use std::{io, marker::PhantomData}; use strum::{Display, EnumString, EnumVariantNames}; @@ -26,7 +26,8 @@ pub enum BackendType { impl BackendType { pub fn factory(&self) -> &'static dyn BackendFactory { #[cfg(feature = "halo2")] - const HALO2_FACTORY: WithSetupFactory = WithSetupFactory(PhantomData); + const HALO2_FACTORY: WithSetupFactory = + WithSetupFactory(PhantomData); #[cfg(feature = "halo2")] const HALO2_MOCK_FACTORY: WithoutSetupFactory = WithoutSetupFactory(PhantomData); diff --git a/backend/src/pilstark/estark.rs b/backend/src/pilstark/estark.rs index 6fbe569d5d..cfe5d498b1 100644 --- a/backend/src/pilstark/estark.rs +++ b/backend/src/pilstark/estark.rs @@ -2,8 +2,8 @@ use std::iter::{once, repeat}; use std::time::Instant; use crate::{pilstark, BackendImpl}; -use ast::analyzed::Analyzed; -use number::{BigInt, DegreeType, FieldElement, GoldilocksField}; +use powdr_ast::analyzed::Analyzed; +use powdr_number::{BigInt, DegreeType, FieldElement, GoldilocksField}; use starky::{ merklehash::MerkleTreeGL, diff --git a/backend/src/pilstark/json_exporter/expression_counter.rs b/backend/src/pilstark/json_exporter/expression_counter.rs index 86784af074..8d3e536872 100644 --- a/backend/src/pilstark/json_exporter/expression_counter.rs +++ b/backend/src/pilstark/json_exporter/expression_counter.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use ast::{ +use powdr_ast::{ analyzed::{ Analyzed, Identity, PolynomialType, PublicDeclaration, StatementIdentifier, Symbol, SymbolKind, diff --git a/backend/src/pilstark/json_exporter/mod.rs b/backend/src/pilstark/json_exporter/mod.rs index af38287c49..3151568e02 100644 --- a/backend/src/pilstark/json_exporter/mod.rs +++ b/backend/src/pilstark/json_exporter/mod.rs @@ -1,8 +1,8 @@ -use number::FieldElement; +use powdr_number::FieldElement; use std::cmp; use std::collections::HashMap; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicBinaryOperator, AlgebraicExpression as Expression, AlgebraicUnaryOperator, Analyzed, IdentityKind, PolyID, PolynomialType, StatementIdentifier, SymbolKind, }; @@ -362,13 +362,13 @@ impl<'a, T: FieldElement> Exporter<'a, T> { #[cfg(test)] mod test { - use pil_analyzer::analyze; + use powdr_pil_analyzer::analyze; use pretty_assertions::assert_eq; use serde_json::Value as JsonValue; use std::{fs, process::Command}; use test_log::test; - use number::GoldilocksField; + use powdr_number::GoldilocksField; use super::*; diff --git a/backend/src/pilstark/mod.rs b/backend/src/pilstark/mod.rs index 30af04c917..acf7de3b9b 100644 --- a/backend/src/pilstark/mod.rs +++ b/backend/src/pilstark/mod.rs @@ -2,8 +2,8 @@ pub mod estark; mod json_exporter; use crate::{BackendImpl, Proof}; -use ast::analyzed::Analyzed; -use number::{DegreeType, FieldElement}; +use powdr_ast::analyzed::Analyzed; +use powdr_number::{DegreeType, FieldElement}; pub struct PilStarkCli; diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 0000000000..f7dca4b837 --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "powdr-cli" +version = "0.1.0" +edition = "2021" + +[features] +default = [] # halo2 is disabled by default +halo2 = ["dep:powdr-halo2", "powdr-backend/halo2", "powdr-pipeline/halo2"] + +[dependencies] +powdr-backend = { path = "../backend" } +powdr-halo2 = { path = "../halo2", optional = true } +powdr-number = { path = "../number" } +powdr-parser = { path = "../parser" } +powdr-pilopt = { path = "../pilopt" } +powdr-pipeline = { path = "../pipeline" } +powdr-riscv = { path = "../riscv" } +powdr-riscv-executor = { path = "../riscv-executor" } + +clap = { version = "^4.3", features = ["derive"] } +env_logger = "0.10.0" +log = "0.4.17" +strum = { version = "0.24.1", features = ["derive"] } +clap-markdown = "0.1.3" + +[dev-dependencies] +tempfile = "3.6" + +[[bin]] +name = "powdr" +path = "src/main.rs" diff --git a/powdr_cli/src/main.rs b/cli/src/main.rs similarity index 95% rename from powdr_cli/src/main.rs rename to cli/src/main.rs index e834c2a30c..b6ceccb501 100644 --- a/powdr_cli/src/main.rs +++ b/cli/src/main.rs @@ -2,16 +2,16 @@ mod util; -use backend::{Backend, BackendType}; use clap::{CommandFactory, Parser, Subcommand}; use env_logger::fmt::Color; use env_logger::{Builder, Target}; use log::LevelFilter; -use number::{read_polys_csv_file, CsvRenderMode}; -use number::{Bn254Field, FieldElement, GoldilocksField}; -use pipeline::{Pipeline, Stage}; -use riscv::continuations::{rust_continuations, rust_continuations_dry_run}; -use riscv::{compile_riscv_asm, compile_rust}; +use powdr_backend::{Backend, BackendType}; +use powdr_number::{read_polys_csv_file, CsvRenderMode}; +use powdr_number::{Bn254Field, FieldElement, GoldilocksField}; +use powdr_pipeline::{Pipeline, Stage}; +use powdr_riscv::continuations::{rust_continuations, rust_continuations_dry_run}; +use powdr_riscv::{compile_riscv_asm, compile_rust}; use std::io::{self, BufReader, BufWriter}; use std::path::PathBuf; use std::{borrow::Cow, fs, io::Write, path::Path}; @@ -398,9 +398,10 @@ fn run_command(command: Commands) { } => { let coprocessors = match coprocessors { Some(list) => { - riscv::CoProcessors::try_from(list.split(',').collect::>()).unwrap() + powdr_riscv::CoProcessors::try_from(list.split(',').collect::>()) + .unwrap() } - None => riscv::CoProcessors::base(), + None => powdr_riscv::CoProcessors::base(), }; call_with_field!(run_rust::( &file, @@ -437,9 +438,10 @@ fn run_command(command: Commands) { let coprocessors = match coprocessors { Some(list) => { - riscv::CoProcessors::try_from(list.split(',').collect::>()).unwrap() + powdr_riscv::CoProcessors::try_from(list.split(',').collect::>()) + .unwrap() } - None => riscv::CoProcessors::base(), + None => powdr_riscv::CoProcessors::base(), }; call_with_field!(run_riscv_asm::( &name, @@ -457,7 +459,7 @@ fn run_command(command: Commands) { } Commands::Reformat { file } => { let contents = fs::read_to_string(&file).unwrap(); - match parser::parse::(Some(&file), &contents) { + match powdr_parser::parse::(Some(&file), &contents) { Ok(ast) => println!("{ast}"), Err(err) => err.output_to_stderr(), }; @@ -547,7 +549,7 @@ fn run_rust( prove_with: Option, export_csv: bool, csv_mode: CsvRenderModeCLI, - coprocessors: riscv::CoProcessors, + coprocessors: powdr_riscv::CoProcessors, just_execute: bool, continuations: bool, ) -> Result<(), Vec> { @@ -596,7 +598,7 @@ fn run_riscv_asm( prove_with: Option, export_csv: bool, csv_mode: CsvRenderModeCLI, - coprocessors: riscv::CoProcessors, + coprocessors: powdr_riscv::CoProcessors, just_execute: bool, continuations: bool, ) -> Result<(), Vec> { @@ -698,11 +700,11 @@ fn run( let mut pipeline = pipeline_factory().with_prover_inputs(inputs); pipeline.advance_to(Stage::AsmString).unwrap(); let program = pipeline.artifact().unwrap().to_asm_string().unwrap(); - riscv_executor::execute::( + powdr_riscv_executor::execute::( program, pipeline.data_callback().unwrap(), &[], - riscv_executor::ExecMode::Fast, + powdr_riscv_executor::ExecMode::Fast, ); } (false, true) => { @@ -750,7 +752,7 @@ fn optimize_and_output(file: &str) { #[cfg(test)] mod test { use crate::{run_command, Commands, CsvRenderModeCLI, FieldArgument}; - use backend::BackendType; + use powdr_backend::BackendType; #[test] fn test_simple_sum() { diff --git a/powdr_cli/src/util.rs b/cli/src/util.rs similarity index 100% rename from powdr_cli/src/util.rs rename to cli/src/util.rs diff --git a/executor/Cargo.toml b/executor/Cargo.toml index 38b001869c..0c6a5e91b4 100644 --- a/executor/Cargo.toml +++ b/executor/Cargo.toml @@ -1,15 +1,16 @@ [package] -name = "executor" +name = "powdr-executor" version = "0.1.0" edition = "2021" [dependencies] +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } +powdr-parser-util = { path = "../parser-util" } +powdr-pil-analyzer = { path = "../pil-analyzer" } + itertools = "^0.10" log = { version = "0.4.17" } -ast = { path = "../ast" } -number = { path = "../number" } -parser_util = { path = "../parser_util" } -pil_analyzer = { path = "../pil_analyzer" } rayon = "1.7.0" bit-vec = "0.6.3" num-traits = "0.2.15" diff --git a/executor/src/constant_evaluator/mod.rs b/executor/src/constant_evaluator/mod.rs index 68bc9eba82..a67bbdd8fc 100644 --- a/executor/src/constant_evaluator/mod.rs +++ b/executor/src/constant_evaluator/mod.rs @@ -1,9 +1,9 @@ use std::{collections::HashMap, fmt::Display, rc::Rc}; -use ast::analyzed::{Analyzed, FunctionValueDefinition}; use itertools::Itertools; -use number::{DegreeType, FieldElement}; -use pil_analyzer::evaluator::{self, Custom, EvalError, SymbolLookup, Value}; +use powdr_ast::analyzed::{Analyzed, FunctionValueDefinition}; +use powdr_number::{DegreeType, FieldElement}; +use powdr_pil_analyzer::evaluator::{self, Custom, EvalError, SymbolLookup, Value}; use rayon::prelude::{IntoParallelIterator, ParallelIterator}; /// Generates the constant polynomial values for all constant polynomials @@ -156,8 +156,8 @@ impl<'a> Display for FixedColumnRef<'a> { #[cfg(test)] mod test { - use number::GoldilocksField; - use pil_analyzer::analyze_string; + use powdr_number::GoldilocksField; + use powdr_pil_analyzer::analyze_string; use pretty_assertions::assert_eq; use test_log::test; diff --git a/executor/src/witgen/affine_expression.rs b/executor/src/witgen/affine_expression.rs index 4a963baf16..81e8743728 100644 --- a/executor/src/witgen/affine_expression.rs +++ b/executor/src/witgen/affine_expression.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use itertools::{Either, Itertools}; use num_traits::Zero; -use number::{BigInt, FieldElement}; +use powdr_number::{BigInt, FieldElement}; use super::global_constraints::RangeConstraintSet; use super::range_constraints::RangeConstraint; @@ -552,7 +552,7 @@ mod test { use super::*; use crate::witgen::{range_constraints::RangeConstraint, EvalError}; - use number::{FieldElement, GoldilocksField}; + use powdr_number::{FieldElement, GoldilocksField}; use pretty_assertions::assert_eq; use test_log::test; diff --git a/executor/src/witgen/block_processor.rs b/executor/src/witgen/block_processor.rs index 4ba88aa9c9..107f202b4e 100644 --- a/executor/src/witgen/block_processor.rs +++ b/executor/src/witgen/block_processor.rs @@ -1,7 +1,9 @@ use std::collections::HashSet; -use ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference, Identity, PolyID}; -use number::FieldElement; +use powdr_ast::analyzed::{ + AlgebraicExpression as Expression, AlgebraicReference, Identity, PolyID, +}; +use powdr_number::FieldElement; use super::{ data_structures::finalizable_data::FinalizableData, @@ -96,9 +98,9 @@ impl<'a, 'b, 'c, T: FieldElement, Q: QueryCallback> BlockProcessor<'a, 'b, 'c mod tests { use std::collections::BTreeMap; - use ast::analyzed::{PolyID, PolynomialType}; - use number::{FieldElement, GoldilocksField}; - use pil_analyzer::analyze_string; + use powdr_ast::analyzed::{PolyID, PolynomialType}; + use powdr_number::{FieldElement, GoldilocksField}; + use powdr_pil_analyzer::analyze_string; use crate::{ constant_evaluator::generate, diff --git a/executor/src/witgen/data_structures/column_map.rs b/executor/src/witgen/data_structures/column_map.rs index 58567ae612..3ec5e0abc2 100644 --- a/executor/src/witgen/data_structures/column_map.rs +++ b/executor/src/witgen/data_structures/column_map.rs @@ -3,7 +3,7 @@ use std::{ ops::{Index, IndexMut}, }; -use ast::analyzed::{PolyID, PolynomialType}; +use powdr_ast::analyzed::{PolyID, PolynomialType}; // Marker types for each PolynomialType #[derive(Clone, Copy)] diff --git a/executor/src/witgen/data_structures/finalizable_data.rs b/executor/src/witgen/data_structures/finalizable_data.rs index a63340315e..88a02bf49f 100644 --- a/executor/src/witgen/data_structures/finalizable_data.rs +++ b/executor/src/witgen/data_structures/finalizable_data.rs @@ -3,9 +3,9 @@ use std::{ ops::{Index, IndexMut}, }; -use ast::analyzed::PolyID; use bit_vec::BitVec; -use number::FieldElement; +use powdr_ast::analyzed::PolyID; +use powdr_number::FieldElement; use crate::witgen::rows::Row; diff --git a/executor/src/witgen/eval_result.rs b/executor/src/witgen/eval_result.rs index 586b107efa..1b70fbb373 100644 --- a/executor/src/witgen/eval_result.rs +++ b/executor/src/witgen/eval_result.rs @@ -1,7 +1,7 @@ use std::fmt; -use ast::analyzed::AlgebraicReference; -use number::FieldElement; +use powdr_ast::analyzed::AlgebraicReference; +use powdr_number::FieldElement; use super::range_constraints::RangeConstraint; diff --git a/executor/src/witgen/expression_evaluator.rs b/executor/src/witgen/expression_evaluator.rs index b1e5f19262..6e4d5063bf 100644 --- a/executor/src/witgen/expression_evaluator.rs +++ b/executor/src/witgen/expression_evaluator.rs @@ -1,11 +1,11 @@ use std::marker::PhantomData; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicBinaryOperator, AlgebraicExpression as Expression, AlgebraicReference, AlgebraicUnaryOperator, }; -use number::FieldElement; +use powdr_number::FieldElement; use super::{affine_expression::AffineResult, IncompleteCause}; diff --git a/executor/src/witgen/fixed_evaluator.rs b/executor/src/witgen/fixed_evaluator.rs index eccbc6d08c..3aaef8c74d 100644 --- a/executor/src/witgen/fixed_evaluator.rs +++ b/executor/src/witgen/fixed_evaluator.rs @@ -1,8 +1,8 @@ use super::affine_expression::AffineResult; use super::expression_evaluator::SymbolicVariables; use super::FixedData; -use ast::analyzed::AlgebraicReference; -use number::FieldElement; +use powdr_ast::analyzed::AlgebraicReference; +use powdr_number::FieldElement; /// Evaluates only fixed columns on a specific row. pub struct FixedEvaluator<'a, T> { diff --git a/executor/src/witgen/generator.rs b/executor/src/witgen/generator.rs index 7a52536781..4077d51aaa 100644 --- a/executor/src/witgen/generator.rs +++ b/executor/src/witgen/generator.rs @@ -1,8 +1,8 @@ -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind, PolyID, }; -use ast::parsed::SelectedExpressions; -use number::{DegreeType, FieldElement}; +use powdr_ast::parsed::SelectedExpressions; +use powdr_number::{DegreeType, FieldElement}; use std::collections::{HashMap, HashSet}; use crate::witgen::data_structures::finalizable_data::FinalizableData; diff --git a/executor/src/witgen/global_constraints.rs b/executor/src/witgen/global_constraints.rs index 541cf1c161..e231226809 100644 --- a/executor/src/witgen/global_constraints.rs +++ b/executor/src/witgen/global_constraints.rs @@ -2,12 +2,12 @@ use std::collections::{BTreeMap, BTreeSet}; use num_traits::Zero; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicBinaryOperator, AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind, PolyID, PolynomialType, }; -use number::FieldElement; +use powdr_number::FieldElement; use crate::witgen::data_structures::column_map::{FixedColumnMap, WitnessColumnMap}; @@ -297,8 +297,8 @@ fn smallest_period_candidate(fixed: &[T]) -> Option { mod test { use std::collections::BTreeMap; - use ast::analyzed::{PolyID, PolynomialType}; - use number::GoldilocksField; + use powdr_ast::analyzed::{PolyID, PolynomialType}; + use powdr_number::GoldilocksField; use pretty_assertions::assert_eq; use test_log::test; @@ -372,7 +372,7 @@ namespace Global(2**20); { D } in { BYTE }; { D } in { SHIFTED }; "; - let analyzed = pil_analyzer::analyze_string::(pil_source); + let analyzed = powdr_pil_analyzer::analyze_string::(pil_source); let constants = crate::constant_evaluator::generate(&analyzed); let fixed_polys = (0..constants.len()) .map(|i| constant_poly_id(i as u64)) @@ -435,7 +435,7 @@ namespace Global(1024); let X; { X * 4 } in { bytes }; "; - let analyzed = pil_analyzer::analyze_string::(pil_source); + let analyzed = powdr_pil_analyzer::analyze_string::(pil_source); let known_constraints = vec![(constant_poly_id(0), RangeConstraint::from_max_bit(7))] .into_iter() .collect(); diff --git a/executor/src/witgen/identity_processor.rs b/executor/src/witgen/identity_processor.rs index 9b5deae64c..d63f4b8a2c 100644 --- a/executor/src/witgen/identity_processor.rs +++ b/executor/src/witgen/identity_processor.rs @@ -1,12 +1,12 @@ use std::{collections::HashMap, sync::Mutex}; -use ast::{ +use itertools::{Either, Itertools}; +use lazy_static::lazy_static; +use powdr_ast::{ analyzed::{AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind}, parsed::SelectedExpressions, }; -use itertools::{Either, Itertools}; -use lazy_static::lazy_static; -use number::FieldElement; +use powdr_number::FieldElement; use crate::witgen::machines::Machine; diff --git a/executor/src/witgen/machines/block_machine.rs b/executor/src/witgen/machines/block_machine.rs index a750a14e63..e048b68fb0 100644 --- a/executor/src/witgen/machines/block_machine.rs +++ b/executor/src/witgen/machines/block_machine.rs @@ -13,12 +13,12 @@ use crate::witgen::sequence_iterator::{ProcessingSequenceCache, ProcessingSequen use crate::witgen::util::try_to_simple_poly; use crate::witgen::{machines::Machine, EvalError, EvalValue, IncompleteCause}; use crate::witgen::{MutableState, QueryCallback}; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind, PolyID, PolynomialType, }; -use ast::parsed::SelectedExpressions; -use number::{DegreeType, FieldElement}; +use powdr_ast::parsed::SelectedExpressions; +use powdr_number::{DegreeType, FieldElement}; enum ProcessResult<'a, T: FieldElement> { Success(FinalizableData<'a, T>, EvalValue<&'a AlgebraicReference, T>), diff --git a/executor/src/witgen/machines/double_sorted_witness_machine.rs b/executor/src/witgen/machines/double_sorted_witness_machine.rs index c43866975e..c0ccbc2266 100644 --- a/executor/src/witgen/machines/double_sorted_witness_machine.rs +++ b/executor/src/witgen/machines/double_sorted_witness_machine.rs @@ -1,9 +1,9 @@ use std::collections::{BTreeMap, HashMap, HashSet}; use std::iter::once; -use ast::parsed::SelectedExpressions; use itertools::Itertools; use num_traits::Zero; +use powdr_ast::parsed::SelectedExpressions; use super::{FixedLookup, Machine}; use crate::witgen::affine_expression::AffineExpression; @@ -11,9 +11,9 @@ use crate::witgen::global_constraints::GlobalConstraints; use crate::witgen::util::is_simple_poly_of_name; use crate::witgen::{EvalResult, FixedData, MutableState, QueryCallback}; use crate::witgen::{EvalValue, IncompleteCause}; -use number::{DegreeType, FieldElement}; +use powdr_number::{DegreeType, FieldElement}; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind, PolyID, }; diff --git a/executor/src/witgen/machines/fixed_lookup_machine.rs b/executor/src/witgen/machines/fixed_lookup_machine.rs index fa6e79bfaa..dc43e14b40 100644 --- a/executor/src/witgen/machines/fixed_lookup_machine.rs +++ b/executor/src/witgen/machines/fixed_lookup_machine.rs @@ -2,12 +2,12 @@ use std::collections::{BTreeMap, HashMap, HashSet}; use std::mem; use std::num::NonZeroUsize; -use ast::analyzed::{ +use itertools::Itertools; +use powdr_ast::analyzed::{ AlgebraicExpression as Expression, AlgebraicReference, IdentityKind, PolyID, PolynomialType, }; -use ast::parsed::SelectedExpressions; -use itertools::Itertools; -use number::FieldElement; +use powdr_ast::parsed::SelectedExpressions; +use powdr_number::FieldElement; use crate::witgen::affine_expression::AffineExpression; use crate::witgen::global_constraints::{GlobalConstraints, RangeConstraintSet}; diff --git a/executor/src/witgen/machines/machine_extractor.rs b/executor/src/witgen/machines/machine_extractor.rs index ddb52034a2..d5aaed5554 100644 --- a/executor/src/witgen/machines/machine_extractor.rs +++ b/executor/src/witgen/machines/machine_extractor.rs @@ -9,11 +9,11 @@ use super::KnownMachine; use crate::witgen::generator::Generator; use crate::witgen::global_constraints::GlobalConstraints; use crate::witgen::machines::write_once_memory::WriteOnceMemory; -use ast::analyzed::{AlgebraicExpression as Expression, Identity, IdentityKind, PolyID}; -use ast::parsed::visitor::ExpressionVisitable; -use ast::parsed::SelectedExpressions; use itertools::Itertools; -use number::FieldElement; +use powdr_ast::analyzed::{AlgebraicExpression as Expression, Identity, IdentityKind, PolyID}; +use powdr_ast::parsed::visitor::ExpressionVisitable; +use powdr_ast::parsed::SelectedExpressions; +use powdr_number::FieldElement; pub struct ExtractionOutput<'a, T: FieldElement> { pub fixed_lookup: FixedLookup, diff --git a/executor/src/witgen/machines/mod.rs b/executor/src/witgen/machines/mod.rs index 678b352c01..35555c4223 100644 --- a/executor/src/witgen/machines/mod.rs +++ b/executor/src/witgen/machines/mod.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; -use ast::analyzed::AlgebraicExpression as Expression; -use ast::analyzed::AlgebraicReference; -use ast::parsed::SelectedExpressions; -use number::FieldElement; +use powdr_ast::analyzed::AlgebraicExpression as Expression; +use powdr_ast::analyzed::AlgebraicReference; +use powdr_ast::parsed::SelectedExpressions; +use powdr_number::FieldElement; use self::block_machine::BlockMachine; use self::double_sorted_witness_machine::DoubleSortedWitnesses; @@ -12,7 +12,7 @@ use self::profiling::record_end; use self::profiling::record_start; use self::sorted_witness_machine::SortedWitnesses; use self::write_once_memory::WriteOnceMemory; -use ast::analyzed::IdentityKind; +use powdr_ast::analyzed::IdentityKind; use super::affine_expression::AffineExpression; use super::generator::Generator; diff --git a/executor/src/witgen/machines/sorted_witness_machine.rs b/executor/src/witgen/machines/sorted_witness_machine.rs index 2fc1176fa4..5bb41fc05d 100644 --- a/executor/src/witgen/machines/sorted_witness_machine.rs +++ b/executor/src/witgen/machines/sorted_witness_machine.rs @@ -1,7 +1,7 @@ use std::collections::{BTreeMap, HashMap, HashSet}; -use ast::parsed::SelectedExpressions; use itertools::Itertools; +use powdr_ast::parsed::SelectedExpressions; use super::super::affine_expression::AffineExpression; use super::{EvalResult, FixedData}; @@ -11,10 +11,10 @@ use crate::witgen::{ symbolic_evaluator::SymbolicEvaluator, }; use crate::witgen::{EvalValue, IncompleteCause, MutableState, QueryCallback}; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind, PolyID, }; -use number::FieldElement; +use powdr_number::FieldElement; /// A machine that can support a lookup in a set of columns that are sorted /// by one specific column and values in that column have to be unique. diff --git a/executor/src/witgen/machines/write_once_memory.rs b/executor/src/witgen/machines/write_once_memory.rs index 3826be9c97..c5a4110036 100644 --- a/executor/src/witgen/machines/write_once_memory.rs +++ b/executor/src/witgen/machines/write_once_memory.rs @@ -1,13 +1,13 @@ use std::collections::{BTreeMap, HashMap}; -use ast::{ +use powdr_ast::{ analyzed::{ AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind, PolyID, PolynomialType, }, parsed::SelectedExpressions, }; -use number::{DegreeType, FieldElement}; +use powdr_number::{DegreeType, FieldElement}; use crate::witgen::{ affine_expression::AffineExpression, util::try_to_simple_poly, EvalError, EvalResult, diff --git a/executor/src/witgen/mod.rs b/executor/src/witgen/mod.rs index 7eddcd082e..f7b360aac9 100644 --- a/executor/src/witgen/mod.rs +++ b/executor/src/witgen/mod.rs @@ -1,10 +1,10 @@ use std::collections::{BTreeMap, HashMap}; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicReference, Analyzed, Expression, FunctionValueDefinition, PolyID, PolynomialType, SymbolKind, }; -use number::{DegreeType, FieldElement}; +use powdr_number::{DegreeType, FieldElement}; use self::data_structures::column_map::{FixedColumnMap, WitnessColumnMap}; pub use self::eval_result::{ diff --git a/executor/src/witgen/processor.rs b/executor/src/witgen/processor.rs index ce98343b41..dce0f8bd8b 100644 --- a/executor/src/witgen/processor.rs +++ b/executor/src/witgen/processor.rs @@ -1,11 +1,11 @@ use std::collections::{BTreeMap, HashSet}; -use ast::{ +use powdr_ast::{ analyzed::{AlgebraicExpression as Expression, AlgebraicReference, Identity, PolyID}, parsed::SelectedExpressions, }; -use number::{DegreeType, FieldElement}; -use parser_util::lines::indent; +use powdr_number::{DegreeType, FieldElement}; +use powdr_parser_util::lines::indent; use crate::witgen::{query_processor::QueryProcessor, util::try_to_simple_poly, Constraint}; diff --git a/executor/src/witgen/query_processor.rs b/executor/src/witgen/query_processor.rs index 5a574ae616..cad9ee57f0 100644 --- a/executor/src/witgen/query_processor.rs +++ b/executor/src/witgen/query_processor.rs @@ -1,9 +1,9 @@ use std::{fmt::Display, rc::Rc}; -use ast::analyzed::{AlgebraicReference, Expression, PolyID, PolynomialType}; use num_traits::ToPrimitive; -use number::FieldElement; -use pil_analyzer::evaluator::{self, Custom, EvalError, SymbolLookup, Value}; +use powdr_ast::analyzed::{AlgebraicReference, Expression, PolyID, PolynomialType}; +use powdr_number::FieldElement; +use powdr_pil_analyzer::evaluator::{self, Custom, EvalError, SymbolLookup, Value}; use super::{rows::RowPair, Constraint, EvalResult, EvalValue, FixedData, IncompleteCause}; diff --git a/executor/src/witgen/range_constraints.rs b/executor/src/witgen/range_constraints.rs index ce295f483b..8f164b1463 100644 --- a/executor/src/witgen/range_constraints.rs +++ b/executor/src/witgen/range_constraints.rs @@ -3,7 +3,7 @@ use std::{cmp, ops}; use num_traits::Zero; -use number::{log2_exact, BigInt, FieldElement}; +use powdr_number::{log2_exact, BigInt, FieldElement}; /// Constraint on the values of a variable X. /// It does not have to be an interval. @@ -245,7 +245,7 @@ impl Display for RangeConstraint { #[cfg(test)] mod test { - use number::GoldilocksField; + use powdr_number::GoldilocksField; use pretty_assertions::assert_eq; use test_log::test; diff --git a/executor/src/witgen/rows.rs b/executor/src/witgen/rows.rs index 9d6bd63b34..2bc72bb25a 100644 --- a/executor/src/witgen/rows.rs +++ b/executor/src/witgen/rows.rs @@ -1,8 +1,8 @@ use std::{collections::HashSet, fmt::Debug}; -use ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference, PolyID}; use itertools::Itertools; -use number::{DegreeType, FieldElement}; +use powdr_ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference, PolyID}; +use powdr_number::{DegreeType, FieldElement}; use crate::witgen::Constraint; diff --git a/executor/src/witgen/sequence_iterator.rs b/executor/src/witgen/sequence_iterator.rs index db6d9866c1..c5e545e522 100644 --- a/executor/src/witgen/sequence_iterator.rs +++ b/executor/src/witgen/sequence_iterator.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use number::FieldElement; +use powdr_number::FieldElement; use super::affine_expression::AffineExpression; diff --git a/executor/src/witgen/symbolic_evaluator.rs b/executor/src/witgen/symbolic_evaluator.rs index 2a0ba7fa23..42e7194110 100644 --- a/executor/src/witgen/symbolic_evaluator.rs +++ b/executor/src/witgen/symbolic_evaluator.rs @@ -1,8 +1,8 @@ use super::affine_expression::{AffineExpression, AffineResult}; use super::expression_evaluator::SymbolicVariables; -use ast::analyzed::AlgebraicReference; -use number::FieldElement; +use powdr_ast::analyzed::AlgebraicReference; +use powdr_number::FieldElement; /// A purely symbolic evaluator, uses AlgebraicReference as keys /// and neither resolves fixed columns nor witness columns. diff --git a/executor/src/witgen/symbolic_witness_evaluator.rs b/executor/src/witgen/symbolic_witness_evaluator.rs index c1bfeaa3c9..3c90a8d126 100644 --- a/executor/src/witgen/symbolic_witness_evaluator.rs +++ b/executor/src/witgen/symbolic_witness_evaluator.rs @@ -1,5 +1,5 @@ -use ast::analyzed::AlgebraicReference; -use number::{DegreeType, FieldElement}; +use powdr_ast::analyzed::AlgebraicReference; +use powdr_number::{DegreeType, FieldElement}; use super::{affine_expression::AffineResult, expression_evaluator::SymbolicVariables, FixedData}; diff --git a/executor/src/witgen/util.rs b/executor/src/witgen/util.rs index 98ae85db7d..17730da795 100644 --- a/executor/src/witgen/util.rs +++ b/executor/src/witgen/util.rs @@ -1,4 +1,4 @@ -use ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference}; +use powdr_ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference}; /// Checks if an expression is /// - a polynomial diff --git a/executor/src/witgen/vm_processor.rs b/executor/src/witgen/vm_processor.rs index cdb57ab80a..2b94a63fa6 100644 --- a/executor/src/witgen/vm_processor.rs +++ b/executor/src/witgen/vm_processor.rs @@ -1,10 +1,10 @@ -use ast::analyzed::{ - AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind, PolyID, -}; use indicatif::{ProgressBar, ProgressStyle}; use itertools::Itertools; -use number::{DegreeType, FieldElement}; -use parser_util::lines::indent; +use powdr_ast::analyzed::{ + AlgebraicExpression as Expression, AlgebraicReference, Identity, IdentityKind, PolyID, +}; +use powdr_number::{DegreeType, FieldElement}; +use powdr_parser_util::lines::indent; use std::cmp::max; use std::collections::HashSet; use std::time::Instant; diff --git a/halo2/Cargo.toml b/halo2/Cargo.toml index ad3e9a1bc6..e0c71b88b2 100644 --- a/halo2/Cargo.toml +++ b/halo2/Cargo.toml @@ -1,12 +1,13 @@ [package] -name = "halo2" +name = "powdr-halo2" version = "0.1.0" edition = "2021" [dependencies] -number = { path = "../number" } -pil_analyzer = { path = "../pil_analyzer" } -ast = { path = "../ast" } +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } +powdr-pil-analyzer = { path = "../pil-analyzer" } + polyexen = { git = "https://github.com/Dhole/polyexen", branch = "feature/shuffles" } halo2_proofs = "0.2" halo2_curves = { git = "https://github.com/privacy-scaling-explorations/halo2curves", tag = "0.3.2", package = "halo2curves" } @@ -19,12 +20,13 @@ log = "0.4.17" rand = "0.8.5" [dev-dependencies] -importer = { path = "../importer" } -analysis = { path = "../analysis" } -pipeline = { path = "../pipeline" } -executor = { path = "../executor" } -parser = { path = "../parser" } -airgen = { path = "../airgen" } +powdr-airgen = { path = "../airgen" } +powdr-analysis = { path = "../analysis" } +powdr-executor = { path = "../executor" } +powdr-importer = { path = "../importer" } +powdr-linker = { path = "../linker" } +powdr-parser = { path = "../parser" } +powdr-pipeline = { path = "../pipeline" } + test-log = "0.2.12" env_logger = "0.10.0" -linker = { path = "../linker" } diff --git a/halo2/src/circuit_builder.rs b/halo2/src/circuit_builder.rs index 75ac78c172..23c73011a5 100644 --- a/halo2/src/circuit_builder.rs +++ b/halo2/src/circuit_builder.rs @@ -1,4 +1,3 @@ -use ast::parsed::SelectedExpressions; use halo2_curves::bn256::Fr; use halo2_curves::ff::FromUniformBytes; use num_bigint::BigUint; @@ -8,12 +7,13 @@ use polyexen::plaf::{ ColumnFixed, ColumnPublic, ColumnWitness, Columns, CopyC, Info, Lookup, Plaf, Poly, Shuffle, Witness, }; +use powdr_ast::parsed::SelectedExpressions; -use ast::analyzed::{ +use num_traits::{One, ToPrimitive}; +use powdr_ast::analyzed::{ AlgebraicBinaryOperator, AlgebraicExpression as Expression, Analyzed, IdentityKind, }; -use num_traits::{One, ToPrimitive}; -use number::{BigInt, FieldElement}; +use powdr_number::{BigInt, FieldElement}; use super::circuit_data::CircuitData; diff --git a/halo2/src/circuit_data.rs b/halo2/src/circuit_data.rs index 6620ae574f..9250384f48 100644 --- a/halo2/src/circuit_data.rs +++ b/halo2/src/circuit_data.rs @@ -3,8 +3,8 @@ use std::collections::HashMap; use num_bigint::BigInt; -use number::{AbstractNumberType, FieldElement}; use polyexen::expr::{Column, ColumnKind}; +use powdr_number::{AbstractNumberType, FieldElement}; pub(crate) struct CircuitData<'a, T> { pub(crate) fixed: Vec<(String, Vec)>, diff --git a/halo2/src/mock_prover.rs b/halo2/src/mock_prover.rs index 899d31ed49..eeb262b199 100644 --- a/halo2/src/mock_prover.rs +++ b/halo2/src/mock_prover.rs @@ -1,9 +1,9 @@ -use ast::analyzed::Analyzed; use polyexen::plaf::PlafDisplayBaseTOML; +use powdr_ast::analyzed::Analyzed; use super::circuit_builder::analyzed_to_circuit; use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr}; -use number::{BigInt, FieldElement}; +use powdr_number::{BigInt, FieldElement}; // Can't depend on compiler::pipeline::GeneratedWitness because of circular dependencies... pub fn mock_prove( @@ -32,8 +32,8 @@ pub fn mock_prove( #[cfg(test)] mod test { - use number::Bn254Field; - use pipeline::{test_util::resolve_test_file, Pipeline}; + use powdr_number::Bn254Field; + use powdr_pipeline::{test_util::resolve_test_file, Pipeline}; use test_log::test; use super::*; diff --git a/halo2/src/prover.rs b/halo2/src/prover.rs index 3264c59d21..664cc401da 100644 --- a/halo2/src/prover.rs +++ b/halo2/src/prover.rs @@ -1,4 +1,3 @@ -use ast::analyzed::Analyzed; use halo2_proofs::{ dev::MockProver, halo2curves::bn256::{Fr, G1Affine}, @@ -14,8 +13,9 @@ use halo2_proofs::{ }, transcript::{EncodedChallenge, TranscriptReadBuffer, TranscriptWriterBuffer}, }; -use number::{BigInt, DegreeType, FieldElement}; use polyexen::plaf::PlafDisplayBaseTOML; +use powdr_ast::analyzed::Analyzed; +use powdr_number::{BigInt, DegreeType, FieldElement}; use snark_verifier::{ loader::native::NativeLoader, system::halo2::{compile, transcript::evm::EvmTranscript, Config}, diff --git a/importer/Cargo.toml b/importer/Cargo.toml index e43b011eea..46a0ec5a58 100644 --- a/importer/Cargo.toml +++ b/importer/Cargo.toml @@ -1,10 +1,11 @@ [package] -name = "importer" +name = "powdr-importer" version = "0.1.0" edition = "2021" [dependencies] -ast = { path = "../ast" } -number = { path = "../number" } -parser = { path = "../parser" } +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } +powdr-parser = { path = "../parser" } + pretty_assertions = "1.4.0" diff --git a/importer/src/lib.rs b/importer/src/lib.rs index 0d440a5c21..b9d1808cf4 100644 --- a/importer/src/lib.rs +++ b/importer/src/lib.rs @@ -6,11 +6,11 @@ mod powdr_std; use std::path::PathBuf; -use ast::parsed::asm::ASMProgram; pub use module_loader::load_module_files; -use number::FieldElement; -use parser::parse_asm; use path_canonicalizer::canonicalize_paths; +use powdr_ast::parsed::asm::ASMProgram; +use powdr_number::FieldElement; +use powdr_parser::parse_asm; use powdr_std::add_std; pub fn load_dependencies_and_resolve( diff --git a/importer/src/module_loader.rs b/importer/src/module_loader.rs index ef87fa235d..5d6166612d 100644 --- a/importer/src/module_loader.rs +++ b/importer/src/module_loader.rs @@ -1,10 +1,10 @@ use std::path::PathBuf; -use ast::parsed::{ +use powdr_ast::parsed::{ asm::{ASMProgram, Module}, folder::Folder, }; -use number::FieldElement; +use powdr_number::FieldElement; static ASM_EXTENSION: &str = "asm"; static FOLDER_MODULE_NAME: &str = "mod"; @@ -61,7 +61,7 @@ impl Folder for Loader { )), } .map(|(file, path)| { - parser::parse_module(None, &file) + powdr_parser::parse_module(None, &file) .map(|res| (res, path)) .unwrap_or_else(|err| { eprintln!( @@ -87,8 +87,8 @@ impl Folder for Loader { mod tests { use std::path::Path; - use number::Bn254Field; - use parser::parse_asm; + use powdr_number::Bn254Field; + use powdr_parser::parse_asm; use super::*; diff --git a/importer/src/path_canonicalizer.rs b/importer/src/path_canonicalizer.rs index 97b14d108b..f0be068446 100644 --- a/importer/src/path_canonicalizer.rs +++ b/importer/src/path_canonicalizer.rs @@ -1,12 +1,12 @@ /// Replace all relative paths in the program with absolute paths to the canonical symbol they point to, and remove all import statements in the program -use number::FieldElement; +use powdr_number::FieldElement; use std::{ collections::{BTreeMap, BTreeSet, HashSet}, convert::Infallible, }; -use ast::{ +use powdr_ast::{ parsed::Expression, parsed::{ asm::{ @@ -416,15 +416,15 @@ fn check_expression( check_expression(location, scrutinee, state, local_variables)?; arms.iter().try_for_each(|MatchArm { pattern, value }| { match pattern { - ast::parsed::MatchPattern::CatchAll => Ok(()), - ast::parsed::MatchPattern::Pattern(e) => { + powdr_ast::parsed::MatchPattern::CatchAll => Ok(()), + powdr_ast::parsed::MatchPattern::Pattern(e) => { check_expression(location, e, state, local_variables) } }?; check_expression(location, value, state, local_variables) }) } - Expression::IfExpression(ast::parsed::IfExpression { + Expression::IfExpression(powdr_ast::parsed::IfExpression { condition, body, else_body, @@ -452,7 +452,7 @@ mod tests { use std::path::PathBuf; use super::*; - use number::Bn254Field; + use powdr_number::Bn254Field; use pretty_assertions::assert_eq; fn expect(path: &str, expected: Result<(), &str>) { @@ -460,7 +460,7 @@ mod tests { .join(path) .with_extension("asm"); let input_str = std::fs::read_to_string(input_path).unwrap(); - let parsed = parser::parse_asm::(None, &input_str).unwrap(); + let parsed = powdr_parser::parse_asm::(None, &input_str).unwrap(); let res = canonicalize_paths(parsed).map(|res| res.to_string().replace('\t', " ")); let expected = expected diff --git a/importer/src/powdr_std.rs b/importer/src/powdr_std.rs index aae17325be..ca55cffae7 100644 --- a/importer/src/powdr_std.rs +++ b/importer/src/powdr_std.rs @@ -1,14 +1,14 @@ use std::{env, path::PathBuf}; -use ast::parsed::{ +use powdr_ast::parsed::{ asm::{ ASMModule, ASMProgram, Import, Module, ModuleStatement, Part, SymbolDefinition, SymbolPath, SymbolValue, }, folder::Folder, }; -use number::FieldElement; -use parser::parse_asm; +use powdr_number::FieldElement; +use powdr_parser::parse_asm; use crate::load_module_files; diff --git a/linker/Cargo.toml b/linker/Cargo.toml index afd2e0a18e..df6122f736 100644 --- a/linker/Cargo.toml +++ b/linker/Cargo.toml @@ -1,16 +1,17 @@ [package] -name = "linker" +name = "powdr-linker" version = "0.1.0" edition = "2021" [dependencies] -ast = { path = "../ast" } -number = { path = "../number" } -analysis = { path = "../analysis" } +powdr-analysis = { path = "../analysis" } +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } + pretty_assertions = "1.3.0" itertools = "^0.10" [dev-dependencies] -parser = { path = "../parser" } -airgen = { path = "../airgen" } -importer = { path = "../importer" } +powdr-airgen = { path = "../airgen" } +powdr-importer = { path = "../importer" } +powdr-parser = { path = "../parser" } diff --git a/linker/src/lib.rs b/linker/src/lib.rs index ec9b23d13b..287046aa3a 100644 --- a/linker/src/lib.rs +++ b/linker/src/lib.rs @@ -1,7 +1,8 @@ #![deny(clippy::print_stdout)] -use analysis::utils::parse_pil_statement; -use ast::{ +use itertools::Itertools; +use powdr_analysis::utils::parse_pil_statement; +use powdr_ast::{ object::{Location, PILGraph}, parsed::{ asm::AbsoluteSymbolPath, @@ -10,8 +11,7 @@ use ast::{ Expression, PILFile, PilStatement, SelectedExpressions, }, }; -use itertools::Itertools; -use number::FieldElement; +use powdr_number::FieldElement; const DEFAULT_DEGREE: u64 = 1024; const MAIN_OPERATION_NAME: &str = "main"; @@ -190,14 +190,14 @@ pub fn link(graph: PILGraph) -> Result, Vec(input: &str) -> PILGraph { let parsed = parse_asm(None, input).unwrap(); - let resolved = importer::load_dependencies_and_resolve(None, parsed).unwrap(); - airgen::compile(convert_asm_to_pil(resolved).unwrap()) + let resolved = powdr_importer::load_dependencies_and_resolve(None, parsed).unwrap(); + powdr_airgen::compile(convert_asm_to_pil(resolved).unwrap()) } #[test] fn degree() { // a graph with two objects of degree `main_degree` and `foo_degree` let test_graph = |main_degree, foo_degree| PILGraph { - main: ast::object::Machine { + main: powdr_ast::object::Machine { location: Location::main(), operation_id: Some("operation_id".into()), latch: Some("latch".into()), @@ -233,7 +233,7 @@ mod test { // a test over a pil file `f` checking if all namespaces have degree `n` let all_namespaces_have_degree = |f: PILFile, n| { f.0.iter().all(|s| match s { - ast::parsed::PilStatement::Namespace(_, _, e) => { + powdr_ast::parsed::PilStatement::Namespace(_, _, e) => { *e == Expression::Number(Bn254Field::from(n)) } _ => true, diff --git a/number/Cargo.toml b/number/Cargo.toml index b2c6b7dbeb..e18dc60db6 100644 --- a/number/Cargo.toml +++ b/number/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "number" +name = "powdr-number" version = "0.1.0" edition = "2021" diff --git a/parser_util/Cargo.toml b/parser-util/Cargo.toml similarity index 88% rename from parser_util/Cargo.toml rename to parser-util/Cargo.toml index 98ff0ebc88..4890287749 100644 --- a/parser_util/Cargo.toml +++ b/parser-util/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "parser_util" +name = "powdr-parser-util" version = "0.1.0" edition = "2021" diff --git a/parser_util/src/lib.rs b/parser-util/src/lib.rs similarity index 100% rename from parser_util/src/lib.rs rename to parser-util/src/lib.rs diff --git a/parser_util/src/lines.rs b/parser-util/src/lines.rs similarity index 100% rename from parser_util/src/lines.rs rename to parser-util/src/lines.rs diff --git a/parser/Cargo.toml b/parser/Cargo.toml index 6e6f40bbad..6ca41ece73 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -1,16 +1,17 @@ [package] -name = "parser" +name = "powdr-parser" version = "0.1.0" edition = "2021" build = "build.rs" [dependencies] +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } +powdr-parser-util = { path = "../parser-util" } + lalrpop-util = {version = "^0.19", features = ["lexer"]} num-bigint = "0.4.3" num-traits = "0.2.15" -number = { path = "../number" } -ast = { path = "../ast" } -parser_util = { path = "../parser_util" } # This is only here to work around https://github.com/lalrpop/lalrpop/issues/750 # It should be removed once that workaround is no longer needed. regex-syntax = { version = "0.6", default_features = false, features = ["unicode"] } diff --git a/parser/src/lib.rs b/parser/src/lib.rs index cdd98323ea..6ebd615d74 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -2,11 +2,11 @@ #![deny(clippy::print_stdout)] -use ast::parsed::asm::ASMProgram; use lalrpop_util::*; +use powdr_ast::parsed::asm::ASMProgram; -use number::FieldElement; -use parser_util::{handle_parse_error, ParseError}; +use powdr_number::FieldElement; +use powdr_parser_util::{handle_parse_error, ParseError}; lalrpop_mod!( #[allow(clippy::all)] @@ -17,7 +17,7 @@ lalrpop_mod!( pub fn parse<'a, T: FieldElement>( file_name: Option<&str>, input: &'a str, -) -> Result, ParseError<'a>> { +) -> Result, ParseError<'a>> { powdr::PILFileParser::new() .parse(input) .map_err(|err| handle_parse_error(err, file_name, input)) @@ -26,14 +26,14 @@ pub fn parse<'a, T: FieldElement>( pub fn parse_asm<'a, T: FieldElement>( file_name: Option<&str>, input: &'a str, -) -> Result, ParseError<'a>> { +) -> Result, ParseError<'a>> { parse_module(file_name, input).map(|main| ASMProgram { main }) } pub fn parse_module<'a, T: FieldElement>( file_name: Option<&str>, input: &'a str, -) -> Result, ParseError<'a>> { +) -> Result, ParseError<'a>> { powdr::ASMModuleParser::new() .parse(input) .map_err(|err| handle_parse_error(err, file_name, input)) @@ -42,11 +42,11 @@ pub fn parse_module<'a, T: FieldElement>( #[cfg(test)] mod test { use super::*; - use ast::parsed::{ + use powdr_ast::parsed::{ build::direct_reference, PILFile, PilStatement, PolynomialName, SelectedExpressions, }; - use number::GoldilocksField; - use parser_util::UnwrapErrToStderr; + use powdr_number::GoldilocksField; + use powdr_parser_util::UnwrapErrToStderr; use std::fs; use test_log::test; @@ -156,9 +156,9 @@ mod test { } mod display { - use number::GoldilocksField; + use powdr_number::GoldilocksField; - use parser_util::UnwrapErrToStderr; + use powdr_parser_util::UnwrapErrToStderr; use pretty_assertions::assert_eq; use crate::parse; diff --git a/parser/src/powdr.lalrpop b/parser/src/powdr.lalrpop index ac8fbdc303..1bbb9de296 100644 --- a/parser/src/powdr.lalrpop +++ b/parser/src/powdr.lalrpop @@ -1,6 +1,6 @@ use std::str::FromStr; -use ast::parsed::{*, asm::*}; -use number::{AbstractNumberType, FieldElement}; +use powdr_ast::parsed::{*, asm::*}; +use powdr_number::{AbstractNumberType, FieldElement}; use num_traits::Num; grammar where T: FieldElement; diff --git a/pil-analyzer/Cargo.toml b/pil-analyzer/Cargo.toml new file mode 100644 index 0000000000..24e30cc2f6 --- /dev/null +++ b/pil-analyzer/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "powdr-pil-analyzer" +version = "0.1.0" +edition = "2021" + +[dependencies] +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } +powdr-parser = { path = "../parser" } +powdr-parser-util = { path = "../parser-util" } + +itertools = "^0.10" + +[dev-dependencies] +test-log = "0.2.12" +env_logger = "0.10.0" +pretty_assertions = "1.3.0" diff --git a/pil_analyzer/src/condenser.rs b/pil-analyzer/src/condenser.rs similarity index 99% rename from pil_analyzer/src/condenser.rs rename to pil-analyzer/src/condenser.rs index 04f130aa66..9f6c4a1bdd 100644 --- a/pil_analyzer/src/condenser.rs +++ b/pil-analyzer/src/condenser.rs @@ -3,7 +3,8 @@ use std::{collections::HashMap, fmt::Display, rc::Rc}; -use ast::{ +use itertools::Itertools; +use powdr_ast::{ analyzed::{ AlgebraicExpression, AlgebraicReference, Analyzed, Expression, FunctionValueDefinition, Identity, IdentityKind, PolynomialReference, PolynomialType, PublicDeclaration, Reference, @@ -11,8 +12,7 @@ use ast::{ }, parsed::{visitor::ExpressionVisitable, BinaryOperator, SelectedExpressions, UnaryOperator}, }; -use itertools::Itertools; -use number::{DegreeType, FieldElement}; +use powdr_number::{DegreeType, FieldElement}; use crate::evaluator::{ self, evaluate, evaluate_function_call, Custom, EvalError, SymbolLookup, Value, @@ -303,7 +303,7 @@ impl<'a, T: FieldElement> SymbolLookup<'a, T, Condensate> for &'a Condenser>, - op: ast::parsed::BinaryOperator, + op: powdr_ast::parsed::BinaryOperator, right: Value<'a, T, Condensate>, ) -> Result>, EvalError> { let left: Condensate = left.try_into()?; diff --git a/pil_analyzer/src/evaluator.rs b/pil-analyzer/src/evaluator.rs similarity index 99% rename from pil_analyzer/src/evaluator.rs rename to pil-analyzer/src/evaluator.rs index c926d8390b..09d0749533 100644 --- a/pil_analyzer/src/evaluator.rs +++ b/pil-analyzer/src/evaluator.rs @@ -4,7 +4,8 @@ use std::{ rc::Rc, }; -use ast::{ +use itertools::Itertools; +use powdr_ast::{ analyzed::{Expression, FunctionValueDefinition, Reference, Symbol}, evaluate_binary_operation, evaluate_unary_operation, parsed::{ @@ -12,8 +13,7 @@ use ast::{ UnaryOperator, }, }; -use itertools::Itertools; -use number::FieldElement; +use powdr_number::FieldElement; /// Evaluates an expression given a hash map of definitions. pub fn evaluate_expression<'a, T: FieldElement>( @@ -403,7 +403,7 @@ mod internal { #[cfg(test)] mod test { - use number::GoldilocksField; + use powdr_number::GoldilocksField; use pretty_assertions::assert_eq; use crate::analyze_string; diff --git a/pil_analyzer/src/expression_processor.rs b/pil-analyzer/src/expression_processor.rs similarity index 97% rename from pil_analyzer/src/expression_processor.rs rename to pil-analyzer/src/expression_processor.rs index b5a3b522a1..af23d85308 100644 --- a/pil_analyzer/src/expression_processor.rs +++ b/pil-analyzer/src/expression_processor.rs @@ -1,13 +1,13 @@ use std::{collections::HashMap, marker::PhantomData}; -use ast::{ +use powdr_ast::{ analyzed::{Expression, PolynomialReference, Reference, RepeatedArray}, parsed::{ self, asm::SymbolPath, ArrayExpression, ArrayLiteral, IfExpression, LambdaExpression, MatchArm, MatchPattern, NamespacedPolynomialReference, SelectedExpressions, }, }; -use number::DegreeType; +use powdr_number::DegreeType; use crate::AnalysisDriver; @@ -41,7 +41,7 @@ impl> ExpressionProcessor { pub fn process_array_expression( &mut self, - array_expression: ::ast::parsed::ArrayExpression, + array_expression: ::powdr_ast::parsed::ArrayExpression, size: DegreeType, ) -> Vec> { match array_expression { @@ -150,7 +150,7 @@ impl> ExpressionProcessor { pub fn process_function( &mut self, params: &[String], - expression: ::ast::parsed::Expression, + expression: ::powdr_ast::parsed::Expression, ) -> Expression { let previous_local_vars = std::mem::take(&mut self.local_variables); diff --git a/pil_analyzer/src/lib.rs b/pil-analyzer/src/lib.rs similarity index 95% rename from pil_analyzer/src/lib.rs rename to pil-analyzer/src/lib.rs index 1dbed3f666..a5c4653731 100644 --- a/pil_analyzer/src/lib.rs +++ b/pil-analyzer/src/lib.rs @@ -8,11 +8,11 @@ pub mod statement_processor; use std::{collections::HashMap, path::Path}; -use ast::{ +use powdr_ast::{ analyzed::{Analyzed, FunctionValueDefinition, SourceRef, Symbol}, parsed::asm::SymbolPath, }; -use number::FieldElement; +use powdr_number::FieldElement; pub fn analyze(path: &Path) -> Analyzed { pil_analyzer::process_pil_file(path) diff --git a/pil_analyzer/src/pil_analyzer.rs b/pil-analyzer/src/pil_analyzer.rs similarity index 96% rename from pil_analyzer/src/pil_analyzer.rs rename to pil-analyzer/src/pil_analyzer.rs index 8e037108cd..3eb5041a40 100644 --- a/pil_analyzer/src/pil_analyzer.rs +++ b/pil-analyzer/src/pil_analyzer.rs @@ -4,11 +4,11 @@ use std::fs; use std::iter::once; use std::path::{Path, PathBuf}; -use ast::parsed::asm::{AbsoluteSymbolPath, SymbolPath}; -use ast::parsed::{PILFile, PilStatement}; -use number::{DegreeType, FieldElement}; +use powdr_ast::parsed::asm::{AbsoluteSymbolPath, SymbolPath}; +use powdr_ast::parsed::{PILFile, PilStatement}; +use powdr_number::{DegreeType, FieldElement}; -use ast::analyzed::{ +use powdr_ast::analyzed::{ Analyzed, Expression, FunctionValueDefinition, Identity, PublicDeclaration, SourceRef, StatementIdentifier, Symbol, }; @@ -62,12 +62,13 @@ struct ParsedFile { impl ParsedFile { #[allow(clippy::print_stderr)] pub fn parse(path: &Path, contents: &str) -> Self { - let line_starts = parser_util::lines::compute_line_starts(contents); - let ast = parser::parse(Some(path.to_str().unwrap()), contents).unwrap_or_else(|err| { - eprintln!("Error parsing .pil file:"); - err.output_to_stderr(); - panic!(); - }); + let line_starts = powdr_parser_util::lines::compute_line_starts(contents); + let ast = + powdr_parser::parse(Some(path.to_str().unwrap()), contents).unwrap_or_else(|err| { + eprintln!("Error parsing .pil file:"); + err.output_to_stderr(); + panic!(); + }); ParsedFile { line_starts, ast } } } @@ -211,7 +212,7 @@ impl PILAnalyzer { } } - fn handle_namespace(&mut self, name: SymbolPath, degree: ::ast::parsed::Expression) { + fn handle_namespace(&mut self, name: SymbolPath, degree: ::powdr_ast::parsed::Expression) { // TODO: the polynomial degree should be handled without going through a field element. This requires having types in Expression let degree = ExpressionProcessor::new(self.driver()).process_expression(degree); let namespace_degree = evaluator::evaluate_expression(°ree, &self.definitions) @@ -267,7 +268,7 @@ impl<'a, T: FieldElement> AnalysisDriver for Driver<'a, T> { fn source_position_to_source_ref(&self, pos: usize) -> SourceRef { let file = self.0.current_file.file_name().unwrap().to_str().unwrap(); SourceRef { - line: parser_util::lines::offset_to_line(pos, &self.0.current_line_starts), + line: powdr_parser_util::lines::offset_to_line(pos, &self.0.current_line_starts), file: file.to_string(), } } @@ -279,7 +280,7 @@ impl<'a, T: FieldElement> AnalysisDriver for Driver<'a, T> { #[cfg(test)] mod test { - use number::GoldilocksField; + use powdr_number::GoldilocksField; use test_log::test; use pretty_assertions::assert_eq; diff --git a/pil_analyzer/src/statement_processor.rs b/pil-analyzer/src/statement_processor.rs similarity index 95% rename from pil_analyzer/src/statement_processor.rs rename to pil-analyzer/src/statement_processor.rs index 0ca7d3d8b1..42b1d59ac7 100644 --- a/pil_analyzer/src/statement_processor.rs +++ b/pil-analyzer/src/statement_processor.rs @@ -1,10 +1,12 @@ use std::collections::{BTreeMap, HashMap}; use std::marker::PhantomData; -use ast::parsed::{self, FunctionDefinition, PilStatement, PolynomialName, SelectedExpressions}; -use number::{DegreeType, FieldElement}; +use powdr_ast::parsed::{ + self, FunctionDefinition, PilStatement, PolynomialName, SelectedExpressions, +}; +use powdr_number::{DegreeType, FieldElement}; -use ast::analyzed::{ +use powdr_ast::analyzed::{ Expression, FunctionValueDefinition, Identity, IdentityKind, PolynomialType, PublicDeclaration, Symbol, SymbolKind, }; @@ -181,7 +183,7 @@ where &mut self, start: usize, name: String, - value: Option<::ast::parsed::Expression>, + value: Option<::powdr_ast::parsed::Expression>, ) -> Vec> { // Determine whether this is a fixed column, a constant or something else // depending on the structure of the value and if we can evaluate @@ -295,7 +297,7 @@ where &mut self, start: usize, name: String, - array_size: Option<::ast::parsed::Expression>, + array_size: Option<::powdr_ast::parsed::Expression>, symbol_kind: SymbolKind, value: Option>, ) -> Vec> { @@ -370,7 +372,10 @@ where })] } - fn evaluate_expression(&self, expr: ::ast::parsed::Expression) -> Result { + fn evaluate_expression( + &self, + expr: ::powdr_ast::parsed::Expression, + ) -> Result { evaluator::evaluate_expression( &ExpressionProcessor::new(self.driver).process_expression(expr), self.driver.definitions(), @@ -382,13 +387,13 @@ where ExpressionProcessor::new(self.driver) } - fn process_expression(&self, expr: ::ast::parsed::Expression) -> Expression { + fn process_expression(&self, expr: ::powdr_ast::parsed::Expression) -> Expression { self.expression_processor().process_expression(expr) } fn process_selected_expressions( &self, - expr: ::ast::parsed::SelectedExpressions<::ast::parsed::Expression>, + expr: ::powdr_ast::parsed::SelectedExpressions<::powdr_ast::parsed::Expression>, ) -> SelectedExpressions> { self.expression_processor() .process_selected_expressions(expr) diff --git a/pil_analyzer/Cargo.toml b/pil_analyzer/Cargo.toml deleted file mode 100644 index fb83d95d0f..0000000000 --- a/pil_analyzer/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "pil_analyzer" -version = "0.1.0" -edition = "2021" - -[dependencies] -number = { path = "../number" } -parser_util = { path = "../parser_util" } -parser = { path = "../parser" } -ast = { path = "../ast" } -itertools = "^0.10" - -[dev-dependencies] -test-log = "0.2.12" -env_logger = "0.10.0" -pretty_assertions = "1.3.0" diff --git a/pilopt/Cargo.toml b/pilopt/Cargo.toml index 60d6acc6a0..791416cc73 100644 --- a/pilopt/Cargo.toml +++ b/pilopt/Cargo.toml @@ -1,11 +1,12 @@ [package] -name = "pilopt" +name = "powdr-pilopt" version = "0.1.0" edition = "2021" [dependencies] -number = { path = "../number" } -ast = { path = "../ast" } -pil_analyzer = { path = "../pil_analyzer" } +powdr-ast = { path = "../ast" } +powdr-number = { path = "../number" } +powdr-pil-analyzer = { path = "../pil-analyzer" } + log = "0.4.17" pretty_assertions = "1.3.0" diff --git a/pilopt/src/lib.rs b/pilopt/src/lib.rs index 090e4f9b4e..4fe43d101a 100644 --- a/pilopt/src/lib.rs +++ b/pilopt/src/lib.rs @@ -3,16 +3,16 @@ use std::collections::{BTreeMap, HashSet}; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicBinaryOperator, AlgebraicExpression, AlgebraicUnaryOperator, Reference, }; -use ast::analyzed::{ +use powdr_ast::analyzed::{ AlgebraicReference, Analyzed, Expression, FunctionValueDefinition, IdentityKind, PolyID, PolynomialReference, }; -use ast::parsed::visitor::ExpressionVisitable; +use powdr_ast::parsed::visitor::ExpressionVisitable; -use number::FieldElement; +use powdr_number::FieldElement; pub fn optimize(mut pil_file: Analyzed) -> Analyzed { let col_count_pre = (pil_file.commitment_count(), pil_file.constant_count()); @@ -339,8 +339,8 @@ fn remove_trivial_identities(pil_file: &mut Analyzed) { #[cfg(test)] mod test { - use number::GoldilocksField; - use pil_analyzer::pil_analyzer::process_pil_file_contents; + use powdr_number::GoldilocksField; + use powdr_pil_analyzer::pil_analyzer::process_pil_file_contents; use crate::optimize; diff --git a/pipeline/Cargo.toml b/pipeline/Cargo.toml index 6f42ad86ff..590a4d28aa 100644 --- a/pipeline/Cargo.toml +++ b/pipeline/Cargo.toml @@ -1,38 +1,40 @@ [package] -name = "pipeline" +name = "powdr-pipeline" version = "0.1.0" edition = "2021" [features] -halo2 = ["dep:halo2", "backend/halo2"] +halo2 = ["dep:powdr-halo2", "powdr-backend/halo2"] [dependencies] -backend = { path = "../backend" } +powdr-airgen = { path = "../airgen" } +powdr-analysis = { path = "../analysis" } +powdr-asm-to-pil = { path = "../asm-to-pil" } +powdr-asm-utils = { path = "../asm-utils" } +powdr-ast = { path = "../ast" } +powdr-backend = { path = "../backend" } +powdr-executor = { path = "../executor" } +powdr-halo2 = { path = "../halo2", optional = true } +powdr-importer = { path = "../importer" } +powdr-linker = { path = "../linker" } +powdr-number = { path = "../number" } +powdr-parser = { path = "../parser" } +powdr-parser-util = { path = "../parser-util" } +powdr-pilopt = { path = "../pilopt" } +powdr-pil-analyzer = { path = "../pil-analyzer" } + itertools = "^0.10" log = "0.4.17" mktemp = "0.5.0" -number = { path = "../number" } -parser_util = { path = "../parser_util" } -parser = { path = "../parser" } -executor = { path = "../executor" } -pilopt = { path = "../pilopt" } -asm_to_pil = { path = "../asm_to_pil" } -pil_analyzer = { path = "../pil_analyzer" } -halo2 = { path = "../halo2", optional = true } -ast = { path = "../ast" } -analysis = { path = "../analysis" } -linker = { path = "../linker" } -airgen = { path = "../airgen" } -importer = { path = "../importer" } serde = { version = "1.0", default-features = false, features = ["alloc", "derive", "rc"] } serde_cbor = "0.11.2" [dev-dependencies] +powdr-riscv = { path = "../riscv" } + test-log = "0.2.12" env_logger = "0.10.0" criterion = { version = "0.4", features = ["html_reports"] } -riscv = { path = "../riscv" } -asm_utils = { path = "../asm_utils" } [build-dependencies] walkdir = "2.4.0" diff --git a/pipeline/benches/executor_benchmark.rs b/pipeline/benches/executor_benchmark.rs index f3d3a317b4..25175f5dc6 100644 --- a/pipeline/benches/executor_benchmark.rs +++ b/pipeline/benches/executor_benchmark.rs @@ -1,14 +1,14 @@ -use ::pipeline::inputs_to_query_callback; -use ::pipeline::Pipeline; -use ast::analyzed::Analyzed; +use ::powdr_pipeline::inputs_to_query_callback; +use ::powdr_pipeline::Pipeline; use criterion::{criterion_group, criterion_main, Criterion}; +use powdr_ast::analyzed::Analyzed; use mktemp::Temp; -use number::{FieldElement, GoldilocksField}; -use riscv::continuations::bootloader::default_input; -use riscv::{compile_rust_crate_to_riscv_asm, compile_rust_to_riscv_asm, compiler}; +use powdr_number::{FieldElement, GoldilocksField}; +use powdr_riscv::continuations::bootloader::default_input; +use powdr_riscv::{compile_rust_crate_to_riscv_asm, compile_rust_to_riscv_asm, compiler}; -use riscv::CoProcessors; +use powdr_riscv::CoProcessors; type T = GoldilocksField; @@ -18,7 +18,7 @@ fn run_witgen( external_witness_values: Vec<(String, Vec)>, ) { let query_callback = inputs_to_query_callback(vec![]); - executor::witgen::WitnessGenerator::new(analyzed, constants, query_callback) + powdr_executor::witgen::WitnessGenerator::new(analyzed, constants, query_callback) .with_external_witness_values(external_witness_values) .generate(); } diff --git a/pipeline/src/lib.rs b/pipeline/src/lib.rs index f39f8d46cb..8f64faa435 100644 --- a/pipeline/src/lib.rs +++ b/pipeline/src/lib.rs @@ -12,11 +12,11 @@ pub mod verify; pub use pipeline::Pipeline; pub use pipeline::Stage; -pub use backend::{BackendType, Proof}; -use executor::witgen::QueryCallback; use itertools::Itertools; +pub use powdr_backend::{BackendType, Proof}; +use powdr_executor::witgen::QueryCallback; -use number::FieldElement; +use powdr_number::FieldElement; pub fn parse_query(query: &str) -> Result, String> { // We are expecting a tuple diff --git a/pipeline/src/pipeline.rs b/pipeline/src/pipeline.rs index 365eeabf20..6affd8f740 100644 --- a/pipeline/src/pipeline.rs +++ b/pipeline/src/pipeline.rs @@ -8,21 +8,21 @@ use std::{ time::Instant, }; -use ast::{ +use log::Level; +use mktemp::Temp; +use powdr_ast::{ analyzed::Analyzed, asm_analysis::AnalysisASMFile, object::PILGraph, parsed::{asm::ASMProgram, PILFile}, DiffMonitor, }; -use backend::{BackendType, Proof}; -use executor::{ +use powdr_backend::{BackendType, Proof}; +use powdr_executor::{ constant_evaluator, witgen::{chain_callbacks, QueryCallback}, }; -use log::Level; -use mktemp::Temp; -use number::{write_polys_csv_file, write_polys_file, CsvRenderMode, FieldElement}; +use powdr_number::{write_polys_csv_file, write_polys_file, CsvRenderMode, FieldElement}; use crate::{ inputs_to_query_callback, serde_data_to_query_callback, @@ -239,7 +239,7 @@ where /// ```rust /// use pipeline::{Pipeline, Stage, verify, BackendType, test_util::resolve_test_file}; /// use std::path::PathBuf; -/// use number::GoldilocksField; +/// use powdr_number::GoldilocksField; /// /// let mut pipeline = Pipeline::::default() /// .from_file(resolve_test_file("pil/fibonacci.pil")) @@ -438,7 +438,7 @@ impl Pipeline { })?, ), Artifact::AsmString(path, asm_string) => { - let parsed_asm = parser::parse_asm(None, &asm_string).unwrap_or_else(|err| { + let parsed_asm = powdr_parser::parse_asm(None, &asm_string).unwrap_or_else(|err| { match path.as_ref() { Some(path) => eprintln!("Error parsing .asm file: {}", path.display()), None => eprintln!("Error parsing .asm file:"), @@ -451,24 +451,24 @@ impl Pipeline { } Artifact::ParsedAsmFile(path, parsed) => { self.log("Loading dependencies and resolving references"); - let resolved = - importer::load_dependencies_and_resolve(path, parsed).map_err(|e| vec![e])?; + let resolved = powdr_importer::load_dependencies_and_resolve(path, parsed) + .map_err(|e| vec![e])?; self.diff_monitor.push(&resolved); Artifact::ResolvedModuleTree(resolved) } Artifact::ResolvedModuleTree(resolved) => { self.log("Run analysis"); - let analyzed_asm = analysis::analyze(resolved, &mut self.diff_monitor)?; + let analyzed_asm = powdr_analysis::analyze(resolved, &mut self.diff_monitor)?; self.log("Analysis done"); log::trace!("{analyzed_asm}"); Artifact::AnalyzedAsm(analyzed_asm) } Artifact::AnalyzedAsm(analyzed_asm) => Artifact::ConstrainedMachineCollection( - analysis::convert_vms_to_constrained(analyzed_asm, &mut self.diff_monitor), + powdr_analysis::convert_vms_to_constrained(analyzed_asm, &mut self.diff_monitor), ), Artifact::ConstrainedMachineCollection(analyzed_asm) => { self.log("Run airgen"); - let graph = airgen::compile(analyzed_asm); + let graph = powdr_airgen::compile(analyzed_asm); self.diff_monitor.push(&graph); self.log("Airgen done"); log::trace!("{graph}"); @@ -476,7 +476,7 @@ impl Pipeline { } Artifact::LinkedMachineGraph(graph) => { self.log("Run linker"); - let linked = linker::link(graph)?; + let linked = powdr_linker::link(graph)?; self.diff_monitor.push(&linked); log::trace!("{linked}"); self.maybe_write_pil(&linked, "")?; @@ -488,19 +488,19 @@ impl Pipeline { self.log("Materialize linked file"); let linked = format!("{linked}"); self.log("Analyzing pil..."); - Artifact::AnalyzedPil(pil_analyzer::analyze_string(&linked)) + Artifact::AnalyzedPil(powdr_pil_analyzer::analyze_string(&linked)) } Artifact::PilFilePath(pil_file) => { self.log("Analyzing pil..."); - Artifact::AnalyzedPil(pil_analyzer::analyze(&pil_file)) + Artifact::AnalyzedPil(powdr_pil_analyzer::analyze(&pil_file)) } Artifact::PilString(pil_string) => { self.log("Analyzing pil..."); - Artifact::AnalyzedPil(pil_analyzer::analyze_string(&pil_string)) + Artifact::AnalyzedPil(powdr_pil_analyzer::analyze_string(&pil_string)) } Artifact::AnalyzedPil(analyzed_pil) => { self.log("Optimizing pil..."); - let optimized = pilopt::optimize(analyzed_pil); + let optimized = powdr_pilopt::optimize(analyzed_pil); self.maybe_write_pil(&optimized, "_opt")?; Artifact::OptimzedPil(optimized) } @@ -525,15 +525,17 @@ impl Pipeline { let start = Instant::now(); let external_witness_values = std::mem::take(&mut self.arguments.external_witness_values); - let query_callback = self - .arguments - .query_callback - .take() - .unwrap_or_else(|| Box::new(executor::witgen::unused_query_callback())); - let witness = - executor::witgen::WitnessGenerator::new(&pil, &fixed_cols, query_callback) - .with_external_witness_values(external_witness_values) - .generate(); + let query_callback = + self.arguments.query_callback.take().unwrap_or_else(|| { + Box::new(powdr_executor::witgen::unused_query_callback()) + }); + let witness = powdr_executor::witgen::WitnessGenerator::new( + &pil, + &fixed_cols, + query_callback, + ) + .with_external_witness_values(external_witness_values) + .generate(); self.log(&format!("Took {}", start.elapsed().as_secs_f32())); witness diff --git a/pipeline/src/test_util.rs b/pipeline/src/test_util.rs index f31386be93..215eaaf16f 100644 --- a/pipeline/src/test_util.rs +++ b/pipeline/src/test_util.rs @@ -1,6 +1,6 @@ -use backend::BackendType; -use number::FieldElement; -use number::{Bn254Field, GoldilocksField}; +use powdr_backend::BackendType; +use powdr_number::FieldElement; +use powdr_number::{Bn254Field, GoldilocksField}; use std::path::PathBuf; use crate::pipeline::{Pipeline, Stage}; @@ -60,7 +60,7 @@ pub fn gen_estark_proof(file_name: &str, inputs: Vec) { .with_tmp_output() .from_file(PathBuf::from(file_name)) .with_prover_inputs(inputs) - .with_backend(backend::BackendType::EStark) + .with_backend(powdr_backend::BackendType::EStark) .proof() .unwrap(); } @@ -72,7 +72,7 @@ pub fn gen_halo2_proof(file_name: &str, inputs: Vec) { .with_tmp_output() .from_file(PathBuf::from(file_name)) .with_prover_inputs(inputs) - .with_backend(backend::BackendType::Halo2) + .with_backend(powdr_backend::BackendType::Halo2) .proof() .unwrap(); } diff --git a/pipeline/src/util.rs b/pipeline/src/util.rs index 31ec7f8b2b..fdccfb81f4 100644 --- a/pipeline/src/util.rs +++ b/pipeline/src/util.rs @@ -1,5 +1,5 @@ -use ast::analyzed::{Analyzed, FunctionValueDefinition, Symbol}; -use number::{read_polys_file, DegreeType, FieldElement}; +use powdr_ast::analyzed::{Analyzed, FunctionValueDefinition, Symbol}; +use powdr_number::{read_polys_file, DegreeType, FieldElement}; use std::{fs::File, io::BufReader, path::Path}; pub trait PolySet { diff --git a/pipeline/tests/asm.rs b/pipeline/tests/asm.rs index 04e1459551..cfdf8b8015 100644 --- a/pipeline/tests/asm.rs +++ b/pipeline/tests/asm.rs @@ -1,5 +1,5 @@ -use number::{FieldElement, GoldilocksField}; -use pipeline::test_util::{gen_estark_proof, gen_halo2_proof, verify_test_file}; +use powdr_number::{FieldElement, GoldilocksField}; +use powdr_pipeline::test_util::{gen_estark_proof, gen_halo2_proof, verify_test_file}; use test_log::test; fn verify_asm(file_name: &str, inputs: Vec) { @@ -316,7 +316,7 @@ fn pil_at_module_level() { mod book { use super::*; - use number::GoldilocksField; + use powdr_number::GoldilocksField; use test_log::test; fn run_book_test(file: &str) { diff --git a/pipeline/tests/pil.rs b/pipeline/tests/pil.rs index 1845da1823..a386eb7966 100644 --- a/pipeline/tests/pil.rs +++ b/pipeline/tests/pil.rs @@ -1,5 +1,5 @@ -use number::GoldilocksField; -use pipeline::test_util::{gen_estark_proof, gen_halo2_proof, verify_test_file}; +use powdr_number::GoldilocksField; +use powdr_pipeline::test_util::{gen_estark_proof, gen_halo2_proof, verify_test_file}; use std::path::Path; use test_log::test; @@ -178,7 +178,7 @@ fn conditional_fixed_constraints() { #[test] fn arith_improved() { let f = "pil/arith_improved.pil"; - pil_analyzer::analyze::( + powdr_pil_analyzer::analyze::( &Path::new(&format!("{}/../test_data/{f}", env!("CARGO_MANIFEST_DIR"))) .canonicalize() .unwrap(), diff --git a/pipeline/tests/powdr_std.rs b/pipeline/tests/powdr_std.rs index 19442953e6..c025408812 100644 --- a/pipeline/tests/powdr_std.rs +++ b/pipeline/tests/powdr_std.rs @@ -1,5 +1,5 @@ -use number::GoldilocksField; -use pipeline::test_util::{gen_estark_proof, gen_halo2_proof, verify_test_file}; +use powdr_number::GoldilocksField; +use powdr_pipeline::test_util::{gen_estark_proof, gen_halo2_proof, verify_test_file}; use test_log::test; #[test] diff --git a/powdr/Cargo.toml b/powdr/Cargo.toml index 5b165b2f59..74f1d96d22 100644 --- a/powdr/Cargo.toml +++ b/powdr/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2021" [dependencies] -executor = { path = "../executor" } -number = { path = "../number" } -pipeline = { path = "../pipeline" } -riscv = { path = "../riscv" } -riscv_executor = { path = "../riscv_executor" } +powdr-executor = { path = "../executor" } +powdr-number = { path = "../number" } +powdr-pipeline = { path = "../pipeline" } +powdr-riscv = { path = "../riscv" } +powdr-riscv-executor = { path = "../riscv-executor" } diff --git a/powdr/src/lib.rs b/powdr/src/lib.rs index d62b7dbcb4..8fbd173819 100644 --- a/powdr/src/lib.rs +++ b/powdr/src/lib.rs @@ -1,5 +1,5 @@ -pub use executor; -pub use number; -pub use pipeline; -pub use riscv; -pub use riscv_executor; +pub use powdr_executor; +pub use powdr_number; +pub use powdr_pipeline; +pub use powdr_riscv; +pub use powdr_riscv_executor; diff --git a/powdr_cli/Cargo.toml b/powdr_cli/Cargo.toml deleted file mode 100644 index 203249c07b..0000000000 --- a/powdr_cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "powdr_cli" -version = "0.1.0" -edition = "2021" - -[features] -default = [] # halo2 is disabled by default -halo2 = ["dep:halo2", "backend/halo2", "pipeline/halo2"] - -[dependencies] -clap = { version = "^4.3", features = ["derive"] } -env_logger = "0.10.0" -log = "0.4.17" -pipeline = { path = "../pipeline" } -parser = { path = "../parser" } -riscv = { path = "../riscv" } -riscv_executor = { path = "../riscv_executor" } -number = { path = "../number" } -halo2 = { path = "../halo2", optional = true } -backend = { path = "../backend" } -pilopt = { path = "../pilopt" } -strum = { version = "0.24.1", features = ["derive"] } -clap-markdown = "0.1.3" - -[dev-dependencies] -tempfile = "3.6" - -[[bin]] -name = "powdr" -path = "src/main.rs" diff --git a/riscv-executor/Cargo.toml b/riscv-executor/Cargo.toml new file mode 100644 index 0000000000..60204b075a --- /dev/null +++ b/riscv-executor/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "powdr-riscv-executor" +version = "0.1.0" +edition = "2021" + +[dependencies] +powdr-analysis = { path = "../analysis" } +powdr-ast = { path = "../ast" } +powdr-executor = { path = "../executor" } +powdr-importer = { path = "../importer" } +powdr-number = { path = "../number" } +powdr-parser = { path = "../parser" } + +log = "0.4.17" +itertools = "0.11" diff --git a/riscv_executor/src/lib.rs b/riscv-executor/src/lib.rs similarity index 92% rename from riscv_executor/src/lib.rs rename to riscv-executor/src/lib.rs index 32fe3a4fab..61e09868ce 100644 --- a/riscv_executor/src/lib.rs +++ b/riscv-executor/src/lib.rs @@ -11,14 +11,14 @@ use std::{collections::HashMap, io}; -use ast::{ +use builder::TraceBuilder; +use powdr_ast::{ asm_analysis::{ AnalysisASMFile, CallableSymbol, FunctionStatement, Item, LabelStatement, Machine, }, parsed::{asm::DebugDirective, Expression, FunctionCall}, }; -use builder::TraceBuilder; -use number::{BigInt, FieldElement, GoldilocksField}; +use powdr_number::{BigInt, FieldElement, GoldilocksField}; pub mod poseidon_gl; @@ -181,8 +181,8 @@ impl<'a> TraceReplay<'a> { mod builder { use std::{cmp, collections::HashMap}; - use ast::asm_analysis::{Machine, RegisterTy}; - use number::FieldElement; + use powdr_ast::asm_analysis::{Machine, RegisterTy}; + use powdr_number::FieldElement; use crate::{ Elem, ExecMode, ExecutionTrace, MemOperation, MemOperationKind, MemoryState, RegWrite, @@ -510,7 +510,7 @@ fn preprocess_main_function(machine: &Machine) -> Preprocess } } -type Callback<'a, F> = dyn executor::witgen::QueryCallback + 'a; +type Callback<'a, F> = dyn powdr_executor::witgen::QueryCallback + 'a; struct Executor<'a, 'b, F: FieldElement> { proc: TraceBuilder<'b>, @@ -746,31 +746,31 @@ impl<'a, 'b, F: FieldElement> Executor<'a, 'b, F> { let r = self.eval_expression(r)[0]; let result = match op { - ast::parsed::BinaryOperator::Add => l.0 + r.0, - ast::parsed::BinaryOperator::Sub => l.0 - r.0, - ast::parsed::BinaryOperator::Mul => { + powdr_ast::parsed::BinaryOperator::Add => l.0 + r.0, + powdr_ast::parsed::BinaryOperator::Sub => l.0 - r.0, + powdr_ast::parsed::BinaryOperator::Mul => { // Do multiplication in the field, in case we overflow. let l: F = l.fe(); let r: F = r.fe(); let res = l * r; Elem::from_fe(res).0 } - ast::parsed::BinaryOperator::Div => l.0 / r.0, - ast::parsed::BinaryOperator::Mod => l.0 % r.0, - ast::parsed::BinaryOperator::Pow => l.0.pow(r.u()), - ast::parsed::BinaryOperator::BinaryAnd => todo!(), - ast::parsed::BinaryOperator::BinaryXor => todo!(), - ast::parsed::BinaryOperator::BinaryOr => todo!(), - ast::parsed::BinaryOperator::ShiftLeft => todo!(), - ast::parsed::BinaryOperator::ShiftRight => todo!(), - ast::parsed::BinaryOperator::LogicalOr => todo!(), - ast::parsed::BinaryOperator::LogicalAnd => todo!(), - ast::parsed::BinaryOperator::Less => todo!(), - ast::parsed::BinaryOperator::LessEqual => todo!(), - ast::parsed::BinaryOperator::Equal => todo!(), - ast::parsed::BinaryOperator::NotEqual => todo!(), - ast::parsed::BinaryOperator::GreaterEqual => todo!(), - ast::parsed::BinaryOperator::Greater => todo!(), + powdr_ast::parsed::BinaryOperator::Div => l.0 / r.0, + powdr_ast::parsed::BinaryOperator::Mod => l.0 % r.0, + powdr_ast::parsed::BinaryOperator::Pow => l.0.pow(r.u()), + powdr_ast::parsed::BinaryOperator::BinaryAnd => todo!(), + powdr_ast::parsed::BinaryOperator::BinaryXor => todo!(), + powdr_ast::parsed::BinaryOperator::BinaryOr => todo!(), + powdr_ast::parsed::BinaryOperator::ShiftLeft => todo!(), + powdr_ast::parsed::BinaryOperator::ShiftRight => todo!(), + powdr_ast::parsed::BinaryOperator::LogicalOr => todo!(), + powdr_ast::parsed::BinaryOperator::LogicalAnd => todo!(), + powdr_ast::parsed::BinaryOperator::Less => todo!(), + powdr_ast::parsed::BinaryOperator::LessEqual => todo!(), + powdr_ast::parsed::BinaryOperator::Equal => todo!(), + powdr_ast::parsed::BinaryOperator::NotEqual => todo!(), + powdr_ast::parsed::BinaryOperator::GreaterEqual => todo!(), + powdr_ast::parsed::BinaryOperator::Greater => todo!(), }; vec![result.into()] @@ -778,10 +778,10 @@ impl<'a, 'b, F: FieldElement> Executor<'a, 'b, F> { Expression::UnaryOperation(op, arg) => { let arg = self.eval_expression(arg)[0]; let result = match op { - ast::parsed::UnaryOperator::Plus => arg.0, - ast::parsed::UnaryOperator::Minus => -arg.0, - ast::parsed::UnaryOperator::LogicalNot => todo!(), - ast::parsed::UnaryOperator::Next => unreachable!(), + powdr_ast::parsed::UnaryOperator::Plus => arg.0, + powdr_ast::parsed::UnaryOperator::Minus => -arg.0, + powdr_ast::parsed::UnaryOperator::LogicalNot => todo!(), + powdr_ast::parsed::UnaryOperator::Next => unreachable!(), }; vec![result.into()] @@ -904,7 +904,7 @@ pub enum ExecMode { /// Execute a Powdr/RISCV assembly source. /// -/// Generic argument F is just used by the parser, before everything is +/// Generic argument F is just used by the powdr_parser, before everything is /// converted to i64, so it is important to the execution itself. pub fn execute( asm_source: &str, @@ -913,11 +913,12 @@ pub fn execute( mode: ExecMode, ) -> (ExecutionTrace, MemoryState) { log::info!("Parsing..."); - let parsed = parser::parse_asm::(None, asm_source).unwrap(); + let parsed = powdr_parser::parse_asm::(None, asm_source).unwrap(); log::info!("Resolving imports..."); - let resolved = importer::load_dependencies_and_resolve(None, parsed).unwrap(); + let resolved = powdr_importer::load_dependencies_and_resolve(None, parsed).unwrap(); log::info!("Analyzing..."); - let analyzed = analysis::analyze(resolved, &mut ast::DiffMonitor::default()).unwrap(); + let analyzed = + powdr_analysis::analyze(resolved, &mut powdr_ast::DiffMonitor::default()).unwrap(); log::info!("Executing..."); execute_ast(&analyzed, inputs, bootloader_inputs, usize::MAX, mode) diff --git a/riscv_executor/src/poseidon_gl.rs b/riscv-executor/src/poseidon_gl.rs similarity index 99% rename from riscv_executor/src/poseidon_gl.rs rename to riscv-executor/src/poseidon_gl.rs index 230a63ee83..cdd4cb74b6 100644 --- a/riscv_executor/src/poseidon_gl.rs +++ b/riscv-executor/src/poseidon_gl.rs @@ -1,4 +1,4 @@ -use number::FieldElement; +use powdr_number::FieldElement; #[rustfmt::skip] const ROUND_CONSTANTS: [[u64; 30]; 12] = [ @@ -69,7 +69,7 @@ pub fn poseidon_gl(inputs: &[F]) -> [F; 4] { #[cfg(test)] mod tests { use itertools::Itertools; - use number::{FieldElement, GoldilocksField}; + use powdr_number::{FieldElement, GoldilocksField}; use super::*; diff --git a/powdr_riscv_rt/Cargo.toml b/riscv-rt/Cargo.toml similarity index 67% rename from powdr_riscv_rt/Cargo.toml rename to riscv-rt/Cargo.toml index eb3c5cf4ba..2b866fb04c 100644 --- a/powdr_riscv_rt/Cargo.toml +++ b/riscv-rt/Cargo.toml @@ -1,10 +1,8 @@ [package] -name = "powdr_riscv_rt" +name = "powdr-riscv-rt" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] serde = { version = "1.0", default-features = false, features = ["alloc", "derive", "rc"] } serde_cbor = { version = "0.11.2", default-features = false, features = ["alloc"] } diff --git a/powdr_riscv_rt/rust-toolchain.toml b/riscv-rt/rust-toolchain.toml similarity index 100% rename from powdr_riscv_rt/rust-toolchain.toml rename to riscv-rt/rust-toolchain.toml diff --git a/powdr_riscv_rt/src/allocator.rs b/riscv-rt/src/allocator.rs similarity index 100% rename from powdr_riscv_rt/src/allocator.rs rename to riscv-rt/src/allocator.rs diff --git a/powdr_riscv_rt/src/coprocessors.rs b/riscv-rt/src/coprocessors.rs similarity index 100% rename from powdr_riscv_rt/src/coprocessors.rs rename to riscv-rt/src/coprocessors.rs diff --git a/powdr_riscv_rt/src/fmt.rs b/riscv-rt/src/fmt.rs similarity index 100% rename from powdr_riscv_rt/src/fmt.rs rename to riscv-rt/src/fmt.rs diff --git a/powdr_riscv_rt/src/lib.rs b/riscv-rt/src/lib.rs similarity index 100% rename from powdr_riscv_rt/src/lib.rs rename to riscv-rt/src/lib.rs diff --git a/riscv/Cargo.toml b/riscv/Cargo.toml index 9fe4caf44c..ac84b76c11 100644 --- a/riscv/Cargo.toml +++ b/riscv/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "riscv" +name = "powdr-riscv" version = "0.1.0" edition = "2021" build = "build.rs" @@ -9,29 +9,31 @@ default = [] # complex-tests is disabled by default complex-tests = [] [dependencies] +powdr-ast = { path = "../ast" } +powdr-asm-utils = { path = "../asm-utils" } +powdr-executor = { path = "../executor" } +powdr-number = { path = "../number" } +powdr-parser-util = { path = "../parser-util" } +powdr-pipeline = { path = "../pipeline" } +powdr-riscv-executor = { path = "../riscv-executor" } + itertools = "^0.10" lalrpop-util = { version = "^0.19", features = ["lexer"] } log = "0.4.17" mktemp = "0.5.0" -number = { path = "../number" } -ast = { path = "../ast" } -parser_util = { path = "../parser_util" } -asm_utils = { path = "../asm_utils" } serde_json = "1.0" # This is only here to work around https://github.com/lalrpop/lalrpop/issues/750 # It should be removed once that workaround is no longer needed. regex-syntax = { version = "0.6", default_features = false, features = [ "unicode", ] } -executor = { path = "../executor" } -riscv_executor = { path = "../riscv_executor" } -pipeline = { path = "../pipeline" } [build-dependencies] lalrpop = "^0.19" [dev-dependencies] +powdr-number = { path = "../number" } + test-log = "0.2.12" env_logger = "0.10.0" hex = "0.4.3" -number = { path = "../number" } diff --git a/riscv/src/compiler.rs b/riscv/src/compiler.rs index 5aca9be0fd..43c7cec228 100644 --- a/riscv/src/compiler.rs +++ b/riscv/src/compiler.rs @@ -3,7 +3,8 @@ use std::{ fmt, }; -use asm_utils::{ +use itertools::Itertools; +use powdr_asm_utils::{ ast::{BinaryOpKind, UnaryOpKind}, data_parser::{self, DataValue}, data_storage::{store_data_objects, SingleDataValue}, @@ -14,7 +15,6 @@ use asm_utils::{ }, Architecture, }; -use itertools::Itertools; use crate::continuations::bootloader::{bootloader, bootloader_preamble}; use crate::coprocessors::*; @@ -37,7 +37,7 @@ impl Register { } } -impl asm_utils::ast::Register for Register {} +impl powdr_asm_utils::ast::Register for Register {} impl fmt::Display for Register { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -51,7 +51,7 @@ pub enum FunctionKind { LoDataRef, } -impl asm_utils::ast::FunctionOpKind for FunctionKind {} +impl powdr_asm_utils::ast::FunctionOpKind for FunctionKind {} impl fmt::Display for FunctionKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -83,9 +83,13 @@ impl Architecture for RiscvArchitecture { } } - fn get_references<'a, R: asm_utils::ast::Register, F: asm_utils::ast::FunctionOpKind>( + fn get_references< + 'a, + R: powdr_asm_utils::ast::Register, + F: powdr_asm_utils::ast::FunctionOpKind, + >( instr: &str, - args: &'a [asm_utils::ast::Argument], + args: &'a [powdr_asm_utils::ast::Argument], ) -> Vec<&'a str> { // fence arguments are not symbols, they are like reserved // keywords affecting the instruction behavior diff --git a/riscv/src/continuations.rs b/riscv/src/continuations.rs index 400068ad16..634de34690 100644 --- a/riscv/src/continuations.rs +++ b/riscv/src/continuations.rs @@ -1,12 +1,12 @@ use std::collections::{BTreeSet, HashMap}; -use ast::{ +use powdr_ast::{ asm_analysis::{AnalysisASMFile, RegisterTy}, parsed::asm::parse_absolute_path, }; -use number::FieldElement; -use pipeline::{Pipeline, Stage}; -use riscv_executor::ExecutionTrace; +use powdr_number::FieldElement; +use powdr_pipeline::{Pipeline, Stage}; +use powdr_riscv_executor::ExecutionTrace; pub mod bootloader; mod memory_merkle_tree; @@ -136,7 +136,7 @@ pub fn rust_continuations_dry_run(mut pipeline: Pipeline) -> log::info!("Executing powdr-asm..."); let (full_trace, memory_accesses) = { - let trace = riscv_executor::execute_ast::( + let trace = powdr_riscv_executor::execute_ast::( program, pipeline.data_callback().unwrap(), // Run full trace without any accessed pages. This would actually violate the @@ -145,7 +145,7 @@ pub fn rust_continuations_dry_run(mut pipeline: Pipeline) -> // we only know them after the full trace has been generated. &default_input(&[]), usize::MAX, - riscv_executor::ExecMode::Trace, + powdr_riscv_executor::ExecMode::Trace, ) .0; (transposed_trace::(&trace), trace.mem_ops) @@ -233,12 +233,12 @@ pub fn rust_continuations_dry_run(mut pipeline: Pipeline) -> log::info!("Simulating chunk execution..."); let (chunk_trace, memory_snapshot_update) = { - let (trace, memory_snapshot_update) = riscv_executor::execute_ast::( + let (trace, memory_snapshot_update) = powdr_riscv_executor::execute_ast::( program, pipeline.data_callback().unwrap(), &bootloader_inputs, num_rows, - riscv_executor::ExecMode::Trace, + powdr_riscv_executor::ExecMode::Trace, ); (transposed_trace(&trace), memory_snapshot_update) }; diff --git a/riscv/src/continuations/bootloader.rs b/riscv/src/continuations/bootloader.rs index 84a48810dd..5a0e0d242b 100644 --- a/riscv/src/continuations/bootloader.rs +++ b/riscv/src/continuations/bootloader.rs @@ -1,4 +1,4 @@ -use number::FieldElement; +use powdr_number::FieldElement; use super::memory_merkle_tree::MerkleTree; diff --git a/riscv/src/continuations/memory_merkle_tree.rs b/riscv/src/continuations/memory_merkle_tree.rs index 0c8767df3e..21a1b42aa5 100644 --- a/riscv/src/continuations/memory_merkle_tree.rs +++ b/riscv/src/continuations/memory_merkle_tree.rs @@ -4,8 +4,8 @@ use super::bootloader::{ BYTES_PER_WORD, N_LEAVES_LOG as N_LEAVES_LOG_BOOTLOADER, WORDS_PER_PAGE as WORDS_PER_PAGE_BOOTLOADER, }; -use number::FieldElement; -use riscv_executor::poseidon_gl::poseidon_gl; +use powdr_number::FieldElement; +use powdr_riscv_executor::poseidon_gl::poseidon_gl; /// A Merkle tree of memory pages. pub struct MerkleTree< @@ -151,7 +151,7 @@ impl #[cfg(test)] mod test { - use number::GoldilocksField; + use powdr_number::GoldilocksField; use super::*; diff --git a/riscv/src/lib.rs b/riscv/src/lib.rs index c2bc4f7c0d..20e9f5ef55 100644 --- a/riscv/src/lib.rs +++ b/riscv/src/lib.rs @@ -21,9 +21,9 @@ mod coprocessors; mod disambiguator; pub mod parser; -type Statement = asm_utils::ast::Statement; -type Argument = asm_utils::ast::Argument; -type Expression = asm_utils::ast::Expression; +type Statement = powdr_asm_utils::ast::Statement; +type Argument = powdr_asm_utils::ast::Argument; +type Expression = powdr_asm_utils::ast::Expression; /// Compiles a rust file all the way down to PIL and generates /// fixed and witness columns. diff --git a/riscv/src/parser.rs b/riscv/src/parser.rs index 3c4c3c4fb0..54c63ce91c 100644 --- a/riscv/src/parser.rs +++ b/riscv/src/parser.rs @@ -4,7 +4,7 @@ use crate::{ compiler::{FunctionKind, Register}, Statement, }; -use parser_util::handle_parse_error; +use powdr_parser_util::handle_parse_error; lalrpop_mod!( #[allow(clippy::all)] @@ -24,7 +24,7 @@ impl Default for RiscParser { } } -impl asm_utils::parser::Parser for RiscParser { +impl powdr_asm_utils::parser::Parser for RiscParser { fn parse(&self, input: &str) -> Result, String> { self.parser.parse(input).map_err(|err| { handle_parse_error(err, None, input).output_to_stderr(); diff --git a/riscv/src/riscv_asm.lalrpop b/riscv/src/riscv_asm.lalrpop index 37cd464685..9cc87a718b 100644 --- a/riscv/src/riscv_asm.lalrpop +++ b/riscv/src/riscv_asm.lalrpop @@ -11,7 +11,7 @@ //! to create the "slightly tweaked" grammar, but this is not ideal. use std::str::FromStr; -use asm_utils::ast::{unescape_string, BinaryOpKind as BOp, UnaryOpKind as UOp, +use powdr_asm_utils::ast::{unescape_string, BinaryOpKind as BOp, UnaryOpKind as UOp, new_binary_op as bin_op, new_unary_op as un_op, new_function_op as fn_op}; use crate::{Argument, Register, Statement, FunctionKind as FOp, Expression, map_insn_i}; diff --git a/riscv/tests/common/mod.rs b/riscv/tests/common/mod.rs index 426a312436..1b865c834c 100644 --- a/riscv/tests/common/mod.rs +++ b/riscv/tests/common/mod.rs @@ -1,5 +1,5 @@ -use number::GoldilocksField; -use pipeline::{test_util::verify_pipeline, Pipeline, Stage}; +use powdr_number::GoldilocksField; +use powdr_pipeline::{test_util::verify_pipeline, Pipeline, Stage}; use std::path::PathBuf; /// Like compiler::test_util::verify_asm_string, but also runs RISCV executor. @@ -12,13 +12,13 @@ pub fn verify_riscv_asm_string(file_name: &str, contents: &str, inputs: Vec, coprocessors: &CoProcessors) { let temp_dir = Temp::new_dir().unwrap(); let riscv_asm = - riscv::compile_rust_to_riscv_asm(&format!("tests/riscv_data/{case}"), &temp_dir); - let powdr_asm = riscv::compiler::compile(riscv_asm, coprocessors, false); + powdr_riscv::compile_rust_to_riscv_asm(&format!("tests/riscv_data/{case}"), &temp_dir); + let powdr_asm = powdr_riscv::compiler::compile(riscv_asm, coprocessors, false); verify_asm_string(&format!("{case}.asm"), &powdr_asm, inputs, vec![]); } @@ -233,8 +233,8 @@ fn test_print_rv32_executor() { fn verify_riscv_file(case: &str, inputs: Vec, coprocessors: &CoProcessors) { let temp_dir = Temp::new_dir().unwrap(); let riscv_asm = - riscv::compile_rust_to_riscv_asm(&format!("tests/riscv_data/{case}"), &temp_dir); - let powdr_asm = riscv::compiler::compile(riscv_asm, coprocessors, false); + powdr_riscv::compile_rust_to_riscv_asm(&format!("tests/riscv_data/{case}"), &temp_dir); + let powdr_asm = powdr_riscv::compiler::compile(riscv_asm, coprocessors, false); verify_riscv_asm_string(&format!("{case}.asm"), &powdr_asm, inputs); } @@ -247,9 +247,9 @@ fn verify_riscv_crate(case: &str, inputs: Vec, coprocessors: &C fn compile_riscv_crate(case: &str, coprocessors: &CoProcessors) -> String { let temp_dir = Temp::new_dir().unwrap(); - let riscv_asm = riscv::compile_rust_crate_to_riscv_asm( + let riscv_asm = powdr_riscv::compile_rust_crate_to_riscv_asm( &format!("tests/riscv_data/{case}/Cargo.toml"), &temp_dir, ); - riscv::compiler::compile(riscv_asm, coprocessors, false) + powdr_riscv::compiler::compile(riscv_asm, coprocessors, false) } diff --git a/riscv_executor/Cargo.toml b/riscv_executor/Cargo.toml deleted file mode 100644 index f43ae70c3b..0000000000 --- a/riscv_executor/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "riscv_executor" -version = "0.1.0" -edition = "2021" - -[dependencies] -log = "0.4.17" -itertools = "0.11" -ast = { path = "../ast" } -number = { path = "../number" } -parser = { path = "../parser" } -importer = { path = "../importer" } -analysis = { path = "../analysis" } -executor = { path = "../executor" }