Skip to content
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

p4RuntimeSerializer does not support stack field references in match keys #291

Closed
antoninbas opened this issue Feb 9, 2017 · 12 comments · Fixed by #294
Closed

p4RuntimeSerializer does not support stack field references in match keys #291

antoninbas opened this issue Feb 9, 2017 · 12 comments · Fixed by #294
Assignees
Labels
enhancement This topic discusses an improvement to existing compiler code.

Comments

@antoninbas
Copy link
Member

The attached program produces the following output:

antonin@ubuntu:~/Documents/p4lang/p4c/build$ ./p4c-bm2-ss --p4-14 stack_ref.p4.txt --p4runtime-file i.bin
stack_ref.p4.txt(11): error: Expression '[]' is too complicated to resolve to a header field
table t { reads { stack[0].f0 : ternary; } }
                  ^^^^^^^^
stack_ref.p4.txt(11): error: Table 't': Match field '[].f0' is too complicated to represent in P4Runtime
table t { reads { stack[0].f0 : ternary; } }

stack_ref.p4.txt

@antoninbas antoninbas added enhancement This topic discusses an improvement to existing compiler code. p4runtime labels Feb 9, 2017
@antoninbas
Copy link
Member Author

To observe this output, this fix is needed: #290. Otherwise the compiler crashes.

@sethfowler
Copy link
Contributor

This is a known problem; header stack references in match keys were something I left for future work in an effort to get p4RuntimeSerializer merged more quickly. I'll cook up a patch.

@sethfowler
Copy link
Contributor

That error should also refer to stack[0].f0 rather than [].f0. I'll see if I can't fix that, too, though it's not immediately obvious to me why it's happening.

@mihaibudiu
Copy link
Contributor

In P4-16 array indexes do not have to be constant values.
If you just use the toString on an array index expression it will skip the index.

@sethfowler
Copy link
Contributor

And that's what ::error() is using internally?

@mihaibudiu
Copy link
Contributor

Yes, ::error calls toString.
BUG calls dbprint
This is documented in the powerpoint in docs/.

@sethfowler
Copy link
Contributor

OK. So I suppose this is a general problem with any compiler error we report involving a header stack, then. Should we change toString()'s behavior to print the index expression, or is there a reason to prefer the current behavior?

@ChrisDodd
Copy link
Contributor

ChrisDodd commented Feb 9, 2017 via email

@mihaibudiu
Copy link
Contributor

This is a problem of usability; if the index expression is complex the error message may be more obscure.
dbprint prints compiler internals, we cannot use that for user errors.

@sethfowler
Copy link
Contributor

The consequence of the current approach is that errors messages refer to code that isn't valid P4 and doesn't actually appear in the program anywhere, though. =\

@mihaibudiu
Copy link
Contributor

If the error refers to an IR node with source position the source code will be quoted exactly.
The rest of the error message should be as informative to the human as possible.

@sethfowler
Copy link
Contributor

It sounds like it would be simplest not to address that issue as part of this PR. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This topic discusses an improvement to existing compiler code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants