xref: /freebsd-src/contrib/llvm-project/compiler-rt/lib/builtins/comparetf2.c (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
10b57cec5SDimitry Andric //===-- lib/comparetf2.c - Quad-precision comparisons -------------*- C -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // // This file implements the following soft-float comparison routines:
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //   __eqtf2   __getf2   __unordtf2
120b57cec5SDimitry Andric //   __letf2   __gttf2
130b57cec5SDimitry Andric //   __lttf2
140b57cec5SDimitry Andric //   __netf2
150b57cec5SDimitry Andric //
160b57cec5SDimitry Andric // The semantics of the routines grouped in each column are identical, so there
170b57cec5SDimitry Andric // is a single implementation for each, and wrappers to provide the other names.
180b57cec5SDimitry Andric //
190b57cec5SDimitry Andric // The main routines behave as follows:
200b57cec5SDimitry Andric //
210b57cec5SDimitry Andric //   __letf2(a,b) returns -1 if a < b
220b57cec5SDimitry Andric //                         0 if a == b
230b57cec5SDimitry Andric //                         1 if a > b
240b57cec5SDimitry Andric //                         1 if either a or b is NaN
250b57cec5SDimitry Andric //
260b57cec5SDimitry Andric //   __getf2(a,b) returns -1 if a < b
270b57cec5SDimitry Andric //                         0 if a == b
280b57cec5SDimitry Andric //                         1 if a > b
290b57cec5SDimitry Andric //                        -1 if either a or b is NaN
300b57cec5SDimitry Andric //
310b57cec5SDimitry Andric //   __unordtf2(a,b) returns 0 if both a and b are numbers
320b57cec5SDimitry Andric //                           1 if either a or b is NaN
330b57cec5SDimitry Andric //
340b57cec5SDimitry Andric // Note that __letf2( ) and __getf2( ) are identical except in their handling of
350b57cec5SDimitry Andric // NaN values.
360b57cec5SDimitry Andric //
370b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric #define QUAD_PRECISION
400b57cec5SDimitry Andric #include "fp_lib.h"
410b57cec5SDimitry Andric 
42*06c3fb27SDimitry Andric #if defined(CRT_HAS_TF_MODE)
43fe6060f1SDimitry Andric #include "fp_compare_impl.inc"
440b57cec5SDimitry Andric 
__letf2(fp_t a,fp_t b)45fe6060f1SDimitry Andric COMPILER_RT_ABI CMP_RESULT __letf2(fp_t a, fp_t b) { return __leXf2__(a, b); }
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric #if defined(__ELF__)
480b57cec5SDimitry Andric // Alias for libgcc compatibility
COMPILER_RT_ALIAS(__letf2,__cmptf2)490b57cec5SDimitry Andric COMPILER_RT_ALIAS(__letf2, __cmptf2)
500b57cec5SDimitry Andric #endif
510b57cec5SDimitry Andric COMPILER_RT_ALIAS(__letf2, __eqtf2)
520b57cec5SDimitry Andric COMPILER_RT_ALIAS(__letf2, __lttf2)
530b57cec5SDimitry Andric COMPILER_RT_ALIAS(__letf2, __netf2)
540b57cec5SDimitry Andric 
55fe6060f1SDimitry Andric COMPILER_RT_ABI CMP_RESULT __getf2(fp_t a, fp_t b) { return __geXf2__(a, b); }
560b57cec5SDimitry Andric 
COMPILER_RT_ALIAS(__getf2,__gttf2)570b57cec5SDimitry Andric COMPILER_RT_ALIAS(__getf2, __gttf2)
580b57cec5SDimitry Andric 
59fe6060f1SDimitry Andric COMPILER_RT_ABI CMP_RESULT __unordtf2(fp_t a, fp_t b) {
60fe6060f1SDimitry Andric   return __unordXf2__(a, b);
610b57cec5SDimitry Andric }
620b57cec5SDimitry Andric 
630b57cec5SDimitry Andric #endif
64