P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::P4Testgen::ProgramInfo Class Referenceabstract

Stores target-specific information about a P4 program. More...

#include <program_info.h>

Inheritance diagram for P4::P4Tools::P4Testgen::ProgramInfo:
[legend]

Public Member Functions

 ProgramInfo (const ProgramInfo &)=default
 
 ProgramInfo (ProgramInfo &&)=default
 
virtual const IR::Expression * createTargetUninitialized (const IR::Type *type, bool forceTaint) const
 
 DECLARE_TYPEINFO (ProgramInfo)
 
virtual const IR::Expression * dropIsActive () const =0
 
virtual const ArchSpecgetArchSpec () const =0
 
const NodesCallGraphgetCallGraph () const
 
cstring getCanonicalBlockName (cstring programBlockName) const
 
virtual const TestgenCompilerResultgetCompilerResult () const
 
const ConcolicMethodImplsgetConcolicMethodImpls () const
 
const P4::Coverage::CoverageSetgetCoverableNodes () const
 Getter to access coverableNodes.
 
const IR::P4Program & getP4Program () const
 
virtual const IR::Type_Bits * getParserErrorType () const =0
 
const std::vector< Continuation::Command > * getPipelineSequence () const
 
std::optional< const IR::Expression * > getTargetConstraints () const
 
virtual const IR::StateVariable & getTargetInputPortVar () const =0
 
virtual const IR::StateVariable & getTargetOutputPortVar () const =0
 
ProgramInfooperator= (const ProgramInfo &)=default
 
ProgramInfooperator= (ProgramInfo &&)=default
 
void produceCopyInOutCall (const IR::Parameter *param, size_t paramIdx, const ArchSpec::ArchMember *archMember, std::vector< Continuation::Command > *copyIns, std::vector< Continuation::Command > *copyOuts) const
 
- Public Member Functions inherited from P4::ICastable
template<typename T >
T & as ()
 Tries to convert the class to type T. A BUG occurs if the cast fails.
 
template<typename T >
const T & as () const
 Tries to convert the class to type T. A BUG occurs if the cast fails.
 
template<typename T >
T * checkedTo ()
 Performs a checked cast. A BUG occurs if the cast fails.
 
template<typename T >
const T * checkedTo () const
 Performs a checked cast. A BUG occurs if the cast fails.
 
- Public Member Functions inherited from P4::RTTI::Base
template<typename T >
bool is () const noexcept
 
virtual bool isA (TypeId typeId) const noexcept=0
 
template<typename T >
const T * to () const noexcept
 Same as to, but returns const pointer to T.
 
template<typename T >
T * to () noexcept
 
virtual TypeId typeId () const noexcept=0
 

Protected Member Functions

 ProgramInfo (const TestgenCompilerResult &compilerResult)
 
- Protected Member Functions inherited from P4::RTTI::Base
virtual const void * toImpl (TypeId typeId) const noexcept=0
 

Protected Attributes

ordered_map< cstring, cstringblockMap
 Maps the programmable blocks in the P4 program to their canonical counterpart.
 
ConcolicMethodImpls concolicMethodImpls
 
std::vector< Continuation::Command > pipelineSequence
 The execution sequence of the P4 program.
 
std::optional< const IR::Expression * > targetConstraints = std::nullopt
 The constraints imposed by the target.
 

Detailed Description

Stores target-specific information about a P4 program.

Member Function Documentation

◆ createTargetUninitialized()

const IR::Expression * P4::P4Tools::P4Testgen::ProgramInfo::createTargetUninitialized ( const IR::Type * type,
bool forceTaint ) const
virtual
Returns
the default value for uninitialized variables for this particular target. This can be a taint variable or simply 0 (bits) or false (booleans). If
Parameters
forceTaintis active, this function always returns a taint variable.

◆ dropIsActive()

virtual const IR::Expression * P4::P4Tools::P4Testgen::ProgramInfo::dropIsActive ( ) const
nodiscardpure virtual
Returns
an expression that checks whether the packet is to be dropped. The computation is target specific.

Implemented in P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo, P4::P4Tools::P4Testgen::EBPF::EBPFProgramInfo, and P4::P4Tools::P4Testgen::Pna::SharedPnaProgramInfo.

◆ getArchSpec()

virtual const ArchSpec & P4::P4Tools::P4Testgen::ProgramInfo::getArchSpec ( ) const
nodiscardpure virtual

A vector that maps the architecture parameters of each pipe to the corresponding global architecture variables. For example, this map specifies which parameter of each pipe refers to the input header.

Returns
a reference to the architecture map defined in this target

Implemented in P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo, P4::P4Tools::P4Testgen::EBPF::EBPFProgramInfo, and P4::P4Tools::P4Testgen::Pna::PnaDpdkProgramInfo.

◆ getCallGraph()

const NodesCallGraph & P4::P4Tools::P4Testgen::ProgramInfo::getCallGraph ( ) const
nodiscard
Returns
the call graph associated with this ProgramInfo.

◆ getCanonicalBlockName()

cstring P4::P4Tools::P4Testgen::ProgramInfo::getCanonicalBlockName ( cstring programBlockName) const
nodiscard
Returns
the canonical name of the program block that is passed in. Throws a BUG, if the name can not be found.

◆ getCompilerResult()

const TestgenCompilerResult & P4::P4Tools::P4Testgen::ProgramInfo::getCompilerResult ( ) const
nodiscardvirtual
Returns
a reference to the compiler result that this program info object was initialized with.

Reimplemented in P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo.

◆ getConcolicMethodImpls()

const ConcolicMethodImpls * P4::P4Tools::P4Testgen::ProgramInfo::getConcolicMethodImpls ( ) const
nodiscard
Returns
the list of implemented concolic methods for this particular program.

◆ getP4Program()

const IR::P4Program & P4::P4Tools::P4Testgen::ProgramInfo::getP4Program ( ) const
nodiscard
Returns
the P4 program associated with this ProgramInfo.

◆ getPipelineSequence()

const std::vector< Continuation::Command > * P4::P4Tools::P4Testgen::ProgramInfo::getPipelineSequence ( ) const
nodiscard
Returns
the series of nodes that has been computed by this particular target.

◆ getTargetConstraints()

std::optional< const IR::Expression * > P4::P4Tools::P4Testgen::ProgramInfo::getTargetConstraints ( ) const
nodiscard
Returns
the constraints of this target. These constraints can influence the execution of the interpreter

◆ getTargetInputPortVar()

virtual const IR::StateVariable & P4::P4Tools::P4Testgen::ProgramInfo::getTargetInputPortVar ( ) const
nodiscardpure virtual

◆ getTargetOutputPortVar()

virtual const IR::StateVariable & P4::P4Tools::P4Testgen::ProgramInfo::getTargetOutputPortVar ( ) const
nodiscardpure virtual

◆ produceCopyInOutCall()

void P4::P4Tools::P4Testgen::ProgramInfo::produceCopyInOutCall ( const IR::Parameter * param,
size_t paramIdx,
const ArchSpec::ArchMember * archMember,
std::vector< Continuation::Command > * copyIns,
std::vector< Continuation::Command > * copyOuts ) const

Helper function to produce copy-in and copy-out helper calls. Copy-in and copy-out is needed to correctly model the value changes of data when it is copied in and out of a programmable block. In many cases, data is reset here or not even copied. TODO: Find a more efficient way to implement copy-in/copy-out. These functions are very expensive.

Member Data Documentation

◆ concolicMethodImpls

ConcolicMethodImpls P4::P4Tools::P4Testgen::ProgramInfo::concolicMethodImpls
protected

The list of concolic methods implemented by the target. This list is assembled during initialization.