-
Notifications
You must be signed in to change notification settings - Fork 444
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
P4 spec issue 1261 add bounded loops #4120
P4 spec issue 1261 add bounded loops #4120
Conversation
This is NOT a complete implementation of for loops in p4c. It probably isn't even a complete or correct change to the syntax as of the first 2 commits. It is a work in progress that I have used to verify that with these proposed grammar changes, bison does not give an error message when it processes the grammar. |
@jafingerhut Some time ago we implemented bounded loops downstream. They employ Let me know if you'd like me to factor our this change and submit just to have some end-to-end implementation. |
Bounded loops are a top-level agenda item of the P4 language working group for this year: Upstreaming this is a great idea and very useful. How the syntax will end up looking like is a different problem though. |
Sure, I can see what could be done. |
@asl Thanks for the offer. Fabian gave the high order answer. There should be a public meeting focused on the topic of loops in P4 coming up soon-ish (within a month or so), and I can be sure to try to include you in the choice of meeting time so it fits in your schedule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've started looking at loops in the compiler, so I'm looking at what to add in the IR for these, and what is needed in other parts of the compiler.
frontends/parsers/p4/p4parser.ypp
Outdated
forCollectionExpr | ||
: expression | ||
| expression ".." expression | ||
| typeRef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is a typeRef
supposed to indicate here? Creating a temp of the type and then iterating over it?
I added an extra commit with the IR changes for this. |
I've almost finished porting our changes for the loops. I will post a PR shortly |
I ported our downstream code at #4558 Currently use-def changes are missed, I am working on porting them asap. Let me know if there are any questions / comments / suggestions |
I've pulled together both changes in #4562 |
I was not part of the original discussion, so do not know about all the details here. But my understanding is that if the intention is to support bounded loops, then I think it should iterate over collection (or as in my original PR, over explicit range like |
Closing this preliminary PR, as #4562 and other changes by Chris Dodd have been merged in. |
No description provided.