[flang-commits] [flang] [flang][runtime] Disable LDBL_MANT_DIG == 113 for the offload builds. (PR #109339)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Thu Sep 19 14:56:57 PDT 2024
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/109339
>From 0480d55103714c25fd055bad7e347a89bb9359ec Mon Sep 17 00:00:00 2001
From: Slava Zakharin <szakharin at nvidia.com>
Date: Thu, 19 Sep 2024 14:43:01 -0700
Subject: [PATCH 1/2] [flang][runtime] Disable LDBL_MANT_DIG == 113 for the
offload builds.
When compiling on aarch64 some `LDBL_MANT_DIG == 113` entries
end up trying to use `complex<long double>` for which there are
no certain specializations in `libcudacxx`. This change-set
includes a clean-up for `LDBL_MANT_DIG == 113` usage, which is replaced
with `HAS_LDBL128` that is set in `float128.h`.
---
flang/include/flang/Common/float128.h | 15 ++++++++-
flang/include/flang/Runtime/cpp-type.h | 4 +--
.../flang/Runtime/matmul-instances.inc | 6 ++--
flang/include/flang/Runtime/numeric.h | 32 +++++++++----------
flang/include/flang/Runtime/reduce.h | 4 +--
flang/include/flang/Runtime/reduction.h | 18 +++++------
.../include/flang/Runtime/transformational.h | 8 ++---
flang/include/flang/Tools/TargetSetup.h | 2 +-
flang/lib/Evaluate/intrinsics-library.cpp | 7 ++--
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +-
flang/runtime/Float128Math/acos.cpp | 2 +-
flang/runtime/Float128Math/acosh.cpp | 2 +-
flang/runtime/Float128Math/asin.cpp | 2 +-
flang/runtime/Float128Math/asinh.cpp | 2 +-
flang/runtime/Float128Math/atan.cpp | 2 +-
flang/runtime/Float128Math/atan2.cpp | 2 +-
flang/runtime/Float128Math/atanh.cpp | 2 +-
flang/runtime/Float128Math/ceil.cpp | 2 +-
flang/runtime/Float128Math/complex-math.c | 4 +--
flang/runtime/Float128Math/complex-math.h | 2 +-
flang/runtime/Float128Math/cos.cpp | 2 +-
flang/runtime/Float128Math/cosh.cpp | 2 +-
flang/runtime/Float128Math/erf.cpp | 2 +-
flang/runtime/Float128Math/erfc.cpp | 2 +-
flang/runtime/Float128Math/exp.cpp | 2 +-
flang/runtime/Float128Math/exponent.cpp | 2 +-
flang/runtime/Float128Math/floor.cpp | 2 +-
flang/runtime/Float128Math/fma.cpp | 2 +-
flang/runtime/Float128Math/fraction.cpp | 2 +-
flang/runtime/Float128Math/hypot.cpp | 2 +-
flang/runtime/Float128Math/j0.cpp | 2 +-
flang/runtime/Float128Math/j1.cpp | 2 +-
flang/runtime/Float128Math/jn.cpp | 2 +-
flang/runtime/Float128Math/lgamma.cpp | 2 +-
flang/runtime/Float128Math/llround.cpp | 2 +-
flang/runtime/Float128Math/log.cpp | 2 +-
flang/runtime/Float128Math/log10.cpp | 2 +-
flang/runtime/Float128Math/lround.cpp | 2 +-
flang/runtime/Float128Math/math-entries.h | 2 +-
flang/runtime/Float128Math/mod-real.cpp | 2 +-
flang/runtime/Float128Math/modulo-real.cpp | 2 +-
flang/runtime/Float128Math/nearest.cpp | 2 +-
flang/runtime/Float128Math/norm2.cpp | 2 +-
flang/runtime/Float128Math/pow.cpp | 2 +-
flang/runtime/Float128Math/random.cpp | 2 +-
flang/runtime/Float128Math/round.cpp | 2 +-
flang/runtime/Float128Math/rrspacing.cpp | 2 +-
flang/runtime/Float128Math/scale.cpp | 2 +-
flang/runtime/Float128Math/set-exponent.cpp | 2 +-
flang/runtime/Float128Math/sin.cpp | 2 +-
flang/runtime/Float128Math/sinh.cpp | 2 +-
flang/runtime/Float128Math/spacing.cpp | 2 +-
flang/runtime/Float128Math/sqrt.cpp | 2 +-
flang/runtime/Float128Math/tan.cpp | 2 +-
flang/runtime/Float128Math/tanh.cpp | 2 +-
flang/runtime/Float128Math/tgamma.cpp | 2 +-
flang/runtime/Float128Math/trunc.cpp | 2 +-
flang/runtime/Float128Math/y0.cpp | 2 +-
flang/runtime/Float128Math/y1.cpp | 2 +-
flang/runtime/Float128Math/yn.cpp | 2 +-
flang/runtime/complex-powi.cpp | 6 ++--
flang/runtime/complex-reduction.c | 12 +++----
flang/runtime/complex-reduction.h | 10 +++---
flang/runtime/dot-product.cpp | 4 +--
flang/runtime/extrema.cpp | 8 ++---
flang/runtime/numeric-templates.h | 2 +-
flang/runtime/numeric.cpp | 16 +++++-----
flang/runtime/product.cpp | 4 +--
flang/runtime/reduce.cpp | 4 +--
flang/runtime/reduction-templates.h | 6 ++--
flang/runtime/sum.cpp | 4 +--
flang/runtime/transformational.cpp | 8 ++---
flang/unittests/Runtime/Numeric.cpp | 2 +-
flang/unittests/Runtime/Reduction.cpp | 4 +--
flang/unittests/Runtime/Transformational.cpp | 8 ++---
75 files changed, 156 insertions(+), 142 deletions(-)
diff --git a/flang/include/flang/Common/float128.h b/flang/include/flang/Common/float128.h
index 2e76bc0a162e61..eddd3cf25382e1 100644
--- a/flang/include/flang/Common/float128.h
+++ b/flang/include/flang/Common/float128.h
@@ -20,6 +20,7 @@
#ifndef FORTRAN_COMMON_FLOAT128_H_
#define FORTRAN_COMMON_FLOAT128_H_
+#include "api-attrs.h"
#include <float.h>
#ifdef __cplusplus
@@ -51,8 +52,20 @@
#endif /* (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)) && \
!defined(_LIBCPP_VERSION) && !defined(__CUDA_ARCH__) */
-/* Define pure C CFloat128Type and CFloat128ComplexType. */
#if LDBL_MANT_DIG == 113
+#define HAS_LDBL128 1
+#endif
+
+#if defined(RT_DEVICE_COMPILATION) && defined(__CUDACC__)
+/*
+ * Most offload targets do not support 128-bit 'long double'.
+ * Disable HAS_LDBL128 for __CUDACC__ for the time being.
+ */
+#undef HAS_LDBL128
+#endif
+
+/* Define pure C CFloat128Type and CFloat128ComplexType. */
+#if HAS_LDBL128
typedef long double CFloat128Type;
#ifndef __cplusplus
typedef long double _Complex CFloat128ComplexType;
diff --git a/flang/include/flang/Runtime/cpp-type.h b/flang/include/flang/Runtime/cpp-type.h
index aef0fbd7ede586..f6180b4a9ab60c 100644
--- a/flang/include/flang/Runtime/cpp-type.h
+++ b/flang/include/flang/Runtime/cpp-type.h
@@ -78,12 +78,12 @@ template <> struct CppTypeForHelper<TypeCategory::Real, 10> {
#endif
#if __STDCPP_FLOAT128_T__
using CppFloat128Type = std::float128_t;
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
using CppFloat128Type = long double;
#elif HAS_FLOAT128
using CppFloat128Type = __float128;
#endif
-#if __STDCPP_FLOAT128_t || LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if __STDCPP_FLOAT128_t || HAS_LDBL128 || HAS_FLOAT128
template <> struct CppTypeForHelper<TypeCategory::Real, 16> {
using type = CppFloat128Type;
};
diff --git a/flang/include/flang/Runtime/matmul-instances.inc b/flang/include/flang/Runtime/matmul-instances.inc
index 88e3067ca029d4..da319481fce3b8 100644
--- a/flang/include/flang/Runtime/matmul-instances.inc
+++ b/flang/include/flang/Runtime/matmul-instances.inc
@@ -121,7 +121,7 @@ MATMUL_DIRECT_INSTANCE(Integer, 16, Complex, 10)
MATMUL_DIRECT_INSTANCE(Real, 10, Integer, 16)
MATMUL_DIRECT_INSTANCE(Complex, 10, Integer, 16)
#endif
-#if MATMUL_FORCE_ALL_TYPES || (LDBL_MANT_DIG == 113 || HAS_FLOAT128)
+#if MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
MATMUL_INSTANCE(Integer, 16, Real, 16)
MATMUL_INSTANCE(Integer, 16, Complex, 16)
MATMUL_INSTANCE(Real, 16, Integer, 16)
@@ -195,7 +195,7 @@ MATMUL_DIRECT_INSTANCE(Complex, 16, Complex, 10)
#endif
#endif // MATMUL_FORCE_ALL_TYPES || HAS_FLOAT80
-#if MATMUL_FORCE_ALL_TYPES || (LDBL_MANT_DIG == 113 || HAS_FLOAT128)
+#if MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
#define FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(macro) \
macro(Integer, 1, Real, 16) \
macro(Integer, 1, Complex, 16) \
@@ -236,7 +236,7 @@ MATMUL_DIRECT_INSTANCE(Complex, 16, Complex, 10)
FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(MATMUL_INSTANCE)
FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(MATMUL_DIRECT_INSTANCE)
-#endif // MATMUL_FORCE_ALL_TYPES || (LDBL_MANT_DIG == 113 || HAS_FLOAT128)
+#endif // MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
#define FOREACH_MATMUL_LOGICAL_TYPE_PAIR(macro) \
macro(Logical, 1, Logical, 1) \
diff --git a/flang/include/flang/Runtime/numeric.h b/flang/include/flang/Runtime/numeric.h
index c3923ee2e0d889..9e6bf357861e75 100644
--- a/flang/include/flang/Runtime/numeric.h
+++ b/flang/include/flang/Runtime/numeric.h
@@ -58,7 +58,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDECL(Ceiling10_16)(
CppTypeFor<TypeCategory::Real, 10>);
#endif
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Integer, 1> RTDECL(Ceiling16_1)(
CppTypeFor<TypeCategory::Real, 16>);
CppTypeFor<TypeCategory::Integer, 2> RTDECL(Ceiling16_2)(
@@ -82,7 +82,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(ErfcScaled8)(
CppTypeFor<TypeCategory::Real, 10> RTDECL(ErfcScaled10)(
CppTypeFor<TypeCategory::Real, 10>);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(ErfcScaled16)(
CppTypeFor<TypeCategory::Real, 16>);
#endif
@@ -102,7 +102,7 @@ CppTypeFor<TypeCategory::Integer, 4> RTDECL(Exponent10_4)(
CppTypeFor<TypeCategory::Integer, 8> RTDECL(Exponent10_8)(
CppTypeFor<TypeCategory::Real, 10>);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT
+#if HAS_LDBL128 || HAS_FLOAT
CppTypeFor<TypeCategory::Integer, 4> RTDECL(Exponent16_4)(
CppTypeFor<TypeCategory::Real, 16>);
CppTypeFor<TypeCategory::Integer, 8> RTDECL(Exponent16_8)(
@@ -148,7 +148,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDECL(Floor10_16)(
CppTypeFor<TypeCategory::Real, 10>);
#endif
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Integer, 1> RTDECL(Floor16_1)(
CppTypeFor<TypeCategory::Real, 16>);
CppTypeFor<TypeCategory::Integer, 2> RTDECL(Floor16_2)(
@@ -172,7 +172,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(Fraction8)(
CppTypeFor<TypeCategory::Real, 10> RTDECL(Fraction10)(
CppTypeFor<TypeCategory::Real, 10>);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(Fraction16)(
CppTypeFor<TypeCategory::Real, 16>);
#endif
@@ -183,7 +183,7 @@ bool RTDECL(IsNaN8)(CppTypeFor<TypeCategory::Real, 8>);
#if HAS_FLOAT80
bool RTDECL(IsNaN10)(CppTypeFor<TypeCategory::Real, 10>);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
bool RTDECL(IsNaN16)(CppTypeFor<TypeCategory::Real, 16>);
#endif
@@ -217,7 +217,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(ModReal10)(
CppTypeFor<TypeCategory::Real, 10>, CppTypeFor<TypeCategory::Real, 10>,
const char *sourceFile = nullptr, int sourceLine = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(ModReal16)(
CppTypeFor<TypeCategory::Real, 16>, CppTypeFor<TypeCategory::Real, 16>,
const char *sourceFile = nullptr, int sourceLine = 0);
@@ -252,7 +252,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(ModuloReal10)(
CppTypeFor<TypeCategory::Real, 10>, CppTypeFor<TypeCategory::Real, 10>,
const char *sourceFile = nullptr, int sourceLine = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(ModuloReal16)(
CppTypeFor<TypeCategory::Real, 16>, CppTypeFor<TypeCategory::Real, 16>,
const char *sourceFile = nullptr, int sourceLine = 0);
@@ -297,7 +297,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDECL(Nint10_16)(
CppTypeFor<TypeCategory::Real, 10>);
#endif
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Integer, 1> RTDECL(Nint16_1)(
CppTypeFor<TypeCategory::Real, 16>);
CppTypeFor<TypeCategory::Integer, 2> RTDECL(Nint16_2)(
@@ -323,7 +323,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(Nearest8)(
CppTypeFor<TypeCategory::Real, 10> RTDECL(Nearest10)(
CppTypeFor<TypeCategory::Real, 10>, bool positive);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(Nearest16)(
CppTypeFor<TypeCategory::Real, 16>, bool positive);
#endif
@@ -337,7 +337,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(RRSpacing8)(
CppTypeFor<TypeCategory::Real, 10> RTDECL(RRSpacing10)(
CppTypeFor<TypeCategory::Real, 10>);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(RRSpacing16)(
CppTypeFor<TypeCategory::Real, 16>);
#endif
@@ -351,7 +351,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(SetExponent8)(
CppTypeFor<TypeCategory::Real, 10> RTDECL(SetExponent10)(
CppTypeFor<TypeCategory::Real, 10>, std::int64_t);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(SetExponent16)(
CppTypeFor<TypeCategory::Real, 16>, std::int64_t);
#endif
@@ -365,7 +365,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(Scale8)(
CppTypeFor<TypeCategory::Real, 10> RTDECL(Scale10)(
CppTypeFor<TypeCategory::Real, 10>, std::int64_t);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(Scale16)(
CppTypeFor<TypeCategory::Real, 16>, std::int64_t);
#endif
@@ -414,7 +414,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(Spacing8)(
CppTypeFor<TypeCategory::Real, 10> RTDECL(Spacing10)(
CppTypeFor<TypeCategory::Real, 10>);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(Spacing16)(
CppTypeFor<TypeCategory::Real, 16>);
#endif
@@ -430,7 +430,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(FPow10i)(
CppTypeFor<TypeCategory::Real, 10> b,
CppTypeFor<TypeCategory::Integer, 4> e);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(FPow16i)(
CppTypeFor<TypeCategory::Real, 16> b,
CppTypeFor<TypeCategory::Integer, 4> e);
@@ -447,7 +447,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(FPow10k)(
CppTypeFor<TypeCategory::Real, 10> b,
CppTypeFor<TypeCategory::Integer, 8> e);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDECL(FPow16k)(
CppTypeFor<TypeCategory::Real, 16> b,
CppTypeFor<TypeCategory::Integer, 8> e);
diff --git a/flang/include/flang/Runtime/reduce.h b/flang/include/flang/Runtime/reduce.h
index c016b37f9592a1..c63782b85f22f5 100644
--- a/flang/include/flang/Runtime/reduce.h
+++ b/flang/include/flang/Runtime/reduce.h
@@ -210,7 +210,7 @@ void RTDECL(ReduceReal10DimValue)(Descriptor &result, const Descriptor &array,
const CppTypeFor<TypeCategory::Real, 10> *identity = nullptr,
bool ordered = true);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppFloat128Type RTDECL(ReduceReal16Ref)(const Descriptor &,
ReferenceReductionOperation<CppFloat128Type>, const char *source, int line,
int dim = 0, const Descriptor *mask = nullptr,
@@ -351,7 +351,7 @@ void RTDECL(CppReduceComplex10DimValue)(Descriptor &result,
const CppTypeFor<TypeCategory::Complex, 10> *identity = nullptr,
bool ordered = true);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDECL(CppReduceComplex16Ref)(CppTypeFor<TypeCategory::Complex, 16> &,
const Descriptor &,
ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 16>>,
diff --git a/flang/include/flang/Runtime/reduction.h b/flang/include/flang/Runtime/reduction.h
index 7eafacee69d034..91811581f645d5 100644
--- a/flang/include/flang/Runtime/reduction.h
+++ b/flang/include/flang/Runtime/reduction.h
@@ -73,7 +73,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(SumReal10)(const Descriptor &,
const char *source, int line, int dim = 0,
const Descriptor *mask = nullptr);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppFloat128Type RTDECL(SumReal16)(const Descriptor &, const char *source,
int line, int dim = 0, const Descriptor *mask = nullptr);
#endif
@@ -95,7 +95,7 @@ void RTDECL(CppSumComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
const Descriptor &, const char *source, int line, int dim = 0,
const Descriptor *mask = nullptr);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDECL(CppSumComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
const Descriptor &, const char *source, int line, int dim = 0,
const Descriptor *mask = nullptr);
@@ -134,7 +134,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(ProductReal10)(const Descriptor &,
const char *source, int line, int dim = 0,
const Descriptor *mask = nullptr);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppFloat128Type RTDECL(ProductReal16)(const Descriptor &, const char *source,
int line, int dim = 0, const Descriptor *mask = nullptr);
#endif
@@ -156,7 +156,7 @@ void RTDECL(CppProductComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
const Descriptor &, const char *source, int line, int dim = 0,
const Descriptor *mask = nullptr);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDECL(CppProductComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
const Descriptor &, const char *source, int line, int dim = 0,
const Descriptor *mask = nullptr);
@@ -314,7 +314,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(MaxvalReal10)(const Descriptor &,
const char *source, int line, int dim = 0,
const Descriptor *mask = nullptr);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppFloat128Type RTDECL(MaxvalReal16)(const Descriptor &, const char *source,
int line, int dim = 0, const Descriptor *mask = nullptr);
#endif
@@ -346,7 +346,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(MinvalReal10)(const Descriptor &,
const char *source, int line, int dim = 0,
const Descriptor *mask = nullptr);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppFloat128Type RTDECL(MinvalReal16)(const Descriptor &, const char *source,
int line, int dim = 0, const Descriptor *mask = nullptr);
#endif
@@ -371,7 +371,7 @@ double RTDECL(Norm2_8)(
CppTypeFor<TypeCategory::Real, 10> RTDECL(Norm2_10)(
const Descriptor &, const char *source, int line, int dim = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppFloat128Type RTDECL(Norm2_16)(
const Descriptor &, const char *source, int line, int dim = 0);
void RTDECL(Norm2DimReal16)(
@@ -421,7 +421,7 @@ double RTDECL(DotProductReal8)(const Descriptor &, const Descriptor &,
CppTypeFor<TypeCategory::Real, 10> RTDECL(DotProductReal10)(const Descriptor &,
const Descriptor &, const char *source = nullptr, int line = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppFloat128Type RTDECL(DotProductReal16)(const Descriptor &, const Descriptor &,
const char *source = nullptr, int line = 0);
#endif
@@ -442,7 +442,7 @@ void RTDECL(CppDotProductComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
const Descriptor &, const Descriptor &, const char *source = nullptr,
int line = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDECL(CppDotProductComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
const Descriptor &, const Descriptor &, const char *source = nullptr,
int line = 0);
diff --git a/flang/include/flang/Runtime/transformational.h b/flang/include/flang/Runtime/transformational.h
index faeaa1baa39ae2..d04fa685978837 100644
--- a/flang/include/flang/Runtime/transformational.h
+++ b/flang/include/flang/Runtime/transformational.h
@@ -53,7 +53,7 @@ void RTDECL(BesselJn_10)(Descriptor &result, int32_t n1, int32_t n2,
int line = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDECL(BesselJn_16)(Descriptor &result, int32_t n1, int32_t n2,
CppFloat128Type x, CppFloat128Type bn2, CppFloat128Type bn2_1,
const char *sourceFile = nullptr, int line = 0);
@@ -76,7 +76,7 @@ void RTDECL(BesselJnX0_10)(Descriptor &result, int32_t n1, int32_t n2,
const char *sourceFile = nullptr, int line = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDECL(BesselJnX0_16)(Descriptor &result, int32_t n1, int32_t n2,
const char *sourceFile = nullptr, int line = 0);
#endif
@@ -101,7 +101,7 @@ void RTDECL(BesselYn_10)(Descriptor &result, int32_t n1, int32_t n2,
int line = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDECL(BesselYn_16)(Descriptor &result, int32_t n1, int32_t n2,
CppFloat128Type x, CppFloat128Type bn1, CppFloat128Type bn1_1,
const char *sourceFile = nullptr, int line = 0);
@@ -124,7 +124,7 @@ void RTDECL(BesselYnX0_10)(Descriptor &result, int32_t n1, int32_t n2,
const char *sourceFile = nullptr, int line = 0);
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDECL(BesselYnX0_16)(Descriptor &result, int32_t n1, int32_t n2,
const char *sourceFile = nullptr, int line = 0);
#endif
diff --git a/flang/include/flang/Tools/TargetSetup.h b/flang/include/flang/Tools/TargetSetup.h
index ee89249441c174..d6d36835bd2cb3 100644
--- a/flang/include/flang/Tools/TargetSetup.h
+++ b/flang/include/flang/Tools/TargetSetup.h
@@ -36,7 +36,7 @@ namespace Fortran::tools {
#ifdef FLANG_RUNTIME_F128_MATH_LIB
// we can use libquadmath wrappers
constexpr bool f128Support = true;
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
// we can use libm wrappers
constexpr bool f128Support = true;
#else
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index ed28d8130808fa..ce9dd6b7b3df86 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -22,8 +22,9 @@
#include <functional>
#if HAS_QUADMATHLIB
#include "quadmath.h"
-#include "flang/Common/float128.h"
#endif
+#include "flang/Common/float128.h"
+#include "flang/Common/float80.h"
#include <type_traits>
namespace Fortran::evaluate {
@@ -414,7 +415,7 @@ template <> struct HostRuntimeLibrary<double, LibraryVersion::LibmExtensions> {
static_assert(map.Verify(), "map must be sorted");
};
-#if LDBL_MANT_DIG == 80 || LDBL_MANT_DIG == 113
+#if HAS_FLOAT80 || HAS_LDBL128
template <>
struct HostRuntimeLibrary<long double, LibraryVersion::LibmExtensions> {
using F = FuncPointer<long double, long double>;
@@ -430,7 +431,7 @@ struct HostRuntimeLibrary<long double, LibraryVersion::LibmExtensions> {
static constexpr HostRuntimeMap map{table};
static_assert(map.Verify(), "map must be sorted");
};
-#endif // LDBL_MANT_DIG == 80 || LDBL_MANT_DIG == 113
+#endif // HAS_FLOAT80 || HAS_LDBL128
#endif //_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
/// Define pgmath description
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index dc0dc47bda9a9d..4e6d92213c1241 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -750,7 +750,7 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
// Generate a call to the Fortran runtime library providing
// support for 128-bit float math.
-// On 'LDBL_MANT_DIG == 113' targets the implementation
+// On 'HAS_LDBL128' targets the implementation
// is provided by FortranRuntime, otherwise, it is done via
// FortranFloat128Math library. In the latter case the compiler
// has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee
diff --git a/flang/runtime/Float128Math/acos.cpp b/flang/runtime/Float128Math/acos.cpp
index 14ff6944856844..d9b4950aa1e35c 100644
--- a/flang/runtime/Float128Math/acos.cpp
+++ b/flang/runtime/Float128Math/acos.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(AcosF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Acos<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/acosh.cpp b/flang/runtime/Float128Math/acosh.cpp
index 9d70804e44a470..c572673ef55e62 100644
--- a/flang/runtime/Float128Math/acosh.cpp
+++ b/flang/runtime/Float128Math/acosh.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(AcoshF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Acosh<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/asin.cpp b/flang/runtime/Float128Math/asin.cpp
index 6781b23f0363db..57b6ffd9673605 100644
--- a/flang/runtime/Float128Math/asin.cpp
+++ b/flang/runtime/Float128Math/asin.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(AsinF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Asin<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/asinh.cpp b/flang/runtime/Float128Math/asinh.cpp
index 1310bc61c1de0f..03dded722b2543 100644
--- a/flang/runtime/Float128Math/asinh.cpp
+++ b/flang/runtime/Float128Math/asinh.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(AsinhF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Asinh<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/atan.cpp b/flang/runtime/Float128Math/atan.cpp
index f01382df90c0ee..19c86cae8867bc 100644
--- a/flang/runtime/Float128Math/atan.cpp
+++ b/flang/runtime/Float128Math/atan.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(AtanF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Atan<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/atan2.cpp b/flang/runtime/Float128Math/atan2.cpp
index dd646b0452b115..09d666ae14304c 100644
--- a/flang/runtime/Float128Math/atan2.cpp
+++ b/flang/runtime/Float128Math/atan2.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(Atan2F128)(
CppTypeFor<TypeCategory::Real, 16> x,
CppTypeFor<TypeCategory::Real, 16> y) {
diff --git a/flang/runtime/Float128Math/atanh.cpp b/flang/runtime/Float128Math/atanh.cpp
index 5fc5ba5debc81a..442d9beafae47e 100644
--- a/flang/runtime/Float128Math/atanh.cpp
+++ b/flang/runtime/Float128Math/atanh.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(AtanhF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Atanh<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/ceil.cpp b/flang/runtime/Float128Math/ceil.cpp
index ed4d164a62bedc..48e20b2b415774 100644
--- a/flang/runtime/Float128Math/ceil.cpp
+++ b/flang/runtime/Float128Math/ceil.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(CeilF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Ceil<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/complex-math.c b/flang/runtime/Float128Math/complex-math.c
index d0180c63a0d7bf..a7e32f3ef755b7 100644
--- a/flang/runtime/Float128Math/complex-math.c
+++ b/flang/runtime/Float128Math/complex-math.c
@@ -9,7 +9,7 @@
#include "complex-math.h"
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CFloat128Type RTDEF(CAbsF128)(CFloat128ComplexType x) { return CAbs(x); }
CFloat128ComplexType RTDEF(CAcosF128)(CFloat128ComplexType x) {
@@ -52,4 +52,4 @@ CFloat128ComplexType RTDEF(CTanhF128)(CFloat128ComplexType x) {
return CTanh(x);
}
-#endif // LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#endif // HAS_LDBL128 || HAS_FLOAT128
diff --git a/flang/runtime/Float128Math/complex-math.h b/flang/runtime/Float128Math/complex-math.h
index 81dd53a175d1aa..cf5e980a39b6bb 100644
--- a/flang/runtime/Float128Math/complex-math.h
+++ b/flang/runtime/Float128Math/complex-math.h
@@ -31,7 +31,7 @@
#define CSqrt(x) csqrtq(x)
#define CTan(x) ctanq(x)
#define CTanh(x) ctanhq(x)
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
/* Use 'long double' versions of libm functions. */
#include <complex.h>
diff --git a/flang/runtime/Float128Math/cos.cpp b/flang/runtime/Float128Math/cos.cpp
index b93c92f275f791..d1b3e0e736ca34 100644
--- a/flang/runtime/Float128Math/cos.cpp
+++ b/flang/runtime/Float128Math/cos.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(CosF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Cos<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/cosh.cpp b/flang/runtime/Float128Math/cosh.cpp
index a3662a826dcb1c..9fe5b61d8f95f7 100644
--- a/flang/runtime/Float128Math/cosh.cpp
+++ b/flang/runtime/Float128Math/cosh.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(CoshF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Cosh<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/erf.cpp b/flang/runtime/Float128Math/erf.cpp
index 631f71c76effe7..2a553bd395e88f 100644
--- a/flang/runtime/Float128Math/erf.cpp
+++ b/flang/runtime/Float128Math/erf.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(ErfF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Erf<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/erfc.cpp b/flang/runtime/Float128Math/erfc.cpp
index ea3cd646d8c4ba..2435ed2786cb32 100644
--- a/flang/runtime/Float128Math/erfc.cpp
+++ b/flang/runtime/Float128Math/erfc.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(ErfcF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Erfc<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/exp.cpp b/flang/runtime/Float128Math/exp.cpp
index b1161b0f29294c..5ca87d9dd25d2f 100644
--- a/flang/runtime/Float128Math/exp.cpp
+++ b/flang/runtime/Float128Math/exp.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(ExpF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Exp<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/exponent.cpp b/flang/runtime/Float128Math/exponent.cpp
index 1be1dd0d0ac8b8..237cde34e86914 100644
--- a/flang/runtime/Float128Math/exponent.cpp
+++ b/flang/runtime/Float128Math/exponent.cpp
@@ -12,7 +12,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
// EXPONENT (16.9.75)
CppTypeFor<TypeCategory::Integer, 4> RTDEF(Exponent16_4)(F128Type x) {
return Exponent<CppTypeFor<TypeCategory::Integer, 4>>(x);
diff --git a/flang/runtime/Float128Math/floor.cpp b/flang/runtime/Float128Math/floor.cpp
index 78a94984cac8a3..28f9c7b55dd513 100644
--- a/flang/runtime/Float128Math/floor.cpp
+++ b/flang/runtime/Float128Math/floor.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(FloorF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Floor<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/fma.cpp b/flang/runtime/Float128Math/fma.cpp
index ec67e8e6fba22b..87176c25dd6047 100644
--- a/flang/runtime/Float128Math/fma.cpp
+++ b/flang/runtime/Float128Math/fma.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(FmaF128)(
CppTypeFor<TypeCategory::Real, 16> x, CppTypeFor<TypeCategory::Real, 16> y,
CppTypeFor<TypeCategory::Real, 16> z) {
diff --git a/flang/runtime/Float128Math/fraction.cpp b/flang/runtime/Float128Math/fraction.cpp
index 8c9889b7f6871e..45ec12cd775187 100644
--- a/flang/runtime/Float128Math/fraction.cpp
+++ b/flang/runtime/Float128Math/fraction.cpp
@@ -12,7 +12,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
// FRACTION (16.9.80)
F128Type RTDEF(Fraction16)(F128Type x) { return Fraction(x); }
#endif
diff --git a/flang/runtime/Float128Math/hypot.cpp b/flang/runtime/Float128Math/hypot.cpp
index b4fa1d66bcfa6a..03049b06d3a248 100644
--- a/flang/runtime/Float128Math/hypot.cpp
+++ b/flang/runtime/Float128Math/hypot.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(HypotF128)(
CppTypeFor<TypeCategory::Real, 16> x,
CppTypeFor<TypeCategory::Real, 16> y) {
diff --git a/flang/runtime/Float128Math/j0.cpp b/flang/runtime/Float128Math/j0.cpp
index 9390a7eeb3c605..7207cbe1a92e75 100644
--- a/flang/runtime/Float128Math/j0.cpp
+++ b/flang/runtime/Float128Math/j0.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(J0F128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return J0<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/j1.cpp b/flang/runtime/Float128Math/j1.cpp
index c54927123388c6..9e49bcbc32ca4b 100644
--- a/flang/runtime/Float128Math/j1.cpp
+++ b/flang/runtime/Float128Math/j1.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(J1F128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return J1<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/jn.cpp b/flang/runtime/Float128Math/jn.cpp
index 15afd83400c320..37e5f428e5e260 100644
--- a/flang/runtime/Float128Math/jn.cpp
+++ b/flang/runtime/Float128Math/jn.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(JnF128)(
int n, CppTypeFor<TypeCategory::Real, 16> x) {
return Jn<true>::invoke(n, x);
diff --git a/flang/runtime/Float128Math/lgamma.cpp b/flang/runtime/Float128Math/lgamma.cpp
index ac31c89a912b32..54d0dd80838685 100644
--- a/flang/runtime/Float128Math/lgamma.cpp
+++ b/flang/runtime/Float128Math/lgamma.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(LgammaF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Lgamma<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/llround.cpp b/flang/runtime/Float128Math/llround.cpp
index b77281c507fe7c..f0c53ccdf66fd8 100644
--- a/flang/runtime/Float128Math/llround.cpp
+++ b/flang/runtime/Float128Math/llround.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Integer, 8> RTDEF(LlroundF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Llround<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/log.cpp b/flang/runtime/Float128Math/log.cpp
index 38e6b581fd849c..28fec1958f10b3 100644
--- a/flang/runtime/Float128Math/log.cpp
+++ b/flang/runtime/Float128Math/log.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(LogF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Log<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/log10.cpp b/flang/runtime/Float128Math/log10.cpp
index 3c89c0e707774f..f844d508f8d3bc 100644
--- a/flang/runtime/Float128Math/log10.cpp
+++ b/flang/runtime/Float128Math/log10.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(Log10F128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Log10<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/lround.cpp b/flang/runtime/Float128Math/lround.cpp
index ce7a228038a1d3..8c2d3315c62a7a 100644
--- a/flang/runtime/Float128Math/lround.cpp
+++ b/flang/runtime/Float128Math/lround.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Integer, 4> RTDEF(LroundF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Lround<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/math-entries.h b/flang/runtime/Float128Math/math-entries.h
index 13fdab26470038..151ed8a09fde0a 100644
--- a/flang/runtime/Float128Math/math-entries.h
+++ b/flang/runtime/Float128Math/math-entries.h
@@ -157,7 +157,7 @@ DEFINE_SIMPLE_ALIAS(Yn, ynq)
// Use cmath INFINITY/NAN definition. Rely on C implicit conversions.
#define F128_RT_INFINITY (INFINITY)
#define F128_RT_QNAN (NAN)
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
// Define wrapper callers for libm.
#include <limits>
diff --git a/flang/runtime/Float128Math/mod-real.cpp b/flang/runtime/Float128Math/mod-real.cpp
index 42e6ce76e2fa1b..e831c2df4abc1f 100644
--- a/flang/runtime/Float128Math/mod-real.cpp
+++ b/flang/runtime/Float128Math/mod-real.cpp
@@ -12,7 +12,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
// MOD (16.9.135)
F128Type RTDEF(ModReal16)(
F128Type x, F128Type p, const char *sourceFile, int sourceLine) {
diff --git a/flang/runtime/Float128Math/modulo-real.cpp b/flang/runtime/Float128Math/modulo-real.cpp
index 13000aba8c8323..88729da7e39875 100644
--- a/flang/runtime/Float128Math/modulo-real.cpp
+++ b/flang/runtime/Float128Math/modulo-real.cpp
@@ -12,7 +12,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
// MODULO (16.9.136)
F128Type RTDEF(ModuloReal16)(
F128Type x, F128Type p, const char *sourceFile, int sourceLine) {
diff --git a/flang/runtime/Float128Math/nearest.cpp b/flang/runtime/Float128Math/nearest.cpp
index 148ac4ef839160..50f6e7ea75a604 100644
--- a/flang/runtime/Float128Math/nearest.cpp
+++ b/flang/runtime/Float128Math/nearest.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(Nearest16)(
CppTypeFor<TypeCategory::Real, 16> x, bool positive) {
return Nextafter<true>::invoke(
diff --git a/flang/runtime/Float128Math/norm2.cpp b/flang/runtime/Float128Math/norm2.cpp
index 15c482f7f007ce..18e9c8cc8a2b96 100644
--- a/flang/runtime/Float128Math/norm2.cpp
+++ b/flang/runtime/Float128Math/norm2.cpp
@@ -13,7 +13,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(Norm2_16)(
const Descriptor &x, const char *source, int line, int dim) {
return GetTotalReduction<TypeCategory::Real, 16>(
diff --git a/flang/runtime/Float128Math/pow.cpp b/flang/runtime/Float128Math/pow.cpp
index 7a48828ee3e765..99aae04c65ecbe 100644
--- a/flang/runtime/Float128Math/pow.cpp
+++ b/flang/runtime/Float128Math/pow.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(PowF128)(
CppTypeFor<TypeCategory::Real, 16> x,
CppTypeFor<TypeCategory::Real, 16> y) {
diff --git a/flang/runtime/Float128Math/random.cpp b/flang/runtime/Float128Math/random.cpp
index cda962b416144e..e34bb2c7992011 100644
--- a/flang/runtime/Float128Math/random.cpp
+++ b/flang/runtime/Float128Math/random.cpp
@@ -13,7 +13,7 @@
using namespace Fortran::runtime::random;
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(RandomNumber16)(
const Descriptor &harvest, const char *source, int line) {
return Generate<CppTypeFor<TypeCategory::Real, 16>, 113>(harvest);
diff --git a/flang/runtime/Float128Math/round.cpp b/flang/runtime/Float128Math/round.cpp
index 6420c1bc9cd25d..e79ce30536b3bf 100644
--- a/flang/runtime/Float128Math/round.cpp
+++ b/flang/runtime/Float128Math/round.cpp
@@ -15,7 +15,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(RoundF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Round<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/rrspacing.cpp b/flang/runtime/Float128Math/rrspacing.cpp
index feddac418eec39..04cefc049bbee2 100644
--- a/flang/runtime/Float128Math/rrspacing.cpp
+++ b/flang/runtime/Float128Math/rrspacing.cpp
@@ -12,7 +12,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
// FRACTION (16.9.80)
F128Type RTDEF(RRSpacing16)(F128Type x) { return RRSpacing<113>(x); }
#endif
diff --git a/flang/runtime/Float128Math/scale.cpp b/flang/runtime/Float128Math/scale.cpp
index 0be958bd9f2a72..6b083afbdf4d1a 100644
--- a/flang/runtime/Float128Math/scale.cpp
+++ b/flang/runtime/Float128Math/scale.cpp
@@ -13,7 +13,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
F128Type RTDEF(Scale16)(F128Type x, std::int64_t p) {
auto ip{static_cast<int>(p)};
if (ip != p) {
diff --git a/flang/runtime/Float128Math/set-exponent.cpp b/flang/runtime/Float128Math/set-exponent.cpp
index 99c34af7962b9a..63c5b325085fb2 100644
--- a/flang/runtime/Float128Math/set-exponent.cpp
+++ b/flang/runtime/Float128Math/set-exponent.cpp
@@ -12,7 +12,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
// SET_EXPONENT (16.9.171)
F128Type RTDEF(SetExponent16)(F128Type x, std::int64_t p) {
return SetExponent(x, p);
diff --git a/flang/runtime/Float128Math/sin.cpp b/flang/runtime/Float128Math/sin.cpp
index 8ebc3f9881586e..99fa3e493e6941 100644
--- a/flang/runtime/Float128Math/sin.cpp
+++ b/flang/runtime/Float128Math/sin.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(SinF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Sin<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/sinh.cpp b/flang/runtime/Float128Math/sinh.cpp
index aa716a3e51ef5a..b6cd96963612e7 100644
--- a/flang/runtime/Float128Math/sinh.cpp
+++ b/flang/runtime/Float128Math/sinh.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(SinhF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Sinh<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/spacing.cpp b/flang/runtime/Float128Math/spacing.cpp
index a86c0b30e567ab..fc6aa2c4ec2d8f 100644
--- a/flang/runtime/Float128Math/spacing.cpp
+++ b/flang/runtime/Float128Math/spacing.cpp
@@ -12,7 +12,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
// SPACING (16.9.180)
F128Type RTDEF(Spacing16)(F128Type x) { return Spacing<113>(x); }
#endif
diff --git a/flang/runtime/Float128Math/sqrt.cpp b/flang/runtime/Float128Math/sqrt.cpp
index 83165a4c623191..871c66e0079845 100644
--- a/flang/runtime/Float128Math/sqrt.cpp
+++ b/flang/runtime/Float128Math/sqrt.cpp
@@ -12,7 +12,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
F128Type RTDEF(SqrtF128)(F128Type x) { return SQRTTy<F128Type>::compute(x); }
#endif
diff --git a/flang/runtime/Float128Math/tan.cpp b/flang/runtime/Float128Math/tan.cpp
index 8f4b723ca977bd..2d6f448ba89554 100644
--- a/flang/runtime/Float128Math/tan.cpp
+++ b/flang/runtime/Float128Math/tan.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(TanF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Tan<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/tanh.cpp b/flang/runtime/Float128Math/tanh.cpp
index b43a89520b6797..f6321f48191911 100644
--- a/flang/runtime/Float128Math/tanh.cpp
+++ b/flang/runtime/Float128Math/tanh.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(TanhF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Tanh<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/tgamma.cpp b/flang/runtime/Float128Math/tgamma.cpp
index 93f97800bdc966..98fd792a633304 100644
--- a/flang/runtime/Float128Math/tgamma.cpp
+++ b/flang/runtime/Float128Math/tgamma.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(TgammaF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Tgamma<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/trunc.cpp b/flang/runtime/Float128Math/trunc.cpp
index ca15a739c030e8..54fa33176813ca 100644
--- a/flang/runtime/Float128Math/trunc.cpp
+++ b/flang/runtime/Float128Math/trunc.cpp
@@ -15,7 +15,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(TruncF128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Trunc<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/y0.cpp b/flang/runtime/Float128Math/y0.cpp
index d6f39aac1053a8..0b3059b4cfe25d 100644
--- a/flang/runtime/Float128Math/y0.cpp
+++ b/flang/runtime/Float128Math/y0.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(Y0F128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Y0<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/y1.cpp b/flang/runtime/Float128Math/y1.cpp
index 477d36a9ea3c66..cb39d87034dc75 100644
--- a/flang/runtime/Float128Math/y1.cpp
+++ b/flang/runtime/Float128Math/y1.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(Y1F128)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Y1<true>::invoke(x);
diff --git a/flang/runtime/Float128Math/yn.cpp b/flang/runtime/Float128Math/yn.cpp
index 3a040cc8858970..bef8f9457df2fd 100644
--- a/flang/runtime/Float128Math/yn.cpp
+++ b/flang/runtime/Float128Math/yn.cpp
@@ -11,7 +11,7 @@
namespace Fortran::runtime {
extern "C" {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(YnF128)(
int n, CppTypeFor<TypeCategory::Real, 16> x) {
return Yn<true>::invoke(n, x);
diff --git a/flang/runtime/complex-powi.cpp b/flang/runtime/complex-powi.cpp
index d7a63724b96c8f..62f73e037b76f7 100644
--- a/flang/runtime/complex-powi.cpp
+++ b/flang/runtime/complex-powi.cpp
@@ -83,12 +83,12 @@ extern "C" double _Complex RTNAME(zpowk)(
return tgpowi(base, exp);
}
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
// Duplicate CFloat128ComplexType definition from flang/Common/float128.h.
// float128.h does not define it for C++, because _Complex triggers
// c99-extension warnings. We decided to disable warnings for this
// particular file, so we can use _Complex here.
-#if LDBL_MANT_DIG == 113
+#if HAS_LDBL128
typedef long double _Complex Qcomplex;
#elif HAS_FLOAT128
#if !defined(_ARCH_PPC) || defined(__LONG_DOUBLE_IEEE128__)
@@ -149,7 +149,7 @@ extern "C" Dcomplex RTNAME(zpowk)(Dcomplex base, std::int64_t exp) {
return *(Dcomplex *)(&cppres);
}
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
struct Qcomplex {
CFloat128Type re;
CFloat128Type im;
diff --git a/flang/runtime/complex-reduction.c b/flang/runtime/complex-reduction.c
index 232c5452488f1a..de1ff3d6830840 100644
--- a/flang/runtime/complex-reduction.c
+++ b/flang/runtime/complex-reduction.c
@@ -19,7 +19,7 @@ struct CppComplexDouble {
struct CppComplexLongDouble {
long double r, i;
};
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
struct CppComplexFloat128 {
CFloat128Type r, i;
};
@@ -75,7 +75,7 @@ static long_double_Complex_t CMPLXL(long double r, long double i) {
#endif
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
#ifndef CMPLXF128
/*
* GCC 7.4.0 (currently minimum GCC version for llvm builds)
@@ -123,7 +123,7 @@ ADAPT_REDUCTION(SumComplex8, double_Complex_t, CppComplexDouble, CMPLX,
ADAPT_REDUCTION(SumComplex10, long_double_Complex_t, CppComplexLongDouble,
CMPLXL, REDUCTION_ARGS, REDUCTION_ARG_NAMES)
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
ADAPT_REDUCTION(SumComplex16, CFloat128ComplexType, CppComplexFloat128,
CMPLXF128, REDUCTION_ARGS, REDUCTION_ARG_NAMES)
#endif
@@ -137,7 +137,7 @@ ADAPT_REDUCTION(ProductComplex8, double_Complex_t, CppComplexDouble, CMPLX,
ADAPT_REDUCTION(ProductComplex10, long_double_Complex_t, CppComplexLongDouble,
CMPLXL, REDUCTION_ARGS, REDUCTION_ARG_NAMES)
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
ADAPT_REDUCTION(ProductComplex16, CFloat128ComplexType, CppComplexFloat128,
CMPLXF128, REDUCTION_ARGS, REDUCTION_ARG_NAMES)
#endif
@@ -151,7 +151,7 @@ ADAPT_REDUCTION(DotProductComplex8, double_Complex_t, CppComplexDouble, CMPLX,
ADAPT_REDUCTION(DotProductComplex10, long_double_Complex_t,
CppComplexLongDouble, CMPLXL, DOT_PRODUCT_ARGS, DOT_PRODUCT_ARG_NAMES)
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
ADAPT_REDUCTION(DotProductComplex16, CFloat128ComplexType, CppComplexFloat128,
CMPLXF128, DOT_PRODUCT_ARGS, DOT_PRODUCT_ARG_NAMES)
#endif
@@ -183,7 +183,7 @@ ADAPT_REDUCTION(ReduceComplex10Value, long_double_Complex_t,
CppComplexLongDouble, CMPLXL, RARGS, REDUCE_ARG_NAMES)
#undef RARGS
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
#define RARGS REDUCE_ARGS(CFloat128ComplexType, CFloat128ComplexType_ref_op)
ADAPT_REDUCTION(ReduceComplex16Ref, CFloat128ComplexType, CppComplexFloat128,
CMPLXF128, RARGS, REDUCE_ARG_NAMES)
diff --git a/flang/runtime/complex-reduction.h b/flang/runtime/complex-reduction.h
index b0f19622fdb1a5..5ff2a828fb3ecc 100644
--- a/flang/runtime/complex-reduction.h
+++ b/flang/runtime/complex-reduction.h
@@ -41,7 +41,7 @@ float_Complex_t RTNAME(SumComplex3)(REDUCTION_ARGS);
float_Complex_t RTNAME(SumComplex4)(REDUCTION_ARGS);
double_Complex_t RTNAME(SumComplex8)(REDUCTION_ARGS);
long_double_Complex_t RTNAME(SumComplex10)(REDUCTION_ARGS);
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CFloat128ComplexType RTNAME(SumComplex16)(REDUCTION_ARGS);
#endif
@@ -50,7 +50,7 @@ float_Complex_t RTNAME(ProductComplex3)(REDUCTION_ARGS);
float_Complex_t RTNAME(ProductComplex4)(REDUCTION_ARGS);
double_Complex_t RTNAME(ProductComplex8)(REDUCTION_ARGS);
long_double_Complex_t RTNAME(ProductComplex10)(REDUCTION_ARGS);
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CFloat128ComplexType RTNAME(ProductComplex16)(REDUCTION_ARGS);
#endif
@@ -65,7 +65,7 @@ float_Complex_t RTNAME(DotProductComplex3)(DOT_PRODUCT_ARGS);
float_Complex_t RTNAME(DotProductComplex4)(DOT_PRODUCT_ARGS);
double_Complex_t RTNAME(DotProductComplex8)(DOT_PRODUCT_ARGS);
long_double_Complex_t RTNAME(DotProductComplex10)(DOT_PRODUCT_ARGS);
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CFloat128ComplexType RTNAME(DotProductComplex16)(DOT_PRODUCT_ARGS);
#endif
@@ -110,7 +110,7 @@ long_double_Complex_t RTNAME(ReduceComplex10Ref)(
REDUCE_ARGS(long_double_Complex_t, long_double_Complex_t_ref_op));
long_double_Complex_t RTNAME(ReduceComplex10Value)(
REDUCE_ARGS(long_double_Complex_t, long_double_Complex_t_value_op));
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
typedef CFloat128ComplexType (*CFloat128ComplexType_ref_op)(
const CFloat128ComplexType *, const CFloat128ComplexType *);
typedef CFloat128ComplexType (*CFloat128ComplexType_value_op)(
@@ -149,7 +149,7 @@ void RTNAME(ReduceComplex10DimRef)(
REDUCE_DIM_ARGS(long_double_Complex_t, long_double_Complex_t_ref_op));
void RTNAME(ReduceComplex10DimValue)(
REDUCE_DIM_ARGS(long_double_Complex_t, long_double_Complex_t_value_op));
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTNAME(ReduceComplex16DimRef)(
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_ref_op));
void RTNAME(ReduceComplex16DimValue)(
diff --git a/flang/runtime/dot-product.cpp b/flang/runtime/dot-product.cpp
index aafef379fad43c..335e5929f0865e 100644
--- a/flang/runtime/dot-product.cpp
+++ b/flang/runtime/dot-product.cpp
@@ -196,7 +196,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDEF(DotProductReal10)(
return DotProduct<TypeCategory::Real, 10>{}(x, y, source, line);
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(DotProductReal16)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 16>{}(x, y, source, line);
@@ -218,7 +218,7 @@ void RTDEF(CppDotProductComplex10)(
result = DotProduct<TypeCategory::Complex, 10>{}(x, y, source, line);
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(CppDotProductComplex16)(
CppTypeFor<TypeCategory::Complex, 16> &result, const Descriptor &x,
const Descriptor &y, const char *source, int line) {
diff --git a/flang/runtime/extrema.cpp b/flang/runtime/extrema.cpp
index 2658709b7de86b..9442fa50f4c794 100644
--- a/flang/runtime/extrema.cpp
+++ b/flang/runtime/extrema.cpp
@@ -243,7 +243,7 @@ void RTDEF(MaxlocReal10)(Descriptor &result, const Descriptor &x, int kind,
"MAXLOC", result, x, kind, source, line, mask, back);
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(MaxlocReal16)(Descriptor &result, const Descriptor &x, int kind,
const char *source, int line, const Descriptor *mask, bool back) {
TotalNumericMaxOrMinLoc<TypeCategory::Real, 16, true>(
@@ -299,7 +299,7 @@ void RTDEF(MinlocReal10)(Descriptor &result, const Descriptor &x, int kind,
"MINLOC", result, x, kind, source, line, mask, back);
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(MinlocReal16)(Descriptor &result, const Descriptor &x, int kind,
const char *source, int line, const Descriptor *mask, bool back) {
TotalNumericMaxOrMinLoc<TypeCategory::Real, 16, false>(
@@ -621,7 +621,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDEF(MaxvalReal10)(const Descriptor &x,
x, source, line, dim, mask, "MAXVAL");
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(MaxvalReal16)(const Descriptor &x,
const char *source, int line, int dim, const Descriptor *mask) {
return TotalNumericMaxOrMin<TypeCategory::Real, 16, true>(
@@ -681,7 +681,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDEF(MinvalReal10)(const Descriptor &x,
x, source, line, dim, mask, "MINVAL");
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(MinvalReal16)(const Descriptor &x,
const char *source, int line, int dim, const Descriptor *mask) {
return TotalNumericMaxOrMin<TypeCategory::Real, 16, false>(
diff --git a/flang/runtime/numeric-templates.h b/flang/runtime/numeric-templates.h
index 8cc63859ab7d4f..0b00bbb94ddd21 100644
--- a/flang/runtime/numeric-templates.h
+++ b/flang/runtime/numeric-templates.h
@@ -163,7 +163,7 @@ template <typename T> struct MAXTy {
}
};
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
template <> struct MAXTy<CppTypeFor<TypeCategory::Real, 16>> {
static CppTypeFor<TypeCategory::Real, 16> compute() {
return MaxOrMinIdentity<TypeCategory::Real, 16, true>::Value();
diff --git a/flang/runtime/numeric.cpp b/flang/runtime/numeric.cpp
index 23f8da3f81f176..4797ecf58fa711 100644
--- a/flang/runtime/numeric.cpp
+++ b/flang/runtime/numeric.cpp
@@ -299,7 +299,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDEF(Ceiling10_16)(
return Ceiling<CppTypeFor<TypeCategory::Integer, 16>>(x);
}
#endif
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
CppTypeFor<TypeCategory::Integer, 1> RTDEF(Ceiling16_1)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Ceiling<CppTypeFor<TypeCategory::Integer, 1>>(x);
@@ -338,7 +338,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDEF(ErfcScaled10)(
return ErfcScaled(x);
}
#endif
-#if LDBL_MANT_DIG == 113
+#if HAS_LDBL128
CppTypeFor<TypeCategory::Real, 16> RTDEF(ErfcScaled16)(
CppTypeFor<TypeCategory::Real, 16> x) {
return ErfcScaled(x);
@@ -439,7 +439,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDEF(Floor10_16)(
return Floor<CppTypeFor<TypeCategory::Integer, 16>>(x);
}
#endif
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
CppTypeFor<TypeCategory::Integer, 1> RTDEF(Floor16_1)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Floor<CppTypeFor<TypeCategory::Integer, 1>>(x);
@@ -489,7 +489,7 @@ bool RTDEF(IsFinite8)(CppTypeFor<TypeCategory::Real, 8> x) {
bool RTDEF(IsFinite10)(CppTypeFor<TypeCategory::Real, 10> x) {
return std::isfinite(x);
}
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
bool RTDEF(IsFinite16)(CppTypeFor<TypeCategory::Real, 16> x) {
return std::isfinite(x);
}
@@ -505,7 +505,7 @@ bool RTDEF(IsNaN8)(CppTypeFor<TypeCategory::Real, 8> x) {
bool RTDEF(IsNaN10)(CppTypeFor<TypeCategory::Real, 10> x) {
return std::isnan(x);
}
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
bool RTDEF(IsNaN16)(CppTypeFor<TypeCategory::Real, 16> x) {
return std::isnan(x);
}
@@ -693,7 +693,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDEF(Nint10_16)(
return Nint<CppTypeFor<TypeCategory::Integer, 16>>(x);
}
#endif
-#elif LDBL_MANT_DIG == 113
+#elif HAS_LDBL128
CppTypeFor<TypeCategory::Integer, 1> RTDEF(Nint16_1)(
CppTypeFor<TypeCategory::Real, 16> x) {
return Nint<CppTypeFor<TypeCategory::Integer, 1>>(x);
@@ -900,7 +900,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDEF(FPow10i)(
return FPowI(b, e);
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(FPow16i)(
CppTypeFor<TypeCategory::Real, 16> b,
CppTypeFor<TypeCategory::Integer, 4> e) {
@@ -925,7 +925,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDEF(FPow10k)(
return FPowI(b, e);
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(FPow16k)(
CppTypeFor<TypeCategory::Real, 16> b,
CppTypeFor<TypeCategory::Integer, 8> e) {
diff --git a/flang/runtime/product.cpp b/flang/runtime/product.cpp
index 39b40d82b05401..aef0f7c4a0bfd9 100644
--- a/flang/runtime/product.cpp
+++ b/flang/runtime/product.cpp
@@ -117,7 +117,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDEF(ProductReal10)(const Descriptor &x,
"PRODUCT");
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(ProductReal16)(const Descriptor &x,
const char *source, int line, int dim, const Descriptor *mask) {
return GetTotalReduction<TypeCategory::Real, 16>(x, source, line, dim, mask,
@@ -149,7 +149,7 @@ void RTDEF(CppProductComplex10)(CppTypeFor<TypeCategory::Complex, 10> &result,
"PRODUCT");
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(CppProductComplex16)(CppTypeFor<TypeCategory::Complex, 16> &result,
const Descriptor &x, const char *source, int line, int dim,
const Descriptor *mask) {
diff --git a/flang/runtime/reduce.cpp b/flang/runtime/reduce.cpp
index 6b62e1cf1e76f1..8fc0bb8c7157e4 100644
--- a/flang/runtime/reduce.cpp
+++ b/flang/runtime/reduce.cpp
@@ -443,7 +443,7 @@ void RTDEF(ReduceReal10DimValue)(Descriptor &result, const Descriptor &array,
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator);
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppFloat128Type RTDEF(ReduceReal16Ref)(const Descriptor &array,
ReferenceReductionOperation<CppFloat128Type> operation, const char *source,
int line, int dim, const Descriptor *mask, const CppFloat128Type *identity,
@@ -634,7 +634,7 @@ void RTDEF(CppReduceComplex10DimValue)(Descriptor &result,
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator);
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(CppReduceComplex16Ref)(CppTypeFor<TypeCategory::Complex, 16> &result,
const Descriptor &array,
ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 16>>
diff --git a/flang/runtime/reduction-templates.h b/flang/runtime/reduction-templates.h
index 6b7d57f98384ae..0d3fc19f5e7542 100644
--- a/flang/runtime/reduction-templates.h
+++ b/flang/runtime/reduction-templates.h
@@ -318,9 +318,9 @@ RT_VAR_GROUP_BEGIN
// Use at least double precision for accumulators.
// Don't use __float128, it doesn't work with abs() or sqrt() yet.
-static constexpr RT_CONST_VAR_ATTRS int Norm2LargestLDKind {
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
- 16
+static constexpr RT_CONST_VAR_ATTRS int Norm2LargestLDKind{
+#if HAS_LDBL128 || HAS_FLOAT128
+ 16
#elif HAS_FLOAT80
10
#else
diff --git a/flang/runtime/sum.cpp b/flang/runtime/sum.cpp
index 88c6c914e1e243..04241443275eb9 100644
--- a/flang/runtime/sum.cpp
+++ b/flang/runtime/sum.cpp
@@ -148,7 +148,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDEF(SumReal10)(const Descriptor &x,
RealSumAccumulator<CppTypeFor<TypeCategory::Real, 10>>{x}, "SUM");
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(SumReal16)(const Descriptor &x,
const char *source, int line, int dim, const Descriptor *mask) {
return GetTotalReduction<TypeCategory::Real, 16>(x, source, line, dim, mask,
@@ -177,7 +177,7 @@ void RTDEF(CppSumComplex10)(CppTypeFor<TypeCategory::Complex, 10> &result,
ComplexSumAccumulator<CppTypeFor<TypeCategory::Real, 10>>{x}, "SUM");
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(CppSumComplex16)(CppTypeFor<TypeCategory::Complex, 16> &result,
const Descriptor &x, const char *source, int line, int dim,
const Descriptor *mask) {
diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index 0ce18171274e42..b65502933b862f 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -353,7 +353,7 @@ void RTDEF(BesselJn_10)(Descriptor &result, int32_t n1, int32_t n2,
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(BesselJn_16)(Descriptor &result, int32_t n1, int32_t n2,
CppTypeFor<TypeCategory::Real, 16> x,
CppTypeFor<TypeCategory::Real, 16> bn2,
@@ -382,7 +382,7 @@ void RTDEF(BesselJnX0_10)(Descriptor &result, int32_t n1, int32_t n2,
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(BesselJnX0_16)(Descriptor &result, int32_t n1, int32_t n2,
const char *sourceFile, int line) {
DoBesselJnX0<TypeCategory::Real, 16>(result, n1, n2, sourceFile, line);
@@ -416,7 +416,7 @@ void RTDEF(BesselYn_10)(Descriptor &result, int32_t n1, int32_t n2,
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(BesselYn_16)(Descriptor &result, int32_t n1, int32_t n2,
CppTypeFor<TypeCategory::Real, 16> x,
CppTypeFor<TypeCategory::Real, 16> bn1,
@@ -445,7 +445,7 @@ void RTDEF(BesselYnX0_10)(Descriptor &result, int32_t n1, int32_t n2,
}
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(BesselYnX0_16)(Descriptor &result, int32_t n1, int32_t n2,
const char *sourceFile, int line) {
DoBesselYnX0<TypeCategory::Real, 16>(result, n1, n2, sourceFile, line);
diff --git a/flang/unittests/Runtime/Numeric.cpp b/flang/unittests/Runtime/Numeric.cpp
index 3e574c06b091e8..29ebbc8ad7aa70 100644
--- a/flang/unittests/Runtime/Numeric.cpp
+++ b/flang/unittests/Runtime/Numeric.cpp
@@ -310,7 +310,7 @@ TEST(Numeric, FPowI) {
EXPECT_EQ(RTNAME(FPow10k)(Real<10>{-3}, Int<8>{3}), Real<10>{-27});
EXPECT_EQ(RTNAME(FPow10k)(Real<10>{-2}, Int<8>{-3}), Real<10>{-0.125});
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
EXPECT_EQ(RTNAME(FPow16i)(Real<16>{0}, Int<4>{0}), Real<16>{1});
EXPECT_EQ(RTNAME(FPow16i)(Real<16>{0.3}, Int<4>{0}), Real<16>{1});
EXPECT_EQ(RTNAME(FPow16i)(Real<16>{2}, Int<4>{-1}), Real<16>{0.5});
diff --git a/flang/unittests/Runtime/Reduction.cpp b/flang/unittests/Runtime/Reduction.cpp
index 25eb5fd760eadb..29675399abf5c1 100644
--- a/flang/unittests/Runtime/Reduction.cpp
+++ b/flang/unittests/Runtime/Reduction.cpp
@@ -619,7 +619,7 @@ TEST(Reductions, DotProduct) {
*logicalVector2, *logicalVector1, __FILE__, __LINE__));
}
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
TEST(Reductions, ExtremaReal16) {
// The identity value for Min/Maxval for REAL(16) was mistakenly
// set to 0.0.
@@ -634,7 +634,7 @@ TEST(Reductions, ExtremaReal16) {
auto maxArray{MakeArray<TypeCategory::Real, 16>(shape, rawMaxData)};
EXPECT_EQ(RTNAME(MaxvalReal16)(*maxArray, __FILE__, __LINE__), -1.0);
}
-#endif // LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#endif // HAS_LDBL128 || HAS_FLOAT128
static std::int32_t IAdd(const std::int32_t *x, const std::int32_t *y) {
return *x + *y;
diff --git a/flang/unittests/Runtime/Transformational.cpp b/flang/unittests/Runtime/Transformational.cpp
index b36ea0a60c670c..1d84b7e23779a7 100644
--- a/flang/unittests/Runtime/Transformational.cpp
+++ b/flang/unittests/Runtime/Transformational.cpp
@@ -111,7 +111,7 @@ static void testBesselJn() {
#if HAS_FLOAT80
testBesselJn<10>(RTNAME(BesselJn_10));
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
testBesselJn<16>(RTNAME(BesselJn_16));
#endif
@@ -120,7 +120,7 @@ static void testBesselJn() {
#if HAS_FLOAT80
testBesselJnX0<10>(RTNAME(BesselJnX0_10));
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
testBesselJnX0<16>(RTNAME(BesselJnX0_16));
#endif
}
@@ -204,7 +204,7 @@ static void testBesselYn() {
#if HAS_FLOAT80
testBesselYn<10>(RTNAME(BesselYn_10));
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
testBesselYn<16>(RTNAME(BesselYn_16));
#endif
@@ -213,7 +213,7 @@ static void testBesselYn() {
#if HAS_FLOAT80
testBesselYnX0<10>(RTNAME(BesselYnX0_10));
#endif
-#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
+#if HAS_LDBL128 || HAS_FLOAT128
testBesselYnX0<16>(RTNAME(BesselYnX0_16));
#endif
}
>From 4ae1c27f0289dfee301e57c5ddec3a128c0b42a4 Mon Sep 17 00:00:00 2001
From: Slava Zakharin <szakharin at nvidia.com>
Date: Thu, 19 Sep 2024 14:56:34 -0700
Subject: [PATCH 2/2] clang-format
---
flang/runtime/reduction-templates.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/runtime/reduction-templates.h b/flang/runtime/reduction-templates.h
index 0d3fc19f5e7542..2a85595bad7dbd 100644
--- a/flang/runtime/reduction-templates.h
+++ b/flang/runtime/reduction-templates.h
@@ -324,7 +324,7 @@ static constexpr RT_CONST_VAR_ATTRS int Norm2LargestLDKind{
#elif HAS_FLOAT80
10
#else
- 8
+ 8
#endif
};
More information about the flang-commits
mailing list