P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch > Class Template Reference

#include <p4RuntimeArchStandard.h>

Inheritance diagram for P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >:
[legend]

Protected Types

using ArchCounterExtern = CounterExtern<arch>
 
using ArchMeterExtern = MeterExtern<arch>
 
using Counter = p4configv1::Counter
 
using CounterSpec = p4configv1::CounterSpec
 
using CounterTraits = Helpers::CounterlikeTraits<ArchCounterExtern>
 
using Meter = p4configv1::Meter
 
using MeterSpec = p4configv1::MeterSpec
 
using MeterTraits = Helpers::CounterlikeTraits<ArchMeterExtern>
 

Protected Member Functions

 P4RuntimeArchHandlerCommon (ReferenceMap *refMap, TypeMap *typeMap, const IR::ToplevelBlock *evaluatedProgram)
 
void addActionProfile (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const ActionProfile &actionProfile)
 
void addCounter (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Helpers::Counterlike< ArchCounterExtern > &counterInstance)
 
void addDigest (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Digest &digest)
 
void addExternEntries (const p4::v1::WriteRequest *, const P4RuntimeSymbolTableIface &, const IR::ExternBlock *) override
 This method is called to add target specific extern entries.
 
void addExternFunction (const P4RuntimeSymbolTableIface &, p4configv1::P4Info *, const P4::ExternFunction *) override
 
void addExternInstance (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info, const IR::ExternBlock *externBlock) override
 
void addMeter (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Helpers::Counterlike< ArchMeterExtern > &meterInstance)
 
void addRegister (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Register &registerInstance)
 
void addTableProperties (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info, p4configv1::Table *table, const IR::TableBlock *tableBlock) override
 
void collectAssignmentStatement (P4RuntimeSymbolTableIface *, const IR::AssignmentStatement *) override
 Collects architecture-specific used in assignment statements.
 
void collectExternFunction (P4RuntimeSymbolTableIface *symbols, const P4::ExternFunction *externFunction) override
 
void collectExternInstance (P4RuntimeSymbolTableIface *symbols, const IR::ExternBlock *externBlock) override
 Collects architecture-specific @externBlock instance in @symbols table.
 
void collectExternMethod (P4RuntimeSymbolTableIface *, const P4::ExternMethod *) override
 Collects architecture-specific @externMethod instance in @symbols table.
 
void collectExtra (P4RuntimeSymbolTableIface *symbols) override
 
void collectTableProperties (P4RuntimeSymbolTableIface *symbols, const IR::TableBlock *tableBlock) override
 
bool filterAnnotations (cstring) override
 called when processing annotations via setPreamble
 
google::protobuf::util::JsonPrintOptions getJsonPrintOptions () override
 Control how JSON is output.
 
void postAdd (const P4RuntimeSymbolTableIface &, ::p4::config::v1::P4Info *) override
 
void postCollect (const P4RuntimeSymbolTableIface &symbols) override
 
template<typename Kind >
void setCounterCommon (const P4RuntimeSymbolTableIface &symbols, Kind *counter, p4rt_id_t id, const Helpers::Counterlike< ArchCounterExtern > &counterInstance)
 Set common fields between Counter and DirectCounter.
 
template<typename Kind >
void setMeterCommon (const P4RuntimeSymbolTableIface &symbols, Kind *meter, p4rt_id_t id, const Helpers::Counterlike< ArchMeterExtern > &meterInstance)
 Set common fields between Meter and DirectMeter.
 

Static Protected Member Functions

static std::optional< ActionProfilegetActionProfile (const IR::ExternBlock *instance)
 
static std::optional< ActionProfilegetActionProfile (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap)
 
static std::optional< ActionProfilegetActionProfile (cstring name, const IR::Type_Extern *type, int64_t size, const IR::IAnnotated *annotations)
 
static const IR::IAnnotated * getTableImplementationAnnotations (const IR::P4Table *table, ReferenceMap *refMap)
 
static std::optional< cstringgetTableImplementationName (const IR::P4Table *table, ReferenceMap *refMap)
 
static const IR::Property * getTableImplementationProperty (const IR::P4Table *table)
 

Protected Attributes

std::unordered_map< cstring, std::set< cstring > > actionProfilesRefs
 
const IR::ToplevelBlock * evaluatedProgram
 
google::protobuf::util::JsonPrintOptions jsonPrintOptions
 
ReferenceMaprefMap
 
std::set< p4rt_id_t > serializedInstances
 The extern instances we've serialized so far. Used for deduplication.
 
