[flang-commits] [flang] [llvm] [flang] Use backend fp128 support to determine REAL(16) availability (PR #221907)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Tue Sep 22 07:39:20 PDT 2026


Meinersbur wrote:

> Would using the availability of the relevant F128 libcalls (e.g. ADD_F128/SUB_F128/MUL_F128/DIV_F128) as the criterion for REAL(16) frontend availability sound reasonable to you?

Thanks for the exhaustive survey. Yes it seams reasonable, unless someone comes up with something better.

For Clang, it seems that TargetInfo.cpp
https://github.com/llvm/llvm-project/blob/52ccbddfd304d16f87a2749b4546b1727b1aadc3/clang/lib/Basic/TargetInfo.cpp#L76
is the source-of-truth of whether f128 is available. For those target triples that do not set it to enabled, it seems the backends do not maintain consistency. When I force enable it with Clang, I get mixed results on where it crashes.

SPIR-V: https://github.com/llvm/llvm-project/blob/1baa43495862650e0d03780d565b8e09d57b3495/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp#L1246

DXIL: `lib/Target/DirectX/DXContainerGlobals.cpp:245: void {anonymous}::DXContainerGlobals::addRootSignature(llvm::Module&, llvm::SmallVector<llvm::GlobalValue*>&): Assertion `MMI.EntryPropertyVec.size() == 1' failed.`

Most others: https://github.com/llvm/llvm-project/blob/abecf784ec30bce9d9163bd2e0d14c4a70094045/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp#L160

The "unsupported library call operation" comes up when the target defines getTypeAction `TypeSoftenFloat` but does not define the library to be supported. I would call that a bug in those backends. IMHO 
those should be fixed. The only other way would be to hardcode the support into TargetCharacteristics like Clang does with `TargetInfo.cpp`





> Where are these libcalls defined? Is it compiler-rt, libquadmath, or some other library?

compiler-rt (https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/addtf3.c) and libgcc (https://github.com/gcc-mirror/gcc/blob/master/libgcc/soft-fp/adddf3.c) implements the basic ones, but not the transcendental one, which may be implemented in libquadmath, libm, etc. Whether these are available is set in LLVM by 

Whether these are available is defined somehwere in https://github.com/llvm/llvm-project/blob/cbab69595ca6f5a1c7296985e5555b8b45a35e55/llvm/include/llvm/IR/RuntimeLibcalls.td#L1180 and https://github.com/llvm/llvm-project/blob/d74c1b77c61492ef6c5dc95bcd2b23685509379b/llvm/lib/Analysis/TargetLibraryInfo.cpp#L109
These do not define which library implements them and I *strongly* recommend against making any assumption about whether these libraries are available at compile-time.





https://github.com/llvm/llvm-project/pull/221907


More information about the flang-commits mailing list