P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::DoResetHeaders Class Reference

Explicitly invalidate uninitialized header variables. More...

Inheritance diagram for P4::DoResetHeaders:

Public Member Functions

 DoResetHeaders (const TypeMap *typeMap)
 
const IR::Node * postorder (IR::Declaration_Variable *decl) override
 
const IR::Node * postorder (IR::P4Control *control) override
 
const IR::Node * postorder (IR::ParserState *state) override
 

Static Public Member Functions

static void generateResets (const TypeMap *typeMap, const IR::Type *type, const IR::Expression *expr, IR::Vector< IR::StatOrDecl > *resets)
 

Detailed Description

Explicitly invalidate uninitialized header variables.

A local uninitialized variable that represents a header must be initialized to invalid. For example:

state X {
H h;
p.extract(h);
}

becomes

state X {
H h;
h.setInvalid();
p.extract(h);
}

This pass also handles header fields in variables of derived types, like structs and unions.

Precondition
An up-to-date TypeMap.
Postcondition
Uninitialized header variables have explicit statements that invalidate those headers.