This update allows constant folding for many 128 bit floating point intrinsics
through the library quadmath, which is only available on some platforms.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
flang/lib/Evaluate/host.h | ||
---|---|---|
170 | I'm confused by this specialization -- shouldn't the more general template now at line 186 work for 128-bit complex anyway? |
flang/lib/Evaluate/host.h | ||
---|---|---|
170 | Without this specialization, I get compilation errors from intrinsics-library.cpp. Here's an excerpt: /local/home/psteinfeld/dev/llvm-project/flang/lib/Evaluate/intrinsics-library.cpp: In instantiation of ‘constexpr const Fortran::evaluate::DynamicType Fortran::evaluate::FuncTypeAnalyzer<__float128 (*)(__float128)>::result’: /local/home/psteinfeld/dev/llvm-project/flang/lib/Evaluate/intrinsics-library.cpp:188:57: required from ‘static constexpr Fortran::evaluate::HostRuntimeFunction Fortran::evaluate::FolderFactory<HostFuncType, func>::Create(const string_view&) [with HostFuncType = __float128 (*)(__float128); HostFuncType func = acosq; std::string_view = std::basic_string_view<char>]’ /local/home/psteinfeld/dev/llvm-project/flang/lib/Evaluate/intrinsics-library.cpp:325:50: required from here /local/home/psteinfeld/dev/llvm-project/flang/lib/Evaluate/intrinsics-library.cpp:105:67: error: ‘Fortran::evaluate::host::FortranType<__float128>’ {aka ‘struct Fortran::evaluate::host::UnknownType’} has no member named ‘GetType’ 105 | static constexpr DynamicType result{host::FortranType<HostTR>{}.GetType()}; | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ /local/home/psteinfeld/dev/llvm-project/flang/lib/Evaluate/intrinsics-library.cpp:105:32: error: no matching function for call to ‘Fortran::evaluate::DynamicType::DynamicType(<brace-enclosed initializer list>)’ 105 | static constexpr DynamicType result{host::FortranType<HostTR>{}.GetType()}; | ^~~~~~ In file included from /local/home/psteinfeld/dev/llvm-project/flang/lib/Evaluate/character.h:12, from /local/home/psteinfeld/dev/llvm-project/flang/lib/Evaluate/fold-implementation.h:12, from /local/home/psteinfeld/dev/llvm-project/flang/lib/Evaluate/intrinsics-library.cpp:15: /local/home/psteinfeld/dev/llvm-project/flang/include/flang/Evaluate/type.h:243:13: note: candidate: ‘constexpr Fortran::evaluate::DynamicType::DynamicType()’ 243 | constexpr DynamicType() {} | ^~~~~~~~~~~ /local/home/psteinfeld/dev/llvm-project/flang/include/flang/Evaluate/type.h:243:13: note: candidate expects 0 arguments, 1 provided |
flang/lib/Evaluate/host.h | ||
---|---|---|
170 | That seems to imply that HostTypeExists<RealT> is false, which seems wrong if you just defined it for KIND=16. I think that the general template for COMPLEX should be made to work, with some if constexpr and #ifdef HAS_FLOAT128 guards to yield __complex128 instead of std::complex<HostType<RealT>> when it should do so. If you can't make that happen, can you at least be consistent above with your use of the kind code 16 and the use of common::RealKindForPrecision(113)? |
flang/lib/Evaluate/host.h | ||
---|---|---|
170 | Thanks for your help with this. I flailed around, but I cannot get things to compile without a separate specialization for 128 bit complex. I did clean up the KIND specification and moved the 128 bit version of the complex specialization closer to the other one. Let me know if there's something I'm missing. |
These changes are to try to get builds to succeed on Debian. I'm now testing
both if the quadmath library exists and if the header file quadmath.h exists in
order to enable use of the quadmath library for folding.
I'm confused by this specialization -- shouldn't the more general template now at line 186 work for 128-bit complex anyway?