-
Notifications
You must be signed in to change notification settings - Fork 442
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
Create a new, smaller frontend #4634
Comments
In reply to @ChrisDodd, #4633 (comment):
That is a good point, we want to make sure the program is type-checked in the minimal frontend. The C++ compiler has a similar problem (constexpr values in template parameters or other compile-time contexts), I believe they solve it by interpreting the values in question. We might already have all the infrastructure for that in place as I believe P4testgen already does expression-level constant folding and other optimizations during the symbolic execution (on concrete values, not on symbolic once). Using that (efficiently) in the type checking might require significant refactor though but I am not able to say how much as I am not very familiar with the code. But it would make some things easier. I can even imagine some targets benefiting from not having to inline all the code into the base blocks. To do this, we would need to understand well what needs to happen in frontend and what are requirements of these passes. |
The Petr4 paper claims the type-inference algorithm of P4C does not need to be as complicated as it currently is (Section 4 - Type Checker). One approach could be to write a clean and easily extendable type-inference/checking pass from scratch. Constant folding on This minimal front-end could be nice, then I could reimplement a translation-validation-style tool within the tools framework. Gauntlet, which uses its own type-inference implementation is too hard too maintain currently.
Yes, we extended the ConstantFolding pass to be standalone without requiring a reference or type map. That also applies to StrengthReduction. |
The problem comes when someone wants to do something like |
Thanks for pointing this out. I also wanted to take a look at p4lang/p4-spec#1213 which I believe tries to clear wording around compile-time values.
Could be. The downside of cource is we could end up with two typechecking passes with slightly different bugs. But I that could happen with any gradual approach too and we would probably be get worse code of the type checker that way. First we need to know where in the type system arbitrary expressions are allowed (is it just
Sure, but if type of |
Taking ideas from #4633 to an issue.
The text was updated successfully, but these errors were encountered: