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

PDLL: Add equals operator #98

Merged
merged 2 commits into from
Mar 14, 2024
Merged

PDLL: Add equals operator #98

merged 2 commits into from
Mar 14, 2024

Conversation

mgehre-amd
Copy link
Collaborator

No description provided.

Comment on lines +43 to +65
LogicalResult equals(mlir::PatternRewriter &, mlir::Attribute lhs,
mlir::Attribute rhs) {
if (auto lhsAttr = dyn_cast_or_null<IntegerAttr>(lhs)) {
auto rhsAttr = dyn_cast_or_null<IntegerAttr>(rhs);
if (!rhsAttr || lhsAttr.getType() != rhsAttr.getType())
return failure();

APInt lhsVal = lhsAttr.getValue();
APInt rhsVal = rhsAttr.getValue();
return success(lhsVal.eq(rhsVal));
}

if (auto lhsAttr = dyn_cast_or_null<FloatAttr>(lhs)) {
auto rhsAttr = dyn_cast_or_null<FloatAttr>(rhs);
if (!rhsAttr || lhsAttr.getType() != rhsAttr.getType())
return failure();

APFloat lhsVal = lhsAttr.getValue();
APFloat rhsVal = rhsAttr.getValue();
return success(lhsVal.compare(rhsVal) == llvm::APFloatBase::cmpEqual);
}
return failure();
}

Choose a reason for hiding this comment

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

Why only IntegerAttr and floatAttr and why don't we use == operator from Attribute class?

@mgehre-amd mgehre-amd force-pushed the matthias.pdll_neg_precedence branch 2 times, most recently from cc9994e to 0be8938 Compare March 7, 2024 13:58
Base automatically changed from matthias.pdll_neg_precedence to feature/fused-ops March 8, 2024 15:36
@ge28boj ge28boj merged commit 9d16822 into feature/fused-ops Mar 14, 2024
@ge28boj ge28boj deleted the matthias.equal branch March 14, 2024 15:12
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.

3 participants