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

Support for invalid union expressions #3843

Merged
merged 7 commits into from
Mar 27, 2023
Merged

Conversation

mihaibudiu
Copy link
Contributor

Signed-off-by: Mihai Budiu mbudiu@vmware.com
However, see #3842; that would need to be fixed to make this complete.

@mihaibudiu mihaibudiu force-pushed the invalid-union branch 2 times, most recently from a657b66 to 4b0edb3 Compare March 5, 2023 00:22
@mihaibudiu mihaibudiu requested a review from fruffy March 23, 2023 23:13
@mihaibudiu
Copy link
Contributor Author

Anyone can review this?

Copy link
Collaborator

@fruffy fruffy left a comment

Choose a reason for hiding this comment

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

I assume p4lang/p4-spec#1215 is the relevant issue.

The fix bellow, commented-out, causes problems elsewhere.
https://github.com/p4lang/p4c/issues/3842
if (ltype->is<IR::Type_HeaderUnion>())
return statement;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does the fix cause problems? Still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is still relevant. Without this pass other later midend passes fail.

@@ -21,6 +21,8 @@ limitations under the License.

#include <memory>
#include <ostream>
// use in combination with "raise" below
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make this a #define instead of commented code? E.g., IR_NODE_USE_SIGNAL or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is not much benefit, the amount of edits needed on a change are about the same.

::error("%1%: Cannot eliminate invalid header union", expression);
return expression;
}
cstring name = refMap->newName("ih");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a dummy name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what you mean by a "dummy" name. We often generate new names for identifiers, this one is for a variable holding an invalid header.

@@ -104,6 +104,9 @@ set (P4_XFAIL_TESTS
# arguments and with incorrect number of arguments
testdata/p4_16_samples/pna-example-mirror-packet-error2.p4
testdata/p4_16_samples/pna-example-mirror-packet-error3.p4
# This test fails only when recompiling the produced output, because
# of the predication pass
testdata/p4_16_samples/invalid-union.p4
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still relevant now that the pass is gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this one.

}
if (expr->is<IR::InvalidHeader>() && e->member.name == IR::Type_Header::isValid) return e;
if (expr->is<IR::InvalidHeaderUnion>() && e->member.name == IR::Type_Header::isValid) return e;
if (expr->is<IR::Invalid>() && e->member.name == IR::Type_Header::isValid) return e;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why remove the brackets? To be more terse?
What is an instance of expr->is<IR::Invalid>()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The literal {#} represents an Invalid expression. Whether it's a header or a union will be decided later.

Mihai Budiu added 5 commits March 24, 2023 11:34
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Mihai Budiu added 2 commits March 24, 2023 12:30
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Copy link
Member

@rst0git rst0git left a comment

Choose a reason for hiding this comment

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

LGTM

@mihaibudiu mihaibudiu merged commit 651de64 into p4lang:main Mar 27, 2023
@mihaibudiu mihaibudiu deleted the invalid-union branch March 27, 2023 20:44
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.

5 participants