Open liao123123123 opened 6 months ago
Agreed that there should be no CompilerBug appearing, ideally.
Personally, I would not mind if open source p4c simply rejected such keys as unsupported, i.e. do not support key expressions that cause other tables to be invoked.
I also would not mind if this was supported, but if so, it would probably most reasonably be done as other "complex" key expressions are supported, i.e. by calculating the expression before the table is applied, and storing it in a temporary variable.
Thank you for your answer. Yes, we can avoid it by using a temporary variable in most cases:
bit<32> temp=fun(
{dstAddr = (tb1.apply().hit ? 0 : 48w1),
srcAddr = ( tb2.apply().hit ? 0: 48w1)}
);
table tb {
key = {
temp: exact @name("abc");
}
actions = {
}
}
The command "p4test test.p4 -v" is used to compile the following code:
result in :
However, in my example, such a key expression seems meaningless.