-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(acir_gen): Brillig stdlib (#4848)
# Description ## Problem\* Expands usage of #3907 to our Brillig directives. ## Summary\* The Brillig stdlib differs slightly from normal Brillig functions calls. We can insert the generated Brillig bytecode at any point during ACIR gen. This includes within the `GeneratedAcir` struct itself. We have a few requirements on what we want to achieve: - We do want to have to thread the ACIR gen `SharedContext` that is used for generating normal Brillig function pointers to the `GeneratedAcir`. Why would we want a reference to code generation inside of our Generated ACIR structure (we don't)? - We want to maintain one Brillig stdlib for an entire program. We do not want to change the `BrilligCall` opcode so we need them to be a part of the main list of `unconstrained_functions` in a program. - Function IDs reference a flat list, so reserving some number of slots would be wasteful if the program does not eventually use a Brillig stdlib function in that slot. So instead we maintain a map as part of the `GeneratedAcir` that notes when we at which opcode location we inserted a call to a `BrilligStdlibFunc`. The ID at this point will just be `0`. After finishing ACIR generation for a function, only then do we resolve the IDs for these `BrilligCall` opcodes. ## Additional Context ## Documentation\* Check one: - [X] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** 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> Co-authored-by: jfecher <jake@aztecprotocol.com> Co-authored-by: TomAFrench <tom@tomfren.ch>
- Loading branch information
1 parent
1969ce3
commit 0c8175c
Showing
4 changed files
with
456 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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 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
Oops, something went wrong.