P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::ControlPlaneAPI::Helpers Namespace Reference

Classes

struct  Counterlike
 
struct  CounterlikeTraits
 A traits class describing the properties of "counterlike" things. More...
 
struct  CounterlikeTraits< Standard::CounterExtern< Standard::Arch::PNA > >
 CounterlikeTraits<> specialization for CounterExtern for PNA More...
 
struct  CounterlikeTraits< Standard::CounterExtern< Standard::Arch::PSA > >
 CounterlikeTraits<> specialization for CounterExtern for PSA More...
 
struct  CounterlikeTraits< Standard::CounterExtern< Standard::Arch::V1MODEL > >
 CounterlikeTraits<> specialization for CounterExtern for v1model More...
 
struct  CounterlikeTraits< Standard::CounterExtern< Standard::Arch::V1MODEL2020 > >
 
struct  CounterlikeTraits< Standard::MeterExtern< Standard::Arch::PNA > >
 CounterlikeTraits<> specialization for MeterExtern for PNA More...
 
struct  CounterlikeTraits< Standard::MeterExtern< Standard::Arch::PSA > >
 CounterlikeTraits<> specialization for MeterExtern for PSA More...
 
struct  CounterlikeTraits< Standard::MeterExtern< Standard::Arch::V1MODEL > >
 CounterlikeTraits<> specialization for MeterExtern for v1model More...
 
struct  CounterlikeTraits< Standard::MeterExtern< Standard::Arch::V1MODEL2020 > >
 

Functions

template<typename Func >
void forAllEvaluatedBlocks (const IR::Block *block, Func function)
 
std::optional< ExternInstancegetExternInstanceFromProperty (const IR::P4Table *table, const cstring &propertyName, ReferenceMap *refMap, TypeMap *typeMap, bool *isConstructedInPlace)
 
bool isExternPropertyConstructedInPlace (const IR::P4Table *table, const cstring &propertyName)
 
std::string serializeOneAnnotation (const IR::Annotation *annotation)
 Serialize an unstructured @annotation to a string.
 
void serializeOneStructuredAnnotation (const IR::Annotation *annotation, ::p4::config::v1::StructuredAnnotation *structuredAnnotation)
 Serialize a structured @annotation to the appropriate Protobuf message.
 
void serializeOneStructuredAnnotation (const IR::Annotation *annotation, p4configv1::StructuredAnnotation *structuredAnnotation)
 
void serializeStructuredExpression (const IR::Expression *expr, p4configv1::Expression *sExpr)
 
void serializeStructuredKVPair (const IR::NamedExpression *kv, p4configv1::KeyValuePair *sKV)
 
', '@id' and documentation annotations are ignored, as well as

Set all the fields in the @preamble, including the 'annotations' and 'doc' fields. ' annotations whose name satisfies predicate .

int64_t getTableSize (const IR::P4Table *table)
 
template<typename UnaryPredicate >
void setPreamble (::p4::config::v1::Preamble *preamble, p4rt_id_t id, cstring name, cstring alias, const IR::IAnnotated *annotated, UnaryPredicate p)
 
void setPreamble (::p4::config::v1::Preamble *preamble, p4rt_id_t id, cstring name, cstring alias, const IR::IAnnotated *annotated)
 
template<typename Kind >
std::optional< Counterlike< Kind > > getDirectCounterlike (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap)
 
', '@id' and documentation unstructured

Serialize @annotated's P4 annotations and attach them to a P4Info message with an 'annotations' and a 'structured_annotations" field. All structured annotations are included. ' annotations are ignored, as well as annotations whose name satisfies predicate .

template<typename Message , typename UnaryPredicate >
void addAnnotations (Message *message, const IR::IAnnotated *annotated, UnaryPredicate p)
 
template<typename Message >
void addAnnotations (Message *message, const IR::IAnnotated *annotated)
 calls addAnnotations with a unconditionally false predicate.
 
template<typename Message >
void addDocumentation (Message *message, const IR::IAnnotated *annotated)
 ' and '@description' annotations if present.
 

Detailed Description

A collection of helper functions which can be used to implement P4RuntimeArchHandlerIface for different architectures.


Class Documentation

◆ P4::ControlPlaneAPI::Helpers::CounterlikeTraits

struct P4::ControlPlaneAPI::Helpers::CounterlikeTraits
template<typename Kind>
struct P4::ControlPlaneAPI::Helpers::CounterlikeTraits< Kind >

A traits class describing the properties of "counterlike" things.

Function Documentation

◆ addDocumentation()

template<typename Message >
void P4::ControlPlaneAPI::Helpers::addDocumentation ( Message * message,
const IR::IAnnotated * annotated )

' and '@description' annotations if present.

Set the 'doc' field for a P4Info message, using the '

◆ forAllEvaluatedBlocks()

template<typename Func >
void P4::ControlPlaneAPI::Helpers::forAllEvaluatedBlocks ( const IR::Block * block,
Func function )

Visit evaluated blocks under the provided block. Guarantees that each block is visited only once, even if multiple paths to reach it exist.

◆ getDirectCounterlike()

template<typename Kind >
std::optional< Counterlike< Kind > > P4::ControlPlaneAPI::Helpers::getDirectCounterlike ( const IR::P4Table * table,
ReferenceMap * refMap,
TypeMap * typeMap )
Returns
the direct counter associated with @table, if it has one, or std::nullopt otherwise.

◆ getExternInstanceFromProperty()

std::optional< ExternInstance > P4::ControlPlaneAPI::Helpers::getExternInstanceFromProperty ( const IR::P4Table * table,
const cstring & propertyName,
ReferenceMap * refMap,
TypeMap * typeMap,
bool * isConstructedInPlace = nullptr )
Returns
an extern instance defined or referenced by the value of @table's @propertyName property, or std::nullopt if no extern was referenced.

◆ getTableSize()

int64_t P4::ControlPlaneAPI::Helpers::getTableSize ( const IR::P4Table * table)
Returns
@table's size property if available, falling back to the architecture's default size.

◆ isExternPropertyConstructedInPlace()

bool P4::ControlPlaneAPI::Helpers::isExternPropertyConstructedInPlace ( const IR::P4Table * table,
const cstring & propertyName )
Returns
true if the extern instance assigned to property @propertyName for the @table was constructed in-place or outside of teh @table declaration.

◆ setPreamble()

void P4::ControlPlaneAPI::Helpers::setPreamble ( ::p4::config::v1::Preamble * preamble,
p4rt_id_t id,
cstring name,
cstring alias,
const IR::IAnnotated * annotated )
inline

Calls setPreamble with a unconditionally false predicate (no annotation filtered out).