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

Allow implicit cast for directionless args #1330

Closed
wants to merge 0 commits into from

Conversation

jaehyun1ee
Copy link
Contributor

I would like to propose allowing implicit cast for directionless method / function / constructor arguments, following the discussion made in #1312.

Regarding it, the current spec section 8.20 mentions that:

The calling convention is copy-in/copy-out (Section 6.8). For generic functions the type arguments can be explicitly specified in the function call. The compiler only inserts implicit casts for direction in arguments to methods or functions as described in Section 8.11. The types for all other arguments must match the parameter types exactly.

So as per the spec, we cannot apply implicit cast for directionless method / function / constructor arguments.

As a side note, directionless action arguments can be implicitly cast as per the spec since it mentions the following in section 6.8.1.

Actions can also be explicitly invoked using function call syntax, either from a control block or from another action. In this case, values for all action parameters must be supplied explicitly, including values for the directionless parameters. The directionless parameters in this case behave like in parameters.

So, like the case for action, I am proposing to allow implicit cast for directionless method / function / constructor arguments.

I believe it better reflects the use cases in the p4c test suite. Below is a drop-down list of tests that expect such a feature.

List of tests
  • extern-funcs-bmv2.p4
  • extern2.p4
  • gauntlet_extern_arguments_2.p4
  • gauntlet_hdr_in_value-bmv2.p4
  • issue1001-1-bmv2.p4
  • issue1001-bmv2.p4
  • issue1043-bmv2.p4
  • issue1334.p4
  • issue1642-bmv2.p4
  • issue1653-bmv2.p4
  • issue1653-complex-bmv2.p4
  • issue1660-bmv2.p4
  • issue1765-1-bmv2.p4
  • issue2648.p4
  • issue3246-1.p4
  • issue383-bmv2.p4
  • issue562-bmv2.p4
  • issue933-1.p4
  • named-arg1.p4
  • v1model-special-ops-bmv2.p4
  • bfd_offload.p4
  • calc-ebpf.p4
  • constructor_cast.p4
  • issue1006.p4
  • issue1097-2-bmv2.p4
  • issue1097-bmv2.p4
  • issue1814-1-bmv2.p4
  • issue1814-bmv2.p4
  • issue1958.p4
  • issue2844-enum.p4
  • issue298-bmv2.p4
  • issue4288.p4
  • issue754.p4
  • list7.p4
  • pr1363.p4
  • psa-action-profile1.p4
  • psa-action-profile3.p4
  • psa-action-profile4.p4
  • psa-basic-counter-bmv2.p4
  • psa-counter1.p4
  • psa-counter2.p4
  • psa-counter3.p4
  • psa-custom-type-counter-index.p4
  • psa-end-of-ingress-test-bmv2.p4
  • psa-example-dpdk-byte-alignment_1.p4
  • psa-example-dpdk-byte-alignment_2.p4
  • psa-example-dpdk-byte-alignment_3.p4
  • psa-example-dpdk-byte-alignment_5.p4
  • psa-example-dpdk-byte-alignment_6.p4
  • psa-example-dpdk-byte-alignment_7.p4
  • psa-example-dpdk-byte-alignment_8.p4
  • psa-example-dpdk-byte-alignment_9.p4
  • pse-example-dpdk-counter.p4
  • psa-example-dpdk-externs.p4
  • psa-example-dpdk-meter-execute-err.p4
  • psa-example-dpdk-meter.p4
  • psa-example-dpdk-meter1.p4
  • psa-example-dpdk-varbit-bmv2.p4
  • psa-meter1.p4
  • psa-meter3.p4
  • psa-meter7-bmv2.p4
  • psa-random.p4
  • psa-register-complex-bmv2.p4
  • psa-register-read-write-2-bmv2.p4
  • psa-register-read-write-bmv2.p4
  • psa-register1.p4
  • psa-register2.p4
  • psa-register3.p4
  • rcp.p4
  • rcp1.p4
  • register-serenum-bmv2.p4
  • simple-firewall_ubpf.p4
  • unused-counter-bmv2.p4
  • value-sets.p4

@jafingerhut
Copy link
Collaborator

jafingerhut commented Nov 14, 2024

@jaehyun1ee Sorry for the inconvenience, but we have, after several months of planning, transitioned the P4 language specification source from Madoko to AsciiDoc. Thus most or all of your PRs will need to be updated so that they apply to that version. Hopefully this should be fairly straightforward, e.g. by looking at examples of how things like section headings, bullet items, etc. are marked up in the latest version of the file P4-16-spec.adoc

If you have questions on how to change things for AsciiDoc, feel free to ask. Note that creating a new PR with similar changes as this PR might be easier than updating this PR.

@jaehyun1ee jaehyun1ee closed this Nov 25, 2024
@jaehyun1ee jaehyun1ee deleted the implicit-directionless branch November 25, 2024 05:07
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

Successfully merging this pull request may close these issues.

2 participants