-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc][math][c23] Add totalorderl function. #102564
Conversation
@llvm/pr-subscribers-libc Author: Job Henandez Lara (Jobhdez) ChangesFull diff: https://github.com/llvm/llvm-project/pull/102564.diff 13 Files Affected:
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index bb0ebca29e6ae2..75e010e63c92df 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -568,6 +568,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
libc.src.math.totalordermagl
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 7fd60799bbcc72..02265aef6fdfb4 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -396,6 +396,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
libc.src.math.totalordermagl
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 0d48b55a965483..f80e741115e793 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -571,6 +571,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
libc.src.math.totalordermagl
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index b9134c8496c30a..683ac8b1c71e37 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -571,6 +571,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
libc.src.math.totalordermagl
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 9185a95192963e..b617289d1364fd 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -228,7 +228,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| setpayloadsig | |check| | |check| | |check| | |check| | |check| | F.10.13.3 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| totalorder | |check| | |check| | | |check| | |check| | F.10.12.1 | N/A |
+| totalorder | |check| | |check| | |check| | |check| | |check| | F.10.12.1 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| totalordermag | |check| | |check| | |check| | |check| | |check| | F.10.12.2 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/newhdrgen/yaml/math.yaml b/libc/newhdrgen/yaml/math.yaml
index 2f1203e581f9a7..f9e1834091f4ec 100644
--- a/libc/newhdrgen/yaml/math.yaml
+++ b/libc/newhdrgen/yaml/math.yaml
@@ -1839,6 +1839,27 @@ functions:
- type: float128 *
- type: float128
guard: LIBC_TYPES_HAS_FLOAT128
+ - name: totalorder
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: double *
+ - type: double *
+ - name: totalorderf
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: float *
+ - type: float *
+ - name: totalorderl
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: long double *
+ - type: long double *
- name: totalorderf16
standards:
- stdc
@@ -1847,6 +1868,14 @@ functions:
- type: _Float16 *
- type: _Float16 *
guard: LIBC_TYPES_HAS_FLOAT16
+ - name: totalorderf16
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: float128 *
+ - type: float128 *
+ guard: LIBC_TYPES_HAS_FLOAT16
- name: totalordermagf16
standards:
- stdc
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 72bfe0cf71aa2b..94fc5cb0ec1028 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -745,6 +745,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"totalorder", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoublePtr>]>,
FunctionSpec<"totalorderf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]>,
+ FunctionSpec<"totalorderf", RetValSpec<IntType>, [ArgSpec<LongDoublePtr>, ArgSpec<LongDoublePtr>]>,
GuardedFunctionSpec<"totalorderf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"totalorderf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index e2ebf2ddd4bfa4..7f1800ab3480d7 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -479,6 +479,7 @@ add_math_entrypoint_object(lgamma_r)
add_math_entrypoint_object(totalorder)
add_math_entrypoint_object(totalorderf)
+add_math_entrypoint_object(totalorderl)
add_math_entrypoint_object(totalorderf16)
add_math_entrypoint_object(totalorderf128)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index c80c7ca7f7af11..534036aa364560 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4368,6 +4368,18 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ totalorderl
+ SRCS
+ totalorderl.cpp
+ HDRS
+ ../totalorderl.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
totalorderf16
SRCS
diff --git a/libc/src/math/generic/totalorderl.cpp b/libc/src/math/generic/totalorderl.cpp
new file mode 100644
index 00000000000000..f3fa2b2c01f6f4
--- /dev/null
+++ b/libc/src/math/generic/totalorderl.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of totalorderl 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/totalorderl.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, totalorderl, (const long double *x, const long double *y)) {
+ return static_cast<int>(fputil::totalorder(*x, *y));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/totalorderl.h b/libc/src/math/totalorderl.h
new file mode 100644
index 00000000000000..064b2a514fa8e9
--- /dev/null
+++ b/libc/src/math/totalorderl.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for totalorderl -------------------*- 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_TOTALORDERL_H
+#define LLVM_LIBC_SRC_MATH_TOTALORDERL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int totalorderl(const long double *x, const long double *y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_TOTALORDERL_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 609ecef42f7459..9fe61672f7258d 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3837,6 +3837,18 @@ add_fp_unittest(
libc.src.math.totalorderf
)
+add_fp_unittest(
+ totalorderl_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ totalorderl_test.cpp
+ HDRS
+ TotalOrderTest.h
+ DEPENDS
+ libc.src.math.totalorderl
+)
+
add_fp_unittest(
totalorderf16_test
SUITE
diff --git a/libc/test/src/math/smoke/totalorderl_test.cpp b/libc/test/src/math/smoke/totalorderl_test.cpp
new file mode 100644
index 00000000000000..fc2353fce3859a
--- /dev/null
+++ b/libc/test/src/math/smoke/totalorderl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for totalorderl -----------------------------------------===//
+//
+// 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 "TotalOrderTest.h"
+
+#include "src/math/totalorderl.h"
+
+LIST_TOTALORDER_TESTS(long double, LIBC_NAMESPACE::totalorderl)
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
libc/spec/stdc.td
Outdated
@@ -745,6 +745,7 @@ def StdC : StandardSpec<"stdc"> { | |||
|
|||
FunctionSpec<"totalorder", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoublePtr>]>, | |||
FunctionSpec<"totalorderf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]>, | |||
FunctionSpec<"totalorderf", RetValSpec<IntType>, [ArgSpec<LongDoublePtr>, ArgSpec<LongDoublePtr>]>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totalorderl
libc/newhdrgen/yaml/math.yaml
Outdated
@@ -1847,6 +1868,14 @@ functions: | |||
- type: _Float16 * | |||
- type: _Float16 * | |||
guard: LIBC_TYPES_HAS_FLOAT16 | |||
- name: totalorderf16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totalorderf128
libc/newhdrgen/yaml/math.yaml
Outdated
arguments: | ||
- type: float128 * | ||
- type: float128 * | ||
guard: LIBC_TYPES_HAS_FLOAT16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FLOAT128
libc/newhdrgen/yaml/math.yaml
Outdated
- stdc | ||
return_type: int | ||
arguments: | ||
- type: double * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const double *
libc/newhdrgen/yaml/math.yaml
Outdated
- type: float * | ||
- type: float * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const float *
libc/newhdrgen/yaml/math.yaml
Outdated
- type: long double * | ||
- type: long double * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const long double *
libc/newhdrgen/yaml/math.yaml
Outdated
- type: _Float16 * | ||
- type: _Float16 * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind changing this to const _Float16 *
also?
libc/newhdrgen/yaml/math.yaml
Outdated
- type: float128 * | ||
- type: float128 * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const float128 *
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/5497 Here is the relevant piece of the build log for the reference:
|
* 'main' of https://github.com/llvm/llvm-project: (700 commits) [SandboxIR][NFC] SingleLLVMInstructionImpl class (llvm#102687) [ThinLTO]Clean up 'import-assume-unique-local' flag. (llvm#102424) [nsan] Make #include more conventional [SandboxIR][NFC] Use Tracker.emplaceIfTracking() [libc] Moved range_reduction_double ifdef statement (llvm#102659) [libc] Fix CFP long double and add tests (llvm#102660) [TargetLowering] Handle vector types in expandFixedPointMul (llvm#102635) [compiler-rt][NFC] Replace environment variable with %t (llvm#102197) [UnitTests] Convert a test to use opaque pointers (llvm#102668) [CodeGen][NFCI] Don't re-implement parts of ASTContext::getIntWidth (llvm#101765) [SandboxIR] Clean up tracking code with the help of emplaceIfTracking() (llvm#102406) [mlir][bazel] remove extra blanks in mlir-tblgen test [NVPTX][NFC] Update tests to use bfloat type (llvm#101493) [mlir] Add support for parsing nested PassPipelineOptions (llvm#101118) [mlir][bazel] add missing td dependency in mlir-tblgen test [flang][cuda] Fix lib dependency [libc] Clean up remaining use of *_WIDTH macros in printf (llvm#102679) [flang][cuda] Convert cuf.alloc for box to fir.alloca in device context (llvm#102662) [SandboxIR] Implement the InsertElementInst class (llvm#102404) [libc] Fix use of cpp::numeric_limits<...>::digits (llvm#102674) [mlir][ODS] Verify type constraints in Types and Attributes (llvm#102326) [LTO] enable `ObjCARCContractPass` only on optimized build (llvm#101114) [mlir][ODS] Consistent `cppType` / `cppClassName` usage (llvm#102657) [lldb] Move definition of SBSaveCoreOptions dtor out of header (llvm#102539) [libc] Use cpp::numeric_limits in preference to C23 <limits.h> macros (llvm#102665) [clang] Implement -fptrauth-auth-traps. (llvm#102417) [LLVM][rtsan] rtsan transform to preserve CFGAnalyses (llvm#102651) Revert "[AMDGPU] Move `AMDGPUAttributorPass` to full LTO post link stage (llvm#102086)" [RISCV][GISel] Add missing tests for G_CTLZ/CTTZ instruction selection. NFC Return available function types for BindingDecls. (llvm#102196) [clang] Wire -fptrauth-returns to "ptrauth-returns" fn attribute. (llvm#102416) [RISCV] Remove riscv-experimental-rv64-legal-i32. (llvm#102509) [RISCV] Move PseudoVSET(I)VLI expansion to use PseudoInstExpansion. (llvm#102496) [NVPTX] support switch statement with brx.idx (reland) (llvm#102550) [libc][newhdrgen]sorted function names in yaml (llvm#102544) [GlobalIsel] Combine G_ADD and G_SUB with constants (llvm#97771) Suppress spurious warnings due to R_RISCV_SET_ULEB128 [scudo] Separated committed and decommitted entries. (llvm#101409) [MIPS] Fix missing ANDI optimization (llvm#97689) [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (llvm#102521) [asan] Switch allocator to dynamic base address (llvm#98511) [AMDGPU] Move `AMDGPUAttributorPass` to full LTO post link stage (llvm#102086) [libc][math][c23] Add fadd{l,f128} C23 math functions (llvm#102531) [mlir][bazel] revert bazel rule change for DLTITransformOps [msan] Support vst{2,3,4}_lane instructions (llvm#101215) Revert "[MLIR][DLTI][Transform] Introduce transform.dlti.query (llvm#101561)" [X86] pr57673.ll - generate MIR test checks [mlir][vector][test] Split tests from vector-transfer-flatten.mlir (llvm#102584) [mlir][bazel] add bazel rule for DLTITransformOps OpenMPOpt: Remove dead include [IR] Add method to GlobalVariable to change type of initializer. (llvm#102553) [flang][cuda] Force default allocator in device code (llvm#102238) [llvm] Construct SmallVector<SDValue> with ArrayRef (NFC) (llvm#102578) [MLIR][DLTI][Transform] Introduce transform.dlti.query (llvm#101561) [AMDGPU][AsmParser][NFC] Remove a misleading comment. (llvm#102604) [Arm][AArch64][Clang] Respect function's branch protection attributes. (llvm#101978) [mlir] Verifier: steal bit to track seen instead of set. (llvm#102626) [Clang] Fix Handling of Init Capture with Parameter Packs in LambdaScopeForCallOperatorInstantiationRAII (llvm#100766) [X86] Convert truncsat clamping patterns to use SDPatternMatch. NFC. [gn] Give two scripts argparse.RawDescriptionHelpFormatter [bazel] Add missing dep for the SPIRVToLLVM target [Clang] Simplify specifying passes via -Xoffload-linker (llvm#102483) [bazel] Port for d45de80 [SelectionDAG] Use unaligned store/load to move AVX registers onto stack for `insertelement` (llvm#82130) [Clang][OMPX] Add the code generation for multi-dim `num_teams` (llvm#101407) [ARM] Regenerate big-endian-vmov.ll. NFC [AMDGPU][AsmParser][NFCI] All NamedIntOperands to be of the i32 type. (llvm#102616) [libc][math][c23] Add totalorderl function. (llvm#102564) [mlir][spirv] Support `memref` in `convert-to-spirv` pass (llvm#102534) [MLIR][GPU-LLVM] Convert `gpu.func` to `llvm.func` (llvm#101664) Fix a unit test input file (llvm#102567) [llvm-readobj][COFF] Dump hybrid objects for ARM64X files. (llvm#102245) AMDGPU/NewPM: Port SIFixSGPRCopies to new pass manager (llvm#102614) [MemoryBuiltins] Simplify getCalledFunction() helper (NFC) [AArch64] Add invalid 1 x vscale costs for reductions and reduction-operations. (llvm#102105) [MemoryBuiltins] Handle allocator attributes on call-site LSV/test/AArch64: add missing lit.local.cfg; fix build (llvm#102607) Revert "Enable logf128 constant folding for hosts with 128bit floats (llvm#96287)" [RISCV] Add Syntacore SCR5 RV32/64 processors definition (llvm#102285) [InstCombine] Remove unnecessary RUN line from test (NFC) [flang][OpenMP] Handle multiple ranges in `num_teams` clause (llvm#102535) [mlir][vector] Add tests for scalable vectors in one-shot-bufferize.mlir (llvm#102361) [mlir][vector] Disable `vector.matrix_multiply` for scalable vectors (llvm#102573) [clang] Implement CWG2627 Bit-fields and narrowing conversions (llvm#78112) [NFC] Use references to avoid copying (llvm#99863) Revert "[mlir][ArmSME] Pattern to swap shape_cast(tranpose) with transpose(shape_cast) (llvm#100731)" (llvm#102457) [IRBuilder] Generate nuw GEPs for struct member accesses (llvm#99538) [bazel] Port for 9b06e25 [CodeGen][NewPM] Improve start/stop pass error message CodeGenPassBuilder (llvm#102591) [AArch64] Implement TRBMPAM_EL1 system register (llvm#102485) [InstCombine] Fixing wrong select folding in vectors with undef elements (llvm#102244) [AArch64] Sink operands to fmuladd. (llvm#102297) LSV: document hang reported in llvm#37865 (llvm#102479) Enable logf128 constant folding for hosts with 128bit floats (llvm#96287) [RISCV][clang] Remove bfloat base type in non-zvfbfmin vcreate (llvm#102146) [RISCV][clang] Add missing `zvfbfmin` to `vget_v` intrinsic (llvm#102149) [mlir][vector] Add mask elimination transform (llvm#99314) [Clang][Interp] Fix display of syntactically-invalid note for member function calls (llvm#102170) [bazel] Port for 3fffa6d [DebugInfo][RemoveDIs] Use iterator-inserters in clang (llvm#102006) ... Signed-off-by: Edwiin Kusuma Jaya <kutemeikito0905@gmail.com>
No description provided.