P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo Class Reference
Inheritance diagram for P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo:
[legend]

Public Member Functions

 Bmv2V1ModelProgramInfo (const BMv2V1ModelCompilerResult &compilerResult, ordered_map< cstring, const IR::Type_Declaration * > inputBlocks, std::map< int, int > declIdToGress)
 
 DECLARE_TYPEINFO (Bmv2V1ModelProgramInfo, ProgramInfo)
 
const IR::Expression * dropIsActive () const override
 
const ArchSpecgetArchSpec () const override
 
const IR::PathExpression * getBlockParam (cstring blockLabel, size_t paramIndex) const
 
const BMv2V1ModelCompilerResultgetCompilerResult () const override
 
int getGress (const IR::Type_Declaration *) const
 
P4::P4RuntimeAPI getP4RuntimeAPI () const
 
const IR::Type_Bits * getParserErrorType () const override
 
const ordered_map< cstring, const IR::Type_Declaration * > * getProgrammableBlocks () const
 
const IR::P4Table * getTableofDirectExtern (const IR::IDeclaration *directExternDecl) const
 
const IR::StateVariable & getTargetInputPortVar () const override
 
const IR::StateVariable & getTargetOutputPortVar () const override
 
- Public Member Functions inherited from P4::P4Tools::P4Testgen::ProgramInfo
 ProgramInfo (const ProgramInfo &)=default
 
 ProgramInfo (ProgramInfo &&)=default
 
virtual const IR::Expression * createTargetUninitialized (const IR::Type *type, bool forceTaint) const
 
 DECLARE_TYPEINFO (ProgramInfo)
 
const NodesCallGraphgetCallGraph () const
 
cstring getCanonicalBlockName (cstring programBlockName) const
 
const ConcolicMethodImplsgetConcolicMethodImpls () const
 
const P4::Coverage::CoverageSetgetCoverableNodes () const
 Getter to access coverableNodes.
 
const IR::P4Program & getP4Program () const
 
const std::vector< Continuation::Command > * getPipelineSequence () const
 
std::optional< const IR::Expression * > getTargetConstraints () const
 
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
 

Static Public Member Functions

static const IR::Member * getParserParamVar (const IR::P4Parser *parser, const IR::Type *type, size_t paramIndex, cstring paramLabel)
 
static const IR::Expression * getPortConstraint (const IR::StateVariable &portVar, const std::vector< std::pair< int, int > > &permittedPortRanges)
 

Static Public Attributes

static const ArchSpec ARCH_SPEC
 

Additional Inherited Members

- Protected Member Functions inherited from P4::P4Tools::P4Testgen::ProgramInfo
 ProgramInfo (const TestgenCompilerResult &compilerResult)
 
- Protected Member Functions inherited from P4::RTTI::Base
virtual const void * toImpl (TypeId typeId) const noexcept=0
 
- Protected Attributes inherited from P4::P4Tools::P4Testgen::ProgramInfo
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.
 

Constructor & Destructor Documentation

◆ Bmv2V1ModelProgramInfo()

P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::Bmv2V1ModelProgramInfo ( const BMv2V1ModelCompilerResult & compilerResult,
ordered_map< cstring, const IR::Type_Declaration * > inputBlocks,
std::map< int, int > declIdToGress )

Compute the series of nodes corresponding to the in-order execution of top-level pipeline-component instantiations. For a standard v1model, this produces the parser, the checksum verifier, the MAU pipeline, the checksum calculator, and finally the deparser. This sequence also includes nodes that handle transitions between the individual component instantiations.

Sending a too short packet in BMV2 produces nonsense, so we require the packet size to be larger than 32 bits.This number needs to be raised to the size of the ethernet header for the PTF and PROTOBUF back ends.

Finally, set the target constraints.

Member Function Documentation

◆ dropIsActive()

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

Implements P4::P4Tools::P4Testgen::ProgramInfo.

◆ getArchSpec()

const ArchSpec & P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getArchSpec ( ) const
nodiscardoverridevirtual
See also
ProgramInfo::getArchSpec

Implements P4::P4Tools::P4Testgen::ProgramInfo.

◆ getBlockParam()

const IR::PathExpression * P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getBlockParam ( cstring blockLabel,
size_t paramIndex ) const
nodiscard
Returns
the name of the parameter for a given programmable-block label and the parameter index. This is the name of the parameter that is used in the P4 program.

◆ getCompilerResult()

const BMv2V1ModelCompilerResult & P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getCompilerResult ( ) const
nodiscardoverridevirtual
Returns
a reference to the compiler result that this program info object was initialized with.

Reimplemented from P4::P4Tools::P4Testgen::ProgramInfo.

◆ getGress()

int P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getGress ( const IR::Type_Declaration * decl) const
Returns
the gress associated with the given parser.

◆ getP4RuntimeAPI()

P4::P4RuntimeAPI P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getP4RuntimeAPI ( ) const
nodiscard
Returns
the P4Runtime API produced by the compiler.

◆ getParserErrorType()

const IR::Type_Bits * P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getParserErrorType ( ) const
nodiscardoverridevirtual

◆ getParserParamVar()

const IR::Member * P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getParserParamVar ( const IR::P4Parser * parser,
const IR::Type * type,
size_t paramIndex,
cstring paramLabel )
static
Returns
the Member variable corresponding to the parameter index for the given parameter. The Member variable uses the parameter struct label as parent and the
Parameters
paramLabelas member.
typeis the type of the member. If the parser does not have this parameter (meaning we are dealing with optional parameters) return the canonical name of this variable.

◆ getPortConstraint()

static const IR::Expression * P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getPortConstraint ( const IR::StateVariable & portVar,
const std::vector< std::pair< int, int > > & permittedPortRanges )
static
Returns
the constraint expression for a given port variable.

◆ getProgrammableBlocks()

const ordered_map< cstring, const IR::Type_Declaration * > * P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getProgrammableBlocks ( ) const
nodiscard
Returns
the programmable blocks of the program. Should be 6.

◆ getTableofDirectExtern()

const IR::P4Table * P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getTableofDirectExtern ( const IR::IDeclaration * directExternDecl) const
Returns
the table associated with the direct extern

◆ getTargetInputPortVar()

const IR::StateVariable & P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getTargetInputPortVar ( ) const
nodiscardoverridevirtual
Returns
the metadata member corresponding to the ingress port

Implements P4::P4Tools::P4Testgen::ProgramInfo.

◆ getTargetOutputPortVar()

const IR::StateVariable & P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::getTargetOutputPortVar ( ) const
nodiscardoverridevirtual
Returns
the metadata member corresponding to the final output port

Implements P4::P4Tools::P4Testgen::ProgramInfo.

Member Data Documentation

◆ ARCH_SPEC

const ArchSpec P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelProgramInfo::ARCH_SPEC
static
Initial value:
= ArchSpec(
"V1Switch"_cs, {
{"Parser"_cs, {nullptr, "*hdr"_cs, "*meta"_cs, "*standard_metadata"_cs}},
{"VerifyChecksum"_cs, {"*hdr"_cs, "*meta"_cs}},
{"Ingress"_cs, {"*hdr"_cs, "*meta"_cs, "*standard_metadata"_cs}},
{"Egress"_cs, {"*hdr"_cs, "*meta"_cs, "*standard_metadata"_cs}},
{"ComputeChecksum"_cs, {"*hdr"_cs, "*meta"_cs}},
{"Deparser"_cs, {nullptr, "*hdr"_cs}}})
See also
ProgramInfo::getArchSpec