|
| 1 | +//===-- lib/comparedf2.c - Double-precision comparisons -----------*- 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 | +// // This file implements the following soft-float comparison routines: |
| 10 | +// |
| 11 | +// __eqdf2 __gedf2 __unorddf2 |
| 12 | +// __ledf2 __gtdf2 |
| 13 | +// __ltdf2 |
| 14 | +// __nedf2 |
| 15 | +// |
| 16 | +// The semantics of the routines grouped in each column are identical, so there |
| 17 | +// is a single implementation for each, and wrappers to provide the other names. |
| 18 | +// |
| 19 | +// The main routines behave as follows: |
| 20 | +// |
| 21 | +// __ledf2(a,b) returns -1 if a < b |
| 22 | +// 0 if a == b |
| 23 | +// 1 if a > b |
| 24 | +// 1 if either a or b is NaN |
| 25 | +// |
| 26 | +// __gedf2(a,b) returns -1 if a < b |
| 27 | +// 0 if a == b |
| 28 | +// 1 if a > b |
| 29 | +// -1 if either a or b is NaN |
| 30 | +// |
| 31 | +// __unorddf2(a,b) returns 0 if both a and b are numbers |
| 32 | +// 1 if either a or b is NaN |
| 33 | +// |
| 34 | +// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of |
| 35 | +// NaN values. |
| 36 | +// |
| 37 | +//===----------------------------------------------------------------------===// |
| 38 | + |
| 39 | +#ifndef CC_RUNTIME_NO_FLOAT |
| 40 | + |
| 41 | +#define DOUBLE_PRECISION |
| 42 | +#include "fp_lib.h" |
| 43 | + |
| 44 | +#include "fp_compare_impl.inc" |
| 45 | + |
| 46 | +COMPILER_RT_ABI CMP_RESULT __ledf2(fp_t a, fp_t b) { return __leXf2__(a, b); } |
| 47 | + |
| 48 | +#if defined(__ELF__) |
| 49 | +// Alias for libgcc compatibility |
| 50 | +COMPILER_RT_ALIAS(__ledf2, __cmpdf2) |
| 51 | +#endif |
| 52 | +COMPILER_RT_ALIAS(__ledf2, __eqdf2) |
| 53 | +COMPILER_RT_ALIAS(__ledf2, __ltdf2) |
| 54 | +COMPILER_RT_ALIAS(__ledf2, __nedf2) |
| 55 | + |
| 56 | +COMPILER_RT_ABI CMP_RESULT __gedf2(fp_t a, fp_t b) { return __geXf2__(a, b); } |
| 57 | + |
| 58 | +COMPILER_RT_ALIAS(__gedf2, __gtdf2) |
| 59 | + |
| 60 | +COMPILER_RT_ABI CMP_RESULT __unorddf2(fp_t a, fp_t b) { |
| 61 | + return __unordXf2__(a, b); |
| 62 | +} |
| 63 | + |
| 64 | +#if defined(__ARM_EABI__) |
| 65 | +#if defined(COMPILER_RT_ARMHF_TARGET) |
| 66 | +AEABI_RTABI int __aeabi_dcmpun(fp_t a, fp_t b) { return __unorddf2(a, b); } |
| 67 | +#else |
| 68 | +COMPILER_RT_ALIAS(__unorddf2, __aeabi_dcmpun) |
| 69 | +#endif |
| 70 | +#endif |
| 71 | + |
| 72 | +#endif |
0 commit comments