Skip to content

Add verifier checks for UnaryOp operand types#331

Open
Lavanya-Malakalapalli wants to merge 1 commit intop4lang:mainfrom
Lavanya-Malakalapalli:unaryop-verifier
Open

Add verifier checks for UnaryOp operand types#331
Lavanya-Malakalapalli wants to merge 1 commit intop4lang:mainfrom
Lavanya-Malakalapalli:unaryop-verifier

Conversation

@Lavanya-Malakalapalli
Copy link
Copy Markdown

This change tightens p4hir.unary verification by enforcing operand type constraints based on the unary operation kind.

Changes:

  • require not to operate on !p4hir.bool
  • require minus, plus, and cmpl to operate on integer-like P4HIR bit types

Also adds a negative test file covering invalid unary operations.

Validation:

  • ninja check-p4mlir passes

Fixes: FIXME in UnaryOp verifier

Signed-off-by: Lavanyampalli <lavanyampalli@gmail.com>
case P4HIR::UnaryOpKind::Neg:
case P4HIR::UnaryOpKind::UPlus:
case P4HIR::UnaryOpKind::Cmpl:
if (!mlir::isa<P4HIR::BitsType>(type))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Neg/UPlus should probably allow infint, right?

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.

2 participants