78 lines · c
1//===-- lib/comparesf2.c - Single-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-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements the following soft-fp_t comparison routines:10//11// __eqsf2 __gesf2 __unordsf212// __lesf2 __gtsf213// __ltsf214// __nesf215//16// The semantics of the routines grouped in each column are identical, so there17// is a single implementation for each, and wrappers to provide the other names.18//19// The main routines behave as follows:20//21// __lesf2(a,b) returns -1 if a < b22// 0 if a == b23// 1 if a > b24// 1 if either a or b is NaN25//26// __gesf2(a,b) returns -1 if a < b27// 0 if a == b28// 1 if a > b29// -1 if either a or b is NaN30//31// __unordsf2(a,b) returns 0 if both a and b are numbers32// 1 if either a or b is NaN33//34// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of35// NaN values.36//37//===----------------------------------------------------------------------===//38 39#define SINGLE_PRECISION40#include "fp_lib.h"41 42#include "fp_compare_impl.inc"43 44COMPILER_RT_ABI CMP_RESULT __lesf2(fp_t a, fp_t b) { return __leXf2__(a, b); }45 46#if defined(__ELF__)47// Alias for libgcc compatibility48COMPILER_RT_ALIAS(__lesf2, __cmpsf2)49#endif50COMPILER_RT_ALIAS(__lesf2, __eqsf2)51COMPILER_RT_ALIAS(__lesf2, __ltsf2)52COMPILER_RT_ALIAS(__lesf2, __nesf2)53 54COMPILER_RT_ABI CMP_RESULT __gesf2(fp_t a, fp_t b) { return __geXf2__(a, b); }55 56COMPILER_RT_ALIAS(__gesf2, __gtsf2)57 58COMPILER_RT_ABI CMP_RESULT __unordsf2(fp_t a, fp_t b) {59 return __unordXf2__(a, b);60}61 62#if defined(__ARM_EABI__)63#if defined(COMPILER_RT_ARMHF_TARGET)64AEABI_RTABI int __aeabi_fcmpun(fp_t a, fp_t b) { return __unordsf2(a, b); }65#else66COMPILER_RT_ALIAS(__unordsf2, __aeabi_fcmpun)67#endif68#endif69 70#if defined(_WIN32) && !defined(__MINGW32__)71// The alias mechanism doesn't work on Windows except for MinGW, so emit72// wrapper functions.73int __eqsf2(fp_t a, fp_t b) { return __lesf2(a, b); }74int __ltsf2(fp_t a, fp_t b) { return __lesf2(a, b); }75int __nesf2(fp_t a, fp_t b) { return __lesf2(a, b); }76int __gtsf2(fp_t a, fp_t b) { return __gesf2(a, b); }77#endif78