From 7881d8022f1911118bd3417f30591db642dd2599 Mon Sep 17 00:00:00 2001 From: Leo Alt Date: Wed, 18 Oct 2023 17:06:38 +0200 Subject: [PATCH] add -j to pil cli --- powdr_cli/src/main.rs | 47 ++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/powdr_cli/src/main.rs b/powdr_cli/src/main.rs index 393023b1d2..2d9b36c0c2 100644 --- a/powdr_cli/src/main.rs +++ b/powdr_cli/src/main.rs @@ -89,6 +89,12 @@ enum Commands { #[arg(default_value_t = CsvRenderMode::Hex)] #[arg(value_parser = clap_enum_variants!(CsvRenderMode))] csv_mode: CsvRenderMode, + + /// Just execute in the RISCV/Powdr executor + #[arg(short, long)] + #[arg(default_value_t = false)] + just_execute: bool, + }, /// Compiles (no-std) rust code to riscv assembly, then to powdr assembly /// and finally to PIL and generates fixed and witness columns. @@ -385,24 +391,32 @@ fn run_command(command: Commands) { prove_with, export_csv, csv_mode, + just_execute, } => { - match call_with_field!(compile_with_csv_export::( - file, - output_directory, - inputs, - force, - prove_with, - export_csv, - csv_mode - )) { - Ok(()) => {} - Err(errors) => { - eprintln!("Errors:"); - for e in errors { - eprintln!("{e}"); + if just_execute { + // assume input is riscv asm and just execute it + let contents = fs::read_to_string(file).unwrap(); + let inputs = split_inputs(&inputs); + riscv_executor::execute::(&contents, &inputs); + } else { + match call_with_field!(compile_with_csv_export::( + file, + output_directory, + inputs, + force, + prove_with, + export_csv, + csv_mode + )) { + Ok(()) => {} + Err(errors) => { + eprintln!("Errors:"); + for e in errors { + eprintln!("{e}"); + } } - } - }; + }; + } } Commands::Prove { file, @@ -676,6 +690,7 @@ mod test { prove_with: Some(BackendType::PilStarkCli), export_csv: true, csv_mode: CsvRenderMode::Hex, + just_execute: false, }; run_command(pil_command);