Skip to content

Commit 44aecca

Browse files
[libc][math][C23] Implemented remquof128 function (#94809)
Added remquof128 function. Closes #94312
1 parent 263be9f commit 44aecca

File tree

10 files changed

+83
-1
lines changed

10 files changed

+83
-1
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
575575
libc.src.math.nextafterf128
576576
libc.src.math.nextdownf128
577577
libc.src.math.nextupf128
578+
libc.src.math.remquof128
578579
libc.src.math.rintf128
579580
libc.src.math.roundf128
580581
libc.src.math.scalbnf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
606606
libc.src.math.nextafterf128
607607
libc.src.math.nextdownf128
608608
libc.src.math.nextupf128
609+
libc.src.math.remquof128
609610
libc.src.math.rintf128
610611
libc.src.math.roundevenf128
611612
libc.src.math.roundf128

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| | | | 7.12.10.2 | F.10.7.2 |
202202
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
203-
| remquo | |check| | |check| | |check| | | | 7.12.10.3 | F.10.7.3 |
203+
| remquo | |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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ def StdC : StandardSpec<"stdc"> {
581581
FunctionSpec<"remainderl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
582582

583583
FunctionSpec<"remquof", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>, ArgSpec<IntPtr>]>,
584+
GuardedFunctionSpec<"remquof128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<IntPtr>], "LIBC_TYPES_HAS_FLOAT128">,
584585
FunctionSpec<"remquo", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>, ArgSpec<IntPtr>]>,
585586
FunctionSpec<"remquol", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>, ArgSpec<IntPtr>]>,
586587

libc/src/math/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ add_math_entrypoint_object(remainderl)
312312

313313
add_math_entrypoint_object(remquo)
314314
add_math_entrypoint_object(remquof)
315+
add_math_entrypoint_object(remquof128)
315316
add_math_entrypoint_object(remquol)
316317

317318
add_math_entrypoint_object(rint)

libc/src/math/generic/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,18 @@ add_entrypoint_object(
24322432
-O2
24332433
)
24342434

2435+
add_entrypoint_object(
2436+
remquof128
2437+
SRCS
2438+
remquof128.cpp
2439+
HDRS
2440+
../remquof128.h
2441+
DEPENDS
2442+
libc.src.__support.FPUtil.division_and_remainder_operations
2443+
COMPILE_OPTIONS
2444+
-O3
2445+
)
2446+
24352447
add_entrypoint_object(
24362448
remquo
24372449
SRCS

libc/src/math/generic/remquof128.cpp

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

libc/src/math/remquof128.h

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

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,20 @@ add_fp_unittest(
25272527
libc.src.__support.FPUtil.fp_bits
25282528
)
25292529

2530+
add_fp_unittest(
2531+
remquof128_test
2532+
SUITE
2533+
libc-math-smoke-tests
2534+
SRCS
2535+
remquof128_test.cpp
2536+
HDRS
2537+
RemQuoTest.h
2538+
DEPENDS
2539+
libc.src.math.remquof128
2540+
libc.src.__support.FPUtil.basic_operations
2541+
libc.src.__support.FPUtil.fp_bits
2542+
)
2543+
25302544
add_fp_unittest(
25312545
remquo_test
25322546
SUITE
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for remquof128 ------------------------------------------===//
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/remquof128.h"
12+
13+
LIST_REMQUO_TESTS(float128, LIBC_NAMESPACE::remquof128)

0 commit comments

Comments
 (0)