Open
Description
The P4 Spec defines bitwise XOR operation on fixed-width integers, but not on arbitrary precision integers.
8.9. Operations on arbitrary-precision integers
Note: bitwise-operations (|, &, ^, ~) are not defined on expressions of type int.
However, the below program is not rejected by p4test
.
bool f(int a, int b) {
return a ^ b == 0; // HERE
}
extern void g(in bool t);
control C(int a, int b);
package P(C c);
control CImpl(int a, int b) {
apply {
bool local = f(a, b);
g(local);
}
}
P(CImpl ()) main;
Function f
performs bitwise XOR on two arbitrary precision integers, a
and b
.
Below is the output of the final pass (MidEnd_50_DumpPipe
) when given --top4
argument:
extern void g(in bool t);
control C(int a, int b);
package P(C c);
control CImpl(int a, int b) {
@hidden action bxorintrep11() {
g(a ^ b == 0); // HERE
}
@hidden table tbl_bxorintrep11 {
actions = {
bxorintrep11();
}
const default_action = bxorintrep11();
}
apply {
tbl_bxorintrep11.apply();
}
}
P(CImpl()) main;
i.e., the operation still exists.