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

Metaprogramming for Loops #907

Closed
2 of 9 tasks
mihaibudiu opened this issue Jan 26, 2021 · 3 comments
Closed
2 of 9 tasks

Metaprogramming for Loops #907

mihaibudiu opened this issue Jan 26, 2021 · 3 comments

Comments

@mihaibudiu
Copy link
Contributor

mihaibudiu commented Jan 26, 2021

Personnel

  • Owner:
  • Supporters: @mbudiu-vmw

Design

  • Document: see below

Implementation

  • p4-spec:
  • p4c:

Process

  • LDWG discussed:
  • LDWG approved:
  • Merged into p4-spec:
  • Merged into p4c:

Here's an (arguably ugly) way to do statically unrolled loops, but which could be very useful in practice:
Define a new preprocessor macro:

#for i (min, max, step)
body
#endfor i

This is expanded by the preprocessor into:

#define i min
#line original
body
#undef i
#define i (min + step)
#line original
body
...
#undef i
#define i (min + ((max - min) / step) * step)
#line original
body
#undef i
@mihaibudiu
Copy link
Contributor Author

Related to #84

@mihaibudiu
Copy link
Contributor Author

mihaibudiu commented Feb 1, 2021

@jnfoster jnfoster changed the title Statically-unrolled loops Metaprogramming for Loops Jun 11, 2021
@jnfoster
Copy link
Collaborator

In the interest of tidying up the set of active issues on the P4 specification repository, I'm marking this as "stalled" and closing it. Of course, we can always re-open it in the future if there is interest in resurrecting it.

Also, we have other issues like #1261 addressing finer-grained proposals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants