P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::RemoveUnusedActionParameters Class Reference
Inheritance diagram for P4::RemoveUnusedActionParameters:

Public Member Functions

 RemoveUnusedActionParameters (ReferenceMap *refMap)
 
const IR::Node * postorder (IR::P4Action *action) override
 

Detailed Description

Removes action parameters which are never referenced.

This can reduce the amount of space required to represent a table, because it reduces the amount of action data. However, in the absence of special target-specific features to support it, this optimization changes the control plane API. For that reason, it's generally not applied for P4-16 programs, since it can be quite surprising if commenting out a block of code changes the control plane API. Some P4-14 compilers did apply this optimization, though, and in those cases it's necessary for backwards compatibility.

action a(bit<32> x, bit<32> y) { some_extern(x); }

is converted to

action a(bit<32> x) { some_extern(x); }
Precondition
No preconditions.
Postcondition
Unused action parameters are removed.