[libc-commits] [libc] [llvm] [libc][math] Refactor bf16divl to header-only (#181025) (PR #181535)
via libc-commits
libc-commits at lists.llvm.org
Sun Feb 15 01:16:52 PST 2026
https://github.com/AbdallahRashed updated https://github.com/llvm/llvm-project/pull/181535
>From b8e90d41aa4fb2d9a612f475ff6454b53a6cf51f Mon Sep 17 00:00:00 2001
From: arashed <arashed at users.noreply.github.com>
Date: Sun, 15 Feb 2026 09:37:33 +0100
Subject: [PATCH] [libc][math] Refactor bf16divl to header-only (#181025)
Move implementation inline to make it header-only. Remove the .cpp
file and update build files accordingly. Also add bf16 narrow math
functions to Bazel build.
---
libc/src/math/bf16divl.h | 7 ++++++-
libc/src/math/generic/CMakeLists.txt | 4 +---
libc/src/math/generic/bf16divl.cpp | 21 -------------------
.../llvm-project-overlay/libc/BUILD.bazel | 10 +++++++++
4 files changed, 17 insertions(+), 25 deletions(-)
delete mode 100644 libc/src/math/generic/bf16divl.cpp
diff --git a/libc/src/math/bf16divl.h b/libc/src/math/bf16divl.h
index b19ac873af3f0..f8c6eb8abc7b6 100644
--- a/libc/src/math/bf16divl.h
+++ b/libc/src/math/bf16divl.h
@@ -9,12 +9,17 @@
#ifndef LLVM_LIBC_SRC_MATH_BF16DIVL_H
#define LLVM_LIBC_SRC_MATH_BF16DIVL_H
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/div.h"
+#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
-bfloat16 bf16divl(long double x, long double y);
+LIBC_INLINE bfloat16 bf16divl(long double x, long double y) {
+ return fputil::generic::div<bfloat16>(x, y);
+}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 98d79e3b3826d..cafd515bee5eb 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -5244,14 +5244,12 @@ add_entrypoint_object(
add_entrypoint_object(
bf16divl
- SRCS
- bf16divl.cpp
HDRS
../bf16divl.h
DEPENDS
- libc.src.__support.common
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.generic.div
+ libc.src.__support.macros.attributes
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
)
diff --git a/libc/src/math/generic/bf16divl.cpp b/libc/src/math/generic/bf16divl.cpp
deleted file mode 100644
index 21dd6b150e07a..0000000000000
--- a/libc/src/math/generic/bf16divl.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation of bf16divl function -------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "src/math/bf16divl.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/FPUtil/generic/div.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16divl, (long double x, long double y)) {
- return fputil::generic::div<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index e08d759f063b0..18a767f42bf77 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -4253,6 +4253,16 @@ libc_math_function(
additional_deps = [":__support_math_atanhf16"],
)
+libc_math_function(name = "bf16addl")
+
+libc_math_function(name = "bf16divl")
+
+libc_math_function(name = "bf16fmal")
+
+libc_math_function(name = "bf16mull")
+
+libc_math_function(name = "bf16subl")
+
libc_math_function(name = "canonicalize")
libc_math_function(name = "canonicalizef")
More information about the libc-commits
mailing list