Skip to content

Commit 657db03

Browse files
ayokunle321lanza
authored andcommitted
[CIR][ThroughMLIR] Add ASinOp Lowering (#1530)
Adds implementation for ASinOp's lowering ThroughMLIR.
1 parent cf67fcf commit 657db03

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,18 @@ class CIRSinOpLowering : public mlir::OpConversionPattern<cir::SinOp> {
491491
}
492492
};
493493

494+
class CIRASinOpLowering : public mlir::OpConversionPattern<cir::ASinOp> {
495+
public:
496+
using mlir::OpConversionPattern<cir::ASinOp>::OpConversionPattern;
497+
498+
mlir::LogicalResult
499+
matchAndRewrite(cir::ASinOp op, OpAdaptor adaptor,
500+
mlir::ConversionPatternRewriter &rewriter) const override {
501+
rewriter.replaceOpWithNewOp<mlir::math::AsinOp>(op, adaptor.getSrc());
502+
return mlir::LogicalResult::success();
503+
}
504+
};
505+
494506
template <typename CIROp, typename MLIROp>
495507
class CIRCountZerosBitOpLowering : public mlir::OpConversionPattern<CIROp> {
496508
public:
@@ -1395,8 +1407,8 @@ void populateCIRToMLIRConversionPatterns(mlir::RewritePatternSet &patterns,
13951407
CIRBitClzOpLowering, CIRBitCtzOpLowering, CIRBitPopcountOpLowering,
13961408
CIRBitClrsbOpLowering, CIRBitFfsOpLowering, CIRBitParityOpLowering,
13971409
CIRIfOpLowering, CIRVectorCreateLowering, CIRVectorInsertLowering,
1398-
CIRVectorExtractLowering, CIRVectorCmpOpLowering, CIRACosOpLowering>(
1399-
converter, patterns.getContext());
1410+
CIRVectorExtractLowering, CIRVectorCmpOpLowering, CIRACosOpLowering,
1411+
CIRASinOpLowering>(converter, patterns.getContext());
14001412
}
14011413

14021414
static mlir::TypeConverter prepareTypeConverter() {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: cir-opt %s -cir-to-mlir -o %t.mlir
2+
// RUN: FileCheck %s --input-file %t.mlir
3+
4+
module {
5+
cir.func @foo() {
6+
%1 = cir.const #cir.fp<1.0> : !cir.float
7+
%2 = cir.const #cir.fp<1.0> : !cir.double
8+
%3 = cir.const #cir.fp<1.0> : !cir.long_double<!cir.f80>
9+
%4 = cir.const #cir.fp<1.0> : !cir.long_double<!cir.double>
10+
%5 = cir.asin %1 : !cir.float
11+
%6 = cir.asin %2 : !cir.double
12+
%7 = cir.asin %3 : !cir.long_double<!cir.f80>
13+
%8 = cir.asin %4 : !cir.long_double<!cir.double>
14+
cir.return
15+
}
16+
}
17+
18+
// CHECK: module {
19+
// CHECK-NEXT: func.func @foo() {
20+
// CHECK-NEXT: %[[C0:.+]] = arith.constant 1.000000e+00 : f32
21+
// CHECK-NEXT: %[[C1:.+]] = arith.constant 1.000000e+00 : f64
22+
// CHECK-NEXT: %[[C2:.+]] = arith.constant 1.000000e+00 : f80
23+
// CHECK-NEXT: %[[C3:.+]] = arith.constant 1.000000e+00 : f64
24+
// CHECK-NEXT: %{{.+}} = math.asin %[[C0]] : f32
25+
// CHECK-NEXT: %{{.+}} = math.asin %[[C1]] : f64
26+
// CHECK-NEXT: %{{.+}} = math.asin %[[C2]] : f80
27+
// CHECK-NEXT: %{{.+}} = math.asin %[[C3]] : f64
28+
// CHECK-NEXT: return
29+
// CHECK-NEXT: }
30+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)