-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat: Enable dynamic indices on slices #2446
Conversation
…nnot merge a load
…up and add other dnyamic slice intrinsics
git status
I mainly checked this box because once this PR is merged, support for slices will fully match arrays. I wasn't sure if the documentation had anything noting that slices have certain limitations vs. arrays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking this temporarily to give me time to review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly questions on the various parts of this PR, why certain parts are needed, etc
crates/nargo_cli/tests/execution_success/slice_dynamic_index/src/main.nr
Show resolved
Hide resolved
crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that loop unrolling is disabled for brillig, can you merge master and verify the checks that were removed are still not needed? Or I suppose that will be done by the CI automatically.
We can look into removing |
# Description ## Problem\* Resolves #4202 and #2446 (comment) ## Summary\* This PR brings back the `capacity_tracker` that was used by the fill internal slices pass and for merging nested slices (#3979). We now track the capacity of slices as we insert instructions. The capacity tracker has also been simplified as it no longer needs to handle nested slice. The current strategy checks for previously saved store instructions and backtracks the instructions to see what is the capacity of a slice when it comes time to merge two slice values. This required an additional `outer_block_stores` map as we `store_values` only track stores within the current branch that is being inlined, and a `get_slice_length` method that ultimately did the recursive backtracking to determine the slice length. With the capacity tracker we already have the slice length once it comes time to perform a slice merger allowing us to remove `outer_block_stores` and `get_slice_length`. Overall, the capacity tracker enables us to have more accurate tracking of slice capacities and gives us a more general strategy for tracking a slice capacity per instruction. ## Additional Context ## Documentation\* Check one: - [X] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [X] I have tested the changes locally. - [X] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Description
Problem*
Resolves #374
Resolves #2536
Resolves #2538
Summary*
This PR implements handling of dynamic indices for slices. After #2347 the slice structure was changed to be a tuple (length, contents) so that we can dynamic carry a slice's true user-facing length throughout SSA. This new length value can now be used to implement dynamic indexing and merging of slices.
The slice length eventually becomes known by the end of SSA through multiple optimization passes such as mem2reg and constant folding. Additional handling of this length needed to be included in flattening. This is the final location in SSA where the length of a slice must be resolved, and where the majority of SSA changes can be found.
All slice intrinsics now need to also be handled inside of ACIR gen.
SliceInsert and SliceRemove in ACIR gen still need to be implemented #2462 (specifically the case where we want to perform an insertion or removal at a dynamic index), and dynamic indexing of arrays/slices needs to be implemented in general (#2461)
Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmt
on default settings.