[libc-commits] [libc] [llvm] [libc][math][c23] Add sinhbf16 function (PR #224645)

via libc-commits libc-commits at lists.llvm.org
Sun Sep 20 05:42:14 PDT 2026


================
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file contains the implementation of sinhbf16.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SINHBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SINHBF16_H
+
+#include "sinhfcoshf_utils.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE bfloat16 sinhbf16(bfloat16 x) {
----------------
dil12321 wrote:

It can be done. We would need to modify `nearest_integer()` to use a constexpr implementation instead of the architecture-specific implementation (e.g. `frint` on AArch64) when `cpp::is_constant_evaluated()` is true. The same change would be needed for the x86 implementation.

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


More information about the libc-commits mailing list