Skip to content

Commit fc51c7f

Browse files
authored
[flang][runtime] Disable LDBL_MANT_DIG == 113 for the offload builds. (#109339)
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`.
1 parent 0f488a0 commit fc51c7f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+157
-143
lines changed

flang/include/flang/Common/float128.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef FORTRAN_COMMON_FLOAT128_H_
2121
#define FORTRAN_COMMON_FLOAT128_H_
2222

23+
#include "api-attrs.h"
2324
#include <float.h>
2425

2526
#ifdef __cplusplus
@@ -51,8 +52,20 @@
5152
#endif /* (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)) && \
5253
!defined(_LIBCPP_VERSION) && !defined(__CUDA_ARCH__) */
5354

54-
/* Define pure C CFloat128Type and CFloat128ComplexType. */
5555
#if LDBL_MANT_DIG == 113
56+
#define HAS_LDBL128 1
57+
#endif
58+
59+
#if defined(RT_DEVICE_COMPILATION) && defined(__CUDACC__)
60+
/*
61+
* Most offload targets do not support 128-bit 'long double'.
62+
* Disable HAS_LDBL128 for __CUDACC__ for the time being.
63+
*/
64+
#undef HAS_LDBL128
65+
#endif
66+
67+
/* Define pure C CFloat128Type and CFloat128ComplexType. */
68+
#if HAS_LDBL128
5669
typedef long double CFloat128Type;
5770
#ifndef __cplusplus
5871
typedef long double _Complex CFloat128ComplexType;

flang/include/flang/Runtime/cpp-type.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ template <> struct CppTypeForHelper<TypeCategory::Real, 10> {
7878
#endif
7979
#if __STDCPP_FLOAT128_T__
8080
using CppFloat128Type = std::float128_t;
81-
#elif LDBL_MANT_DIG == 113
81+
#elif HAS_LDBL128
8282
using CppFloat128Type = long double;
8383
#elif HAS_FLOAT128
8484
using CppFloat128Type = __float128;
8585
#endif
86-
#if __STDCPP_FLOAT128_t || LDBL_MANT_DIG == 113 || HAS_FLOAT128
86+
#if __STDCPP_FLOAT128_t || HAS_LDBL128 || HAS_FLOAT128
8787
template <> struct CppTypeForHelper<TypeCategory::Real, 16> {
8888
using type = CppFloat128Type;
8989
};

flang/include/flang/Runtime/matmul-instances.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ MATMUL_DIRECT_INSTANCE(Integer, 16, Complex, 10)
121121
MATMUL_DIRECT_INSTANCE(Real, 10, Integer, 16)
122122
MATMUL_DIRECT_INSTANCE(Complex, 10, Integer, 16)
123123
#endif
124-
#if MATMUL_FORCE_ALL_TYPES || (LDBL_MANT_DIG == 113 || HAS_FLOAT128)
124+
#if MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
125125
MATMUL_INSTANCE(Integer, 16, Real, 16)
126126
MATMUL_INSTANCE(Integer, 16, Complex, 16)
127127
MATMUL_INSTANCE(Real, 16, Integer, 16)
@@ -195,7 +195,7 @@ MATMUL_DIRECT_INSTANCE(Complex, 16, Complex, 10)
195195
#endif
196196
#endif // MATMUL_FORCE_ALL_TYPES || HAS_FLOAT80
197197

198-
#if MATMUL_FORCE_ALL_TYPES || (LDBL_MANT_DIG == 113 || HAS_FLOAT128)
198+
#if MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
199199
#define FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(macro) \
200200
macro(Integer, 1, Real, 16) \
201201
macro(Integer, 1, Complex, 16) \
@@ -236,7 +236,7 @@ MATMUL_DIRECT_INSTANCE(Complex, 16, Complex, 10)
236236

237237
FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(MATMUL_INSTANCE)
238238
FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(MATMUL_DIRECT_INSTANCE)
239-
#endif // MATMUL_FORCE_ALL_TYPES || (LDBL_MANT_DIG == 113 || HAS_FLOAT128)
239+
#endif // MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
240240

241241
#define FOREACH_MATMUL_LOGICAL_TYPE_PAIR(macro) \
242242
macro(Logical, 1, Logical, 1) \

flang/include/flang/Runtime/numeric.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDECL(Ceiling10_16)(
5858
CppTypeFor<TypeCategory::Real, 10>);
5959
#endif
6060
#endif
61-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
61+
#if HAS_LDBL128 || HAS_FLOAT128
6262
CppTypeFor<TypeCategory::Integer, 1> RTDECL(Ceiling16_1)(
6363
CppTypeFor<TypeCategory::Real, 16>);
6464
CppTypeFor<TypeCategory::Integer, 2> RTDECL(Ceiling16_2)(
@@ -82,7 +82,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(ErfcScaled8)(
8282
CppTypeFor<TypeCategory::Real, 10> RTDECL(ErfcScaled10)(
8383
CppTypeFor<TypeCategory::Real, 10>);
8484
#endif
85-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
85+
#if HAS_LDBL128 || HAS_FLOAT128
8686
CppTypeFor<TypeCategory::Real, 16> RTDECL(ErfcScaled16)(
8787
CppTypeFor<TypeCategory::Real, 16>);
8888
#endif
@@ -102,7 +102,7 @@ CppTypeFor<TypeCategory::Integer, 4> RTDECL(Exponent10_4)(
102102
CppTypeFor<TypeCategory::Integer, 8> RTDECL(Exponent10_8)(
103103
CppTypeFor<TypeCategory::Real, 10>);
104104
#endif
105-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT
105+
#if HAS_LDBL128 || HAS_FLOAT
106106
CppTypeFor<TypeCategory::Integer, 4> RTDECL(Exponent16_4)(
107107
CppTypeFor<TypeCategory::Real, 16>);
108108
CppTypeFor<TypeCategory::Integer, 8> RTDECL(Exponent16_8)(
@@ -148,7 +148,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDECL(Floor10_16)(
148148
CppTypeFor<TypeCategory::Real, 10>);
149149
#endif
150150
#endif
151-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
151+
#if HAS_LDBL128 || HAS_FLOAT128
152152
CppTypeFor<TypeCategory::Integer, 1> RTDECL(Floor16_1)(
153153
CppTypeFor<TypeCategory::Real, 16>);
154154
CppTypeFor<TypeCategory::Integer, 2> RTDECL(Floor16_2)(
@@ -172,7 +172,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(Fraction8)(
172172
CppTypeFor<TypeCategory::Real, 10> RTDECL(Fraction10)(
173173
CppTypeFor<TypeCategory::Real, 10>);
174174
#endif
175-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
175+
#if HAS_LDBL128 || HAS_FLOAT128
176176
CppTypeFor<TypeCategory::Real, 16> RTDECL(Fraction16)(
177177
CppTypeFor<TypeCategory::Real, 16>);
178178
#endif
@@ -183,7 +183,7 @@ bool RTDECL(IsNaN8)(CppTypeFor<TypeCategory::Real, 8>);
183183
#if HAS_FLOAT80
184184
bool RTDECL(IsNaN10)(CppTypeFor<TypeCategory::Real, 10>);
185185
#endif
186-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
186+
#if HAS_LDBL128 || HAS_FLOAT128
187187
bool RTDECL(IsNaN16)(CppTypeFor<TypeCategory::Real, 16>);
188188
#endif
189189

@@ -217,7 +217,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(ModReal10)(
217217
CppTypeFor<TypeCategory::Real, 10>, CppTypeFor<TypeCategory::Real, 10>,
218218
const char *sourceFile = nullptr, int sourceLine = 0);
219219
#endif
220-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
220+
#if HAS_LDBL128 || HAS_FLOAT128
221221
CppTypeFor<TypeCategory::Real, 16> RTDECL(ModReal16)(
222222
CppTypeFor<TypeCategory::Real, 16>, CppTypeFor<TypeCategory::Real, 16>,
223223
const char *sourceFile = nullptr, int sourceLine = 0);
@@ -252,7 +252,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(ModuloReal10)(
252252
CppTypeFor<TypeCategory::Real, 10>, CppTypeFor<TypeCategory::Real, 10>,
253253
const char *sourceFile = nullptr, int sourceLine = 0);
254254
#endif
255-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
255+
#if HAS_LDBL128 || HAS_FLOAT128
256256
CppTypeFor<TypeCategory::Real, 16> RTDECL(ModuloReal16)(
257257
CppTypeFor<TypeCategory::Real, 16>, CppTypeFor<TypeCategory::Real, 16>,
258258
const char *sourceFile = nullptr, int sourceLine = 0);
@@ -297,7 +297,7 @@ CppTypeFor<TypeCategory::Integer, 16> RTDECL(Nint10_16)(
297297
CppTypeFor<TypeCategory::Real, 10>);
298298
#endif
299299
#endif
300-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
300+
#if HAS_LDBL128 || HAS_FLOAT128
301301
CppTypeFor<TypeCategory::Integer, 1> RTDECL(Nint16_1)(
302302
CppTypeFor<TypeCategory::Real, 16>);
303303
CppTypeFor<TypeCategory::Integer, 2> RTDECL(Nint16_2)(
@@ -323,7 +323,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(Nearest8)(
323323
CppTypeFor<TypeCategory::Real, 10> RTDECL(Nearest10)(
324324
CppTypeFor<TypeCategory::Real, 10>, bool positive);
325325
#endif
326-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
326+
#if HAS_LDBL128 || HAS_FLOAT128
327327
CppTypeFor<TypeCategory::Real, 16> RTDECL(Nearest16)(
328328
CppTypeFor<TypeCategory::Real, 16>, bool positive);
329329
#endif
@@ -337,7 +337,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(RRSpacing8)(
337337
CppTypeFor<TypeCategory::Real, 10> RTDECL(RRSpacing10)(
338338
CppTypeFor<TypeCategory::Real, 10>);
339339
#endif
340-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
340+
#if HAS_LDBL128 || HAS_FLOAT128
341341
CppTypeFor<TypeCategory::Real, 16> RTDECL(RRSpacing16)(
342342
CppTypeFor<TypeCategory::Real, 16>);
343343
#endif
@@ -351,7 +351,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(SetExponent8)(
351351
CppTypeFor<TypeCategory::Real, 10> RTDECL(SetExponent10)(
352352
CppTypeFor<TypeCategory::Real, 10>, std::int64_t);
353353
#endif
354-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
354+
#if HAS_LDBL128 || HAS_FLOAT128
355355
CppTypeFor<TypeCategory::Real, 16> RTDECL(SetExponent16)(
356356
CppTypeFor<TypeCategory::Real, 16>, std::int64_t);
357357
#endif
@@ -365,7 +365,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(Scale8)(
365365
CppTypeFor<TypeCategory::Real, 10> RTDECL(Scale10)(
366366
CppTypeFor<TypeCategory::Real, 10>, std::int64_t);
367367
#endif
368-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
368+
#if HAS_LDBL128 || HAS_FLOAT128
369369
CppTypeFor<TypeCategory::Real, 16> RTDECL(Scale16)(
370370
CppTypeFor<TypeCategory::Real, 16>, std::int64_t);
371371
#endif
@@ -414,7 +414,7 @@ CppTypeFor<TypeCategory::Real, 8> RTDECL(Spacing8)(
414414
CppTypeFor<TypeCategory::Real, 10> RTDECL(Spacing10)(
415415
CppTypeFor<TypeCategory::Real, 10>);
416416
#endif
417-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
417+
#if HAS_LDBL128 || HAS_FLOAT128
418418
CppTypeFor<TypeCategory::Real, 16> RTDECL(Spacing16)(
419419
CppTypeFor<TypeCategory::Real, 16>);
420420
#endif
@@ -430,7 +430,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(FPow10i)(
430430
CppTypeFor<TypeCategory::Real, 10> b,
431431
CppTypeFor<TypeCategory::Integer, 4> e);
432432
#endif
433-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
433+
#if HAS_LDBL128 || HAS_FLOAT128
434434
CppTypeFor<TypeCategory::Real, 16> RTDECL(FPow16i)(
435435
CppTypeFor<TypeCategory::Real, 16> b,
436436
CppTypeFor<TypeCategory::Integer, 4> e);
@@ -447,7 +447,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(FPow10k)(
447447
CppTypeFor<TypeCategory::Real, 10> b,
448448
CppTypeFor<TypeCategory::Integer, 8> e);
449449
#endif
450-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
450+
#if HAS_LDBL128 || HAS_FLOAT128
451451
CppTypeFor<TypeCategory::Real, 16> RTDECL(FPow16k)(
452452
CppTypeFor<TypeCategory::Real, 16> b,
453453
CppTypeFor<TypeCategory::Integer, 8> e);

flang/include/flang/Runtime/reduce.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void RTDECL(ReduceReal10DimValue)(Descriptor &result, const Descriptor &array,
210210
const CppTypeFor<TypeCategory::Real, 10> *identity = nullptr,
211211
bool ordered = true);
212212
#endif
213-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
213+
#if HAS_LDBL128 || HAS_FLOAT128
214214
CppFloat128Type RTDECL(ReduceReal16Ref)(const Descriptor &,
215215
ReferenceReductionOperation<CppFloat128Type>, const char *source, int line,
216216
int dim = 0, const Descriptor *mask = nullptr,
@@ -351,7 +351,7 @@ void RTDECL(CppReduceComplex10DimValue)(Descriptor &result,
351351
const CppTypeFor<TypeCategory::Complex, 10> *identity = nullptr,
352352
bool ordered = true);
353353
#endif
354-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
354+
#if HAS_LDBL128 || HAS_FLOAT128
355355
void RTDECL(CppReduceComplex16Ref)(CppTypeFor<TypeCategory::Complex, 16> &,
356356
const Descriptor &,
357357
ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 16>>,

flang/include/flang/Runtime/reduction.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(SumReal10)(const Descriptor &,
7373
const char *source, int line, int dim = 0,
7474
const Descriptor *mask = nullptr);
7575
#endif
76-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
76+
#if HAS_LDBL128 || HAS_FLOAT128
7777
CppFloat128Type RTDECL(SumReal16)(const Descriptor &, const char *source,
7878
int line, int dim = 0, const Descriptor *mask = nullptr);
7979
#endif
@@ -95,7 +95,7 @@ void RTDECL(CppSumComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
9595
const Descriptor &, const char *source, int line, int dim = 0,
9696
const Descriptor *mask = nullptr);
9797
#endif
98-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
98+
#if HAS_LDBL128 || HAS_FLOAT128
9999
void RTDECL(CppSumComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
100100
const Descriptor &, const char *source, int line, int dim = 0,
101101
const Descriptor *mask = nullptr);
@@ -134,7 +134,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(ProductReal10)(const Descriptor &,
134134
const char *source, int line, int dim = 0,
135135
const Descriptor *mask = nullptr);
136136
#endif
137-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
137+
#if HAS_LDBL128 || HAS_FLOAT128
138138
CppFloat128Type RTDECL(ProductReal16)(const Descriptor &, const char *source,
139139
int line, int dim = 0, const Descriptor *mask = nullptr);
140140
#endif
@@ -156,7 +156,7 @@ void RTDECL(CppProductComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
156156
const Descriptor &, const char *source, int line, int dim = 0,
157157
const Descriptor *mask = nullptr);
158158
#endif
159-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
159+
#if HAS_LDBL128 || HAS_FLOAT128
160160
void RTDECL(CppProductComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
161161
const Descriptor &, const char *source, int line, int dim = 0,
162162
const Descriptor *mask = nullptr);
@@ -314,7 +314,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(MaxvalReal10)(const Descriptor &,
314314
const char *source, int line, int dim = 0,
315315
const Descriptor *mask = nullptr);
316316
#endif
317-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
317+
#if HAS_LDBL128 || HAS_FLOAT128
318318
CppFloat128Type RTDECL(MaxvalReal16)(const Descriptor &, const char *source,
319319
int line, int dim = 0, const Descriptor *mask = nullptr);
320320
#endif
@@ -346,7 +346,7 @@ CppTypeFor<TypeCategory::Real, 10> RTDECL(MinvalReal10)(const Descriptor &,
346346
const char *source, int line, int dim = 0,
347347
const Descriptor *mask = nullptr);
348348
#endif
349-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
349+
#if HAS_LDBL128 || HAS_FLOAT128
350350
CppFloat128Type RTDECL(MinvalReal16)(const Descriptor &, const char *source,
351351
int line, int dim = 0, const Descriptor *mask = nullptr);
352352
#endif
@@ -371,7 +371,7 @@ double RTDECL(Norm2_8)(
371371
CppTypeFor<TypeCategory::Real, 10> RTDECL(Norm2_10)(
372372
const Descriptor &, const char *source, int line, int dim = 0);
373373
#endif
374-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
374+
#if HAS_LDBL128 || HAS_FLOAT128
375375
CppFloat128Type RTDECL(Norm2_16)(
376376
const Descriptor &, const char *source, int line, int dim = 0);
377377
void RTDECL(Norm2DimReal16)(
@@ -421,7 +421,7 @@ double RTDECL(DotProductReal8)(const Descriptor &, const Descriptor &,
421421
CppTypeFor<TypeCategory::Real, 10> RTDECL(DotProductReal10)(const Descriptor &,
422422
const Descriptor &, const char *source = nullptr, int line = 0);
423423
#endif
424-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
424+
#if HAS_LDBL128 || HAS_FLOAT128
425425
CppFloat128Type RTDECL(DotProductReal16)(const Descriptor &, const Descriptor &,
426426
const char *source = nullptr, int line = 0);
427427
#endif
@@ -442,7 +442,7 @@ void RTDECL(CppDotProductComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
442442
const Descriptor &, const Descriptor &, const char *source = nullptr,
443443
int line = 0);
444444
#endif
445-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
445+
#if HAS_LDBL128 || HAS_FLOAT128
446446
void RTDECL(CppDotProductComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
447447
const Descriptor &, const Descriptor &, const char *source = nullptr,
448448
int line = 0);

flang/include/flang/Runtime/transformational.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void RTDECL(BesselJn_10)(Descriptor &result, int32_t n1, int32_t n2,
5353
int line = 0);
5454
#endif
5555

56-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
56+
#if HAS_LDBL128 || HAS_FLOAT128
5757
void RTDECL(BesselJn_16)(Descriptor &result, int32_t n1, int32_t n2,
5858
CppFloat128Type x, CppFloat128Type bn2, CppFloat128Type bn2_1,
5959
const char *sourceFile = nullptr, int line = 0);
@@ -76,7 +76,7 @@ void RTDECL(BesselJnX0_10)(Descriptor &result, int32_t n1, int32_t n2,
7676
const char *sourceFile = nullptr, int line = 0);
7777
#endif
7878

79-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
79+
#if HAS_LDBL128 || HAS_FLOAT128
8080
void RTDECL(BesselJnX0_16)(Descriptor &result, int32_t n1, int32_t n2,
8181
const char *sourceFile = nullptr, int line = 0);
8282
#endif
@@ -101,7 +101,7 @@ void RTDECL(BesselYn_10)(Descriptor &result, int32_t n1, int32_t n2,
101101
int line = 0);
102102
#endif
103103

104-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
104+
#if HAS_LDBL128 || HAS_FLOAT128
105105
void RTDECL(BesselYn_16)(Descriptor &result, int32_t n1, int32_t n2,
106106
CppFloat128Type x, CppFloat128Type bn1, CppFloat128Type bn1_1,
107107
const char *sourceFile = nullptr, int line = 0);
@@ -124,7 +124,7 @@ void RTDECL(BesselYnX0_10)(Descriptor &result, int32_t n1, int32_t n2,
124124
const char *sourceFile = nullptr, int line = 0);
125125
#endif
126126

127-
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
127+
#if HAS_LDBL128 || HAS_FLOAT128
128128
void RTDECL(BesselYnX0_16)(Descriptor &result, int32_t n1, int32_t n2,
129129
const char *sourceFile = nullptr, int line = 0);
130130
#endif

flang/include/flang/Tools/TargetSetup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Fortran::tools {
3636
#ifdef FLANG_RUNTIME_F128_MATH_LIB
3737
// we can use libquadmath wrappers
3838
constexpr bool f128Support = true;
39-
#elif LDBL_MANT_DIG == 113
39+
#elif HAS_LDBL128
4040
// we can use libm wrappers
4141
constexpr bool f128Support = true;
4242
#else

flang/lib/Evaluate/intrinsics-library.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
#include <functional>
2323
#if HAS_QUADMATHLIB
2424
#include "quadmath.h"
25-
#include "flang/Common/float128.h"
2625
#endif
26+
#include "flang/Common/float128.h"
27+
#include "flang/Common/float80.h"
2728
#include <type_traits>
2829

2930
namespace Fortran::evaluate {
@@ -414,7 +415,7 @@ template <> struct HostRuntimeLibrary<double, LibraryVersion::LibmExtensions> {
414415
static_assert(map.Verify(), "map must be sorted");
415416
};
416417

417-
#if LDBL_MANT_DIG == 80 || LDBL_MANT_DIG == 113
418+
#if HAS_FLOAT80 || HAS_LDBL128
418419
template <>
419420
struct HostRuntimeLibrary<long double, LibraryVersion::LibmExtensions> {
420421
using F = FuncPointer<long double, long double>;
@@ -430,7 +431,7 @@ struct HostRuntimeLibrary<long double, LibraryVersion::LibmExtensions> {
430431
static constexpr HostRuntimeMap map{table};
431432
static_assert(map.Verify(), "map must be sorted");
432433
};
433-
#endif // LDBL_MANT_DIG == 80 || LDBL_MANT_DIG == 113
434+
#endif // HAS_FLOAT80 || HAS_LDBL128
434435
#endif //_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
435436

436437
/// Define pgmath description

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
750750

751751
// Generate a call to the Fortran runtime library providing
752752
// support for 128-bit float math.
753-
// On 'LDBL_MANT_DIG == 113' targets the implementation
753+
// On 'HAS_LDBL128' targets the implementation
754754
// is provided by FortranRuntime, otherwise, it is done via
755755
// FortranFloat128Math library. In the latter case the compiler
756756
// has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee

0 commit comments

Comments
 (0)