p4lang / project-ideas

Ideas for P4 Projects.
Apache License 2.0
6 stars 0 forks source link

Full support for `if` statements within actions for BMv2 #9

Closed jafingerhut closed 6 days ago

jafingerhut commented 1 month ago

Status as of 2024-Nov-08: This is done in the p4 BMv2 back end, in any version of p4c after this PR was merged in on 2024-Nov-08:https://github.com/p4lang/p4c/pull/4999

I have updated the articles linked below to say that if statements within action bodies is now fully supported, as long as you use a recent-enough version of p4c.

See this article:

Especially this section on BMv2:

This should not require any changes to BMv2, as BMv2 already has support for jump statements within the definitions of actions in the BMv2 JSON file.

It does require probably significant changes in the BMv2 back end code of p4c, to generate different BMv2 JSON files for P4 programs with if statements in action bodies. It would be good to eliminate the Predication pass in the compiler when compiling programs for the BMv2 back end, since it has several bugs, and there is no reason that I can think of to use it any longer if more general if statement support was added.