Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/comparesf2.c
35260 views
//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements the following soft-fp_t comparison routines:9//10// __eqsf2 __gesf2 __unordsf211// __lesf2 __gtsf212// __ltsf213// __nesf214//15// The semantics of the routines grouped in each column are identical, so there16// is a single implementation for each, and wrappers to provide the other names.17//18// The main routines behave as follows:19//20// __lesf2(a,b) returns -1 if a < b21// 0 if a == b22// 1 if a > b23// 1 if either a or b is NaN24//25// __gesf2(a,b) returns -1 if a < b26// 0 if a == b27// 1 if a > b28// -1 if either a or b is NaN29//30// __unordsf2(a,b) returns 0 if both a and b are numbers31// 1 if either a or b is NaN32//33// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of34// NaN values.35//36//===----------------------------------------------------------------------===//3738#define SINGLE_PRECISION39#include "fp_lib.h"4041#include "fp_compare_impl.inc"4243COMPILER_RT_ABI CMP_RESULT __lesf2(fp_t a, fp_t b) { return __leXf2__(a, b); }4445#if defined(__ELF__)46// Alias for libgcc compatibility47COMPILER_RT_ALIAS(__lesf2, __cmpsf2)48#endif49COMPILER_RT_ALIAS(__lesf2, __eqsf2)50COMPILER_RT_ALIAS(__lesf2, __ltsf2)51COMPILER_RT_ALIAS(__lesf2, __nesf2)5253COMPILER_RT_ABI CMP_RESULT __gesf2(fp_t a, fp_t b) { return __geXf2__(a, b); }5455COMPILER_RT_ALIAS(__gesf2, __gtsf2)5657COMPILER_RT_ABI CMP_RESULT __unordsf2(fp_t a, fp_t b) {58return __unordXf2__(a, b);59}6061#if defined(__ARM_EABI__)62#if defined(COMPILER_RT_ARMHF_TARGET)63AEABI_RTABI int __aeabi_fcmpun(fp_t a, fp_t b) { return __unordsf2(a, b); }64#else65COMPILER_RT_ALIAS(__unordsf2, __aeabi_fcmpun)66#endif67#endif6869#if defined(_WIN32) && !defined(__MINGW32__)70// The alias mechanism doesn't work on Windows except for MinGW, so emit71// wrapper functions.72int __eqsf2(fp_t a, fp_t b) { return __lesf2(a, b); }73int __ltsf2(fp_t a, fp_t b) { return __lesf2(a, b); }74int __nesf2(fp_t a, fp_t b) { return __lesf2(a, b); }75int __gtsf2(fp_t a, fp_t b) { return __gesf2(a, b); }76#endif777879