-
Notifications
You must be signed in to change notification settings - Fork 381
feat(acir): Handle dynamic array operations for nested slices #3187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
c2f2f62
enabled dynamic indices on nested arrays
vezenovm 45b3787
remove debug
vezenovm 7ccf8e9
working non-homogenous arr accesses for block params
vezenovm d5d16d7
add array_set, broken, need to maintain structure from SSA for accura…
vezenovm ec54e01
merge conflcits w/ master
vezenovm e2eff9b
working non-homogenous arrays using internal type element size array,…
vezenovm 219c8f2
cleanup lots of debug and move const index access into its own method
vezenovm 3195325
updating array_get and array_set to reduce repeated code
vezenovm 8fb3bb1
restrict dynamic indices for non-homogenous slices
vezenovm 469c333
cleanup array_get_value
vezenovm 0648142
add internal_memory_blocks map
vezenovm b99f0e2
do not make separate bool for handle_constant_index
vezenovm 5784170
fetch dummy value with predicate index
vezenovm 05f35c6
flatten the index once for both array_set and array_get, do not modif…
vezenovm f2dd702
remove first_elem param
vezenovm 490f5af
initial slice changes with fetch flat size from SSA values, need to g…
vezenovm 0037867
merge master
vezenovm 3636bc6
initial working nested dynamic slices
vezenovm 31e7bc2
cleanup and fmt
vezenovm 4354b76
cargo clippy and fmt
vezenovm 87e8314
merge conflicts w/ master
vezenovm 658d234
remove boolean AcirType
vezenovm 408ac2c
remove deaad code not in master
vezenovm 22ce20c
better solution for fetching nested slice with multiple slice mergesr
vezenovm 686640e
bring back assert in nested_array_dynamic
vezenovm 626616b
add assert to nested_slice_dynamic test
vezenovm f60183c
cleanup w/ copy_dynamic_array method
vezenovm be5dc79
starting test for slices in struct fields
vezenovm a7fde3e
more initial debugging for adding slices to struct fields
vezenovm d1c9192
basic slice struct fields working, but broken for struct fields of di…
vezenovm 6ab1212
got old nested array and slice working with new acir, basic array get…
vezenovm d5911b8
merged w/ master, and working old nested arr/slice tests, array_set f…
vezenovm b9c6a0a
heavy debugging work to get flattening with slice of slices working
vezenovm 11f7dc8
working slice field in a struct
vezenovm 7f4c822
little test func for flattened slice size of res
vezenovm d97b965
merge conflicts w/ master
vezenovm 20f61a5
Merge branch 'master' into mv/slice-struct-fields
vezenovm 37a0f0f
merge conflicts w/ master
vezenovm 1e0bd3f
update slice struct fields to use map of slice sizes in ACIR gen
vezenovm 3b08844
clean up dbgs and old debug in acvm
vezenovm 9086383
cleanup
vezenovm f1c707c
comments update
vezenovm 9108769
check if we have side effects enabeld when flattening index
vezenovm 589185c
Merge branch 'master' into mv/slice-struct-fields
vezenovm 4209388
cleanup
vezenovm 2949302
add TODOs to value merger
vezenovm 1456af9
Merge branch 'master' into mv/slice-struct-fields
vezenovm e58dbba
Merge branch 'master' into mv/slice-struct-fields
TomAFrench f30062e
Update compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
vezenovm dd3baec
feat(slices): Fill slice internal dummy data initial pass (#3258)
vezenovm 3b30290
simplify predicate logic when fetching flattened index
vezenovm 4926713
Update compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
vezenovm 24bfae9
use ok_or_else on store value slice sizes
vezenovm a8dae7a
reduce nesting from compute_slice_sizes in acir gen
vezenovm d558647
Merge branch 'master' into mv/slice-struct-fields
vezenovm ed372cc
Merge branch 'master' into mv/slice-struct-fields
ff280cb
Merge branch 'master' into mv/slice-struct-fields
vezenovm 402f421
revert merge of 3258
vezenovm 5286fd1
use slice not mutable vec for array_get_value
vezenovm 96805de
comment out failing constraints fixed by fill internal slices pass
vezenovm c7649d3
Update compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
vezenovm bf0aa94
wrap parent_array in Some
vezenovm 2528f3d
Update compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
vezenovm 38669e9
add comments for slize sizes
vezenovm 2b446a1
remove catch all for contains_slice_element
vezenovm 33beadf
Merge branch 'master' into mv/slice-struct-fields
vezenovm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
tooling/nargo_cli/tests/execution_success/regression_mem_op_predicate/src/main.nr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| fn main(mut x: [u32; 5], idx: Field) { | ||
| // We should not hit out of bounds here as we have a predicate | ||
| // that should not be hit | ||
| if idx as u32 < 3 { | ||
| if idx as u32 < 3 { | ||
| x[idx] = 10; | ||
| } | ||
| assert(x[4] == 111); | ||
| } | ||
| assert(x[4] == 111); | ||
| } |
6 changes: 6 additions & 0 deletions
6
tooling/nargo_cli/tests/execution_success/slice_struct_field/Nargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| name = "slice_struct_field" | ||
| type = "bin" | ||
| authors = [""] | ||
|
|
||
| [dependencies] |
1 change: 1 addition & 0 deletions
1
tooling/nargo_cli/tests/execution_success/slice_struct_field/Prover.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| y = "3" |
125 changes: 125 additions & 0 deletions
125
tooling/nargo_cli/tests/execution_success/slice_struct_field/src/main.nr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| struct FooParent { | ||
| parent_arr: [Field; 3], | ||
| foos: [Foo], | ||
| } | ||
|
|
||
| struct Bar { | ||
| inner: [Field; 3], | ||
| } | ||
|
|
||
| struct Foo { | ||
| a: Field, | ||
| b: [Field], | ||
| bar: Bar, | ||
| } | ||
|
|
||
| fn main(y : pub Field) { | ||
| let mut b_one = [2, 3, 20]; | ||
| b_one = b_one.push_back(20); | ||
| // let b_one = Vec::from_slice([2, 3, 20]); | ||
| let foo_one = Foo { a: 1, b: b_one, bar: Bar { inner: [100, 101, 102] } }; | ||
| let mut b_two = [5, 6, 21]; | ||
| b_two = b_two.push_back(21); | ||
| // let b_two = Vec::from_slice([5, 6, 21]); | ||
| let foo_two = Foo { a: 4, b: b_two, bar: Bar { inner: [103, 104, 105] } }; | ||
| let foo_three = Foo { a: 7, b: [8, 9, 22], bar: Bar { inner: [106, 107, 108] } }; | ||
| let foo_four = Foo { a: 10, b: [11, 12, 23], bar: Bar { inner: [109, 110, 111] } }; | ||
|
|
||
| let mut x = [foo_one, foo_two]; | ||
| x = x.push_back(foo_three); | ||
| x = x.push_back(foo_four); | ||
|
|
||
| assert(x[y - 3].a == 1); | ||
| let struct_slice = x[y - 3].b; | ||
| for i in 0..4 { | ||
| assert(struct_slice[i] == b_one[i]); | ||
| } | ||
|
|
||
| assert(x[y - 2].a == 4); | ||
| let struct_slice = x[y - 2].b; | ||
| for i in 0..4 { | ||
| assert(struct_slice[i] == b_two[i]); | ||
| } | ||
|
|
||
| assert(x[y - 1].a == 7); | ||
| let struct_slice = x[y - 1].b; | ||
| assert(struct_slice[0] == 8); | ||
| assert(struct_slice[1] == 9); | ||
| assert(struct_slice[2] == 22); | ||
|
|
||
| assert(x[y].a == 10); | ||
| let struct_slice = x[y].b; | ||
| assert(struct_slice[0] == 11); | ||
| assert(struct_slice[1] == 12); | ||
| assert(struct_slice[2] == 23); | ||
| assert(x[y].bar.inner == [109, 110, 111]); | ||
|
|
||
| // TODO: Enable merging nested slices | ||
| // if y != 2 { | ||
| // x[y].a = 50; | ||
| // } else { | ||
| // x[y].a = 100; | ||
| // } | ||
| // assert(x[3].a == 50); | ||
|
|
||
| // if y == 2 { | ||
| // x[y - 1].b = [50, 51, 52]; | ||
| // } else { | ||
| // x[y - 1].b = [100, 101, 102]; | ||
| // } | ||
| // assert(x[2].b[0] == 100); | ||
| // assert(x[2].b[1] == 101); | ||
| // assert(x[2].b[2] == 102); | ||
|
|
||
| assert(x[y - 3].bar.inner == [100, 101, 102]); | ||
| assert(x[y - 2].bar.inner == [103, 104, 105]); | ||
| assert(x[y - 1].bar.inner == [106, 107, 108]); | ||
| assert(x[y].bar.inner == [109, 110, 111]); | ||
|
|
||
| let q = x.push_back(foo_four); | ||
| let foo_parent_one = FooParent { parent_arr: [0, 1, 2], foos: x }; | ||
| let foo_parent_two = FooParent { parent_arr: [3, 4, 5], foos: q }; | ||
| let mut foo_parents = [foo_parent_one]; | ||
| foo_parents = foo_parents.push_back(foo_parent_two); | ||
|
|
||
| // TODO: Merging nested slices is broken | ||
| // if y == 2 { | ||
| // foo_parents[y - 2].foos[y - 1].b[y - 1] = 5000; | ||
| // } else { | ||
| // foo_parents[y - 2].foos[y - 1].b[y - 1] = 1000; | ||
| // } | ||
| assert(foo_parents[y - 2].foos[y - 1].a == 7); | ||
| foo_parents[y - 2].foos[y - 1].a = 50; | ||
| assert(foo_parents[y - 2].foos[y - 1].a == 50); | ||
|
|
||
| assert(foo_parents[y - 2].foos[y - 2].b[y - 1] == 21); | ||
| foo_parents[y - 2].foos[y - 2].b[y - 1] = 5000; | ||
| assert(foo_parents[y - 2].foos[y - 2].b[y - 1] == 5000); | ||
|
|
||
| let b_array = foo_parents[y - 2].foos[y - 3].b; | ||
| assert(b_array[0] == 2); | ||
| assert(b_array[1] == 3); | ||
| assert(b_array[2] == 20); | ||
| assert(b_array[3] == 20); | ||
|
|
||
| let b_array = foo_parents[y - 2].foos[y - 2].b; | ||
| assert(b_array[0] == 5); | ||
| assert(b_array[1] == 6); | ||
| assert(b_array[2] == 5000); | ||
| assert(b_array[3] == 21); | ||
|
|
||
| let b_array = foo_parents[y - 2].foos[y - 1].b; | ||
| assert(b_array[0] == 8); | ||
| assert(b_array[1] == 9); | ||
| assert(b_array[2] == 22); | ||
|
|
||
| // Fixed by #3410 | ||
| // let b_array = foo_parents[y - 2].foos[y].b; | ||
| // assert(b_array[0] == 11); | ||
| // assert(b_array[1] == 12); | ||
| // assert(b_array[2] == 23); | ||
|
|
||
| // assert(foo_parents[y - 2].foos[y - 3].bar.inner == [100, 101, 102]); | ||
| // assert(foo_parents[y - 2].foos[y - 2].bar.inner == [103, 104, 105]); | ||
| // assert(foo_parents[y - 2].foos[y - 1].bar.inner == [106, 107, 108]); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.