Skip to content

IR crate#6

Open
0xddom wants to merge 21 commits intomainfrom
dani/ir-crate
Open

IR crate#6
0xddom wants to merge 21 commits intomainfrom
dani/ir-crate

Conversation

@0xddom
Copy link
Copy Markdown
Collaborator

@0xddom 0xddom commented Feb 6, 2026

Final version of the IR crate

@0xddom 0xddom requested a review from a team February 6, 2026 15:20
Copy link
Copy Markdown
Contributor

@iangneal iangneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks fine, though I am missing some context for this project. Where are the end-to-end tests for the IR usage? Overall this is a lot of code and feels a bit under tested.

*self = inner.clone();
}
}
IRAexprImpl::Sum(_, _) => todo!(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for another PR? Or is there an issue attached to these todos?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, since I've been working on and off at this for a while I basically forgot

}
IRBexprImpl::And(exprs) => {
for expr in exprs {
expr.canonicalize();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I misunderstand, but this canonicalizes the inner expressions without then seeing if they can be merged at the top level; for example, (&& (&& a b) (&& c d)) should be canonicalized (I think) to (&& a b c d), but it doesn't appear that this happens here. Same with the OR case.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that idea didn't occur to me... but makes sense

}

#[cfg(test)]
mod tests {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any tests for all the canonicalization logic?


/// Folds the statements if the expressions are constant.
/// If a assert-like statement folds into a tautology (i.e. `(= 0 0 )`) gets removed. If it
/// folds into a unsatisfiable proposition the method returns an error.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't seem particularly relevant here.

@0xddom
Copy link
Copy Markdown
Collaborator Author

0xddom commented Feb 9, 2026

Overall looks fine, though I am missing some context for this project.

This is so low priority that I don't blame you if you don't remember what all this was about. This crate defines the IR used by the lowering pipeline:

  ..> (Uses)                                                  
 --> (Pipeline)                                                     
                                        [ IR (this crate) ] <........                       /-----> [ LLZK backend ]
                                                                    .                       |
( Input circuit ) --------> [ Circuit synthesis ]  --------> [ IR generation ] -----> [ Backend crate ]
                                                                                            |
                                                                                            \-----> [ Picus backend ]

Is in a separate crate from the rest of the IR generation because clients may need to emit custom IR, so this keeps the dependencies simpler and a bit lighter. The rest of the framework currently lives here and my plan is to incrementally merge into main parts of the framework as they pass some quality control in a PR.

Where are the end-to-end tests for the IR usage? Overall this is a lot of code and feels a bit under tested.

The IR has been tested while using it... but you are right that the crate on it's own is under tested. I'll work on that.
I'm splitting the parts of the Halo2 frontend into small PRs but with this one it's still a lot of code...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants