diff --git a/flang/runtime/complex-reduction.h b/flang/runtime/complex-reduction.h --- a/flang/runtime/complex-reduction.h +++ b/flang/runtime/complex-reduction.h @@ -16,6 +16,7 @@ #define FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_ #include "entry-names.h" +#include struct CppDescriptor; /* dummy type name for Fortran::runtime::Descriptor */ diff --git a/flang/runtime/complex-reduction.c b/flang/runtime/complex-reduction.c --- a/flang/runtime/complex-reduction.c +++ b/flang/runtime/complex-reduction.c @@ -9,7 +9,6 @@ #include "complex-reduction.h" #include "flang/Common/long-double.h" -#include struct CppComplexFloat { float r, i; diff --git a/flang/runtime/numeric.h b/flang/runtime/numeric.h --- a/flang/runtime/numeric.h +++ b/flang/runtime/numeric.h @@ -87,8 +87,10 @@ CppTypeFor); CppTypeFor RTNAME(Ceiling4_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Ceiling4_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Ceiling8_1)( CppTypeFor); CppTypeFor RTNAME(Ceiling8_2)( @@ -97,8 +99,10 @@ CppTypeFor); CppTypeFor RTNAME(Ceiling8_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Ceiling8_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Ceiling10_1)( CppTypeFor); CppTypeFor RTNAME(Ceiling10_2)( @@ -107,8 +111,10 @@ CppTypeFor); CppTypeFor RTNAME(Ceiling10_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Ceiling10_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Ceiling16_1)( CppTypeFor); CppTypeFor RTNAME(Ceiling16_2)( @@ -117,8 +123,10 @@ CppTypeFor); CppTypeFor RTNAME(Ceiling16_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Ceiling16_16)( CppTypeFor); +#endif // EXPONENT is defined to return default INTEGER; support INTEGER(4 & 8) CppTypeFor RTNAME(Exponent4_4)( @@ -147,8 +155,10 @@ CppTypeFor); CppTypeFor RTNAME(Floor4_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Floor4_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Floor8_1)( CppTypeFor); CppTypeFor RTNAME(Floor8_2)( @@ -157,8 +167,10 @@ CppTypeFor); CppTypeFor RTNAME(Floor8_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Floor8_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Floor10_1)( CppTypeFor); CppTypeFor RTNAME(Floor10_2)( @@ -167,8 +179,10 @@ CppTypeFor); CppTypeFor RTNAME(Floor10_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Floor10_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Floor16_1)( CppTypeFor); CppTypeFor RTNAME(Floor16_2)( @@ -177,8 +191,10 @@ CppTypeFor); CppTypeFor RTNAME(Floor16_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Floor16_16)( CppTypeFor); +#endif // FRACTION CppTypeFor RTNAME(Fraction4)( @@ -199,9 +215,11 @@ CppTypeFor, CppTypeFor); CppTypeFor RTNAME(ModInteger8)( CppTypeFor, CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(ModInteger16)( CppTypeFor, CppTypeFor); +#endif CppTypeFor RTNAME(ModReal4)( CppTypeFor, CppTypeFor); CppTypeFor RTNAME(ModReal8)( @@ -219,9 +237,11 @@ CppTypeFor, CppTypeFor); CppTypeFor RTNAME(ModuloInteger8)( CppTypeFor, CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(ModuloInteger16)( CppTypeFor, CppTypeFor); +#endif CppTypeFor RTNAME(ModuloReal4)( CppTypeFor, CppTypeFor); CppTypeFor RTNAME(ModuloReal8)( @@ -240,8 +260,10 @@ CppTypeFor); CppTypeFor RTNAME(Nint4_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Nint4_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Nint8_1)( CppTypeFor); CppTypeFor RTNAME(Nint8_2)( @@ -250,8 +272,10 @@ CppTypeFor); CppTypeFor RTNAME(Nint8_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Nint8_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Nint10_1)( CppTypeFor); CppTypeFor RTNAME(Nint10_2)( @@ -260,8 +284,10 @@ CppTypeFor); CppTypeFor RTNAME(Nint10_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Nint10_16)( CppTypeFor); +#endif CppTypeFor RTNAME(Nint16_1)( CppTypeFor); CppTypeFor RTNAME(Nint16_2)( @@ -270,8 +296,10 @@ CppTypeFor); CppTypeFor RTNAME(Nint16_8)( CppTypeFor); +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Nint16_16)( CppTypeFor); +#endif // NEAREST // The second argument to NEAREST is the result of a comparison diff --git a/flang/runtime/numeric.cpp b/flang/runtime/numeric.cpp --- a/flang/runtime/numeric.cpp +++ b/flang/runtime/numeric.cpp @@ -284,10 +284,12 @@ CppTypeFor x) { return Ceiling>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Ceiling4_16)( CppTypeFor x) { return Ceiling>(x); } +#endif CppTypeFor RTNAME(Ceiling8_1)( CppTypeFor x) { return Ceiling>(x); @@ -304,10 +306,12 @@ CppTypeFor x) { return Ceiling>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Ceiling8_16)( CppTypeFor x) { return Ceiling>(x); } +#endif #if LONG_DOUBLE == 80 CppTypeFor RTNAME(Ceiling10_1)( CppTypeFor x) { @@ -325,10 +329,12 @@ CppTypeFor x) { return Ceiling>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Ceiling10_16)( CppTypeFor x) { return Ceiling>(x); } +#endif #else CppTypeFor RTNAME(Ceiling16_1)( CppTypeFor x) { @@ -346,11 +352,13 @@ CppTypeFor x) { return Ceiling>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Ceiling16_16)( CppTypeFor x) { return Ceiling>(x); } #endif +#endif CppTypeFor RTNAME(Exponent4_4)( CppTypeFor x) { @@ -404,10 +412,12 @@ CppTypeFor x) { return Floor>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Floor4_16)( CppTypeFor x) { return Floor>(x); } +#endif CppTypeFor RTNAME(Floor8_1)( CppTypeFor x) { return Floor>(x); @@ -424,10 +434,12 @@ CppTypeFor x) { return Floor>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Floor8_16)( CppTypeFor x) { return Floor>(x); } +#endif #if LONG_DOUBLE == 80 CppTypeFor RTNAME(Floor10_1)( CppTypeFor x) { @@ -445,10 +457,12 @@ CppTypeFor x) { return Floor>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Floor10_16)( CppTypeFor x) { return Floor>(x); } +#endif #else CppTypeFor RTNAME(Floor16_1)( CppTypeFor x) { @@ -466,11 +480,13 @@ CppTypeFor x) { return Floor>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Floor16_16)( CppTypeFor x) { return Floor>(x); } #endif +#endif CppTypeFor RTNAME(Fraction4)( CppTypeFor x) { @@ -512,11 +528,13 @@ CppTypeFor p) { return IntMod(x, p); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(ModInteger16)( CppTypeFor x, CppTypeFor p) { return IntMod(x, p); } +#endif CppTypeFor RTNAME(ModReal4)( CppTypeFor x, CppTypeFor p) { return RealMod(x, p); @@ -559,11 +577,13 @@ CppTypeFor p) { return IntMod(x, p); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(ModuloInteger16)( CppTypeFor x, CppTypeFor p) { return IntMod(x, p); } +#endif CppTypeFor RTNAME(ModuloReal4)( CppTypeFor x, CppTypeFor p) { return RealMod(x, p); @@ -622,10 +642,12 @@ CppTypeFor x) { return Anint>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Nint4_16)( CppTypeFor x) { return Anint>(x); } +#endif CppTypeFor RTNAME(Nint8_1)( CppTypeFor x) { return Anint>(x); @@ -642,10 +664,12 @@ CppTypeFor x) { return Anint>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Nint8_16)( CppTypeFor x) { return Anint>(x); } +#endif #if LONG_DOUBLE == 80 CppTypeFor RTNAME(Nint10_1)( CppTypeFor x) { @@ -663,10 +687,12 @@ CppTypeFor x) { return Anint>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Nint10_16)( CppTypeFor x) { return Anint>(x); } +#endif #else CppTypeFor RTNAME(Nint16_1)( CppTypeFor x) { @@ -684,11 +710,13 @@ CppTypeFor x) { return Anint>(x); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(Nint16_16)( CppTypeFor x) { return Anint>(x); } #endif +#endif CppTypeFor RTNAME(RRSpacing4)( CppTypeFor x) { diff --git a/flang/runtime/reduction.h b/flang/runtime/reduction.h --- a/flang/runtime/reduction.h +++ b/flang/runtime/reduction.h @@ -51,8 +51,10 @@ int line, int dim = 0, const Descriptor *mask = nullptr); std::int64_t RTNAME(SumInteger8)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); +#ifdef __SIZEOF_INT128__ common::int128_t RTNAME(SumInteger16)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); +#endif // REAL/COMPLEX(2 & 3) return 32-bit float results for the caller to downconvert float RTNAME(SumReal2)(const Descriptor &, const char *source, int line, @@ -100,9 +102,11 @@ int line, int dim = 0, const Descriptor *mask = nullptr); std::int64_t RTNAME(ProductInteger8)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); +#ifdef __SIZEOF_INT128__ common::int128_t RTNAME(ProductInteger16)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); +#endif // REAL/COMPLEX(2 & 3) return 32-bit float results for the caller to downconvert float RTNAME(ProductReal2)(const Descriptor &, const char *source, int line, @@ -166,8 +170,10 @@ int line, int dim = 0, const Descriptor *mask = nullptr); std::int64_t RTNAME(MaxvalInteger8)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); +#ifdef __SIZEOF_INT128__ common::int128_t RTNAME(MaxvalInteger16)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); +#endif float RTNAME(MaxvalReal2)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); float RTNAME(MaxvalReal3)(const Descriptor &, const char *source, int line, @@ -191,8 +197,10 @@ int line, int dim = 0, const Descriptor *mask = nullptr); std::int64_t RTNAME(MivalInteger8)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); +#ifdef __SIZEOF_INT128__ common::int128_t RTNAME(MivalInteger16)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); +#endif float RTNAME(MinvalReal2)(const Descriptor &, const char *source, int line, int dim = 0, const Descriptor *mask = nullptr); float RTNAME(MinvalReal3)(const Descriptor &, const char *source, int line, diff --git a/flang/runtime/reduction.cpp b/flang/runtime/reduction.cpp --- a/flang/runtime/reduction.cpp +++ b/flang/runtime/reduction.cpp @@ -92,7 +92,11 @@ using CppType = CppTypeFor; DoTotalReduction(x, dim, mask, accumulator, intrinsic, terminator); CppType result; +#ifdef _MSC_VER // work around MSVC spurious error + accumulator.GetResult(&result); +#else accumulator.template GetResult(&result); +#endif return result; } @@ -130,7 +134,11 @@ break; } } +#ifdef _MSC_VER // work around MSVC spurious error + accumulator.GetResult(result, zeroBasedDim); +#else accumulator.template GetResult(result, zeroBasedDim); +#endif } template @@ -154,7 +162,11 @@ } } } +#ifdef _MSC_VER // work around MSVC spurious error + accumulator.GetResult(result, zeroBasedDim); +#else accumulator.template GetResult(result, zeroBasedDim); +#endif } // Utility: establishes & allocates the result array for a partial @@ -253,11 +265,13 @@ TypeCategory::Integer, 8>( result, x, dim, mask, terminator, intrinsic); return; +#ifdef __SIZEOF_INT128__ case 16: PartialReduction>, TypeCategory::Integer, 16>( result, x, dim, mask, terminator, intrinsic); return; +#endif } break; case TypeCategory::Real: @@ -416,12 +430,14 @@ return GetTotalReduction(x, source, line, dim, mask, IntegerSumAccumulator>{x}, "SUM"); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(SumInteger16)(const Descriptor &x, const char *source, int line, int dim, const Descriptor *mask) { return GetTotalReduction(x, source, line, dim, mask, IntegerSumAccumulator>{x}, "SUM"); } +#endif // TODO: real/complex(2 & 3) CppTypeFor RTNAME(SumReal4)(const Descriptor &x, @@ -549,6 +565,7 @@ NonComplexProductAccumulator>{x}, "PRODUCT"); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(ProductInteger16)( const Descriptor &x, const char *source, int line, int dim, const Descriptor *mask) { @@ -557,6 +574,7 @@ NonComplexProductAccumulator>{x}, "PRODUCT"); } +#endif // TODO: real/complex(2 & 3) CppTypeFor RTNAME(ProductReal4)(const Descriptor &x, @@ -725,10 +743,12 @@ accumulator.GetResult( result.OffsetElement>()); break; +#ifdef __SIZEOF_INT128__ case 16: accumulator.GetResult( result.OffsetElement>()); break; +#endif default: terminator.Crash("%s: bad KIND=%d", intrinsic, kind); } @@ -786,10 +806,12 @@ DoMaxOrMinLoc( intrinsic, result, x, kind, source, line, mask, back); return; +#ifdef __SIZEOF_INT128__ case 16: DoMaxOrMinLoc( intrinsic, result, x, kind, source, line, mask, back); return; +#endif } break; case TypeCategory::Real: @@ -875,10 +897,12 @@ PartialReduction>, TypeCategory::Integer, 8>(result, x, dim, mask, terminator, intrinsic); break; +#ifdef __SIZEOF_INT128__ case 16: PartialReduction>, TypeCategory::Integer, 16>(result, x, dim, mask, terminator, intrinsic); break; +#endif default: terminator.Crash("%s: bad KIND=%d", intrinsic, kind); } @@ -925,10 +949,12 @@ DoPartialMaxOrMinLoc( intrinsic, result, x, kind, dim, mask, back, terminator); return; +#ifdef __SIZEOF_INT128__ case 16: DoPartialMaxOrMinLoc( intrinsic, result, x, kind, dim, mask, back, terminator); return; +#endif } break; case TypeCategory::Real: @@ -1101,11 +1127,13 @@ NumericExtremumAccumulator>( result, x, dim, mask, intrinsic, terminator); return; +#ifdef __SIZEOF_INT128__ case 16: DoMaxOrMin( result, x, dim, mask, intrinsic, terminator); return; +#endif } break; case TypeCategory::Real: @@ -1223,12 +1251,14 @@ return TotalNumericMaxOrMin( x, source, line, dim, mask, "MAXVAL"); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(MaxvalInteger16)( const Descriptor &x, const char *source, int line, int dim, const Descriptor *mask) { return TotalNumericMaxOrMin( x, source, line, dim, mask, "MAXVAL"); } +#endif // TODO: REAL(2 & 3) CppTypeFor RTNAME(MaxvalReal4)(const Descriptor &x, @@ -1280,12 +1310,14 @@ return TotalNumericMaxOrMin( x, source, line, dim, mask, "MINVAL"); } +#ifdef __SIZEOF_INT128__ CppTypeFor RTNAME(MinvalInteger16)( const Descriptor &x, const char *source, int line, int dim, const Descriptor *mask) { return TotalNumericMaxOrMin( x, source, line, dim, mask, "MINVAL"); } +#endif // TODO: REAL(2 & 3) CppTypeFor RTNAME(MinvalReal4)(const Descriptor &x, @@ -1513,9 +1545,11 @@ case 8: CountDimension<8>(result, x, dim, terminator); break; +#ifdef __SIZEOF_INT128__ case 16: CountDimension<16>(result, x, dim, terminator); break; +#endif default: terminator.Crash("COUNT: bad KIND=%d", kind); }