Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e4135e3
add: FPType::BFloat16
krishna2803 Jun 3, 2025
6cd97e4
chore: remove compiler version checks and add bfloat16 to is_floating…
krishna2803 Jun 4, 2025
0ddfaed
feat: update MPCommon.h for bfloat16 type and change __bf16 to our ow…
krishna2803 Jun 5, 2025
7aac686
feat: add BFloat16 checks in compiler features
krishna2803 Jun 6, 2025
e35655c
feat: add dummy bfloat16 -> float conversion function
krishna2803 Jun 9, 2025
7974903
chore: add entrypoints for fbfloat16 function
krishna2803 Jun 9, 2025
8aacba6
chore: add dummy tests for fbfloat16
krishna2803 Jun 9, 2025
78a77f6
chore: update fbfloat16 dummy smoke tests
krishna2803 Jun 9, 2025
ed3f8ac
fix: circular dependencies
krishna2803 Jun 11, 2025
e9e089b
refactor: remove `LIBC_TYPES_HAS_BFLOAT16` dependency from sources an…
krishna2803 Jun 9, 2025
8ded7ba
chore: complete smoke tests for fbfloat16 function
krishna2803 Jun 12, 2025
823d84f
refactor: rename fbfloat16 smoke test suite, refactor bfloat16 specia…
krishna2803 Jun 12, 2025
4e7a38e
feat: add exhaustive tests for fbfloat16
krishna2803 Jun 12, 2025
ea6cdae
feat: implement fabsbf16 function
krishna2803 Jun 13, 2025
e27d59d
refactor: remove unused files and reorganize structure
krishna2803 Jul 12, 2025
b44b27c
refactor: use LIST_FABS_TEST api for fabsbf16
krishna2803 Jul 12, 2025
f3d8a3f
chore: remove redundant stuff and add indents
krishna2803 Jul 12, 2025
df7471f
Update libc/config/linux/x86_64/entrypoints.txt
krishna2803 Jul 22, 2025
1dd72fa
refactor: change includes
krishna2803 Jul 22, 2025
5997531
chore: add entrypoints for all platforms
krishna2803 Jul 23, 2025
aa293e2
nit: indentation
krishna2803 Jul 23, 2025
e61cb99
Update libc/src/math/generic/CMakeLists.txt
krishna2803 Jul 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,12 @@ if(LIBC_TYPES_HAS_FLOAT128)
)
endif()


list(APPEND TARGET_LIBM_ENTRYPOINTS
# Bfloat16 Entrypoints
libc.src.math.fabsbf16
)

if(LIBC_COMPILER_HAS_FIXED_POINT)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# stdfix.h _Fract and _Accum entrypoints
Expand Down
1 change: 1 addition & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ add_math_entrypoint_object(fabsf)
add_math_entrypoint_object(fabsl)
add_math_entrypoint_object(fabsf16)
add_math_entrypoint_object(fabsf128)
add_math_entrypoint_object(fabsbf16)

add_math_entrypoint_object(fadd)
add_math_entrypoint_object(faddl)
Expand Down
21 changes: 21 additions & 0 deletions libc/src/math/fabsbf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for fabsbf16 ----------------------*- C++ -*-===//
//
// 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_MATH_FABSBF16_H
#define LLVM_LIBC_SRC_MATH_FABSBF16_H

#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

bfloat16 fabsbf16(bfloat16 x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FABSBF16_H
12 changes: 12 additions & 0 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,18 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
)

add_entrypoint_object(
fabsbf16
SRCS
fabsbf16.cpp
HDRS
../fabsbf16.h
DEPENDS
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.config
)

add_entrypoint_object(
fadd
SRCS
Expand Down
19 changes: 19 additions & 0 deletions libc/src/math/generic/fabsbf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fabsbf16 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/fabsbf16.h"

#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(bfloat16, fabsbf16, (bfloat16 x)) { return fputil::abs(x); }

} // namespace LIBC_NAMESPACE_DECL
1 change: 0 additions & 1 deletion libc/test/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ add_fp_unittest(
DEPENDS
libc.src.math.generic.ceill
)

13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fabsbf16_test
SUITE
libc-math-smoke-tests
SRCS
fabsbf16_test.cpp
HDRS
FAbsTest.h
DEPENDS
libc.src.__support.FPUtil.bfloat16
libc.src.math.fabsbf16
)

add_fp_unittest(
fadd_test
SUITE
Expand Down
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fabsbf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fabsbf16 --------------------------------------------===//
//
// 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 "FAbsTest.h"

#include "src/math/fabsbf16.h"

LIST_FABS_TESTS(bfloat16, LIBC_NAMESPACE::fabsbf16)
Loading