P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::DoTableKeyNames Class Referencefinal
Inheritance diagram for P4::DoTableKeyNames:

Public Member Functions

 DoTableKeyNames (const TypeMap *typeMap)
 
const IR::Node * postorder (IR::KeyElement *keyElement) override
 

Detailed Description

Adds a "@name" annotation to each table key that does not have a name. The string used for the name is derived from the expression itself - if the expression is "simple" enough. If the expression is not simple the compiler will give an error. Simple expressions are:

  • .isValid(),
  • ArrayIndex,
  • Constant,
  • Member,
  • PathExpression,
  • Slice.

Examples of control plane names generated from expressions:

  • arr[16w5].f : @name("arr[5].f")
  • .foo : @name(".foo")
  • foo.bar : @name("foo.bar")
  • f.isValid() : @name("f.isValid()")
  • f[3:0] : @name("f[3:0]")
Precondition
This must run before passes that change key expressions, eg. constant folding. Otherwise the generated control plane names may not match the syntax of the original P4 program.
Postcondition
All key fields have @name annotations.

Emit a compilation error if the program contains complex key expressions without @name annotations.