Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification on directionless action arguments behaving like direction in #1350

Open
jaehyun1ee opened this issue Nov 25, 2024 · 0 comments

Comments

@jaehyun1ee
Copy link
Contributor

The spec mentions about directionless action arguments:

For an action, a directionless parameter indicates that it is “action data”. See Section 14.1 for the meaning of action data, but its meaning includes the following possibilities:

  • The parameter's value is provided in the P4 program. In this case, the parameter behaves as if the direction were in.

The phrase "behaves as if the direction were in", I believe, is not quite clear, particularly regarding compile-time known-ness.

The differences between an in parameter and a directionless parameters, aside their copy-in/out semantics, is:

  • in can be implicitly cast, while directionless cannot (as per the current spec)
  • directionless argument should be compile-time known, while no such restriction exists for in argument.

So, I wonder if "behaves as if the direction were in" also imply that the directionless arguments supplied to actions in a P4 program (not by the control plane) need not be a compile-time known value?

Relevant to this issue, issue473.p4 in the p4c test suite is expected to be rejected by the frontend.

action b(inout bit<32> x, bit<8> data) {
    meta.a = meta.a ^ (bit<4>) x ^ (bit<4>) data;
}
table t1 {
    key = { hdr.ethernet.srcAddr : exact; }
    actions = { b(meta.c); }
    default_action = b(meta.c, (bit<8>) meta.d);
}
issue473.p4(70): [--Werror=type-error] error: (bit<8>)meta.d: action argument must be a compile-time constant
        default_action = b(meta.c, (bit<8>) meta.d);
                                   ^^^^^^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant