P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
BMV2::HeaderConverter Class Reference
Inheritance diagram for BMV2::HeaderConverter:

Public Member Functions

 HeaderConverter (ConversionContext *ctxt, cstring scalarsName)
 
void addHeaderStacks (const IR::Type_Struct *type)
 
void addTypesAndInstances (const IR::Type_StructLike *type, bool meta)
 
void end_apply (const IR::Node *node) override
 
Visitor::profile_t init_apply (const IR::Node *node) override
 
bool isHeaders (const IR::Type_StructLike *st)
 
bool preorder (const IR::Parameter *param) override
 

Protected Member Functions

void addHeaderField (const cstring &header, const cstring &name, int size, bool is_signed)
 
void addHeaderType (const IR::Type_StructLike *st)
 
Util::JsonArrayaddHeaderUnionFields (cstring hdrName, const IR::Type_HeaderUnion *type)
 
Util::JsonArraypushNewArray (Util::JsonArray *parent)
 

Member Function Documentation

◆ addTypesAndInstances()

void BMV2::HeaderConverter::addTypesAndInstances ( const IR::Type_StructLike * type,
bool meta )

Create header type and header instance from a IR::StructLike type

Parameters
metathis boolean indicates if the struct is a metadata or header.

◆ init_apply()

Visitor::profile_t BMV2::HeaderConverter::init_apply ( const IR::Node * node)
override

We synthesize a "header_type" for each local which has a struct type and we pack all the scalar-typed locals into a 'scalar' type

◆ preorder()

bool BMV2::HeaderConverter::preorder ( const IR::Parameter * param)
override

Generate ctxt->json for header from IR::Block's constructor parameters

The only allowed fields in a struct are: Type_Bits, Type_Bool and Type_Header

header H { bit<32> x; }

struct { bit<32> x; bool y; H h; }

Type_Struct within a Type_Struct, i.e. nested struct, should be flattened apriori.

Precondition
assumes no nested struct in parameters.
Postcondition
none