P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::CheckExternInvocationCommon Class Referenceabstract

Base class which can be used to prepare classes for checking constraints for invocations of externs (both methods and pure functions) in parsers and control blocks. More...

Inheritance diagram for P4::CheckExternInvocationCommon:

Public Member Functions

bool preorder (const IR::MethodCallExpression *expr) override
 

Protected Member Functions

 CheckExternInvocationCommon (ReferenceMap *refMap, TypeMap *typeMap)
 
virtual void checkExtern (const ExternFunction *extFunction, const IR::MethodCallExpression *expr)
 Method for checking constraints of extern functions given by parameters.
 
virtual void checkExtern (const ExternMethod *extMethod, const IR::MethodCallExpression *expr)
 Method for checking constraints of extern method given by parameters.
 
void checkPipeConstraints (cstring extType, bitvec bv, const IR::MethodCallExpression *expr, cstring extName, cstring pipe)
 Check if the invocation of extern object method or extern function is valid in the block where it is invoked.
 
cstring extractBlock (bitvec vec)
 Get the name of the block which is represented by bit set in the bitvec.
 
virtual cstring getBlockName (int bit)=0
 Get the name of the block which is represented in bit vector (bitvec) by bit with index given by 'bit' parameter.
 
virtual void initPipeConstraints ()=0
 Method used to initialize the constraints.
 
void setPipeConstraints (cstring extType, bitvec vec)
 Set the pipe (parser/control block) constraints.
 

Protected Attributes

std::map< cstring, bitvecpipeConstraints
 
ReferenceMaprefMap
 
TypeMaptypeMap
 

Detailed Description

Base class which can be used to prepare classes for checking constraints for invocations of externs (both methods and pure functions) in parsers and control blocks.

This class contains basic operations which should be common for checkers used for various targets and architectures.

Example class which inherits from this base class can be seen in backends/dpdk/dpdkCheckExternInvocation.h.

Member Function Documentation

◆ checkExtern() [1/2]

virtual void P4::CheckExternInvocationCommon::checkExtern ( const ExternFunction * extFunction,
const IR::MethodCallExpression * expr )
inlineprotectedvirtual

Method for checking constraints of extern functions given by parameters.

If there are no constraints for extern functions, inheriting class does not need to implement this method.

Parameters
extMethodPointer to object representing extern function.
exprPointer to function call expression.

◆ checkExtern() [2/2]

virtual void P4::CheckExternInvocationCommon::checkExtern ( const ExternMethod * extMethod,
const IR::MethodCallExpression * expr )
inlineprotectedvirtual

Method for checking constraints of extern method given by parameters.

If there are no constraints for extern methods, inheriting class does not need to implement this method.

Parameters
extMethodPointer to object representing extern method.
exprPointer to method call expression.

◆ checkPipeConstraints()

void P4::CheckExternInvocationCommon::checkPipeConstraints ( cstring extType,
bitvec bv,
const IR::MethodCallExpression * expr,
cstring extName,
cstring pipe )
inlineprotected

Check if the invocation of extern object method or extern function is valid in the block where it is invoked.

Parameters
extTypeName of the extern object or extern function.
bvBit vector which has set the bit representing the block in which the extern object method or extern function is invoked.
exprMethod or function call expression.
extNameName of extern object in case of extern object method invocation. Empty string ("") in case of extern function invocation.
pipeName of the parser or control block in which the method or the function is invoked.

◆ extractBlock()

cstring P4::CheckExternInvocationCommon::extractBlock ( bitvec vec)
inlineprotected

Get the name of the block which is represented by bit set in the bitvec.

Parameters
vecBit vector.
Returns
cstring Name of the block represented by index of set bit in the bitvec.

◆ getBlockName()

virtual cstring P4::CheckExternInvocationCommon::getBlockName ( int bit)
protectedpure virtual

Get the name of the block which is represented in bit vector (bitvec) by bit with index given by 'bit' parameter.

Parameters
bitIndex of bit which represents the block in bit vector.
Returns
cstring Name of the block represented by index with 'bit' parameter value.

◆ initPipeConstraints()

virtual void P4::CheckExternInvocationCommon::initPipeConstraints ( )
protectedpure virtual

Method used to initialize the constraints.

Method setPipeConstraints() can be used in implementation of initPipeConstraints() method to initialize the constraints.

Method initPipeConstraints() should be called in the constructor of inheriting class.

◆ setPipeConstraints()

void P4::CheckExternInvocationCommon::setPipeConstraints ( cstring extType,
bitvec vec )
inlineprotected

Set the pipe (parser/control block) constraints.

Should be used in the initPipeConstraints() method.

Parameters
extTypeName of the extern object or function for which we set constraints.
vecBit vector representing the blocks (parser/control) in which the use of extern object method or function is valid.