1a6b264b5SAlexey Samsonov //===-- lib/comparesf2.c - Single-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-fp_t comparison routines:
10a6b264b5SAlexey Samsonov //
11a6b264b5SAlexey Samsonov // __eqsf2 __gesf2 __unordsf2
12a6b264b5SAlexey Samsonov // __lesf2 __gtsf2
13a6b264b5SAlexey Samsonov // __ltsf2
14a6b264b5SAlexey Samsonov // __nesf2
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 // __lesf2(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 // __gesf2(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 // __unordsf2(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 __lesf2( ) and __gesf2( ) are identical except in their handling of
35a6b264b5SAlexey Samsonov // NaN values.
36a6b264b5SAlexey Samsonov //
37a6b264b5SAlexey Samsonov //===----------------------------------------------------------------------===//
38a6b264b5SAlexey Samsonov
39a6b264b5SAlexey Samsonov #define SINGLE_PRECISION
40a6b264b5SAlexey Samsonov #include "fp_lib.h"
41a6b264b5SAlexey Samsonov
42*777ca513SAlex Richardson #include "fp_compare_impl.inc"
43a6b264b5SAlexey Samsonov
__lesf2(fp_t a,fp_t b)44*777ca513SAlex Richardson COMPILER_RT_ABI CMP_RESULT __lesf2(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(__lesf2,__cmpsf2)4884da0e1bSPetr Hosek COMPILER_RT_ALIAS(__lesf2, __cmpsf2)
490d6094b9SSaleem Abdulrasool #endif
5084da0e1bSPetr Hosek COMPILER_RT_ALIAS(__lesf2, __eqsf2)
5184da0e1bSPetr Hosek COMPILER_RT_ALIAS(__lesf2, __ltsf2)
5284da0e1bSPetr Hosek COMPILER_RT_ALIAS(__lesf2, __nesf2)
53772527c5SJosh Gao
54*777ca513SAlex Richardson COMPILER_RT_ABI CMP_RESULT __gesf2(fp_t a, fp_t b) { return __geXf2__(a, b); }
55a6b264b5SAlexey Samsonov
COMPILER_RT_ALIAS(__gesf2,__gtsf2)5684da0e1bSPetr Hosek COMPILER_RT_ALIAS(__gesf2, __gtsf2)
5784da0e1bSPetr Hosek
58*777ca513SAlex Richardson COMPILER_RT_ABI CMP_RESULT __unordsf2(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_fcmpun(fp_t a,fp_t b)64082b89b2SPetr Hosek AEABI_RTABI int __aeabi_fcmpun(fp_t a, fp_t b) { return __unordsf2(a, b); }
650d586d06SEli Friedman #else
COMPILER_RT_ALIAS(__unordsf2,__aeabi_fcmpun)6684da0e1bSPetr Hosek COMPILER_RT_ALIAS(__unordsf2, __aeabi_fcmpun)
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 __eqsf2(fp_t a, fp_t b) { return __lesf2(a, b); }
__ltsf2(fp_t a,fp_t b)743961507bSReid Kleckner int __ltsf2(fp_t a, fp_t b) { return __lesf2(a, b); }
__nesf2(fp_t a,fp_t b)753961507bSReid Kleckner int __nesf2(fp_t a, fp_t b) { return __lesf2(a, b); }
__gtsf2(fp_t a,fp_t b)763961507bSReid Kleckner int __gtsf2(fp_t a, fp_t b) { return __gesf2(a, b); }
773961507bSReid Kleckner #endif
78