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

Public Member Functions

const IR::Node * postorder (IR::Entry *entry) override
 
const IR::Node * postorder (IR::KeyElement *key) override
 

Detailed Description

Adds a bit<1> cast to all boolean keys. This is because these keys need to be converted into bit expressions for the control plane. Also replaces all the corresponding entries in the table with the appropriate expression. Example:

table t {
key = { h.a : exact; }
const entries = {
true : action();
+ }
}
apply {
t.apply();
}

is transformed to

table t {
key = { (bit<1>) h.a : exact; }
const entries = {
1w1 : action();
+ }
}
apply {
t.apply();
}
Precondition
none
Postcondition
all boolean table key expressions are replaced with a bit<1> cast. Constant entries are replaced with 1w1 (true) or 1w0 (false).