[flang-commits] [flang] [flang] Implement `sinpi` (PR #149525)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Tue Jul 22 10:02:06 PDT 2025


================
@@ -8060,6 +8061,21 @@ mlir::Value IntrinsicLibrary::genSind(mlir::Type resultType,
   return getRuntimeCallGenerator("sin", ftype)(builder, loc, {arg});
 }
 
+// SINPI
+mlir::Value IntrinsicLibrary::genSinpi(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:

As I understand it, flang-rt is set up to call either glibc or libquadmath depending what is available. If possible it would be good to re-use that mechanism instead of adding further logic for that here. So far as I can tell, the runtime call generator is calling the right runtime function for f128, at least for sind.

But yes I see what you mean about the 64-bit constants used with sind. I think merging this is okay so long as this does get fixed later.

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


More information about the flang-commits mailing list