[clang] [clang] constexpr built-in fma function. (PR #113020)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 09:22:12 PDT 2024


AaronBallman wrote:

Given the massive amount of effort it takes to implement constant expression floating-point math and the various edge cases it involves, I think the goal is for Clang to share as much code with llvm-libc as possible because they have to implement all the same logic anyway. I'm imagining a situation where we have some sort of library layer for the actual implementation of the functionality, llvm-libc would then link against that library layer, exposing the C interfaces for it, and Clang would link against that library layer and use it to implement a tablegen driven series of `__builtin_whatever` functions that would be implemented in Clang's constant expression evaluator(s) and libc++ would then be able to make use of directly.

We'd have to be careful for that library layer to be designed so that we get the *target* environment's floating-point semantics instead of the host environment's and it would need to be aware of the floating-point environment changes that come through things like pragmas.

CC @michaelrj-google for opinions, but I think we may want to have the broader design in mind before we start adding piecemeal support for constexpr float functionality even if we don't think we need it for `fma` support right now.

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


More information about the cfe-commits mailing list