[P4-dev] annotation of contants

Venkat Pullela onepullela at gmail.com
Wed Aug 23 13:22:05 EDT 2017


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> 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] *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/d81e86a5/attachment-0002.html>


More information about the P4-dev mailing list