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

Public Member Functions

 DoConvertEnums (ChooseEnumRepresentation *policy, TypeMap *typeMap)
 
const IR::Node * postorder (IR::Member *expression) override
 process enum expression, e.g., X.a
 
const IR::Node * postorder (IR::Type_Name *type) override
 
const IR::Node * preorder (IR::Type_Enum *type) override
 

Friends

class ConvertEnums
 

Detailed Description

implement a pass to convert Type_Enum to Type_Bits

User must provide a class to extend ChooseEnumRepresentation to specify the width of the generated Type_Bits. User must also implement a policy to decide whether an Enum type shall be converted.

Example:

enum e { A, B, }

struct st { // Type_Name A a; }

if the policy is to convert enum to bit<32>, then the above is replaced by:

struct st { // Type_Bits bit<32> a; }

Precondition
none
Postcondition
all Type_Enum types accepted by 'policy' are converted.