-
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
Add struct with emit to bmv2 backend #1659
Comments
Have you tested the program? |
Here is a short test program that fails. The failure log is included first, followed by the test P4 program.
|
This error is provided by the front-end and is in conformance with the Section 15 of the language spec. |
In a private workspace few weeks back, I had changed the frontend code, also the midend ExpandEmit pass, and then the bmv2 deparser gave me the error. When I get a chance during the next few days, I'd be happy to ressurect that code changes and add a log. |
I created this workspace to add code changes to create the bmv2 failure for emit with struct. https://github.com/hesingh/emit-struct In the workspace, the shorter test P4 program is included in path testdata/p4_16_samples/emit-struct.p4 creates the problem. Please see test log below.
|
Hello everyone, |
See this commit to p4c which added We have discussed emit and base types in this Issue. Search for "emit" in the note below to see the discussion. Once code is changed by fixing this Issue, then the p4-spec will also be changed for text in Section 14. |
@hesingh: In the original issue you created, you wrote: "The bmv2 backend implementation should be as close to the P4-16 specification as possible. The specification supports emit for a struct, but the bmv2 backend does not. We should add the support to the bmv2 backend." The P4_16 specification at this time says that you can call emit on a struct, but only if that struct contains nothing but members with type header, header stack, and/or header_union. I believe p4c and simple_switch support that already today. If so, then the implementations are following the language spec on this issue. Do you see anything between them that differs? |
The bmv2 backend has an issue that it does not even allow a struct with emit as shown in a log I added. See the URL below. |
That emit is for a struct type that contains members that are not headers, not header stacks, and not header_union. Thus the P4_16 language spec says it should be illegal. Do you agree? |
Ah, got it. I was only looking at the top-level emit expression which is a struct. But, then I see section 15.1 saying "emit calls itself recursively over fields in the struct". This is when emit would hit a base type which is not allowed. Now we have a separate discussion, which is to allow emit of struct with base types, if anyone has a good use case. |
The bmv2 backend implementation should be as close to the P4-16 specification as possible. The specification supports emit for a struct, but the bmv2 backend does not. We should add the support to the bmv2 backend.
See p4c/backends/bmv2/common/deparser.cpp and this code:
The text was updated successfully, but these errors were encountered: