-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
At present we have a bunch of things that call themselves Passes - ConstantFoldPass, MonomorphizePass, RemoveDeadFuncsPass.
Each of these has its own copy of code to allow setting a ValidationLevel, and some have other pass-specific configuration. There is no common interface - the idea of a "pass" is purely conceptual. They then run via ValidationLevel::run_validated_pass with a callback (leading to quite a complicated signature, and possibly fun with the borrow-checker).
We could improve on this via:
- A
trait Passwhich could be roughly,fn run(h: &mut impl HugrMut) -> Result<(), Self::Error>(plus associated typeError) - A
ValidatingPass<P: Pass>(P, ValidationLevel)that wraps another pass with something like the current ValidationLevel but without ValidationLevel::None. We could have a singleValidationPassError<E>that reports either an error in validation (before/after) or an underlying errorE - Some kind of "SequencePass" that wraps a bunch of other passes (I think this would have to use
dynso maybe just two arbitrary passes) - and we can add methods totrait Passthat combine Passes e.g.and_then(other: impl Pass) -> impl Pass. This would combine with the previous to allow validation before/after a number of passes but not at steps inbetween. - Maybe common config for specifying inputs, reachable functions, anything else - e.g. constant folding: FuncDefns and FuncDecls are not considered neededย #1797 / Decide on which functions are "public"ย #1752
ss2165
Metadata
Metadata
Assignees
Labels
No labels