[flang-commits] [flang] [flang] Implement `sinpi` (PR #149525)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Tue Jul 22 10:28:30 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);
----------------
vzakhari wrote:
I think you may follow the implementation of `SinF128` as Tom suggested. As long as `libquadmath` does not support `sinpi` for `float128` you may implement `SinpiF128` in `flang-rt/lib/quadmath` same way you implement it here but using proper `PI` definition from https://gcc.gnu.org/onlinedocs/libquadmath/Typedef-and-constants.html
https://github.com/llvm/llvm-project/pull/149525
More information about the flang-commits
mailing list