Skip to content
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

Add justification in ACIR Gen for duplicated ACIR Abi generation information #1425

Closed
Tracked by #1376
kevaundray opened this issue May 27, 2023 · 0 comments · Fixed by #2095
Closed
Tracked by #1376

Add justification in ACIR Gen for duplicated ACIR Abi generation information #1425

kevaundray opened this issue May 27, 2023 · 0 comments · Fixed by #2095
Assignees
Labels
enhancement New feature or request refactor ssa

Comments

@kevaundray
Copy link
Contributor

Problem

The first observation to make is that SSA IR will destructure structs and tuples essentially losing the infromation about the initial higher level type. This makes the SSA IR a lot simpler.

ABI Generation

Abi generation is done here where we take the function signature from the frontend and assign witness indices to types depending on how many field elements it takes to generate the type.

The witness indices will start from 1 and the Abi will only be produced for the input parameters. The witnesses for the return type is passed in as a parameter. We can also compute this at the same time, and when we acir gen the body, it will use the return type' witness index, since the code always checks to see if a ValueId has been assigned a witness index.

ACIR Gen

In ACIR gen, the SSA block parameters are linked to the main parameters to a Noir program. See here where we convert each block parameter to a AcirVar and consequently to a Witness.

This needs to match the Abi Gen section, for example consider:

fn main(x : Field) {}

Abi gen will assign x to the witness index 1.

Acir gen will also need to assign the block parameter linked to x, the witness index 1.

We therefore have two different parts in the codebase which are implicitly linked.

Happy Case

One solution to this is that the ssa generation pass produces a map which tells us what AbiParameters (parameters to main) map to block parameters.

This way we can compute AcirGen and it will produce witnesses for block parameters in whatever way it sees fit, then given the map from AbiParameters to block parameters, we can connect it with the map from block parameters to witness indices that AcirGen will have to create a map from Abi Parameters to witness indices.

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor ssa
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants