Skip to content

Commit

Permalink
chore(brillig): master into brillig main (#1663)
Browse files Browse the repository at this point in the history
* fix(ssa refactor): resolve replaced value ids for printing (#1535)

* fix(ssa refactor): resolve replaced value ids for printing

* fix(ssa refactor): Expand PR #1535 to resolve ValueIds in all SSA passes (#1642)

* Expand PR

* chore(ssa refactor): more value id resolving

* chore(ssa refactor): another value id resolve

---------

Co-authored-by: Joss <joss@aztecprotocol.com>

---------

Co-authored-by: jfecher <jake@aztecprotocol.com>

* chore(ssa refactor): enable_side_effects instruction (#1547)

* chore(ssa refactor): enable_side_effects instruction

* chore(ssa refactor): fix and document enable_side_effects insertions

* chore(ssa refactor): rm comments

* fix(ssa refactor): redundant EnableSideEffects

* chore(ssa refactor): cp working tests (#1619)

* chore(ssa gen): ssa gen truncate instruction

* chore(ssa refactor): max bit size for subtract

* Update crates/noirc_evaluator/src/ssa_refactor/ssa_gen/context.rs

Co-authored-by: jfecher <jake@aztecprotocol.com>

* chore(ssa refactor): truncate shift left

* chore(ssa refactor): Add integer modulus when truncating subtraction

* chore(ssa refactor): clippy

* chore(ssa refactor): fix left shift max bit size

* chore(ssa refactor): cp xor test

* chore(ssa refactor): cp working tests

* chore(ssa refactor): more working tests

* chore(ssa refactor): cp working test

---------

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
Co-authored-by: jfecher <jake@aztecprotocol.com>

* chore(ssa refactor): Remove unit values from SSA IR (#1646)

* Remove unit values

* Fix test

* Fix comment

* chore: Upgrade codespan dependencies (#1647)

* chore(ssa refactor): Implement dead instruction elimination pass (#1595)

* Add dead instruction elimination pass

* Enable the pass

* chore(ssa refactor): simple mut test

* chore(ssa refactor): fixup and add doc comments

* chore(ssa refactor): post merge fix

---------

Co-authored-by: Joss <joss@aztecprotocol.com>

* chore(brillig): Update acvm dependency (#1653)

chore: update acvm dep

* refactor: remove unused assign

---------

Co-authored-by: joss-aztec <94053499+joss-aztec@users.noreply.github.com>
Co-authored-by: jfecher <jake@aztecprotocol.com>
Co-authored-by: kevaundray <kevtheappdev@gmail.com>
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
Co-authored-by: Joss <joss@aztecprotocol.com>
  • Loading branch information
6 people authored Jun 13, 2023
1 parent f7f2647 commit 2893855
Show file tree
Hide file tree
Showing 89 changed files with 1,214 additions and 137 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ edition = "2021"
rust-version = "1.66"

[workspace.dependencies]
acvm = "=0.14.3"
acvm = "=0.14.4"
arena = { path = "crates/arena" }
fm = { path = "crates/fm" }
iter-extended = { path = "crates/iter-extended" }
Expand All @@ -40,8 +40,8 @@ noir_wasm = { path = "crates/wasm" }

cfg-if = "1.0.0"
clap = { version = "4.1.4", features = ["derive"] }
codespan = "0.9.5"
codespan-reporting = "0.9.5"
codespan = "0.11.1"
codespan-reporting = "0.11.1"
chumsky = { git = "https://github.com/jfecher/chumsky", rev = "ad9d312" }
dirs = "4"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/fm/src/file_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl FileMap {
FileId(file_id)
}
pub fn get_file(&self, file_id: FileId) -> Option<File> {
self.0.get(file_id.0).map(File)
self.0.get(file_id.0).map(File).ok()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main(x: Field) {
assert(x == 1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "0x00"
y = "0x10"
18 changes: 18 additions & 0 deletions crates/nargo_cli/tests/test_data_ssa_refactor/bit_and/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// You can only do bit operations with integers.
// (Kobi/Daira/Circom/#37) https://github.com/iden3/circom/issues/37
fn main(x : Field, y : Field) {
let x_as_u8 = x as u8;
let y_as_u8 = y as u8;

assert((x_as_u8 & y_as_u8) == x_as_u8);

//bitwise and with 1 bit:
let flag = (x == 0) & (y == 16);
assert(flag);

//bitwise and with odd bits:
let x_as_u11 = x as u11;
let y_as_u11 = y as u11;
assert((x_as_u11 & y_as_u11) == x_as_u11);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = 64
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main(x: u64) {
let two: u64 = 2;
let three: u64 = 3;

// comptime shifts on comptime values
assert(two << 2 == 8);
assert((two << 3) / 8 == two);
assert((three >> 1) == 1);

// comptime shifts on runtime values
assert(x << 1 == 128);
assert(x >> 2 == 16);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use dep::std;
fn main(x: u1) {
assert(!x == 0);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "1"
y = "0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use dep::std;
fn main(x: u1, y: u1) {
assert(x | y == 1);

assert(x | y | x == 1);
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ fn main(x: Field) {
}

#[oracle(oracle_print_impl)]
unconstrained fn oracle_print(_x : Field) {}
unconstrained fn oracle_print(_x : Field) -> Field {}

unconstrained fn oracle_print_wrapper(x: Field) {
oracle_print(x);
}

#[oracle(oracle_print_array_impl)]
unconstrained fn oracle_print_array(_arr : [Field; 2]) {}
unconstrained fn oracle_print_array(_arr : [Field; 2]) -> Field {}

unconstrained fn oracle_print_array_wrapper(arr: [Field; 2]) {
oracle_print_array(arr);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "10"
y = "10"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main(x: Field, y: Field) {
let z = x == y;
let t = z as u8;
assert(t == 1);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = [1, 2, 3]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fn main(a: [Field; 3]) {
let i = 1;

// Using a comptime variable as a parameter should not make it non-comptime
let ii = foo(i);
let elem1 = a[i];

// Nor should using it in an expression with a non-comptime variable.
let two = i + ii;
assert(i == ii);

let elem2 = a[i];
assert(elem1 == elem2);
assert(two == 2);
}

fn foo(x: Field) -> Field { x }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 5
y = 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main(x: Field, y: Field) {
let flag = (x == 1) | (y == 2);
assert(flag | false == flag);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 3
y = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main(x : Field, y : pub Field) {
assert(x * 2 == y * 3);
}

contract Foo {
fn double(x: Field) -> pub Field { x * 2 }
fn triple(x: Field) -> pub Field { x * 3 }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
input = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use dep::std;

fn main(input : Field) -> pub Field {
std::hash::hash_to_field([input])
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = true
y = [true, false]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main(x : bool, y: [bool;2]) {
if x {
assert(1 != 2);
}

assert(x);
assert(y[0] != y[1]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "8"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main(x: pub Field) -> pub Field {
x
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "2"
y = "13"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn hello(x : Field) -> Field {
x
}
14 changes: 14 additions & 0 deletions crates/nargo_cli/tests/test_data_ssa_refactor/modules/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod foo;
// This is a comment.
//
// `main` is the entry point to a binary
//
// You can have a `Binary` or a `Library`
// Release : 0.2
//
// To run a proof on the command line, type `cargo run prove {proof_name}`
//
// To verify that proof, type `cargo run verify {proof_name}`
fn main(x: Field, y: pub Field) {
assert(x != foo::hello(y));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Loading

0 comments on commit 2893855

Please sign in to comment.