[llvm-branch-commits] [flang] [flang] Implement `tanpi` (PR #149527)

Tom Eccles via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jul 21 07:44:39 PDT 2025


================
@@ -8157,6 +8158,21 @@ mlir::Value IntrinsicLibrary::genTand(mlir::Type resultType,
   return getRuntimeCallGenerator("tan", ftype)(builder, loc, {arg});
 }
 
+// TANPI
+mlir::Value IntrinsicLibrary::genTanpi(mlir::Type resultType,
+                                       llvm::ArrayRef<mlir::Value> args) {
+  assert(args.size() == 1);
+  mlir::MLIRContext *context = builder.getContext();
+  mlir::FunctionType ftype =
+      mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
+  llvm::APFloat pi = llvm::APFloat(llvm::numbers::pi);
+  mlir::Value dfactor =
+      builder.createRealConstant(loc, mlir::Float64Type::get(context), pi);
+  mlir::Value factor = builder.createConvert(loc, args[0].getType(), dfactor);
----------------
tblah wrote:

See my comment on the other PR. Otherwise this looks okay.

https://github.com/llvm/llvm-project/pull/149527


More information about the llvm-branch-commits mailing list