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

Public Member Functions

 DoCopyStructures (TypeMap *typeMap, bool errorOnMethodCall, bool copyHeaders=false)
 
const IR::Node * postorder (IR::AssignmentStatement *statement) override
 

Detailed Description

Convert assignments between structures to assignments between fields

Examples: struct src { bit<32> hdr; } struct dst { bit<32> hdr; } action test() { dst = src; }

is replaced by

action test() { dst.hdr = src.hdr; }

Further, struct initialization is converted to assignment on struct fields

Note, header assignments are not converted in this pass.

Precondition
none
Postcondition
  • struct to struct copy is replaced by field assignment
  • struct initialization is replaced by field assignment