Skip to content

Commit 15a5548

Browse files
author
Michael Flanders
authored
[libc][math] Adds entrypoint and test for nextafterf128 (#84882)
1 parent 5d7796e commit 15a5548

File tree

13 files changed

+118
-3
lines changed

13 files changed

+118
-3
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
438438
libc.src.math.lrintf128
439439
libc.src.math.lroundf128
440440
libc.src.math.modff128
441+
libc.src.math.nextafterf128
441442
libc.src.math.rintf128
442443
libc.src.math.roundf128
443444
libc.src.math.sqrtf128

libc/config/linux/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
446446
libc.src.math.lrintf128
447447
libc.src.math.lroundf128
448448
libc.src.math.modff128
449+
libc.src.math.nextafterf128
449450
libc.src.math.rintf128
450451
libc.src.math.roundf128
451452
libc.src.math.sqrtf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
481481
libc.src.math.lrintf128
482482
libc.src.math.lroundf128
483483
libc.src.math.modff128
484+
libc.src.math.nextafterf128
484485
libc.src.math.rintf128
485486
libc.src.math.roundf128
486487
libc.src.math.sqrtf128

libc/docs/math/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ Basic Operations
271271
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
272272
| nextafterl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
273273
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
274+
| nextafterf128| |check| | |check| | | |check| | | | | | | | | |
275+
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
274276
| nexttoward | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
275277
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
276278
| nexttowardf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |

libc/spec/stdc.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ def StdC : StandardSpec<"stdc"> {
530530
FunctionSpec<"nextafterf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
531531
FunctionSpec<"nextafter", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
532532
FunctionSpec<"nextafterl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
533+
GuardedFunctionSpec<"nextafterf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
533534

534535
FunctionSpec<"nexttowardf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<LongDoubleType>]>,
535536
FunctionSpec<"nexttoward", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<LongDoubleType>]>,

libc/src/math/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ add_math_entrypoint_object(nearbyintl)
198198
add_math_entrypoint_object(nextafter)
199199
add_math_entrypoint_object(nextafterf)
200200
add_math_entrypoint_object(nextafterl)
201+
add_math_entrypoint_object(nextafterf128)
201202

202203
add_math_entrypoint_object(nexttoward)
203204
add_math_entrypoint_object(nexttowardf)

libc/src/math/generic/CMakeLists.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ add_entrypoint_object(
17891789
DEPENDS
17901790
libc.src.__support.FPUtil.manipulation_functions
17911791
COMPILE_OPTIONS
1792-
-O2
1792+
-O3
17931793
)
17941794

17951795
add_entrypoint_object(
@@ -1801,7 +1801,7 @@ add_entrypoint_object(
18011801
DEPENDS
18021802
libc.src.__support.FPUtil.manipulation_functions
18031803
COMPILE_OPTIONS
1804-
-O2
1804+
-O3
18051805
)
18061806

18071807
add_entrypoint_object(
@@ -1813,7 +1813,20 @@ add_entrypoint_object(
18131813
DEPENDS
18141814
libc.src.__support.FPUtil.manipulation_functions
18151815
COMPILE_OPTIONS
1816-
-O2
1816+
-O3
1817+
)
1818+
1819+
add_entrypoint_object(
1820+
nextafterf128
1821+
SRCS
1822+
nextafterf128.cpp
1823+
HDRS
1824+
../nextafterf128.h
1825+
DEPENDS
1826+
libc.src.__support.macros.properties.types
1827+
libc.src.__support.FPUtil.manipulation_functions
1828+
COMPILE_OPTIONS
1829+
-O3
18171830
)
18181831

18191832
add_entrypoint_object(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===-- Implementation of nextafterf128 function --------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/math/nextafterf128.h"
10+
#include "src/__support/FPUtil/ManipulationFunctions.h"
11+
#include "src/__support/common.h"
12+
13+
namespace LIBC_NAMESPACE {
14+
15+
LLVM_LIBC_FUNCTION(float128, nextafterf128, (float128 x, float128 y)) {
16+
return fputil::nextafter(x, y);
17+
}
18+
19+
} // namespace LIBC_NAMESPACE

libc/src/math/nextafterf128.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for nextafterf128 ------------------*- C++-*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_MATH_NEXTAFTERF128_H
10+
#define LLVM_LIBC_SRC_MATH_NEXTAFTERF128_H
11+
12+
#include "src/__support/macros/properties/types.h"
13+
14+
namespace LIBC_NAMESPACE {
15+
16+
float128 nextafterf128(float128 x, float128 y);
17+
18+
} // namespace LIBC_NAMESPACE
19+
20+
#endif // LLVM_LIBC_SRC_MATH_NEXTAFTERF128_H

libc/test/src/math/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,21 @@ add_fp_unittest(
12731273
libc.src.__support.FPUtil.fp_bits
12741274
)
12751275

1276+
add_fp_unittest(
1277+
nextafterf128_test
1278+
SUITE
1279+
libc-math-unittests
1280+
SRCS
1281+
nextafterf128_test.cpp
1282+
HDRS
1283+
NextAfterTest.h
1284+
DEPENDS
1285+
libc.include.math
1286+
libc.src.math.nextafterf128
1287+
libc.src.__support.FPUtil.basic_operations
1288+
libc.src.__support.FPUtil.fp_bits
1289+
)
1290+
12761291
# TODO(lntue): The current implementation of fputil::general::fma<float> is only
12771292
# correctly rounded for the default rounding mode round-to-nearest tie-to-even.
12781293
add_fp_unittest(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for nextafterf128 ---------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "NextAfterTest.h"
10+
11+
#include "src/math/nextafterf128.h"
12+
13+
LIST_NEXTAFTER_TESTS(float128, LIBC_NAMESPACE::nextafterf128)

libc/test/src/math/smoke/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,21 @@ add_fp_unittest(
15511551
libc.src.__support.FPUtil.fp_bits
15521552
)
15531553

1554+
add_fp_unittest(
1555+
nextafterf128_test
1556+
SUITE
1557+
libc-math-smoke-tests
1558+
SRCS
1559+
nextafterf128_test.cpp
1560+
HDRS
1561+
NextAfterTest.h
1562+
DEPENDS
1563+
libc.include.math
1564+
libc.src.math.nextafterf128
1565+
libc.src.__support.FPUtil.basic_operations
1566+
libc.src.__support.FPUtil.fp_bits
1567+
)
1568+
15541569
# FIXME: These tests are currently spurious for the GPU.
15551570
if(NOT LIBC_TARGET_OS_IS_GPU)
15561571
add_fp_unittest(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for nextafterf128 ---------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "NextAfterTest.h"
10+
11+
#include "src/math/nextafterf128.h"
12+
13+
LIST_NEXTAFTER_TESTS(float128, LIBC_NAMESPACE::nextafterf128)

0 commit comments

Comments
 (0)