-
Notifications
You must be signed in to change notification settings - Fork 82
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
Clarify whether P4-16 allows switch
statements in actions
#1362
Comments
I have no objections language-wise to allowing Historically, my initial proposed implementation of |
@jafingerhut I suppose that a backend that cannot support
|
@kfcripps -- having two distinct midend passes definitely makes sense. It might even make sense to have an additional annotation to guide the compiler, e.g. in case the desugaring happens inside a control, where both approaches should be possible and the compiler might have difficulty choosing one method over another. The implementation that uses |
Another option would be:
Is #3 possibly the best choice for back ends that can optimize switch statements inside actions, in the implementation on their target? If we really want P4 programs that have switch statements inside of actions to work on BMv2 (without updating BMv2), then yes, at least an option to replace such switch statements with |
Ah, there were already a couple of PRs merged several years ago that intended to allow I think there are just a couple of places in the spec (mentioned in the issue description) that were missed by #945 and need to be cleaned up. If nobody has any objection to this, I can open a PR to do that. |
I would say it is. Luckily we can always just not use the desugaring passes for them :-). Side note: this is another case that highlights that we should have some more flexibility than |
IIRC there are already command line options for p4c for completely skipping arbitrary passes. I don't think p4c CI ever uses that today, but such tests could be developed. |
Current behavior of the
p4c
compiler is:EliminateSwitch
midend pass:switch
statements in actions for backends that do not run theEliminateSwitch
midend pass.p4c
repository because thep4test
backend does run theEliminateSwitch
midend pass.However, the P4-16 spec seems to indicate that
switch
statements are not supported in actions at all.Should the P4-16 spec be modified to allow
switch
statements in actions? Or should the above error message be moved to a frontend pass that is by default run for all backends?Below is an example program, which backends that do not run
EliminateSwitch
do accept, and backends that do runEliminateSwitch
do not accept.The text was updated successfully, but these errors were encountered: