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

[P4Testgen] Resolve method call arguments before stepping into an extern - preserve InOut references #4255

Merged
merged 4 commits into from
Dec 1, 2023

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Nov 18, 2023

Finally fixing this longstanding issue. We always had to resolve method call arguments within an extern, which often resulted in unnecessary redundant code. Further, for InOut parameters, the original reference was lost.

Now we frontload this directly in the method call expression. We resolve arguments In and InOut parameters before stepping into the extern. For InOut arguments, we replace the expression with an InOutReference, which preserves the reference. This way we can read the input argument and also write to the original reference once we step into an extern. With #4215 merged, we can also pass in any complex expression such as header or struct expressions as arguments.

@fruffy fruffy force-pushed the fruffy/resolve_args_before_enterning_extern branch 4 times, most recently from 5b014f7 to b134e29 Compare November 19, 2023 17:38
@fruffy fruffy force-pushed the fruffy/resolve_args_before_enterning_extern branch 3 times, most recently from 2e0a6f4 to f9733b7 Compare November 23, 2023 19:31
@fruffy fruffy force-pushed the fruffy/resolve_args_before_enterning_extern branch from f9733b7 to cc991df Compare November 29, 2023 15:07
@fruffy fruffy marked this pull request as ready for review November 29, 2023 23:40
Copy link
Contributor

@vlstill vlstill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way this simplifies writting extern implementations. I have some small questions and suggestions.

@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Nov 30, 2023
@fruffy fruffy force-pushed the fruffy/resolve_args_before_enterning_extern branch from 8554058 to d84c89b Compare November 30, 2023 22:33
@fruffy fruffy force-pushed the fruffy/resolve_args_before_enterning_extern branch from 1a849a6 to a77b818 Compare December 1, 2023 19:19
@fruffy fruffy merged commit 689e013 into main Dec 1, 2023
13 checks passed
@fruffy fruffy deleted the fruffy/resolve_args_before_enterning_extern branch December 1, 2023 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants