-
Notifications
You must be signed in to change notification settings - Fork 444
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
Make don't care args action-local when used in actions #4817
Make don't care args action-local when used in actions #4817
Conversation
Not exactly straightforward but take a look at https://github.com/p4lang/p4c/blob/main/test/gtest/strength_reduction.cpp |
@fruffy I was hoping for something that'd allow me to just pass |
We could probably modify |
It might be fairly involved to extend With the gtest you could just expect the IR to have a specific structure after your pass. The input to the gtest is just a P4 program. |
Well, you can just run the .test script with |
On second thought, this would be a bad idea as it would break as soon as someone would try adding a new
It looks like https://github.com/p4lang/p4c/blob/main/test/gtest/strength_reduction.cpp is just running the entire set of frontend passes twice (once with some flag passed to the strength reduction pass) and checking the final output each time. It is not just running the strength reduction pass only and checking its exact output. Is my understanding not correct? If my understanding is correct, are you suggesting to create and use my own version of |
61d919a
to
1f956c2
Compare
@fruffy I think https://github.com/p4lang/p4c/blob/main/test/gtest/frontend_test.cpp was closer to what I needed. Added the |
0049337
to
24a8a02
Compare
@@ -44,6 +44,14 @@ class DontcareArgs : public Transform, public ResolutionContext { | |||
toAdd.clear(); | |||
return function; | |||
} | |||
const IR::Node *postorder(IR::P4Action *action) override { | |||
IR::IndexedVector<IR::StatOrDecl> body; | |||
for (auto d : toAdd) body.push_back(d); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto d : toAdd) body.push_back(d); | |
for (auto d : toAdd) { | |
body.push_back(d); | |
} |
might be easier to read. This code was copied from the function segment, maybe change that piece of code, too?
@@ -0,0 +1,115 @@ | |||
#include <gtest/gtest.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice! We should definitely have more tests like these...
Signed-off-by: Kyle Cripps <[email protected]>
Signed-off-by: kfcripps <[email protected]>
Signed-off-by: kfcripps <[email protected]>
Signed-off-by: Kyle Cripps <[email protected]>
24a8a02
to
859b705
Compare
It may be easier for some passes to process action-locals that are actually action-local variables instead of control-local variables in the IR. Also note that we already do this in the
DontcareArgs
pass for functions, but not actions for some reason:On
main
branch, the output of--top4 RemoveDontcareArgs
for the attached test is:and on this branch:
@fruffy Is there an easy way to test the output of a specific pass? This will get cleaned up by later passes so the change is not visible in the attached reference outputs.