Add verifier checks for UnaryOp operand types#331
Open
Lavanya-Malakalapalli wants to merge 1 commit intop4lang:mainfrom
Open
Add verifier checks for UnaryOp operand types#331Lavanya-Malakalapalli wants to merge 1 commit intop4lang:mainfrom
Lavanya-Malakalapalli wants to merge 1 commit intop4lang:mainfrom
Conversation
Signed-off-by: Lavanyampalli <lavanyampalli@gmail.com>
331a1a2 to
78ffddf
Compare
mtsamis
reviewed
Apr 1, 2026
| case P4HIR::UnaryOpKind::Neg: | ||
| case P4HIR::UnaryOpKind::UPlus: | ||
| case P4HIR::UnaryOpKind::Cmpl: | ||
| if (!mlir::isa<P4HIR::BitsType>(type)) |
Collaborator
There was a problem hiding this comment.
Neg/UPlus should probably allow infint, right?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change tightens
p4hir.unaryverification by enforcing operand type constraints based on the unary operation kind.Changes:
notto operate on!p4hir.boolminus,plus, andcmplto operate on integer-like P4HIR bit typesAlso adds a negative test file covering invalid unary operations.
Validation:
ninja check-p4mlirpassesFixes: FIXME in UnaryOp verifier