P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::DoSetHeaders Class Referencefinal
Inheritance diagram for P4::DoSetHeaders:

Public Member Functions

 DoSetHeaders (ReferenceMap *refMap, TypeMap *typeMap)
 
const IR::Node * postorder (IR::AssignmentStatement *assign) override
 

Detailed Description

Assigning a list expression to a header should also set the header validity bit. For example, given:

header H { ... }; struct S { H h; } S s;

The following fragment:

s = { { 1, 2 } };

is converted to:

s.h.setValid(); s = { { 1, 2 } };

Precondition
This pass should be run after RemoveInitializers - it only looks at assignment statements. It should also run after SideEffectOrdering, because that pass inserts temporaries for the case of tuples passed as arguments to functions expecting headers, reducing them to assignments.