TypeMaptypeMap
 

Additional Inherited Members

- Public Member Functions inherited from P4::ControlPlaneAPI::P4RuntimeArchHandlerIface
virtual void addExternFunction (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, const P4::ExternFunction *externFunction)=0
 
virtual void addExternInstance (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, const IR::ExternBlock *externBlock)=0
 
virtual void addTableProperties (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, ::p4::config::v1::Table *table, const IR::TableBlock *tableBlock)=0
 
virtual cstring getControlPlaneName (const IR::Block *block)
 Get control plane name for @block.
 

Detailed Description

template<Arch arch>
class P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >

Parent class for P4RuntimeArchHandlerV1Model and P4RuntimeArchHandlerPSA; it includes all the common code between the two architectures (which is only dependent on the @arch template parameter. The major difference at the moment is handling of digest, which is an extern function in v1model and an extern type in PSA.

Member Function Documentation

◆ addExternEntries()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::addExternEntries ( const p4::v1::WriteRequest * entries,
const P4RuntimeSymbolTableIface & symbols,
const IR::ExternBlock * externBlock )
inlineoverrideprotectedvirtual

This method is called to add target specific extern entries.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ collectAssignmentStatement()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::collectAssignmentStatement ( P4RuntimeSymbolTableIface * symbols,
const IR::AssignmentStatement * assign )
inlineoverrideprotectedvirtual

Collects architecture-specific used in assignment statements.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ collectExternFunction()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::collectExternFunction ( P4RuntimeSymbolTableIface * symbols,
const P4::ExternFunction * externFunction )
inlineoverrideprotectedvirtual

Collects extern method call @externFunction in @symbols table in case it needs to be exposed to the control-plane (e.g. digest call for v1model).

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

Reimplemented in P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerV1Model.

◆ collectExternInstance()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::collectExternInstance ( P4RuntimeSymbolTableIface * symbols,
const IR::ExternBlock * externBlock )
inlineoverrideprotectedvirtual

◆ collectExternMethod()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::collectExternMethod ( P4RuntimeSymbolTableIface * symbols,
const P4::ExternMethod * externMethod )
inlineoverrideprotectedvirtual

Collects architecture-specific @externMethod instance in @symbols table.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ collectExtra()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::collectExtra ( P4RuntimeSymbolTableIface * symbols)
inlineoverrideprotectedvirtual

Collects any extra symbols you may want to include in the symbol table and that are not covered by the above collection methods.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ collectTableProperties()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::collectTableProperties ( P4RuntimeSymbolTableIface * symbols,
const IR::TableBlock * tableBlock )
inlineoverrideprotectedvirtual

Collects architecture-specific properties for @tableBlock in @symbols table.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ filterAnnotations()

template<Arch arch>
bool P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::filterAnnotations ( cstring anno)
inlineoverrideprotectedvirtual

called when processing annotations via setPreamble

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ getActionProfile() [1/2]

template<Arch arch>
static std::optional< ActionProfile > P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::getActionProfile ( const IR::ExternBlock * instance)
inlinestaticprotected
Returns
the action profile declared with @decl

◆ getActionProfile() [2/2]

template<Arch arch>
static std::optional< ActionProfile > P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::getActionProfile ( const IR::P4Table * table,
ReferenceMap * refMap,
TypeMap * typeMap )
inlinestaticprotected
Returns
the action profile referenced in @table's implementation property, if it has one, or std::nullopt otherwise.

◆ getJsonPrintOptions()

template<Arch arch>
google::protobuf::util::JsonPrintOptions P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::getJsonPrintOptions ( )
inlineoverrideprotectedvirtual

Control how JSON is output.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ getTableImplementationProperty()

template<Arch arch>
static const IR::Property * P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::getTableImplementationProperty ( const IR::P4Table * table)
inlinestaticprotected
Returns
the table implementation property, or nullptr if the table has no such property.

◆ postAdd()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::postAdd ( const P4RuntimeSymbolTableIface & symbols,
::p4::config::v1::P4Info * p4info )
inlineoverrideprotectedvirtual

This method is called after the add pass in case the architecture requires some logic to be performed then.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ postCollect()

template<Arch arch>
void P4::ControlPlaneAPI::Standard::P4RuntimeArchHandlerCommon< arch >::postCollect ( const P4RuntimeSymbolTableIface & symbols)
inlineoverrideprotectedvirtual

This method is called between the two passes (collect and add) in case the architecture requires some logic to be performed then.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.