[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

Jun Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 22 05:39:16 PST 2021


junaire updated this revision to Diff 395853.
junaire added a comment.

Sorry, It seems that the base branch is wrong, reupdate it.


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,
@@ -3128,8 +3134,8 @@
       Result = Builder.CreateBinaryIntrinsic(
           llvm::Intrinsic::abs, Op0, Builder.getFalse(), nullptr, "elt.abs");
     else
-      Result = Builder.CreateUnaryIntrinsic(llvm::Intrinsic::fabs, Op0, nullptr,
-                                            "elt.abs");
+      Result = emitUnaryBuiltin(*this, E, llvm::Intrinsic::fabs, "elt.abs");
+
     return RValue::get(Result);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116161.395853.patch
Type: text/x-patch
Size: 1137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211222/01a8887a/attachment-0001.bin>


More information about the cfe-commits mailing list