[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
https://github.com/AmrDeveloper closed https://github.com/llvm/llvm-project/pull/156356 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
https://github.com/AmrDeveloper created
https://github.com/llvm/llvm-project/pull/156356
Upstream support for FPToFPBuiltin ACosOp
>From a23eb7b29d90a7afc9c02080ca9747f365a67270 Mon Sep 17 00:00:00 2001
From: AmrDeveloper
Date: Sun, 31 Aug 2025 18:55:45 +0200
Subject: [PATCH] [CIR] Upstream builtin ACos op
---
clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 +
clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp | 11 ++
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 10 +
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.h | 9 +
clang/test/CIR/CodeGen/builtins-elementwise.c | 38 +++
5 files changed, 77 insertions(+)
create mode 100644 clang/test/CIR/CodeGen/builtins-elementwise.c
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 982533f5e3b84..0f6c7332cd9ba 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -3732,6 +3732,15 @@ class CIR_UnaryFPToFPBuiltinOp
let llvmOp = llvmOpName;
}
+def CIR_ACosOp : CIR_UnaryFPToFPBuiltinOp<"acos", "ACosOp"> {
+ let summary = "Computes the arcus cosine of the specified value";
+ let description = [{
+`cir.acos`computes the arcus cosine of a given value and
+returns a result of the same type. ignoring floating-point
+exceptions. It does not set `errno`.
+ }];
+}
+
def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> {
let summary = "Computes the floating-point absolute value";
let description = [{
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index b6a6299667308..b68e91f64dc84 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -85,6 +85,14 @@ static RValue
emitUnaryMaybeConstrainedFPBuiltin(CIRGenFunction &cgf,
return RValue::get(call->getResult(0));
}
+template
+static RValue emitUnaryFPBuiltin(CIRGenFunction &cgf, const CallExpr &e) {
+ mlir::Value arg = cgf.emitScalarExpr(e.getArg(0));
+ auto call =
+ Operation::create(cgf.getBuilder(), arg.getLoc(), arg.getType(), arg);
+ return RValue::get(call->getResult(0));
+}
+
RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned
builtinID,
const CallExpr *e,
ReturnValueSlot returnValue) {
@@ -349,6 +357,9 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
case Builtin::BI__builtin_unreachable:
emitUnreachable(e->getExprLoc(), /*createNewBlock=*/true);
return RValue::get(nullptr);
+
+ case Builtin::BI__builtin_elementwise_acos:
+return emitUnaryFPBuiltin(*this, *e);
}
// If this is an alias for a lib function (e.g. __builtin_sin), emit
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index f1fdfed166bbc..ede10c5d1e6c0 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -577,6 +577,15 @@ struct ConvertCIRToLLVMPass
StringRef getArgument() const override { return "cir-flat-to-llvm"; }
};
+mlir::LogicalResult CIRToLLVMACosOpLowering::matchAndRewrite(
+cir::ACosOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+ mlir::Type resTy = typeConverter->convertType(op.getType());
+ rewriter.replaceOpWithNewOp(op, resTy,
+ adaptor.getOperands()[0]);
+ return mlir::success();
+}
+
mlir::LogicalResult CIRToLLVMAssumeOpLowering::matchAndRewrite(
cir::AssumeOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
@@ -2395,6 +2404,7 @@ void ConvertCIRToLLVMPass::runOnOperation() {
dl);
patterns.add<
// clang-format off
+ CIRToLLVMACosOpLowering,
CIRToLLVMAssumeOpLowering,
CIRToLLVMAssumeAlignedOpLowering,
CIRToLLVMAssumeSepStorageOpLowering,
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
index da7df8982d34c..656a776035885 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
@@ -718,6 +718,15 @@ class CIRToLLVMFAbsOpLowering : public
mlir::OpConversionPattern {
mlir::ConversionPatternRewriter &) const override;
};
+class CIRToLLVMACosOpLowering : public mlir::OpConversionPattern {
+public:
+ using mlir::OpConversionPattern::OpConversionPattern;
+
+ mlir::LogicalResult
+ matchAndRewrite(cir::ACosOp op, OpAdaptor,
+ mlir::ConversionPatternRewriter &) const override;
+};
+
class CIRToLLVMInlineAsmOpLowering
: public mlir::OpConversionPattern {
mlir::DataLayout const &dataLayout;
diff --git a/clang/test/CIR/CodeGen/builtins-ele
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
https://github.com/xlauko approved this pull request. lgtm https://github.com/llvm/llvm-project/pull/156356 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
https://github.com/xlauko edited https://github.com/llvm/llvm-project/pull/156356 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
llvmbot wrote:
@llvm/pr-subscribers-clangir
Author: Amr Hesham (AmrDeveloper)
Changes
Upstream support for FPToFPBuiltin ACosOp
---
Full diff: https://github.com/llvm/llvm-project/pull/156356.diff
5 Files Affected:
- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+9)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+11)
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+10)
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h (+9)
- (added) clang/test/CIR/CodeGen/builtins-elementwise.c (+38)
``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 982533f5e3b84..0f6c7332cd9ba 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -3732,6 +3732,15 @@ class CIR_UnaryFPToFPBuiltinOp
let llvmOp = llvmOpName;
}
+def CIR_ACosOp : CIR_UnaryFPToFPBuiltinOp<"acos", "ACosOp"> {
+ let summary = "Computes the arcus cosine of the specified value";
+ let description = [{
+`cir.acos`computes the arcus cosine of a given value and
+returns a result of the same type. ignoring floating-point
+exceptions. It does not set `errno`.
+ }];
+}
+
def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> {
let summary = "Computes the floating-point absolute value";
let description = [{
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index b6a6299667308..b68e91f64dc84 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -85,6 +85,14 @@ static RValue
emitUnaryMaybeConstrainedFPBuiltin(CIRGenFunction &cgf,
return RValue::get(call->getResult(0));
}
+template
+static RValue emitUnaryFPBuiltin(CIRGenFunction &cgf, const CallExpr &e) {
+ mlir::Value arg = cgf.emitScalarExpr(e.getArg(0));
+ auto call =
+ Operation::create(cgf.getBuilder(), arg.getLoc(), arg.getType(), arg);
+ return RValue::get(call->getResult(0));
+}
+
RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned
builtinID,
const CallExpr *e,
ReturnValueSlot returnValue) {
@@ -349,6 +357,9 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
case Builtin::BI__builtin_unreachable:
emitUnreachable(e->getExprLoc(), /*createNewBlock=*/true);
return RValue::get(nullptr);
+
+ case Builtin::BI__builtin_elementwise_acos:
+return emitUnaryFPBuiltin(*this, *e);
}
// If this is an alias for a lib function (e.g. __builtin_sin), emit
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index f1fdfed166bbc..ede10c5d1e6c0 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -577,6 +577,15 @@ struct ConvertCIRToLLVMPass
StringRef getArgument() const override { return "cir-flat-to-llvm"; }
};
+mlir::LogicalResult CIRToLLVMACosOpLowering::matchAndRewrite(
+cir::ACosOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+ mlir::Type resTy = typeConverter->convertType(op.getType());
+ rewriter.replaceOpWithNewOp(op, resTy,
+ adaptor.getOperands()[0]);
+ return mlir::success();
+}
+
mlir::LogicalResult CIRToLLVMAssumeOpLowering::matchAndRewrite(
cir::AssumeOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
@@ -2395,6 +2404,7 @@ void ConvertCIRToLLVMPass::runOnOperation() {
dl);
patterns.add<
// clang-format off
+ CIRToLLVMACosOpLowering,
CIRToLLVMAssumeOpLowering,
CIRToLLVMAssumeAlignedOpLowering,
CIRToLLVMAssumeSepStorageOpLowering,
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
index da7df8982d34c..656a776035885 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
@@ -718,6 +718,15 @@ class CIRToLLVMFAbsOpLowering : public
mlir::OpConversionPattern {
mlir::ConversionPatternRewriter &) const override;
};
+class CIRToLLVMACosOpLowering : public mlir::OpConversionPattern {
+public:
+ using mlir::OpConversionPattern::OpConversionPattern;
+
+ mlir::LogicalResult
+ matchAndRewrite(cir::ACosOp op, OpAdaptor,
+ mlir::ConversionPatternRewriter &) const override;
+};
+
class CIRToLLVMInlineAsmOpLowering
: public mlir::OpConversionPattern {
mlir::DataLayout const &dataLayout;
diff --git a/clang/test/CIR/CodeGen/builtins-elementwise.c
b/clang/test/CIR/CodeGen/builtins-elementwise.c
new file mode 100644
index 0..1898f56a33628
--- /dev/null
+++ b/clang/test/CIR/C
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
https://github.com/andykaylor approved this pull request. lgtm with xlauko's comments addressed https://github.com/llvm/llvm-project/pull/156356 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
https://github.com/bcardosolopes approved this pull request. https://github.com/llvm/llvm-project/pull/156356 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
https://github.com/AmrDeveloper updated
https://github.com/llvm/llvm-project/pull/156356
>From a23eb7b29d90a7afc9c02080ca9747f365a67270 Mon Sep 17 00:00:00 2001
From: AmrDeveloper
Date: Sun, 31 Aug 2025 18:55:45 +0200
Subject: [PATCH 1/2] [CIR] Upstream builtin ACos op
---
clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 +
clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp | 11 ++
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 10 +
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.h | 9 +
clang/test/CIR/CodeGen/builtins-elementwise.c | 38 +++
5 files changed, 77 insertions(+)
create mode 100644 clang/test/CIR/CodeGen/builtins-elementwise.c
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 982533f5e3b84..0f6c7332cd9ba 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -3732,6 +3732,15 @@ class CIR_UnaryFPToFPBuiltinOp
let llvmOp = llvmOpName;
}
+def CIR_ACosOp : CIR_UnaryFPToFPBuiltinOp<"acos", "ACosOp"> {
+ let summary = "Computes the arcus cosine of the specified value";
+ let description = [{
+`cir.acos`computes the arcus cosine of a given value and
+returns a result of the same type. ignoring floating-point
+exceptions. It does not set `errno`.
+ }];
+}
+
def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> {
let summary = "Computes the floating-point absolute value";
let description = [{
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index b6a6299667308..b68e91f64dc84 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -85,6 +85,14 @@ static RValue
emitUnaryMaybeConstrainedFPBuiltin(CIRGenFunction &cgf,
return RValue::get(call->getResult(0));
}
+template
+static RValue emitUnaryFPBuiltin(CIRGenFunction &cgf, const CallExpr &e) {
+ mlir::Value arg = cgf.emitScalarExpr(e.getArg(0));
+ auto call =
+ Operation::create(cgf.getBuilder(), arg.getLoc(), arg.getType(), arg);
+ return RValue::get(call->getResult(0));
+}
+
RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned
builtinID,
const CallExpr *e,
ReturnValueSlot returnValue) {
@@ -349,6 +357,9 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
case Builtin::BI__builtin_unreachable:
emitUnreachable(e->getExprLoc(), /*createNewBlock=*/true);
return RValue::get(nullptr);
+
+ case Builtin::BI__builtin_elementwise_acos:
+return emitUnaryFPBuiltin(*this, *e);
}
// If this is an alias for a lib function (e.g. __builtin_sin), emit
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index f1fdfed166bbc..ede10c5d1e6c0 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -577,6 +577,15 @@ struct ConvertCIRToLLVMPass
StringRef getArgument() const override { return "cir-flat-to-llvm"; }
};
+mlir::LogicalResult CIRToLLVMACosOpLowering::matchAndRewrite(
+cir::ACosOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+ mlir::Type resTy = typeConverter->convertType(op.getType());
+ rewriter.replaceOpWithNewOp(op, resTy,
+ adaptor.getOperands()[0]);
+ return mlir::success();
+}
+
mlir::LogicalResult CIRToLLVMAssumeOpLowering::matchAndRewrite(
cir::AssumeOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
@@ -2395,6 +2404,7 @@ void ConvertCIRToLLVMPass::runOnOperation() {
dl);
patterns.add<
// clang-format off
+ CIRToLLVMACosOpLowering,
CIRToLLVMAssumeOpLowering,
CIRToLLVMAssumeAlignedOpLowering,
CIRToLLVMAssumeSepStorageOpLowering,
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
index da7df8982d34c..656a776035885 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
@@ -718,6 +718,15 @@ class CIRToLLVMFAbsOpLowering : public
mlir::OpConversionPattern {
mlir::ConversionPatternRewriter &) const override;
};
+class CIRToLLVMACosOpLowering : public mlir::OpConversionPattern {
+public:
+ using mlir::OpConversionPattern::OpConversionPattern;
+
+ mlir::LogicalResult
+ matchAndRewrite(cir::ACosOp op, OpAdaptor,
+ mlir::ConversionPatternRewriter &) const override;
+};
+
class CIRToLLVMInlineAsmOpLowering
: public mlir::OpConversionPattern {
mlir::DataLayout const &dataLayout;
diff --git a/clang/test/CIR/CodeGen/builtins-elementwise.c
b/clang/test/CIR/CodeGen/bu
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
https://github.com/AmrDeveloper updated
https://github.com/llvm/llvm-project/pull/156356
>From a23eb7b29d90a7afc9c02080ca9747f365a67270 Mon Sep 17 00:00:00 2001
From: AmrDeveloper
Date: Sun, 31 Aug 2025 18:55:45 +0200
Subject: [PATCH 1/2] [CIR] Upstream builtin ACos op
---
clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 +
clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp | 11 ++
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 10 +
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.h | 9 +
clang/test/CIR/CodeGen/builtins-elementwise.c | 38 +++
5 files changed, 77 insertions(+)
create mode 100644 clang/test/CIR/CodeGen/builtins-elementwise.c
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 982533f5e3b84..0f6c7332cd9ba 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -3732,6 +3732,15 @@ class CIR_UnaryFPToFPBuiltinOp
let llvmOp = llvmOpName;
}
+def CIR_ACosOp : CIR_UnaryFPToFPBuiltinOp<"acos", "ACosOp"> {
+ let summary = "Computes the arcus cosine of the specified value";
+ let description = [{
+`cir.acos`computes the arcus cosine of a given value and
+returns a result of the same type. ignoring floating-point
+exceptions. It does not set `errno`.
+ }];
+}
+
def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> {
let summary = "Computes the floating-point absolute value";
let description = [{
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index b6a6299667308..b68e91f64dc84 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -85,6 +85,14 @@ static RValue
emitUnaryMaybeConstrainedFPBuiltin(CIRGenFunction &cgf,
return RValue::get(call->getResult(0));
}
+template
+static RValue emitUnaryFPBuiltin(CIRGenFunction &cgf, const CallExpr &e) {
+ mlir::Value arg = cgf.emitScalarExpr(e.getArg(0));
+ auto call =
+ Operation::create(cgf.getBuilder(), arg.getLoc(), arg.getType(), arg);
+ return RValue::get(call->getResult(0));
+}
+
RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned
builtinID,
const CallExpr *e,
ReturnValueSlot returnValue) {
@@ -349,6 +357,9 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
case Builtin::BI__builtin_unreachable:
emitUnreachable(e->getExprLoc(), /*createNewBlock=*/true);
return RValue::get(nullptr);
+
+ case Builtin::BI__builtin_elementwise_acos:
+return emitUnaryFPBuiltin(*this, *e);
}
// If this is an alias for a lib function (e.g. __builtin_sin), emit
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index f1fdfed166bbc..ede10c5d1e6c0 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -577,6 +577,15 @@ struct ConvertCIRToLLVMPass
StringRef getArgument() const override { return "cir-flat-to-llvm"; }
};
+mlir::LogicalResult CIRToLLVMACosOpLowering::matchAndRewrite(
+cir::ACosOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+ mlir::Type resTy = typeConverter->convertType(op.getType());
+ rewriter.replaceOpWithNewOp(op, resTy,
+ adaptor.getOperands()[0]);
+ return mlir::success();
+}
+
mlir::LogicalResult CIRToLLVMAssumeOpLowering::matchAndRewrite(
cir::AssumeOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
@@ -2395,6 +2404,7 @@ void ConvertCIRToLLVMPass::runOnOperation() {
dl);
patterns.add<
// clang-format off
+ CIRToLLVMACosOpLowering,
CIRToLLVMAssumeOpLowering,
CIRToLLVMAssumeAlignedOpLowering,
CIRToLLVMAssumeSepStorageOpLowering,
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
index da7df8982d34c..656a776035885 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
@@ -718,6 +718,15 @@ class CIRToLLVMFAbsOpLowering : public
mlir::OpConversionPattern {
mlir::ConversionPatternRewriter &) const override;
};
+class CIRToLLVMACosOpLowering : public mlir::OpConversionPattern {
+public:
+ using mlir::OpConversionPattern::OpConversionPattern;
+
+ mlir::LogicalResult
+ matchAndRewrite(cir::ACosOp op, OpAdaptor,
+ mlir::ConversionPatternRewriter &) const override;
+};
+
class CIRToLLVMInlineAsmOpLowering
: public mlir::OpConversionPattern {
mlir::DataLayout const &dataLayout;
diff --git a/clang/test/CIR/CodeGen/builtins-elementwise.c
b/clang/test/CIR/CodeGen/bu
[clang] [CIR] Upstream FPToFPBuiltin ACosOp (PR #156356)
@@ -3732,6 +3732,15 @@ class CIR_UnaryFPToFPBuiltinOp
let llvmOp = llvmOpName;
}
+def CIR_ACosOp : CIR_UnaryFPToFPBuiltinOp<"acos", "ACosOp"> {
+ let summary = "Computes the arcus cosine of the specified value";
+ let description = [{
+`cir.acos`computes the arcus cosine of a given value and
+returns a result of the same type. ignoring floating-point
+exceptions. It does not set `errno`.
+ }];
xlauko wrote:
```suggestion
`cir.acos` computes the arc cosine of a given value and
returns a result of the same type.
Floating-point exceptions are ignored, and it does not set errno.
}];
```
https://github.com/llvm/llvm-project/pull/156356
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
