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

Pass to get rid of action_run() calls #5053

Merged
merged 1 commit into from
Mar 8, 2025

Conversation

ChrisDodd
Copy link
Contributor

This is a general midend pass for any target that does not support action_run directly. It rewrites the actions in a table that uses action_run to set a newly introduced metadata tmp enum that records which action was run, and changes the switch statement to use that.

It is kind-of logically the reverse of EliminateSwitch, which converts switch statements that don't use action_run() into ones that do, so it would never make sense to use both passes for a backend.

Need to update p4test so we can select which pass(es) to run in a test by some annotation in the test program to better allow testing this.

@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Dec 5, 2024
@ChrisDodd ChrisDodd force-pushed the cdodd-action-run branch 6 times, most recently from bd15e5c to 7976cfe Compare December 10, 2024 01:00
@ChrisDodd ChrisDodd force-pushed the cdodd-action-run branch 2 times, most recently from 89e94d6 to a26e2e0 Compare January 5, 2025 06:03
@ChrisDodd ChrisDodd force-pushed the cdodd-action-run branch 2 times, most recently from 96ece1f to e448341 Compare February 3, 2025 04:35
@ChrisDodd ChrisDodd requested review from asl, vlstill and fruffy February 11, 2025 05:58
@ChrisDodd
Copy link
Contributor Author

I've added the ability to use @command_line annotations to add command-line args in test cases, so this case actually be tested

@ChrisDodd ChrisDodd force-pushed the cdodd-action-run branch 2 times, most recently from f544827 to 2f64c87 Compare February 11, 2025 07:23
@fruffy
Copy link
Collaborator

fruffy commented Feb 11, 2025

The other failures is caused by this line

This is also not a supported option for P4Testgen but the pragma is still parsed as input.

@fruffy
Copy link
Collaborator

fruffy commented Feb 11, 2025

I see three possible ways to solve this:

  1. Since options may depend on the compiler executing the program, maybe extend this pragma with a "target"/"arch" field to ensure the option is interpreted correctly?

  2. Add another option to enable/disable this pragma and adding options.

  3. Or just ignore any unknown option made available by the pragma. Maybe print a warning that the option is not supported by the tool interpreting the program.

@ChrisDodd
Copy link
Contributor Author

The other failures is caused by this line

This is also not a supported option for P4Testgen but the pragma is still parsed as input.

This line was not touched by this change, so there's no change here

@fruffy
Copy link
Collaborator

fruffy commented Feb 12, 2025

This line was not touched by this change, so there's no change here

It's existing code that had no impact but is now active because of https://github.com/p4lang/p4c/pull/5053/files#diff-b033ed467d2767be363300d09ff13ac0a990d2e0de7464b732d9b29888da81a1R54.

@ChrisDodd ChrisDodd force-pushed the cdodd-action-run branch 2 times, most recently from f5d6769 to 5e02a50 Compare February 12, 2025 06:55
@ChrisDodd
Copy link
Contributor Author

I modified P4COptionPragmaParser so that targets can decide whether or not they want to support @command_line option pragmas -- most real targets probably want to, but special targets like p4testgen and p4graphs possibly do not. I also remove <v1model.p4> from the testcase so p4testgen doesn't pick it up.

@ChrisDodd ChrisDodd requested a review from fruffy February 12, 2025 21:46
@fruffy fruffy added the run-validation Use this tag to trigger a Validation CI run. label Feb 12, 2025
@fruffy
Copy link
Collaborator

fruffy commented Feb 12, 2025

Will be able to review the action_run pass later this week. But I'd suggest to split out the changes to P4COptionPragmaParser into a PR we can discuss separately. I think it is a cool and useful feature but it shouldn't be tagged on to this PR.

@ChrisDodd
Copy link
Contributor Author

Will be able to review the action_run pass later this week. But I'd suggest to split out the changes to P4COptionPragmaParser into a PR we can discuss separately. I think it is a cool and useful feature but it shouldn't be tagged on to this PR.

Created #5123

@fruffy
Copy link
Collaborator

fruffy commented Feb 18, 2025

Could you remove the code that is related to #5123. Or do you want to rebase it on top of that PR?

Would be good to get a review from other stake holders here @kfcripps @vlstill.

@ChrisDodd
Copy link
Contributor Author

Could you remove the code that is related to #5123. Or do you want to rebase it on top of that PR?

It requires that PR (for the testcase included here), and is (re)based on that. Ideally, that one will be approved (and merge first), then this one will rebase and become just the one change.

@fruffy
Copy link
Collaborator

fruffy commented Feb 18, 2025

It requires that PR (for the testcase included here), and is (re)based on that. Ideally, that one will be approved (and merge first), then this one will rebase and become just the one change.

It might take a little longer until #5123 is approved. @asl also had apprehensions.

This PR could be merged before that, given the tests pass and look ok.

@ChrisDodd ChrisDodd force-pushed the cdodd-action-run branch 4 times, most recently from 841a8fb to ececb06 Compare February 26, 2025 03:49
@ChrisDodd ChrisDodd requested review from fruffy and kfcripps March 4, 2025 21:38
@ChrisDodd ChrisDodd force-pushed the cdodd-action-run branch 2 times, most recently from ca82e11 to 977125f Compare March 5, 2025 10:42
- introduce new metadata set in the actions of the table

Signed-off-by: Chris Dodd <[email protected]>
@ChrisDodd ChrisDodd added this pull request to the merge queue Mar 8, 2025
Merged via the queue into p4lang:main with commit 6ad7c9a Mar 8, 2025
21 checks passed
@ChrisDodd ChrisDodd deleted the cdodd-action-run branch March 8, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser) run-validation Use this tag to trigger a Validation CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants