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

Is value_set's size compile-time known? #1347

Open
jaehyun1ee opened this issue Nov 25, 2024 · 4 comments
Open

Is value_set's size compile-time known? #1347

jaehyun1ee opened this issue Nov 25, 2024 · 4 comments

Comments

@jaehyun1ee
Copy link
Contributor

jaehyun1ee commented Nov 25, 2024

The spec mentions about the size argument to a value_set constructor:

Parser Value Sets support a size argument to provide hints to the compiler to reserve hardware resources to implement the value set.

Although the phrase "hints to the compiler" already implies that the size argument should be a local** compile-time known value, can we make it clearly written in the spec? (** edited)

@jafingerhut
Copy link
Collaborator

Does p4c currently support using a constructor parameter of a control as the size of a value_set? Or the size of a P4 table?

I hope that the answer is "yes". At least, I can imagine scenarios where that would be a nice-to-have choice available, as a P4 developer.

If yes, then I would recommend against specifying that these should be local compile-time known values.

@jaehyun1ee
Copy link
Contributor Author

Ah, yes, thank you for the comment :) The P4 spec mentions about the size property of a table,

When present, its value must always be a compile-time known value that is an integer.

So I would instead propose: size argument to a value_set constructor should be a compile-time known value.

@jafingerhut
Copy link
Collaborator

Adding an explicit restriction that the size parameter of a value_set must be compile-time known seems reasonable to me. If it is not already explicitly stated that the value of a table's size property must be compile-time known, that also seems like a reasonable addition.

@jaehyun1ee
Copy link
Contributor Author

Thank you for the comment! I made a related PR :)

@jaehyun1ee jaehyun1ee changed the title Is value_set's size (local) compile-time known? Is value_set's size compile-time known? Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants