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

[CIR][Lowering] Add MLIR lowering support for CIR sin operations #586

Merged
merged 5 commits into from
May 8, 2024

Conversation

GaoXiangYa
Copy link
Contributor

This PR add cir.sin lowering to MLIR math dialect. In the future, I will submit a PR to lowering cir.floor, cir.fabs and other operations to MLIR.

@GaoXiangYa GaoXiangYa changed the title [CIR][Lowering]Add MLIR lowering support for CIR cos operations [CIR][Lowering]Add MLIR lowering support for CIR sin operations May 7, 2024
@bcardosolopes bcardosolopes changed the title [CIR][Lowering]Add MLIR lowering support for CIR sin operations [CIR][Lowering] Add MLIR lowering support for CIR sin operations May 7, 2024
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Missing just a merge conflict fix, once you handle that I'll land it.

@GaoXiangYa
Copy link
Contributor Author

@bcardosolopes Hello, I have dealt with conflict, and in the next pr, I will add cir.sqrt, cir.fabs, cif.floor, cir.ceil lowering mlir passes together

// CHECK-NEXT: %{{.+}} = math.sin %[[C3]] : f64
// CHECK-NEXT: return
// CHECK-NEXT: }
// CHECK-NEXT: }
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Please add the newline.

@@ -208,6 +209,18 @@ class CIRCosOpLowering : public mlir::OpConversionPattern<mlir::cir::CosOp> {
}
};

class CIRSinOpLowering : public mlir::OpConversionPattern<mlir::cir::SinOp> {
Copy link
Contributor

Choose a reason for hiding this comment

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

May I suggest to introduce a template for the 1:1 lowerings from cir to math ops instead? Here, it would just be used by the existing cos and new sin pattern, but looking at #592, the boilerplate duplication would become quite significant otherwise.

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, you are right, we can use a template for the 1:1 lowerings from cir to mlir math ops, and we can also use the same template for the 1:1 lowerings from cir to llvm math ops. But the cir.rint cir.shift ops cannot use template, these ops should use the old way.

Copy link
Member

Choose a reason for hiding this comment

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

Instead of using templates I'd rather leverage tablegen to do these. There's a similar idea introduced for LLVM lowering in #434 we could leverage, once that lands (I might commander that PR soon, but happy to let someone else take it) we could do similar for MLIR lowering.

@bcardosolopes bcardosolopes merged commit cee2f1c into llvm:main May 8, 2024
6 checks passed
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.

None yet

3 participants