Skip to content

Commit 7e53ea7

Browse files
committed
[libc][math][c23] Add remquof16 C23 math function
1 parent 6c4c533 commit 7e53ea7

File tree

11 files changed

+85
-8
lines changed

11 files changed

+85
-8
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
537537
# libc.src.math.nexttowardf16
538538
libc.src.math.nextupf16
539539
libc.src.math.remainderf16
540+
libc.src.math.remquof16
540541
libc.src.math.rintf16
541542
libc.src.math.roundf16
542543
libc.src.math.roundevenf16

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
567567
libc.src.math.nexttowardf16
568568
libc.src.math.nextupf16
569569
libc.src.math.remainderf16
570+
libc.src.math.remquof16
570571
libc.src.math.rintf16
571572
libc.src.math.roundf16
572573
libc.src.math.roundevenf16

libc/docs/math/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Basic Operations
200200
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
201201
| remainder | |check| | |check| | |check| | |check| | | 7.12.10.2 | F.10.7.2 |
202202
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
203-
| remquo | |check| | |check| | |check| | | |check| | 7.12.10.3 | F.10.7.3 |
203+
| remquo | |check| | |check| | |check| | |check| | |check| | 7.12.10.3 | F.10.7.3 |
204204
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
205205
| rint | |check| | |check| | |check| | |check| | |check| | 7.12.9.4 | F.10.6.4 |
206206
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+

libc/spec/stdc.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,11 @@ def StdC : StandardSpec<"stdc"> {
586586
FunctionSpec<"remainderl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
587587
GuardedFunctionSpec<"remainderf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
588588

589-
FunctionSpec<"remquof", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>, ArgSpec<IntPtr>]>,
590-
GuardedFunctionSpec<"remquof128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<IntPtr>], "LIBC_TYPES_HAS_FLOAT128">,
591589
FunctionSpec<"remquo", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>, ArgSpec<IntPtr>]>,
590+
FunctionSpec<"remquof", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>, ArgSpec<IntPtr>]>,
592591
FunctionSpec<"remquol", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>, ArgSpec<IntPtr>]>,
592+
GuardedFunctionSpec<"remquof16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<Float16Type>, ArgSpec<IntPtr>], "LIBC_TYPES_HAS_FLOAT16">,
593+
GuardedFunctionSpec<"remquof128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<IntPtr>], "LIBC_TYPES_HAS_FLOAT128">,
593594

594595
FunctionSpec<"round", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
595596
FunctionSpec<"roundf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,

libc/src/math/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ add_math_entrypoint_object(remquo)
321321
add_math_entrypoint_object(remquof)
322322
add_math_entrypoint_object(remquof128)
323323
add_math_entrypoint_object(remquol)
324+
add_math_entrypoint_object(remquof16)
324325

325326
add_math_entrypoint_object(rint)
326327
add_math_entrypoint_object(rintf)

libc/src/math/generic/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,6 +2534,19 @@ add_entrypoint_object(
25342534
-O2
25352535
)
25362536

2537+
add_entrypoint_object(
2538+
remquof16
2539+
SRCS
2540+
remquof16.cpp
2541+
HDRS
2542+
../remquof16.h
2543+
DEPENDS
2544+
libc.src.__support.macros.properties.types
2545+
libc.src.__support.FPUtil.division_and_remainder_operations
2546+
COMPILE_OPTIONS
2547+
-O2
2548+
)
2549+
25372550
add_entrypoint_object(
25382551
remainderf
25392552
SRCS

libc/src/math/generic/remquof16.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===-- Implementation of remquof16 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/remquof16.h"
10+
#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
11+
#include "src/__support/common.h"
12+
13+
namespace LIBC_NAMESPACE {
14+
15+
LLVM_LIBC_FUNCTION(float16, remquof16, (float16 x, float16 y, int *exp)) {
16+
return fputil::remquo(x, y, *exp);
17+
}
18+
19+
} // namespace LIBC_NAMESPACE

libc/src/math/remquof16.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for remquof16 ---------------------*- 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_REMQUOF16_H
10+
#define LLVM_LIBC_SRC_MATH_REMQUOF16_H
11+
12+
#include "src/__support/macros/properties/types.h"
13+
14+
namespace LIBC_NAMESPACE {
15+
16+
float16 remquof16(float16 x, float16 y, int *exp);
17+
18+
} // namespace LIBC_NAMESPACE
19+
20+
#endif // LLVM_LIBC_SRC_MATH_REMQUOF16_H

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,7 +2608,6 @@ add_fp_unittest(
26082608
RemQuoTest.h
26092609
DEPENDS
26102610
libc.src.math.remquof
2611-
libc.src.__support.FPUtil.basic_operations
26122611
libc.src.__support.FPUtil.fp_bits
26132612
)
26142613

@@ -2636,7 +2635,6 @@ add_fp_unittest(
26362635
RemQuoTest.h
26372636
DEPENDS
26382637
libc.src.math.remquo
2639-
libc.src.__support.FPUtil.basic_operations
26402638
libc.src.__support.FPUtil.fp_bits
26412639
)
26422640

@@ -2650,7 +2648,19 @@ add_fp_unittest(
26502648
RemQuoTest.h
26512649
DEPENDS
26522650
libc.src.math.remquol
2653-
libc.src.__support.FPUtil.basic_operations
2651+
libc.src.__support.FPUtil.fp_bits
2652+
)
2653+
2654+
add_fp_unittest(
2655+
remquof16_test
2656+
SUITE
2657+
libc-math-smoke-tests
2658+
SRCS
2659+
remquof16_test.cpp
2660+
HDRS
2661+
RemQuoTest.h
2662+
DEPENDS
2663+
libc.src.math.remquof16
26542664
libc.src.__support.FPUtil.fp_bits
26552665
)
26562666

libc/test/src/math/smoke/RemQuoTest.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#ifndef LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
1010
#define LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
1111

12-
#include "hdr/math_macros.h"
13-
#include "src/__support/FPUtil/BasicOperations.h"
1412
#include "src/__support/FPUtil/FPBits.h"
1513
#include "test/UnitTest/FEnvSafeTest.h"
1614
#include "test/UnitTest/FPMatcher.h"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for remquof16 -------------------------------------------===//
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 "RemQuoTest.h"
10+
11+
#include "src/math/remquof16.h"
12+
13+
LIST_REMQUO_TESTS(float16, LIBC_NAMESPACE::remquof16)

0 commit comments

Comments
 (0)