[llvm] [APFloat] Add exp function for APFloat::IEEESsingle using expf implementation from LLVM libc. (PR #143959)
Corentin Jabot via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 13 00:51:14 PDT 2025
================
@@ -5601,6 +5606,35 @@ float APFloat::convertToFloat() const {
return Temp.getIEEE().convertToFloat();
}
+#ifdef LLVM_INTEGRATE_LIBC
+APFloat exp(const APFloat &X, RoundingMode rounding_mode) {
+ assert((&X.getSemantics() == (const llvm::fltSemantics *)&semIEEEsingle) &&
+ "Float semantics is not IEEEsingle");
+ if (&X.getSemantics() == (const llvm::fltSemantics *)&semIEEEsingle) {
+ int current_rounding_mode = fegetround();
+ switch (rounding_mode) {
+ case APFloat::rmNearestTiesToEven:
+ fesetround(FE_TONEAREST);
----------------
cor3ntin wrote:
I think the suggestion is to do `LIBC_NAMESPACE::shared::expf(X.convertToFloat(), rounding_mode)` and not mess with global state. It would be _much_ cleaner if that were possible
https://github.com/llvm/llvm-project/pull/143959
More information about the llvm-commits
mailing list