p4c icon indicating copy to clipboard operation
p4c copied to clipboard

Add pure/localState/packetStata annotations

Open ChrisDodd opened this issue 5 years ago • 4 comments

  • add annotations in appropriate places in v1mode.p4 and psa.p4
  • fix resolveReferences to look at parameters

ChrisDodd avatar Dec 30 '19 23:12 ChrisDodd

In the interests of moving things forward here, if @pure and @noSideEffects are the only two annotations that we really have good use cases for taking advantage of in compiler optimization passes, would it be better to only add those two, and leave out all of the others?

I apologize if I introduced confusion by describing the other kinds of annotations -- just my over-exuberance in looking for other broader kinds of categories that extern functions/methods fit into, regardless of whether they enabled compiler optimizations.

jafingerhut avatar Jan 29 '20 02:01 jafingerhut

The parts of these changes that add the @pure annotation, and changes to v1model.p4 and psa.p4 architectures to add @pure and @noSideEffects annotations, have been merged with this commit: https://github.com/p4lang/p4c/commit/301411d7ee4cc22d381a923037f840f575635aa2

As of this writing, there is currently no PR that makes the rest of these changes. I do not know if such a thing is of interest, either, until and unless there is a known compiler optimization use case for additional similar annotations.

jafingerhut avatar Apr 09 '20 17:04 jafingerhut

@ChrisDodd @mihaibudiu Does it seem reasonable to close this, since @pure and @noSideEffects have been in the P4 spec and p4c implementation for a couple of years now, and no one seems interested in pursuing other annotations like packetState since then?

jafingerhut avatar Aug 19 '23 19:08 jafingerhut

I have no problem closing this, but it is Chris' PR.

mihaibudiu avatar Sep 01 '23 16:09 mihaibudiu