[P4-design] Deparse emit of Header Union

Andy Keep (akeep) akeep at cisco.com
Fri Aug 4 09:58:28 EDT 2017

Hey David,

It might be a little unclear, but I think the document is correct.  What the code there does, is look for each field within the header union (which are the individual headers in the union) and then recursively call emit on them, where the validity bit will be checked on the individual header.  Since the header union ensures that no more than one header in the union can ever be valid, it will emit the data for only the valid header (if there is one).


On August 4, 2017 at 9:30:53 AM, David George (david.george at netronome.com<mailto:david.george at netronome.com>) wrote:

Am I correct in saying that emitting a header_union will result in all fields of all member to be written out whether valid or not? I believe this is what the spec implies:

>> else if (isHeaderUnion(T) || isStruct(T))
>>      for (f : data.fields$)
>>            emit(e.f)

I believe the sensible behaviour should be to emit only the valid one.

David George
P4-design mailing list
P4-design at lists.p4.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-design_lists.p4.org/attachments/20170804/aab54a1f/attachment-0002.html>

More information about the P4-design mailing list