Skip to content

Commit 7b51777

Browse files
author
Job Henandez Lara
authored
[libc][math][c23] add entrypoints and tests for totalordermag{f,l,f128} (#100159)
Fixes #100139
1 parent 3f6eb13 commit 7b51777

23 files changed

+344
-4
lines changed

libc/config/darwin/arm/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ set(TARGET_LIBM_ENTRYPOINTS
241241
libc.src.math.tan
242242
libc.src.math.tanf
243243
libc.src.math.tanhf
244+
libc.src.math.totalordermag
245+
libc.src.math.totalordermagf
246+
libc.src.math.totalordermagl
244247
libc.src.math.trunc
245248
libc.src.math.truncf
246249
libc.src.math.truncl

libc/config/darwin/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ set(TARGET_LIBM_ENTRYPOINTS
207207
#libc.src.math.sqrtl
208208
#libc.src.math.tanf
209209
#libc.src.math.tanhf
210+
#libc.src.math.totalordermag
211+
#libc.src.math.totalordermagf
212+
#libc.src.math.totalordermagl
210213
#libc.src.math.trunc
211214
#libc.src.math.truncf
212215
#libc.src.math.truncl

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ set(TARGET_LIBM_ENTRYPOINTS
514514
libc.src.math.tan
515515
libc.src.math.tanf
516516
libc.src.math.tanhf
517+
libc.src.math.totalordermag
518+
libc.src.math.totalordermagf
519+
libc.src.math.totalordermagl
517520
libc.src.math.trunc
518521
libc.src.math.truncf
519522
libc.src.math.truncl
@@ -637,6 +640,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
637640
libc.src.math.roundevenf128
638641
libc.src.math.scalbnf128
639642
libc.src.math.sqrtf128
643+
libc.src.math.totalordermagf128
640644
libc.src.math.truncf128
641645
libc.src.math.ufromfpf128
642646
libc.src.math.ufromfpxf128

libc/config/linux/arm/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ set(TARGET_LIBM_ENTRYPOINTS
373373
libc.src.math.tan
374374
libc.src.math.tanf
375375
libc.src.math.tanhf
376+
libc.src.math.totalordermag
377+
libc.src.math.totalordermagf
378+
libc.src.math.totalordermagl
376379
libc.src.math.trunc
377380
libc.src.math.truncf
378381
libc.src.math.truncl

libc/config/linux/riscv/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ set(TARGET_LIBM_ENTRYPOINTS
542542
libc.src.math.tan
543543
libc.src.math.tanf
544544
libc.src.math.tanhf
545+
libc.src.math.totalordermag
546+
libc.src.math.totalordermagf
547+
libc.src.math.totalordermagl
545548
libc.src.math.trunc
546549
libc.src.math.truncf
547550
libc.src.math.truncl
@@ -600,6 +603,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
600603
libc.src.math.roundf128
601604
libc.src.math.scalbnf128
602605
libc.src.math.sqrtf128
606+
libc.src.math.totalordermagf128
603607
libc.src.math.truncf128
604608
libc.src.math.ufromfpf128
605609
libc.src.math.ufromfpxf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ set(TARGET_LIBM_ENTRYPOINTS
542542
libc.src.math.tan
543543
libc.src.math.tanf
544544
libc.src.math.tanhf
545+
libc.src.math.totalordermag
546+
libc.src.math.totalordermagf
547+
libc.src.math.totalordermagl
545548
libc.src.math.trunc
546549
libc.src.math.truncf
547550
libc.src.math.truncl
@@ -686,6 +689,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
686689
libc.src.math.roundf128
687690
libc.src.math.scalbnf128
688691
libc.src.math.sqrtf128
692+
libc.src.math.totalordermagf128
689693
libc.src.math.truncf128
690694
libc.src.math.ufromfpf128
691695
libc.src.math.ufromfpxf128

libc/docs/math/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Basic Operations
230230
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
231231
| totalorder | | | | |check| | | F.10.12.1 | N/A |
232232
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
233-
| totalordermag | | | | |check| | | F.10.12.2 | N/A |
233+
| totalordermag | |check| | |check| | |check| | |check| | |check| | F.10.12.2 | N/A |
234234
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
235235
| trunc | |check| | |check| | |check| | |check| | |check| | 7.12.9.9 | F.10.6.9 |
236236
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+

libc/spec/stdc.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,13 @@ def StdC : StandardSpec<"stdc"> {
720720

721721
FunctionSpec<"dsqrtl", RetValSpec<DoubleType>, [ArgSpec<LongDoubleType>]>,
722722

723+
GuardedFunctionSpec<"totalorderf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
723724

724-
GuardedFunctionSpec<"totalorderf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
725-
726-
GuardedFunctionSpec<"totalordermagf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
725+
FunctionSpec<"totalordermag", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoublePtr>]>,
726+
FunctionSpec<"totalordermagf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]>,
727+
FunctionSpec<"totalordermagl", RetValSpec<IntType>, [ArgSpec<LongDoublePtr>, ArgSpec<LongDoublePtr>]>,
728+
GuardedFunctionSpec<"totalordermagf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
729+
GuardedFunctionSpec<"totalordermagf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,
727730

728731
GuardedFunctionSpec<"getpayloadf16", RetValSpec<Float16Type>, [ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
729732

libc/src/math/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,11 @@ add_math_entrypoint_object(tgammaf)
435435

436436
add_math_entrypoint_object(totalorderf16)
437437

438+
add_math_entrypoint_object(totalordermag)
439+
add_math_entrypoint_object(totalordermagf)
440+
add_math_entrypoint_object(totalordermagl)
438441
add_math_entrypoint_object(totalordermagf16)
442+
add_math_entrypoint_object(totalordermagf128)
439443

440444
add_math_entrypoint_object(trunc)
441445
add_math_entrypoint_object(truncf)

libc/src/math/generic/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,6 +3965,42 @@ add_entrypoint_object(
39653965
-O3
39663966
)
39673967

3968+
add_entrypoint_object(
3969+
totalordermag
3970+
SRCS
3971+
totalordermag.cpp
3972+
HDRS
3973+
../totalordermag.h
3974+
DEPENDS
3975+
libc.src.__support.FPUtil.basic_operations
3976+
COMPILE_OPTIONS
3977+
-O3
3978+
)
3979+
3980+
add_entrypoint_object(
3981+
totalordermagf
3982+
SRCS
3983+
totalordermagf.cpp
3984+
HDRS
3985+
../totalordermagf.h
3986+
DEPENDS
3987+
libc.src.__support.FPUtil.basic_operations
3988+
COMPILE_OPTIONS
3989+
-O3
3990+
)
3991+
3992+
add_entrypoint_object(
3993+
totalordermagl
3994+
SRCS
3995+
totalordermagl.cpp
3996+
HDRS
3997+
../totalordermagl.h
3998+
DEPENDS
3999+
libc.src.__support.FPUtil.basic_operations
4000+
COMPILE_OPTIONS
4001+
-O3
4002+
)
4003+
39684004
add_entrypoint_object(
39694005
totalordermagf16
39704006
SRCS
@@ -3977,6 +4013,19 @@ add_entrypoint_object(
39774013
-O3
39784014
)
39794015

4016+
add_entrypoint_object(
4017+
totalordermagf128
4018+
SRCS
4019+
totalordermagf128.cpp
4020+
HDRS
4021+
../totalordermagf128.h
4022+
DEPENDS
4023+
libc.src.__support.FPUtil.basic_operations
4024+
libc.src.__support.macros.properties.types
4025+
COMPILE_OPTIONS
4026+
-O3
4027+
)
4028+
39804029
add_entrypoint_object(
39814030
getpayloadf16
39824031
SRCS
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of totalordermag 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/totalordermag.h"
10+
#include "src/__support/FPUtil/BasicOperations.h"
11+
#include "src/__support/common.h"
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(int, totalordermag, (const double *x, const double *y)) {
17+
return static_cast<int>(fputil::totalordermag(*x, *y));
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of totalordermagf 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/totalordermagf.h"
10+
#include "src/__support/FPUtil/BasicOperations.h"
11+
#include "src/__support/common.h"
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(int, totalordermagf, (const float *x, const float *y)) {
17+
return static_cast<int>(fputil::totalordermag(*x, *y));
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation of totalordermagf128 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/totalordermagf128.h"
10+
#include "src/__support/FPUtil/BasicOperations.h"
11+
#include "src/__support/common.h"
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(int, totalordermagf128,
17+
(const float128 *x, const float128 *y)) {
18+
return static_cast<int>(fputil::totalordermag(*x, *y));
19+
}
20+
21+
} // namespace LIBC_NAMESPACE_DECL
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation of totalordermagl 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/totalordermagl.h"
10+
#include "src/__support/FPUtil/BasicOperations.h"
11+
#include "src/__support/common.h"
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(int, totalordermagl,
17+
(const long double *x, const long double *y)) {
18+
return static_cast<int>(fputil::totalordermag(*x, *y));
19+
}
20+
21+
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/totalordermag.h

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

libc/src/math/totalordermagf.h

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

libc/src/math/totalordermagf128.h

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

libc/src/math/totalordermagl.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for totalordermag -----------------*- 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_TOTALORDERMAGL_H
10+
#define LLVM_LIBC_SRC_MATH_TOTALORDERMAGL_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
int totalordermagl(const long double *x, const long double *y);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_TOTALORDERMAGl_H

0 commit comments

Comments
 (0)