[libc-commits] [libc] 047b145 - [libc] add shared mulsf3 builtin (#205678)
via libc-commits
libc-commits at lists.llvm.org
Tue Jul 7 07:36:13 PDT 2026
Author: hulxv
Date: 2026-07-07T17:36:06+03:00
New Revision: 047b145c0cfe2ebcf73694f0ab39a0fc11dc9d09
URL: https://github.com/llvm/llvm-project/commit/047b145c0cfe2ebcf73694f0ab39a0fc11dc9d09
DIFF: https://github.com/llvm/llvm-project/commit/047b145c0cfe2ebcf73694f0ab39a0fc11dc9d09.diff
LOG: [libc] add shared mulsf3 builtin (#205678)
Re-exposes LLVM-libc's `__mulsf3` as `shared::mulsf3` for reuse by
compiler-rt's builtins.
Stacked change - merge these first:
- #200094
- #205669
- #205670
- #205671
- #205672
- #205673
- #205674
- #205675
- #205676
- #205677
Part of #197824
Added:
libc/shared/builtins/mulsf3.h
libc/src/__support/builtins/mulsf3.h
Modified:
libc/shared/builtins.h
libc/src/__support/builtins/CMakeLists.txt
libc/test/shared/CMakeLists.txt
libc/test/shared/shared_builtins_test.cpp
Removed:
################################################################################
diff --git a/libc/shared/builtins.h b/libc/shared/builtins.h
index a0cf05b5e64e6..7415f7eec4473 100644
--- a/libc/shared/builtins.h
+++ b/libc/shared/builtins.h
@@ -23,6 +23,7 @@
#include "builtins/divdf3.h"
#include "builtins/divtf3.h"
#include "builtins/muldf3.h"
+#include "builtins/mulsf3.h"
#include "builtins/multf3.h"
#include "builtins/subdf3.h"
#include "builtins/subsf3.h"
diff --git a/libc/shared/builtins/mulsf3.h b/libc/shared/builtins/mulsf3.h
new file mode 100644
index 0000000000000..b0b24b1b2e620
--- /dev/null
+++ b/libc/shared/builtins/mulsf3.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __mulsf3 implementation as shared::mulsf3 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_MULSF3_H
+#define LLVM_LIBC_SHARED_BUILTINS_MULSF3_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/mulsf3.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::mulsf3;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_MULSF3_H
diff --git a/libc/src/__support/builtins/CMakeLists.txt b/libc/src/__support/builtins/CMakeLists.txt
index d68a36a613de7..a97265e5028d8 100644
--- a/libc/src/__support/builtins/CMakeLists.txt
+++ b/libc/src/__support/builtins/CMakeLists.txt
@@ -91,3 +91,12 @@ add_header_library(
libc.src.__support.FPUtil.generic.add_sub
libc.src.__support.macros.config
)
+
+add_header_library(
+ mulsf3
+ HDRS
+ mulsf3.h
+ DEPENDS
+ libc.src.__support.FPUtil.generic.mul
+ libc.src.__support.macros.config
+)
diff --git a/libc/src/__support/builtins/mulsf3.h b/libc/src/__support/builtins/mulsf3.h
new file mode 100644
index 0000000000000..d1fef264d945a
--- /dev/null
+++ b/libc/src/__support/builtins/mulsf3.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __mulsf3 implementation as builtins::mulsf3
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULSF3_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULSF3_H
+
+#include "src/__support/FPUtil/generic/mul.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Multiplication at float precision; mirrors compiler-rt's __mulsf3.
+LIBC_INLINE float mulsf3(float x, float y) {
+ return fputil::generic::mul<float>(x, y);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULSF3_H
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 5156e7e5b32d0..0489bd2efaf79 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -833,6 +833,7 @@ add_fp_unittest(
libc.src.__support.builtins.divdf3
libc.src.__support.builtins.divtf3
libc.src.__support.builtins.muldf3
+ libc.src.__support.builtins.mulsf3
libc.src.__support.builtins.multf3
libc.src.__support.builtins.subdf3
libc.src.__support.builtins.subsf3
diff --git a/libc/test/shared/shared_builtins_test.cpp b/libc/test/shared/shared_builtins_test.cpp
index dc72824626416..3e455f27b42c8 100644
--- a/libc/test/shared/shared_builtins_test.cpp
+++ b/libc/test/shared/shared_builtins_test.cpp
@@ -12,6 +12,7 @@
TEST(LlvmLibcSharedBuiltinsTest, AllFloat) {
EXPECT_FP_EQ(3.0f, LIBC_NAMESPACE::shared::addsf3(1.0f, 2.0f));
+ EXPECT_FP_EQ(6.0f, LIBC_NAMESPACE::shared::mulsf3(2.0f, 3.0f));
EXPECT_FP_EQ(2.0f, LIBC_NAMESPACE::shared::subsf3(5.0f, 3.0f));
}
More information about the libc-commits
mailing list