Skip to content

Commit 0699749

Browse files
authored
[flang][runtime] Moved support for some REAL(16) intrinsics to Float128Math. (#83383)
This adds support for 128-bit float versions of SCALE, NEAREST, MOD, MODULO, SET_EXPONENT, EXPONENT, FRACTION, SPACING and RRSPACING.
1 parent 2d61979 commit 0699749

Some content is hidden

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

53 files changed

+762
-444
lines changed

flang/runtime/Float128Math/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ set(sources
5959
erf.cpp
6060
erfc.cpp
6161
exp.cpp
62+
exponent.cpp
6263
floor.cpp
64+
fraction.cpp
6365
hypot.cpp
6466
j0.cpp
6567
j1.cpp
@@ -69,11 +71,18 @@ set(sources
6971
log.cpp
7072
log10.cpp
7173
lround.cpp
74+
mod-real.cpp
75+
modulo-real.cpp
76+
nearest.cpp
7277
norm2.cpp
7378
pow.cpp
7479
round.cpp
80+
rrspacing.cpp
81+
scale.cpp
82+
set-exponent.cpp
7583
sin.cpp
7684
sinh.cpp
85+
spacing.cpp
7786
sqrt.cpp
7887
tan.cpp
7988
tanh.cpp

flang/runtime/Float128Math/acos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(AcosF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Acos<RTNAME(AcosF128)>::invoke(x);
17+
return Acos<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/acosh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(AcoshF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Acosh<RTNAME(AcoshF128)>::invoke(x);
17+
return Acosh<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/asin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(AsinF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Asin<RTNAME(AsinF128)>::invoke(x);
17+
return Asin<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/asinh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(AsinhF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Asinh<RTNAME(AsinhF128)>::invoke(x);
17+
return Asinh<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/atan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(AtanF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Atan<RTNAME(AtanF128)>::invoke(x);
17+
return Atan<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/atan2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern "C" {
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(Atan2F128)(
1616
CppTypeFor<TypeCategory::Real, 16> x,
1717
CppTypeFor<TypeCategory::Real, 16> y) {
18-
return Atan2<RTNAME(Atan2F128)>::invoke(x, y);
18+
return Atan2<true>::invoke(x, y);
1919
}
2020
#endif
2121

flang/runtime/Float128Math/atanh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(AtanhF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Atanh<RTNAME(AtanhF128)>::invoke(x);
17+
return Atanh<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/cabs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern "C" {
1616
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1717
// NOTE: Flang calls the runtime APIs using C _Complex ABI
1818
CppTypeFor<TypeCategory::Real, 16> RTDEF(CAbsF128)(CFloat128ComplexType x) {
19-
return CAbs<RTNAME(CAbsF128)>::invoke(x);
19+
return CAbs<true>::invoke(x);
2020
}
2121
#endif
2222
#endif

flang/runtime/Float128Math/ceil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(CeilF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Ceil<RTNAME(CeilF128)>::invoke(x);
17+
return Ceil<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/cos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(CosF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Cos<RTNAME(CosF128)>::invoke(x);
17+
return Cos<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/cosh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(CoshF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Cosh<RTNAME(CoshF128)>::invoke(x);
17+
return Cosh<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/erf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(ErfF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Erf<RTNAME(ErfF128)>::invoke(x);
17+
return Erf<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/erfc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(ErfcF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Erfc<RTNAME(ErfcF128)>::invoke(x);
17+
return Erfc<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/exp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(ExpF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Exp<RTNAME(ExpF128)>::invoke(x);
17+
return Exp<true>::invoke(x);
1818
}
1919
#endif
2020

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===-- runtime/Float128Math/exponent.cpp ---------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "math-entries.h"
10+
#include "numeric-template-specs.h"
11+
12+
namespace Fortran::runtime {
13+
extern "C" {
14+
15+
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
16+
// EXPONENT (16.9.75)
17+
CppTypeFor<TypeCategory::Integer, 4> RTDEF(Exponent16_4)(F128Type x) {
18+
return Exponent<CppTypeFor<TypeCategory::Integer, 4>>(x);
19+
}
20+
CppTypeFor<TypeCategory::Integer, 8> RTDEF(Exponent16_8)(F128Type x) {
21+
return Exponent<CppTypeFor<TypeCategory::Integer, 8>>(x);
22+
}
23+
#endif
24+
25+
} // extern "C"
26+
} // namespace Fortran::runtime

flang/runtime/Float128Math/floor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(FloorF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Floor<RTNAME(FloorF128)>::invoke(x);
17+
return Floor<true>::invoke(x);
1818
}
1919
#endif
2020

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- runtime/Float128Math/fraction.cpp ---------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "math-entries.h"
10+
#include "numeric-template-specs.h"
11+
12+
namespace Fortran::runtime {
13+
extern "C" {
14+
15+
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
16+
// FRACTION (16.9.80)
17+
F128Type RTDEF(Fraction16)(F128Type x) { return Fraction(x); }
18+
#endif
19+
20+
} // extern "C"
21+
} // namespace Fortran::runtime

flang/runtime/Float128Math/hypot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern "C" {
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(HypotF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x,
1717
CppTypeFor<TypeCategory::Real, 16> y) {
18-
return Hypot<RTNAME(HypotF128)>::invoke(x, y);
18+
return Hypot<true>::invoke(x, y);
1919
}
2020
#endif
2121

flang/runtime/Float128Math/j0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(J0F128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return J0<RTNAME(J0F128)>::invoke(x);
17+
return J0<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/j1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(J1F128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return J1<RTNAME(J1F128)>::invoke(x);
17+
return J1<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/jn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(JnF128)(
1616
int n, CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Jn<RTNAME(JnF128)>::invoke(n, x);
17+
return Jn<true>::invoke(n, x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/lgamma.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(LgammaF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Lgamma<RTNAME(LgammaF128)>::invoke(x);
17+
return Lgamma<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/llround.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Integer, 8> RTDEF(LlroundF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Llround<RTNAME(LlroundF128)>::invoke(x);
17+
return Llround<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(LogF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Log<RTNAME(LogF128)>::invoke(x);
17+
return Log<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/log10.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Real, 16> RTDEF(Log10F128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Log10<RTNAME(Log10F128)>::invoke(x);
17+
return Log10<true>::invoke(x);
1818
}
1919
#endif
2020

flang/runtime/Float128Math/lround.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
1515
CppTypeFor<TypeCategory::Integer, 4> RTDEF(LroundF128)(
1616
CppTypeFor<TypeCategory::Real, 16> x) {
17-
return Lround<RTNAME(LroundF128)>::invoke(x);
17+
return Lround<true>::invoke(x);
1818
}
1919
#endif
2020

0 commit comments

Comments
 (0)