[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.
Jun Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 24 00:12:04 PST 2021
junaire updated this revision to Diff 396140.
junaire added a comment.
Fix wrong usage.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116161/new/
https://reviews.llvm.org/D116161
Files:
clang/lib/CodeGen/CGBuiltin.cpp
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
return CGF.Builder.CreateCall(F, Src0);
}
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+ unsigned IntrinsicID, llvm::StringRef Name) {
+ llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+ return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
// Emit an intrinsic that has 2 operands of the same type as its result.
static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
const CallExpr *E,
@@ -3130,16 +3136,14 @@
else
Result = Builder.CreateUnaryIntrinsic(llvm::Intrinsic::fabs, Op0, nullptr,
"elt.abs");
- return RValue::get(Result);
- }
- case Builtin::BI__builtin_elementwise_ceil: {
- Value *Op0 = EmitScalarExpr(E->getArg(0));
- Value *Result = Builder.CreateUnaryIntrinsic(llvm::Intrinsic::ceil, Op0,
- nullptr, "elt.ceil");
return RValue::get(Result);
}
+ case Builtin::BI__builtin_elementwise_ceil:
+ return RValue::get(
+ emitUnaryBuiltin(*this, E, llvm::Intrinsic::ceil, "elt.ceil"));
+
case Builtin::BI__builtin_elementwise_max: {
Value *Op0 = EmitScalarExpr(E->getArg(0));
Value *Op1 = EmitScalarExpr(E->getArg(1));
@@ -3211,12 +3215,9 @@
return RValue::get(Result);
}
- case Builtin::BI__builtin_reduce_xor: {
- Value *Op0 = EmitScalarExpr(E->getArg(0));
- Value *Result = Builder.CreateUnaryIntrinsic(
- llvm::Intrinsic::vector_reduce_xor, Op0, nullptr, "rdx.xor");
- return RValue::get(Result);
- }
+ case Builtin::BI__builtin_reduce_xor:
+ return RValue::get(emitUnaryBuiltin(
+ *this, E, llvm::Intrinsic::vector_reduce_xor, "rdx.xor"));
case Builtin::BI__builtin_matrix_transpose: {
const auto *MatrixTy = E->getArg(0)->getType()->getAs<ConstantMatrixType>();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116161.396140.patch
Type: text/x-patch
Size: 2109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211224/02ce4997/attachment-0001.bin>
More information about the cfe-commits
mailing list