1a6b264b5SAlexey Samsonov //===-- lib/comparedf2.c - Double-precision comparisons -----------*- C -*-===//
2a6b264b5SAlexey Samsonov //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6a6b264b5SAlexey Samsonov //
7a6b264b5SAlexey Samsonov //===----------------------------------------------------------------------===//
8a6b264b5SAlexey Samsonov //
9a6b264b5SAlexey Samsonov // // This file implements the following soft-float comparison routines:
10a6b264b5SAlexey Samsonov //
11a6b264b5SAlexey Samsonov // __eqdf2 __gedf2 __unorddf2
12a6b264b5SAlexey Samsonov // __ledf2 __gtdf2
13a6b264b5SAlexey Samsonov // __ltdf2
14a6b264b5SAlexey Samsonov // __nedf2
15a6b264b5SAlexey Samsonov //
16a6b264b5SAlexey Samsonov // The semantics of the routines grouped in each column are identical, so there
17a6b264b5SAlexey Samsonov // is a single implementation for each, and wrappers to provide the other names.
18a6b264b5SAlexey Samsonov //
19a6b264b5SAlexey Samsonov // The main routines behave as follows:
20a6b264b5SAlexey Samsonov //
21a6b264b5SAlexey Samsonov // __ledf2(a,b) returns -1 if a < b
22a6b264b5SAlexey Samsonov // 0 if a == b
23a6b264b5SAlexey Samsonov // 1 if a > b
24a6b264b5SAlexey Samsonov // 1 if either a or b is NaN
25a6b264b5SAlexey Samsonov //
26a6b264b5SAlexey Samsonov // __gedf2(a,b) returns -1 if a < b
27a6b264b5SAlexey Samsonov // 0 if a == b
28a6b264b5SAlexey Samsonov // 1 if a > b
29a6b264b5SAlexey Samsonov // -1 if either a or b is NaN
30a6b264b5SAlexey Samsonov //
31a6b264b5SAlexey Samsonov // __unorddf2(a,b) returns 0 if both a and b are numbers
32a6b264b5SAlexey Samsonov // 1 if either a or b is NaN
33a6b264b5SAlexey Samsonov //
34a6b264b5SAlexey Samsonov // Note that __ledf2( ) and __gedf2( ) are identical except in their handling of
35a6b264b5SAlexey Samsonov // NaN values.
36a6b264b5SAlexey Samsonov //
37a6b264b5SAlexey Samsonov //===----------------------------------------------------------------------===//
38a6b264b5SAlexey Samsonov
39a6b264b5SAlexey Samsonov #define DOUBLE_PRECISION
40a6b264b5SAlexey Samsonov #include "fp_lib.h"
41a6b264b5SAlexey Samsonov
42*777ca513SAlex Richardson #include "fp_compare_impl.inc"
43a6b264b5SAlexey Samsonov
__ledf2(fp_t a,fp_t b)44*777ca513SAlex Richardson COMPILER_RT_ABI CMP_RESULT __ledf2(fp_t a, fp_t b) { return __leXf2__(a, b); }
45a6b264b5SAlexey Samsonov
460d6094b9SSaleem Abdulrasool #if defined(__ELF__)
47772527c5SJosh Gao // Alias for libgcc compatibility
COMPILER_RT_ALIAS(__ledf2,__cmpdf2)4884da0e1bSPetr Hosek COMPILER_RT_ALIAS(__ledf2, __cmpdf2)
490d6094b9SSaleem Abdulrasool #endif
5084da0e1bSPetr Hosek COMPILER_RT_ALIAS(__ledf2, __eqdf2)
5184da0e1bSPetr Hosek COMPILER_RT_ALIAS(__ledf2, __ltdf2)
5284da0e1bSPetr Hosek COMPILER_RT_ALIAS(__ledf2, __nedf2)
53772527c5SJosh Gao
54*777ca513SAlex Richardson COMPILER_RT_ABI CMP_RESULT __gedf2(fp_t a, fp_t b) { return __geXf2__(a, b); }
55a6b264b5SAlexey Samsonov
COMPILER_RT_ALIAS(__gedf2,__gtdf2)5684da0e1bSPetr Hosek COMPILER_RT_ALIAS(__gedf2, __gtdf2)
5784da0e1bSPetr Hosek
58*777ca513SAlex Richardson COMPILER_RT_ABI CMP_RESULT __unorddf2(fp_t a, fp_t b) {
59*777ca513SAlex Richardson return __unordXf2__(a, b);
60a6b264b5SAlexey Samsonov }
61a6b264b5SAlexey Samsonov
6236ac5ddfSSaleem Abdulrasool #if defined(__ARM_EABI__)
630d586d06SEli Friedman #if defined(COMPILER_RT_ARMHF_TARGET)
__aeabi_dcmpun(fp_t a,fp_t b)64082b89b2SPetr Hosek AEABI_RTABI int __aeabi_dcmpun(fp_t a, fp_t b) { return __unorddf2(a, b); }
650d586d06SEli Friedman #else
COMPILER_RT_ALIAS(__unorddf2,__aeabi_dcmpun)6684da0e1bSPetr Hosek COMPILER_RT_ALIAS(__unorddf2, __aeabi_dcmpun)
6736ac5ddfSSaleem Abdulrasool #endif
680d586d06SEli Friedman #endif
693961507bSReid Kleckner
70b1f39102SMartin Storsjo #if defined(_WIN32) && !defined(__MINGW32__)
71b1f39102SMartin Storsjo // The alias mechanism doesn't work on Windows except for MinGW, so emit
72b1f39102SMartin Storsjo // wrapper functions.
733961507bSReid Kleckner int __eqdf2(fp_t a, fp_t b) { return __ledf2(a, b); }
__ltdf2(fp_t a,fp_t b)743961507bSReid Kleckner int __ltdf2(fp_t a, fp_t b) { return __ledf2(a, b); }
__nedf2(fp_t a,fp_t b)753961507bSReid Kleckner int __nedf2(fp_t a, fp_t b) { return __ledf2(a, b); }
__gtdf2(fp_t a,fp_t b)763961507bSReid Kleckner int __gtdf2(fp_t a, fp_t b) { return __gedf2(a, b); }
773961507bSReid Kleckner #endif
78