junaire created this revision. junaire added reviewers: fhahn, arsenm. junaire requested review of this revision. Herald added subscribers: cfe-commits, wdng. Herald added a project: clang.
This patch adds an overload for emitUnaryBuiltin, which is addressed in D115429 <https://reviews.llvm.org/D115429>. After this change, we can avoid some duplicate codes when emitting IR for __builtin_elementwise_*. Signed-off-by: Jun Zhang <j...@junz.org> Repository: rG LLVM Github Monorepo 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,
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,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits