-
Notifications
You must be signed in to change notification settings - Fork 190
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
Consider introducing BrilligFunctionPointer
into ACIR
#3907
Comments
When we want to have ACIR functions, this might be a good way to do it too instead of inlining the ACIR into ACIR |
Duplicate of #2936 |
This feels like something that can be handled with this general solution: #4428 |
Agreed, I'm going to assign this to you and we can close it at the same time as when we handle the folding case. |
It just occurred to me that we should potentially still keep brillig and ACIR separated to resolve this rather than just treating them as circuits with a single |
Yup agreed |
This starts work towards noir-lang/noir#3907 but is only the breaking serialization change. Codegen and evaluation will come in a follow-up. This PR is purely additive and does not remove the current way we do Brillig gen during ACIR gen. Codegen for normal Brillig functions is working in my follow-up, however, removing the existing Brillig opcode will most likely have to come once we settle on how to [handle the brillig std lib](noir-lang/acvm#471) as we are currently generating code such as calculating a quotient during ACIR gen. --------- Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
This starts work towards #3907 but is only the breaking serialization change. Codegen and evaluation will come in a follow-up. This PR is purely additive and does not remove the current way we do Brillig gen during ACIR gen. Codegen for normal Brillig functions is working in my follow-up, however, removing the existing Brillig opcode will most likely have to come once we settle on how to [handle the brillig std lib](noir-lang/acvm#471) as we are currently generating code such as calculating a quotient during ACIR gen. --------- Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
This starts work towards noir-lang/noir#3907 but is only the breaking serialization change. Codegen and evaluation will come in a follow-up. This PR is purely additive and does not remove the current way we do Brillig gen during ACIR gen. Codegen for normal Brillig functions is working in my follow-up, however, removing the existing Brillig opcode will most likely have to come once we settle on how to [handle the brillig std lib](noir-lang/acvm#471) as we are currently generating code such as calculating a quotient during ACIR gen. --------- Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Resolves noir-lang/noir#3907 This PR builds upon #5709. These changes do not yet include a Brillig stdlib and removal of the `Brillig` opcode itself. The generated stdlib Brillig (such as for quotient) is not created in the same manner as other Brillig calls which are generated during SSA. I have decided to leave this for another follow-up where we can actually remove `Brillig`. --------- Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> Co-authored-by: jfecher <jfecher11@gmail.com>
…ages#5737) Resolves #3907 This PR builds upon AztecProtocol/aztec-packages#5709. These changes do not yet include a Brillig stdlib and removal of the `Brillig` opcode itself. The generated stdlib Brillig (such as for quotient) is not created in the same manner as other Brillig calls which are generated during SSA. I have decided to leave this for another follow-up where we can actually remove `Brillig`. --------- Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> Co-authored-by: jfecher <jfecher11@gmail.com>
# 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>
Problem
Currently we inline the bytecode into ACIR for each ACIR call.
A brillig opcode in ACIR will therefore contain the bytecode to be executed. This is a problem because if the same Brillig function is called N times, we will be duplicating the bytecode for that function N times.
Happy Case
We can store the bytecode in an ordered set and replace the bytecode for Brillig in the ACIR opcode, with a pointer to that ordered set.
If the same function is called multiple times, we only duplicate the pointer/index to the ordered set.
Alternatives Considered
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: