Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions libc/config/baremetal/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -790,6 +793,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/baremetal/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -793,6 +796,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/baremetal/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -793,6 +796,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/darwin/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -623,6 +626,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/darwin/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -266,6 +269,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/gpu/amdgpu/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -649,6 +652,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/gpu/nvptx/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -651,6 +654,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -878,6 +881,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/linux/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -493,6 +496,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -896,6 +899,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -929,6 +932,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
5 changes: 5 additions & 0 deletions libc/config/windows/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.fabsbf16
libc.src.math.fdimbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
libc.src.math.fmaximumbf16
Expand All @@ -339,6 +342,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpxbf16
libc.src.math.getpayloadbf16
libc.src.math.ilogbbf16
libc.src.math.iscanonicalbf16
libc.src.math.issignalingbf16
libc.src.math.ldexpbf16
libc.src.math.llogbbf16
libc.src.math.llrintbf16
Expand Down
10 changes: 5 additions & 5 deletions libc/docs/headers/math/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ Basic Operations
+==================+==================+=================+========================+======================+========================+========================+========================+============================+
| ceil | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.1 | F.10.6.1 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| canonicalize | |check| | |check| | |check| | |check| | |check| | | 7.12.11.7 | F.10.8.7 |
| canonicalize | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.11.7 | F.10.8.7 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| copysign | |check| | |check| | |check| | |check| | |check| | | 7.12.11.1 | F.10.8.1 |
| copysign | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.11.1 | F.10.8.1 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| dadd | N/A | N/A | |check| | N/A | |check|\* | N/A | 7.12.14.1 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
Expand Down Expand Up @@ -147,7 +147,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fadd | N/A | |check| | |check| | N/A | |check| | N/A | 7.12.14.1 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fdim | |check| | |check| | |check| | |check| | |check| | | 7.12.12.1 | F.10.9.1 |
| fdim | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.12.1 | F.10.9.1 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fdiv | N/A | |check| | |check| | N/A | |check|\* | N/A | 7.12.14.4 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
Expand Down Expand Up @@ -191,9 +191,9 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| ilogb | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.6.8 | F.10.3.8 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| iscanonical | |check| | |check| | |check| | |check| | |check| | | 7.12.3.2 | N/A |
| iscanonical | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.3.2 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| issignaling | |check| | |check| | |check| | |check| | |check| | | 7.12.3.8 | N/A |
| issignaling | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.3.8 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| ldexp | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.6.9 | F.10.3.9 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
Expand Down
2 changes: 1 addition & 1 deletion libc/src/__support/FPUtil/BasicOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ LIBC_INLINE T fdim(T x, T y) {
return y;
}

return (x > y ? x - y : 0);
return (x > y ? x - y : T(0));
}

// Avoid reusing `issignaling` macro.
Expand Down
5 changes: 5 additions & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ add_math_entrypoint_object(canonicalizef)
add_math_entrypoint_object(canonicalizel)
add_math_entrypoint_object(canonicalizef16)
add_math_entrypoint_object(canonicalizef128)
add_math_entrypoint_object(canonicalizebf16)

add_math_entrypoint_object(iscanonical)
add_math_entrypoint_object(iscanonicalf)
add_math_entrypoint_object(iscanonicall)
add_math_entrypoint_object(iscanonicalf16)
add_math_entrypoint_object(iscanonicalf128)
add_math_entrypoint_object(iscanonicalbf16)

add_math_entrypoint_object(cbrt)
add_math_entrypoint_object(cbrtf)
Expand All @@ -100,6 +102,7 @@ add_math_entrypoint_object(copysignf)
add_math_entrypoint_object(copysignl)
add_math_entrypoint_object(copysignf16)
add_math_entrypoint_object(copysignf128)
add_math_entrypoint_object(copysignbf16)

add_math_entrypoint_object(cos)
add_math_entrypoint_object(cosf)
Expand Down Expand Up @@ -203,6 +206,7 @@ add_math_entrypoint_object(fdimf)
add_math_entrypoint_object(fdiml)
add_math_entrypoint_object(fdimf16)
add_math_entrypoint_object(fdimf128)
add_math_entrypoint_object(fdimbf16)

add_math_entrypoint_object(fdiv)
add_math_entrypoint_object(fdivl)
Expand Down Expand Up @@ -355,6 +359,7 @@ add_math_entrypoint_object(issignalingf)
add_math_entrypoint_object(issignalingl)
add_math_entrypoint_object(issignalingf16)
add_math_entrypoint_object(issignalingf128)
add_math_entrypoint_object(issignalingbf16)

add_math_entrypoint_object(llogb)
add_math_entrypoint_object(llogbf)
Expand Down
21 changes: 21 additions & 0 deletions libc/src/math/canonicalizebf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for canonicalizebf16 --------------*- 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_CANONICALIZEBF16_H
#define LLVM_LIBC_SRC_MATH_CANONICALIZEBF16_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

int canonicalizebf16(bfloat16 *cx, const bfloat16 *x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_CANONICALIZEBF16_H
21 changes: 21 additions & 0 deletions libc/src/math/copysignbf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for copysignbf16 ------------------*- 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_COPYSIGNBF16_H
#define LLVM_LIBC_SRC_MATH_COPYSIGNBF16_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

bfloat16 copysignbf16(bfloat16 x, bfloat16 y);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_COPYSIGNBF16_H
21 changes: 21 additions & 0 deletions libc/src/math/fdimbf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for fdimbf16 ----------------------*- 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_FDIMBF16_H
#define LLVM_LIBC_SRC_MATH_FDIMBF16_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

bfloat16 fdimbf16(bfloat16 x, bfloat16 y);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FDIMBF16_H
Loading
Loading