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

Specializes each Parser and Control by substituting type arguments and constructor parameters. More...

Inheritance diagram for P4::SpecializeAll:

Public Member Functions

 SpecializeAll (ReferenceMap *refMap, TypeMap *typeMap, FrontEndPolicy *policy)
 

Detailed Description

Specializes each Parser and Control by substituting type arguments and constructor parameters.

The primary goal of this pass is to specialize Control and Parser types with instantiations that supply constructor parameters, which is accomplished via Specialize.

This is an iterative process, however: Specialize will only substitute constant values for constructor parameters, but constructor calls may have (a) expressions and (b) other constructor parameters as arguments. Hence, each iteration applies constant folding and then specialization until reaching convergence.

Eventually, all instantiations of Control or Parser type declarations with constructor parameters will be replaced by instantiations of specialized type declarations, at which point it is safe to remove the original (now unused) type declarations.

Precondition
Actual arguments that are suitable for substitution, meaning that this pass must run after SimplifyExpressions.
Postcondition
No declarations nor instantiations remain of Parser or Control types with constructor parameters.