-
Notifications
You must be signed in to change notification settings - Fork 448
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
Support for op= assignments in the frontend/midend #5108
base: main
Are you sure you want to change the base?
Conversation
ChrisDodd
commented
Jan 22, 2025
- these are parsed as IR::OpAssignmentStatements
- they are (optionally) converted to normal assignments in the frontend
- they may be kept as special nodes by backends that desire to treat them specially (making it easier to generate 2-operands instructions)
- frontend and midend passes are all made aware of the new IR node kinds and deal with them appropriately (either disabling transforms or fixing them to be correct in the presence of OpAssignmentStatements
There was a similar PR once but it was never resolved #3669. I guess this one supersedes it. Related P4-specification issue: p4lang/p4-spec#1139 |
It seems like a good idea to have a test case that has side effects in the l-value, e.g. something like |
7346913
to
c0058f6
Compare
- these are parsed as IR::OpAssignmentStatements - they are (optionally) converted to normal assignments in the frontend - they may be kept as special nodes by backends that desire to treat them specially (making it easier to generate 2-operands instructions) - frontend and midend passes are all made aware of the new IR node kinds and deal with them appropriately (either disabling transforms or fixing them to be correct in the presence of OpAssignmentStatements Signed-off-by: Chris Dodd <cdodd@nvidia.com>
c0058f6
to
6f82eaf
Compare
I added this in a second testcase, as well as pulling in @rst0git's testcase |
This patch adds support for compound assignment expressions of the form `E1 op= E2`. Signed-off-by: Radostin Stoyanov <radostin.stoyanov@eng.ox.ac.uk> Signed-off-by: Chris Dodd <cdodd@nvidia.com>
Signed-off-by: Chris Dodd <cdodd@nvidia.com>
The P4Testgen failures are because of crashes in BMv2. It is possible that the generated JSON is invalid. |
The .stf test I wrote by hand works fine, so BMv2 is at least reading the JSON and running that packet correctly. The testgen script seems to be creating tests with packets that are too short (the p4 program expects a packet with 48 bytes of headers), so it is getting PacketTooShort in the parser and then apparently crashing? |
6f82eaf
to
5e82b7a
Compare