[P4-dev] annotation of contants

Mihai Budiu mbudiu at vmware.com
Wed Aug 23 12:58:22 EDT 2017


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] On Behalf Of Venkat Pullela
Sent: Wednesday, August 23, 2017 9:55 AM
To: 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/223b0632/attachment-0002.html>


More information about the P4-dev mailing list