[libc-commits] [libc] [libc][math][c23] Add {fromfp, fromfpx, ufromfp, ufromfpx}f16 C23 math functions (PR #94254)
via libc-commits
libc-commits at lists.llvm.org
Mon Jun 3 09:51:57 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: OverMighty (overmighty)
<details>
<summary>Changes</summary>
cc @<!-- -->lntue
---
Patch is 75.63 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94254.diff
25 Files Affected:
- (modified) libc/config/linux/aarch64/entrypoints.txt (+4)
- (modified) libc/config/linux/x86_64/entrypoints.txt (+4)
- (modified) libc/docs/c23.rst (+4-3)
- (modified) libc/docs/math/index.rst (+4-4)
- (modified) libc/spec/stdc.td (+8-4)
- (modified) libc/src/__support/FPUtil/NearestIntegerOperations.h (+8-4)
- (modified) libc/src/math/CMakeLists.txt (+4)
- (added) libc/src/math/fromfpf16.h (+20)
- (added) libc/src/math/fromfpxf16.h (+20)
- (modified) libc/src/math/generic/CMakeLists.txt (+68-16)
- (added) libc/src/math/generic/fromfpf16.cpp (+20)
- (added) libc/src/math/generic/fromfpxf16.cpp (+20)
- (added) libc/src/math/generic/ufromfpf16.cpp (+20)
- (added) libc/src/math/generic/ufromfpxf16.cpp (+20)
- (added) libc/src/math/ufromfpf16.h (+20)
- (added) libc/src/math/ufromfpxf16.h (+20)
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+48)
- (modified) libc/test/src/math/smoke/FromfpTest.h (+52-54)
- (modified) libc/test/src/math/smoke/FromfpxTest.h (+54-58)
- (modified) libc/test/src/math/smoke/UfromfpTest.h (+38-40)
- (modified) libc/test/src/math/smoke/UfromfpxTest.h (+40-42)
- (added) libc/test/src/math/smoke/fromfpf16_test.cpp (+13)
- (added) libc/test/src/math/smoke/fromfpxf16_test.cpp (+13)
- (added) libc/test/src/math/smoke/ufromfpf16_test.cpp (+13)
- (added) libc/test/src/math/smoke/ufromfpxf16_test.cpp (+13)
``````````diff
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index ca0418c3618ae..43199e080cd9c 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -500,6 +500,10 @@ if(LIBC_TYPES_HAS_FLOAT16)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float16 entrypoints
libc.src.math.fabsf16
+ libc.src.math.fromfpf16
+ libc.src.math.fromfpxf16
+ libc.src.math.ufromfpf16
+ libc.src.math.ufromfpxf16
)
endif()
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 367db7d384d23..dbaa288d431ca 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -533,6 +533,10 @@ if(LIBC_TYPES_HAS_FLOAT16)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float16 entrypoints
libc.src.math.fabsf16
+ libc.src.math.fromfpf16
+ libc.src.math.fromfpxf16
+ libc.src.math.ufromfpf16
+ libc.src.math.ufromfpxf16
)
endif()
diff --git a/libc/docs/c23.rst b/libc/docs/c23.rst
index 8ccfd46271797..33896b5d2fd4d 100644
--- a/libc/docs/c23.rst
+++ b/libc/docs/c23.rst
@@ -55,9 +55,10 @@ Additions:
* powr*
* rootn*
* roundeven* |check|
- * fromfp*
- * ufromfp*
- * fromfpx*
+ * fromfp* |check|
+ * ufromfp* |check|
+ * fromfpx* |check|
+ * ufromfpx* |check|
* nextup*
* nextdown*
* canonicalize*
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index cd90b6ae85769..251eea851071e 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -162,9 +162,9 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| frexp | |check| | |check| | |check| | | |check| | 7.12.6.7 | F.10.3.7 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| fromfp | |check| | |check| | |check| | | |check| | 7.12.9.10 | F.10.6.10 |
+| fromfp | |check| | |check| | |check| | |check| | |check| | 7.12.9.10 | F.10.6.10 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| fromfpx | |check| | |check| | |check| | | |check| | 7.12.9.11 | F.10.6.11 |
+| fromfpx | |check| | |check| | |check| | |check| | |check| | 7.12.9.11 | F.10.6.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| fsub | N/A | | | N/A | | 7.12.14.2 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
@@ -212,9 +212,9 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| trunc | |check| | |check| | |check| | | |check| | 7.12.9.9 | F.10.6.9 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| ufromfp | |check| | |check| | |check| | | |check| | 7.12.9.10 | F.10.6.10 |
+| ufromfp | |check| | |check| | |check| | |check| | |check| | 7.12.9.10 | F.10.6.10 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| ufromfpx | |check| | |check| | |check| | | |check| | 7.12.9.11 | F.10.6.11 |
+| ufromfpx | |check| | |check| | |check| | |check| | |check| | 7.12.9.11 | F.10.6.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 109721b8b12a0..f492cebaab4e3 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -474,22 +474,26 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"fromfp", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
FunctionSpec<"fromfpf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
FunctionSpec<"fromfpl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
- GuardedFunctionSpec<"fromfpf128", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT128">,
+ GuardedFunctionSpec<"fromfpf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT16">,
+ GuardedFunctionSpec<"fromfpf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"fromfpx", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
FunctionSpec<"fromfpxf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
FunctionSpec<"fromfpxl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
- GuardedFunctionSpec<"fromfpxf128", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT128">,
+ GuardedFunctionSpec<"fromfpxf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT16">,
+ GuardedFunctionSpec<"fromfpxf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"ufromfp", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
FunctionSpec<"ufromfpf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
FunctionSpec<"ufromfpl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
- GuardedFunctionSpec<"ufromfpf128", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT128">,
+ GuardedFunctionSpec<"ufromfpf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT16">,
+ GuardedFunctionSpec<"ufromfpf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"ufromfpx", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
FunctionSpec<"ufromfpxf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
FunctionSpec<"ufromfpxl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>]>,
- GuardedFunctionSpec<"ufromfpxf128", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT128">,
+ GuardedFunctionSpec<"ufromfpxf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT16">,
+ GuardedFunctionSpec<"ufromfpxf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<IntType>, ArgSpec<UnsignedIntType>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"hypot", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"hypotf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
diff --git a/libc/src/__support/FPUtil/NearestIntegerOperations.h b/libc/src/__support/FPUtil/NearestIntegerOperations.h
index 4645ab0b5350b..97ca91d36ba15 100644
--- a/libc/src/__support/FPUtil/NearestIntegerOperations.h
+++ b/libc/src/__support/FPUtil/NearestIntegerOperations.h
@@ -181,7 +181,9 @@ round_using_specific_rounding_mode(T x, int rnd) {
uint32_t trim_size = FPBits<T>::FRACTION_LEN - exponent;
FPBits<T> new_bits = bits;
- new_bits.set_mantissa((bits.get_mantissa() >> trim_size) << trim_size);
+ StorageType trunc_mantissa =
+ static_cast<StorageType>((bits.get_mantissa() >> trim_size) << trim_size);
+ new_bits.set_mantissa(trunc_mantissa);
T trunc_value = new_bits.get_val();
// If x is already an integer, return it.
@@ -190,7 +192,8 @@ round_using_specific_rounding_mode(T x, int rnd) {
StorageType trim_value =
bits.get_mantissa() & ((StorageType(1) << trim_size) - 1);
- StorageType half_value = (StorageType(1) << (trim_size - 1));
+ StorageType half_value =
+ static_cast<StorageType>((StorageType(1) << (trim_size - 1)));
// If exponent is 0, trimSize will be equal to the mantissa width, and
// truncIsOdd` will not be correct. So, we handle it as a special case
// below.
@@ -271,7 +274,8 @@ fromfp(T x, int rnd, unsigned int width) {
if (width - 1 > FPBits<T>::EXP_BIAS)
return rounded_value;
- StorageType range_exp = width - 1U + FPBits<T>::EXP_BIAS;
+ StorageType range_exp =
+ static_cast<StorageType>(width - 1 + FPBits<T>::EXP_BIAS);
// rounded_value < -2^(width - 1)
T range_min =
FPBits<T>::create_value(Sign::NEG, range_exp, EXPLICIT_BIT).get_val();
@@ -300,7 +304,7 @@ fromfp(T x, int rnd, unsigned int width) {
if (width > FPBits<T>::EXP_BIAS)
return rounded_value;
- StorageType range_exp = width + FPBits<T>::EXP_BIAS;
+ StorageType range_exp = static_cast<StorageType>(width + FPBits<T>::EXP_BIAS);
// rounded_value > 2^width - 1
T range_max =
FPBits<T>::create_value(Sign::POS, range_exp, EXPLICIT_BIT).get_val() -
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 31df5d0ab8809..ec089c34233fc 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -178,11 +178,13 @@ add_math_entrypoint_object(frexpf128)
add_math_entrypoint_object(fromfp)
add_math_entrypoint_object(fromfpf)
add_math_entrypoint_object(fromfpl)
+add_math_entrypoint_object(fromfpf16)
add_math_entrypoint_object(fromfpf128)
add_math_entrypoint_object(fromfpx)
add_math_entrypoint_object(fromfpxf)
add_math_entrypoint_object(fromfpxl)
+add_math_entrypoint_object(fromfpxf16)
add_math_entrypoint_object(fromfpxf128)
add_math_entrypoint_object(hypot)
@@ -336,9 +338,11 @@ add_math_entrypoint_object(truncf128)
add_math_entrypoint_object(ufromfp)
add_math_entrypoint_object(ufromfpf)
add_math_entrypoint_object(ufromfpl)
+add_math_entrypoint_object(ufromfpf16)
add_math_entrypoint_object(ufromfpf128)
add_math_entrypoint_object(ufromfpx)
add_math_entrypoint_object(ufromfpxf)
add_math_entrypoint_object(ufromfpxl)
+add_math_entrypoint_object(ufromfpxf16)
add_math_entrypoint_object(ufromfpxf128)
diff --git a/libc/src/math/fromfpf16.h b/libc/src/math/fromfpf16.h
new file mode 100644
index 0000000000000..6e37c2de2e016
--- /dev/null
+++ b/libc/src/math/fromfpf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for fromfpf16 ---------------------*- 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_FROMFPF16_H
+#define LLVM_LIBC_SRC_MATH_FROMFPF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float16 fromfpf16(float16 x, int rnd, unsigned int width);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_FROMFPF16_H
diff --git a/libc/src/math/fromfpxf16.h b/libc/src/math/fromfpxf16.h
new file mode 100644
index 0000000000000..f53afbcf3ffdf
--- /dev/null
+++ b/libc/src/math/fromfpxf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for fromfpxf16 --------------------*- 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_FROMFPXF16_H
+#define LLVM_LIBC_SRC_MATH_FROMFPXF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float16 fromfpxf16(float16 x, int rnd, unsigned int width);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_FROMFPXF16_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 04656e3186181..18fbfda2b5240 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2543,7 +2543,7 @@ add_entrypoint_object(
HDRS
../fromfp.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2555,7 +2555,7 @@ add_entrypoint_object(
HDRS
../fromfpf.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2567,7 +2567,20 @@ add_entrypoint_object(
HDRS
../fromfpl.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ fromfpf16
+ SRCS
+ fromfpf16.cpp
+ HDRS
+ ../fromfpf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2580,7 +2593,7 @@ add_entrypoint_object(
../fromfpf128.h
DEPENDS
libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2592,7 +2605,7 @@ add_entrypoint_object(
HDRS
../fromfpx.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2604,7 +2617,7 @@ add_entrypoint_object(
HDRS
../fromfpxf.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2616,7 +2629,20 @@ add_entrypoint_object(
HDRS
../fromfpxl.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ fromfpxf16
+ SRCS
+ fromfpxf16.cpp
+ HDRS
+ ../fromfpxf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2629,7 +2655,7 @@ add_entrypoint_object(
../fromfpxf128.h
DEPENDS
libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2641,7 +2667,7 @@ add_entrypoint_object(
HDRS
../ufromfp.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2653,7 +2679,7 @@ add_entrypoint_object(
HDRS
../ufromfpf.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2665,7 +2691,20 @@ add_entrypoint_object(
HDRS
../ufromfpl.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ ufromfpf16
+ SRCS
+ ufromfpf16.cpp
+ HDRS
+ ../ufromfpf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2678,7 +2717,7 @@ add_entrypoint_object(
../ufromfpf128.h
DEPENDS
libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2690,7 +2729,7 @@ add_entrypoint_object(
HDRS
../ufromfpx.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2702,7 +2741,7 @@ add_entrypoint_object(
HDRS
../ufromfpxf.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2714,7 +2753,20 @@ add_entrypoint_object(
HDRS
../ufromfpxl.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ ufromfpxf16
+ SRCS
+ ufromfpxf16.cpp
+ HDRS
+ ../ufromfpxf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
@@ -2727,7 +2779,7 @@ add_entrypoint_object(
../ufromfpxf128.h
DEPENDS
libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.nearest_integer
+ libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O3
)
diff --git a/libc/src/math/generic/fromfpf16.cpp b/libc/src/math/generic/fromfpf16.cpp
new file mode 100644
index 0000000000000..36040049fe3aa
--- /dev/null
+++ b/libc/src/math/generic/fromfpf16.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of fromfpf16 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/fromfpf16.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float16, fromfpf16,
+ (float16 x, int rnd, unsigned int width)) {
+ return fputil::fromfp</*IsSigned=*/true>(x, rnd, width);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/generic/fromfpxf16.cpp b/libc/src/math/generic/fromfpxf16.cpp
new file mode 100644
index 0000000000000..0854cb6613513
--- /dev/null
+++ b/libc/src/math/generic/fromfpxf16.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of fromfpxf16 function -----------------------------===//
+//
+// ...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/94254
More information about the libc-commits
mailing list