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

Specializes each generic function by substituting type parameters. More...

Inheritance diagram for P4::SpecializeFunctions:

Public Member Functions

 SpecializeFunctions (FunctionSpecializationMap *specMap)
 
const IR::Node * insert (const IR::Node *before)
 
const IR::Node * postorder (IR::Function *function) override
 
const IR::Node * postorder (IR::MethodCallExpression *) override
 
const IR::Node * preorder (IR::Function *function) override
 
const IR::Node * preorder (IR::P4Control *control) override
 
const IR::Node * preorder (IR::P4Parser *parser) override
 

Detailed Description

Specializes each generic function by substituting type parameters.

For example:

T f<T>(in T data) { return data; }
...
bit<32> b = f(32w0);

generates the following extra code:

bit<32> f_0(in bit<32> data) { return data; }
...
bit<32> b = f_0(32w0);

A different specialization is made for each function invocation.