[libc-commits] [libc] [libc][math][c++23] Add log2bf16 math function (PR #177275)
via libc-commits
libc-commits at lists.llvm.org
Sat Feb 21 22:13:53 PST 2026
================
@@ -0,0 +1,128 @@
+//===-- Double-precision log2(x) 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LOG2BF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LOG2BF16_H
+
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+// Generated by Sollya with the following commands:
+// > display = hexadecimal;
+// > for i from 0 to 127 do print(round(log2(1 + i * 2^-7), SG, RN));
+static constexpr float LOG2F_1_PLUS_M[128] = {
----------------
lntue wrote:
remove `static`, use `LIBC_INLINE_VAR`
https://github.com/llvm/llvm-project/pull/177275
More information about the libc-commits
mailing list