Two tests in p4c use a ternary match on bool and error types. However, it is unclear what its semantics should be.
The specification mentions about ternary as:
a ternary match kind on a key field means that the field in the table specifies a set of values for the key field using a value and a mask. The meaning of the (value, mask) pair is similar to the P4 mask expressions, as described in Section 8.15.3: a key field k matches the table entry when k & mask == value & mask.
Thus, a ternary match makes sense for numeric types, but I'm not sure what its semantics is for non-numeric types, and whether they should be allowed at the first place.
Below are the two tests in p4c that exhibit such use case:
struct meta_t {
/* ... omitted ... */
error err_field; // error code
}
control ingress(
inout headers_t hdr,
inout meta_t meta,
inout standard_metadata_t standard_metadata)
table custom_table {
key = {
/* ... omitted ... */
meta.err_field : ternary;
}
actions = {
set_output;
set_headers;
my_drop;
}
default_action = my_drop();
}
}
meta.err_field has error type, matched with ternary in custom_table.
table test_table {
key = {
hdr.ethernet.isValid() : ternary;
}
actions = {
DummyAction;
NoAction;
}
const entries = {
(true) : DummyAction();
}
}
hdr.ethernet.isValid() has bool type, matched with ternary in test_table.
Two tests in
p4cuse aternarymatch onboolanderrortypes. However, it is unclear what its semantics should be.The specification mentions about
ternaryas:Thus, a
ternarymatch makes sense for numeric types, but I'm not sure what its semantics is for non-numeric types, and whether they should be allowed at the first place.Below are the two tests in
p4cthat exhibit such use case:metrics/metrics_test_4.p4meta.err_fieldhaserrortype, matched withternaryincustom_table.psa-bool-ternary-const-entry-bmv2.p4hdr.ethernet.isValid()hasbooltype, matched withternaryintest_table.