From 8778a1d35ed6649cdc1e9714a87ed2704ab6c706 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Tue, 30 May 2023 10:10:09 +0100 Subject: [PATCH] chore(ssa refactor): Add basic binary operation program (#1419) * make prove_and_verify method take in the experimental-ssa flag * add new test directory for experimental-ssa * move noir_integration code into another function and parametrize it with a boolean which will allow us to still test the normal ssa when the boolean is false, but then test the experimental ssa when true with tests in a different directory. * add milestone 0 program * use underscores since x and y are unused. It just makes the CI have less information * use convert_ssa_value to either fetch the value of a previous ValueId or create one if its a constant. * add basic program that does binary addition * Add a function to check whether the return type is the unit and then exit early if so * use public abi for public parameters * fix clippy --- .../simple_program_addition/Nargo.toml | 5 +++++ .../simple_program_addition/Prover.toml | 1 + .../simple_program_addition/src/main.nr | 5 +++++ crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs | 5 ++++- 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/Nargo.toml create mode 100644 crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/Prover.toml create mode 100644 crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/src/main.nr diff --git a/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/Nargo.toml b/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/Nargo.toml new file mode 100644 index 00000000000..e0b467ce5da --- /dev/null +++ b/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/Nargo.toml @@ -0,0 +1,5 @@ +[package] +authors = [""] +compiler_version = "0.1" + +[dependencies] \ No newline at end of file diff --git a/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/Prover.toml b/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/Prover.toml new file mode 100644 index 00000000000..07890234a19 --- /dev/null +++ b/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/Prover.toml @@ -0,0 +1 @@ +x = "3" diff --git a/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/src/main.nr b/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/src/main.nr new file mode 100644 index 00000000000..59b03556d94 --- /dev/null +++ b/crates/nargo_cli/tests/test_data_ssa_refactor/simple_program_addition/src/main.nr @@ -0,0 +1,5 @@ +// The feature being tested is handling of +// a binary operation. +fn main(x : Field) -> pub Field { + x + 1 +} \ No newline at end of file diff --git a/crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs b/crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs index 07c78b2a377..7241414be4e 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs @@ -110,7 +110,10 @@ impl Context { _ => unreachable!("ICE: Program must have a singular return"), }; - let is_return_unit_type = return_values.len() == 1 && dfg.type_of_value(return_values[0]) == Type::Unit; + // Check if the program returns the `Unit/None` type. + // This type signifies that the program returns nothing. + let is_return_unit_type = + return_values.len() == 1 && dfg.type_of_value(return_values[0]) == Type::Unit; if is_return_unit_type { return; }