[P4-dev] annotation of contants

Mihai Budiu mbudiu at vmware.com
Wed Aug 23 13:24:18 EDT 2017


Annotations should not be discarded. But you are showing only the RHS of the declaration (the initializer value), the annotation is on the whole declaration, it should be present on a parent node of the one you are showing.

Mihai

From: Venkat Pullela [mailto:onepullela at gmail.com]
Sent: Wednesday, August 23, 2017 10:22 AM
To: Mihai Budiu <mbudiu at vmware.com>
Cc: p4-dev at lists.p4.org
Subject: Re: [P4-dev] annotation of contants

Thanks Mihai.
Agree it will not make through some passes. I am still thinking that annotation may survive fine in many cases. The sample JSON i sent is one such case. The node type "Constant" made it to JSON, any annotation in the node would have made it to JSON too. This would be very useful.

Are annotations discarded for constants from the beginning?, or is it that it had to be dropped in one of the stages (understandably for not over engineering).

Thanks,
Venkat



On Wed, Aug 23, 2017 at 9:58 AM, Mihai Budiu <mbudiu at vmware.com<mailto:mbudiu at vmware.com>> wrote:
That won’t be easy, since constant values are inlined by the compiler wherever used, and they participate in constant folding and copy propagation. We would have to add significant metadata to the IR to carry such information around through all compiler passes.

This would be difficult to do even for enum values.

Mihai

From: P4-dev [mailto:p4-dev-bounces at lists.p4.org<mailto:p4-dev-bounces at lists.p4.org>] On Behalf Of Venkat Pullela
Sent: Wednesday, August 23, 2017 9:55 AM
To: p4-dev at lists.p4.org<mailto:p4-dev at lists.p4.org>
Subject: [P4-dev] annotation of contants

Hi All,
Is there a way we can retain the names of constants to be included in JSON.

I was looking for some thing like :

@name("CPU_OUT_PORT") const PortId CPU_OUT_PORT = 0xE;

to magically show up in :

"right" : {

                    "Node_ID" : 6750,

                    "Node_Type" : "Constant",

                    "type" : {

                      "Node_ID" : 150

                    },

                    "value" : 14,

                    "base" : 16

                  }

as annotation like "annotations" : { ... }.

Thanks,

Venkat



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170823/106deed0/attachment-0002.html>


More information about the P4-dev mailing list