Skip to content

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: } No newline at end of file
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.

}
};

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
bruteforceboy pushed a commit to bruteforceboy/clangir that referenced this pull request Oct 2, 2024
…m#586)

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.

---------

Co-authored-by: Gao Xiang <gaoxiang@gaoxiang>
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
…m#586)

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.

---------

Co-authored-by: Gao Xiang <gaoxiang@gaoxiang>
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
…m#586)

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.

---------

Co-authored-by: Gao Xiang <gaoxiang@gaoxiang>
lanza pushed a commit that referenced this pull request Nov 5, 2024
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.

---------

Co-authored-by: Gao Xiang <gaoxiang@gaoxiang>
lanza pushed a commit that referenced this pull request Mar 18, 2025
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.

---------

Co-authored-by: Gao Xiang <gaoxiang@gaoxiang>
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